Skip to content

Commit

Permalink
fix opt args inside method
Browse files Browse the repository at this point in the history
  • Loading branch information
lassade committed Jul 27, 2023
1 parent 6dc3d33 commit dd1b6ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 10 additions & 3 deletions src/Transpiler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1191,12 +1191,19 @@ fn visitCXXMethodDecl(self: *Self, value: *const json.Value, this_opt: ?[]const

if (z_opt.items.len > 0) {
// optional arguments
try self.out.print("({s}", .{z_args.items});
try self.out.print("(", .{});
if (this_opt != null) {
try self.out.print("self, ", .{});
}
if (z_args.items.len > 0) {
try self.out.print(", ", .{});
try self.out.print("{s}, ", .{z_args.items});
}
try self.out.print("__opt: struct {{ {s} }},) {s} {{\n", .{ z_opt.items, method_tret });
try self.out.print(" return @\"{s}\"({s});\n", .{ mangled_name, z_call.items });
if (this_opt != null) {
try self.out.print(" return @\"{s}\"(self{s});\n", .{ mangled_name, z_call.items });
} else {
try self.out.print(" return @\"{s}\"({s});\n", .{ mangled_name, z_call.items });
}
try self.out.print("}}\n\n", .{});
} else {
try self.out.print(" = @\"{s}\";\n\n", .{mangled_name});
Expand Down
6 changes: 0 additions & 6 deletions src/typedefs.h

This file was deleted.

0 comments on commit dd1b6ac

Please sign in to comment.