| ... | ... | @@ -336,6 +336,7 @@ fn transStmt( |
| 336 | 336 | .ImplicitCastExprClass => return transImplicitCastExpr(rp, scope, @ptrCast(*const ZigClangImplicitCastExpr, stmt), result_used), |
| 337 | 337 | .IntegerLiteralClass => return transIntegerLiteral(rp, scope, @ptrCast(*const ZigClangIntegerLiteral, stmt), result_used), |
| 338 | 338 | .ReturnStmtClass => return transReturnStmt(rp, scope, @ptrCast(*const ZigClangReturnStmt, stmt)), |
| 339 | .StringLiteralClass => return transStringLiteral(rp, scope, @ptrCast(*const ZigClangStringLiteral, stmt), result_used), |
| 339 | 340 | else => { |
| 340 | 341 | return revertAndWarn( |
| 341 | 342 | rp, |
| ... | ... | @@ -647,6 +648,41 @@ fn transReturnStmt( |
| 647 | 648 | }; |
| 648 | 649 | } |
| 649 | 650 | |
| 651 | fn transStringLiteral( |
| 652 | rp: RestorePoint, |
| 653 | scope: *Scope, |
| 654 | stmt: *const ZigClangStringLiteral, |
| 655 | result_used: ResultUsed, |
| 656 | ) !TransResult { |
| 657 | const kind = ZigClangStringLiteral_getKind(stmt); |
| 658 | switch (kind) { |
| 659 | .Ascii, .UTF8 => { |
| 660 | var len: usize = undefined; |
| 661 | const cstr = ZigClangStringLiteral_getString_bytes_begin_size(stmt, &len); |
| 662 | const zstr = try rp.c.str(cstr); |
| 663 | const token = try appendToken(rp.c, .StringLiteral, zstr); |
| 664 | const node = try rp.c.a().create(ast.Node.StringLiteral); |
| 665 | node.* = ast.Node.StringLiteral{ |
| 666 | .base = ast.Node{ .id = .StringLiteral }, |
| 667 | .token = token, |
| 668 | }; |
| 669 | const res = TransResult{ |
| 670 | .node = &node.base, |
| 671 | .child_scope = scope, |
| 672 | .node_scope = scope, |
| 673 | }; |
| 674 | return maybeSuppressResult(rp, scope, result_used, res); |
| 675 | }, |
| 676 | .UTF16, .UTF32, .Wide => return revertAndWarn( |
| 677 | rp, |
| 678 | error.UnsupportedTranslation, |
| 679 | ZigClangStmt_getBeginLoc(@ptrCast(*const ZigClangStmt, stmt)), |
| 680 | "TODO: support string literal kind {}", |
| 681 | kind, |
| 682 | ), |
| 683 | } |
| 684 | } |
| 685 | |
| 650 | 686 | fn transCCast( |
| 651 | 687 | rp: RestorePoint, |
| 652 | 688 | scope: *Scope, |