@@ -5,26 +5,26 @@ const TestClass = @import("TestClass.zig");
55
66const WrapTarget = @import ("WrapTarget.zig" );
77const Serialization = @import ("Serialization.zig" );
8+
89comptime {
910 node_api .register (init );
1011}
1112
1213fn init (node : node_api.NodeContext ) ! ? node_api.NodeValue {
13- // const i = getInt();
14- // const ui = getUInt();
15- // const b = try node.deserialize(bool, try node.serialize(true));
16-
17- // const ;
14+ const ptr = try std .heap .c_allocator .create (WrapTarget );
15+ ptr .* = .{ .foo = 123 , .bar = "hopla" };
1816
19- const v = try node .serialize (.{
20- .serialization = try node . defineClass ( Serialization ) ,
21- .TestClass = try node . defineClass ( TestClass ) ,
17+ return try node .serialize (.{
18+ .serialization = Serialization ,
19+ .TestClass = TestClass ,
2220 .wrappedInstance = try node .wrapInstance (WrapTarget , .{ .foo = 123 , .bar = "hopla" }),
21+ .wrappedByConvention = ptr ,
2322 .functions = .{
24- .fnWithJsNewedNativeInstance = try node . defineFunction ( fnWithJsNewedNativeInstance ) ,
25- .fnWithSerializedParams = try node . defineFunction ( fnWithSerializedParams ) ,
23+ .fnWithJsNewedNativeInstance = fnWithJsNewedNativeInstance ,
24+ .fnWithSerializedParams = fnWithSerializedParams ,
2625 .fnWithAllocatorParam = try node .defineFunction (fnWithAllocatorParam ),
2726 .fnCallback = try node .defineFunction (fnCallback ),
27+ // async must still be done explicitly
2828 .fnCallbackAsync = try node .defineAsyncFunction (fnCallbackAsync ),
2929 .asyncFunction = try node .defineAsyncFunction (sleep ),
3030 },
@@ -35,24 +35,7 @@ fn init(node: node_api.NodeContext) !?node_api.NodeValue {
3535 .comptime_int = try node .deserialize (i32 , try node .serialize (1234 )),
3636 .float = try node .deserialize (f32 , try node .serialize (12.34 )),
3737 },
38- // .s = s,
39- // .x = x,
40- // .b = b,
41- // .foo = "foo",
42- // .bar = "bar",
43- // .int = 123,
44- // .f = 12.34,
45- // .i = i,
46- // .ui = ui,
47- // .nested = .{ .more = "foo" },
48- // .callMet = try node.createFunction(),
4938 });
50-
51- // const v = try node.serialize(.{
52- // .fun = try node.createFunc(testFuncNative2),
53- // });
54-
55- return v ;
5639}
5740
5841fn getInt () i16 {
0 commit comments