@@ -594,7 +594,7 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
594594 var origin : ? v8.ScriptOrigin = null ;
595595 if (name ) | n | {
596596 const scr_name = v8 .String .initUtf8 (isolate , n );
597- origin = v8 .ScriptOrigin .initDefault (self . isolate , scr_name .toValue ());
597+ origin = v8 .ScriptOrigin .initDefault (scr_name .toValue ());
598598 }
599599 const scr_js = v8 .String .initUtf8 (isolate , src );
600600 const scr = v8 .Script .compile (context , scr_js , origin ) catch {
@@ -1142,7 +1142,6 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
11421142 const script_source = v8 .String .initUtf8 (isolate , src );
11431143
11441144 const origin = v8 .ScriptOrigin .init (
1145- isolate ,
11461145 script_name .toValue (),
11471146 0 , // resource_line_offset
11481147 0 , // resource_column_offset
@@ -1201,14 +1200,15 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
12011200 if (@hasDecl (Struct , "get_symbol_toStringTag" ) == false ) {
12021201 // If this WAS defined, then we would have created it in generateProperty.
12031202 // But if it isn't, we create a default one
1204- const key = v8 .Symbol .getToStringTag (isolate ).toName ();
1205- template_proto .setGetter (key , struct {
1206- fn stringTag (_ : ? * const v8.C_Name , raw_info : ? * const v8.C_PropertyCallbackInfo ) callconv (.c ) void {
1207- const info = v8 .PropertyCallbackInfo .initFromV8 (raw_info );
1203+ const string_tag_callback = v8 .FunctionTemplate .initCallback (isolate , struct {
1204+ fn stringTag (raw_info : ? * const v8.C_FunctionCallbackInfo ) callconv (.c ) void {
1205+ const info = v8 .FunctionCallbackInfo .initFromV8 (raw_info );
12081206 const class_name = v8 .String .initUtf8 (info .getIsolate (), comptime classNameForStruct (Struct ));
12091207 info .getReturnValue ().set (class_name );
12101208 }
12111209 }.stringTag );
1210+ const key = v8 .Symbol .getToStringTag (isolate ).toName ();
1211+ template_proto .setAccessorGetter (key , string_tag_callback );
12121212 }
12131213
12141214 generateIndexer (Struct , template_proto );
@@ -1309,9 +1309,9 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
13091309 js_name = v8 .String .initUtf8 (isolate , name ).toName ();
13101310 }
13111311
1312- const getter_callback = struct {
1313- fn callback (_ : ? * const v8.C_Name , raw_info : ? * const v8.C_PropertyCallbackInfo ) callconv (.c ) void {
1314- const info = v8 .PropertyCallbackInfo .initFromV8 (raw_info );
1312+ const getter_callback = v8 . FunctionTemplate . initCallback ( isolate , struct {
1313+ fn callback (raw_info : ? * const v8.C_FunctionCallbackInfo ) callconv (.c ) void {
1314+ const info = v8 .FunctionCallbackInfo .initFromV8 (raw_info );
13151315 var caller = Caller (Self , State ).init (info );
13161316 defer caller .deinit ();
13171317
@@ -1320,28 +1320,30 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
13201320 caller .handleError (Struct , named_function , err , info );
13211321 };
13221322 }
1323- }.callback ;
1323+ }.callback ) ;
13241324
13251325 const setter_name = "set_" ++ name ;
13261326 if (@hasDecl (Struct , setter_name ) == false ) {
1327- template_proto .setGetter (js_name , getter_callback );
1327+ template_proto .setAccessorGetter (js_name , getter_callback );
13281328 return ;
13291329 }
13301330
1331- const setter_callback = struct {
1332- fn callback (_ : ? * const v8.C_Name , raw_value : ? * const v8.C_Value , raw_info : ? * const v8.C_PropertyCallbackInfo ) callconv (.c ) void {
1333- const info = v8 .PropertyCallbackInfo .initFromV8 (raw_info );
1331+ const setter_callback = v8 . FunctionTemplate . initCallback ( isolate , struct {
1332+ fn callback (raw_info : ? * const v8.C_FunctionCallbackInfo ) callconv (.c ) void {
1333+ const info = v8 .FunctionCallbackInfo .initFromV8 (raw_info );
13341334 var caller = Caller (Self , State ).init (info );
13351335 defer caller .deinit ();
13361336
1337- const js_value = v8.Value { .handle = raw_value .? };
1337+ std .debug .assert (info .length () == 1 );
1338+ const js_value = info .getArg (0 );
13381339 const named_function = comptime NamedFunction .init (Struct , "set_" ++ name );
13391340 caller .setter (Struct , named_function , js_value , info ) catch | err | {
13401341 caller .handleError (Struct , named_function , err , info );
13411342 };
13421343 }
1343- }.callback ;
1344- template_proto .setGetterAndSetter (js_name , getter_callback , setter_callback );
1344+ }.callback );
1345+
1346+ template_proto .setAccessorGetterAndSetter (js_name , getter_callback , setter_callback );
13451347 }
13461348
13471349 fn generateIndexer (comptime Struct : type , template_proto : v8.ObjectTemplate ) void {
@@ -1350,14 +1352,15 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
13501352 }
13511353 const configuration = v8.IndexedPropertyHandlerConfiguration {
13521354 .getter = struct {
1353- fn callback (idx : u32 , raw_info : ? * const v8.C_PropertyCallbackInfo ) callconv (.c ) void {
1355+ fn callback (idx : u32 , raw_info : ? * const v8.C_PropertyCallbackInfo ) callconv (.c ) u8 {
13541356 const info = v8 .PropertyCallbackInfo .initFromV8 (raw_info );
13551357 var caller = Caller (Self , State ).init (info );
13561358 defer caller .deinit ();
13571359
13581360 const named_function = comptime NamedFunction .init (Struct , "indexed_get" );
1359- caller .getIndex (Struct , named_function , idx , info ) catch | err | {
1361+ return caller .getIndex (Struct , named_function , idx , info ) catch | err | blk : {
13601362 caller .handleError (Struct , named_function , err , info );
1363+ break :blk v8 .Intercepted .No ;
13611364 };
13621365 }
13631366 }.callback ,
@@ -1379,14 +1382,15 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
13791382 }
13801383 const configuration = v8.NamedPropertyHandlerConfiguration {
13811384 .getter = struct {
1382- fn callback (c_name : ? * const v8.C_Name , raw_info : ? * const v8.C_PropertyCallbackInfo ) callconv (.c ) void {
1385+ fn callback (c_name : ? * const v8.C_Name , raw_info : ? * const v8.C_PropertyCallbackInfo ) callconv (.c ) u8 {
13831386 const info = v8 .PropertyCallbackInfo .initFromV8 (raw_info );
13841387 var caller = Caller (Self , State ).init (info );
13851388 defer caller .deinit ();
13861389
13871390 const named_function = comptime NamedFunction .init (Struct , "named_get" );
1388- caller .getNamedIndex (Struct , named_function , .{ .handle = c_name .? }, info ) catch | err | {
1391+ return caller .getNamedIndex (Struct , named_function , .{ .handle = c_name .? }, info ) catch | err | blk : {
13891392 caller .handleError (Struct , named_function , err , info );
1393+ break :blk v8 .Intercepted .No ;
13901394 };
13911395 }
13921396 }.callback ,
@@ -1762,7 +1766,7 @@ fn Caller(comptime E: type, comptime State: type) type {
17621766 info .getReturnValue ().set (try self .zigValueToJs (res ));
17631767 }
17641768
1765- fn getter (self : * Self , comptime Struct : type , comptime named_function : NamedFunction , info : v8.PropertyCallbackInfo ) ! void {
1769+ fn getter (self : * Self , comptime Struct : type , comptime named_function : NamedFunction , info : v8.FunctionCallbackInfo ) ! void {
17661770 const func = @field (Struct , named_function .name );
17671771 const Getter = @TypeOf (func );
17681772 if (@typeInfo (Getter ).@"fn" .return_type == null ) {
@@ -1788,7 +1792,7 @@ fn Caller(comptime E: type, comptime State: type) type {
17881792 info .getReturnValue ().set (try self .zigValueToJs (res ));
17891793 }
17901794
1791- fn setter (self : * Self , comptime Struct : type , comptime named_function : NamedFunction , js_value : v8.Value , info : v8.PropertyCallbackInfo ) ! void {
1795+ fn setter (self : * Self , comptime Struct : type , comptime named_function : NamedFunction , js_value : v8.Value , info : v8.FunctionCallbackInfo ) ! void {
17921796 const func = @field (Struct , named_function .name );
17931797 comptime assertSelfReceiver (Struct , named_function );
17941798
@@ -1820,7 +1824,7 @@ fn Caller(comptime E: type, comptime State: type) type {
18201824 _ = @call (.auto , func , args );
18211825 }
18221826
1823- fn getIndex (self : * Self , comptime Struct : type , comptime named_function : NamedFunction , idx : u32 , info : v8.PropertyCallbackInfo ) ! void {
1827+ fn getIndex (self : * Self , comptime Struct : type , comptime named_function : NamedFunction , idx : u32 , info : v8.PropertyCallbackInfo ) ! u8 {
18241828 const func = @field (Struct , named_function .name );
18251829 const IndexedGet = @TypeOf (func );
18261830 if (@typeInfo (IndexedGet ).@"fn" .return_type == null ) {
@@ -1849,15 +1853,13 @@ fn Caller(comptime E: type, comptime State: type) type {
18491853
18501854 const res = @call (.auto , func , args );
18511855 if (has_value == false ) {
1852- // for an indexed parameter, say nodes[10000], we should return
1853- // undefined, not null, if the index is out of rante
1854- info .getReturnValue ().set (try self .zigValueToJs ({}));
1855- } else {
1856- info .getReturnValue ().set (try self .zigValueToJs (res ));
1856+ return v8 .Intercepted .No ;
18571857 }
1858+ info .getReturnValue ().set (try self .zigValueToJs (res ));
1859+ return v8 .Intercepted .Yes ;
18581860 }
18591861
1860- fn getNamedIndex (self : * Self , comptime Struct : type , comptime named_function : NamedFunction , name : v8.Name , info : v8.PropertyCallbackInfo ) ! void {
1862+ fn getNamedIndex (self : * Self , comptime Struct : type , comptime named_function : NamedFunction , name : v8.Name , info : v8.PropertyCallbackInfo ) ! u8 {
18611863 const func = @field (Struct , named_function .name );
18621864 const NamedGet = @TypeOf (func );
18631865 if (@typeInfo (NamedGet ).@"fn" .return_type == null ) {
@@ -1885,12 +1887,10 @@ fn Caller(comptime E: type, comptime State: type) type {
18851887
18861888 const res = @call (.auto , func , args );
18871889 if (has_value == false ) {
1888- // for an indexed parameter, say nodes[10000], we should return
1889- // undefined, not null, if the index is out of rante
1890- info .getReturnValue ().set (try self .zigValueToJs ({}));
1891- } else {
1892- info .getReturnValue ().set (try self .zigValueToJs (res ));
1890+ return v8 .Intercepted .No ;
18931891 }
1892+ info .getReturnValue ().set (try self .zigValueToJs (res ));
1893+ return v8 .Intercepted .Yes ;
18941894 }
18951895
18961896 fn nameToString (self : * Self , name : v8.Name ) ! []const u8 {
0 commit comments