This repository was archived by the owner on Nov 12, 2022. It is now read-only.
File tree 2 files changed +16
-4
lines changed
2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -400,11 +400,11 @@ macro_rules! rooted {
400
400
} ;
401
401
( in( $cx: expr) let $name: ident: $type: ty) => {
402
402
let mut __root = $crate:: jsapi:: Rooted :: new_unrooted( ) ;
403
- let $name = $crate:: rust:: RootedGuard :: new( $cx, & mut __root, <$type as Default >:: default ( ) ) ;
403
+ let $name = $crate:: rust:: RootedGuard :: new( $cx, & mut __root, <$type as GCMethods >:: initial ( ) ) ;
404
404
} ;
405
405
( in( $cx: expr) let mut $name: ident: $type: ty) => {
406
406
let mut __root = $crate:: jsapi:: Rooted :: new_unrooted( ) ;
407
- let mut $name = $crate:: rust:: RootedGuard :: new( $cx, & mut __root, <$type as Default >:: default ( ) ) ;
407
+ let mut $name = $crate:: rust:: RootedGuard :: new( $cx, & mut __root, <$type as GCMethods >:: initial ( ) ) ;
408
408
} ;
409
409
}
410
410
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ use mozjs::jsapi::JSPROP_ENUMERATE;
21
21
use mozjs:: jsapi:: JS_SetGCZeal ;
22
22
use mozjs:: jsapi:: OnNewGlobalHookOption ;
23
23
use mozjs:: jsapi:: Value ;
24
+ use mozjs:: jsapi:: { JSObject , JSString , JSFunction } ;
24
25
use mozjs:: jsval:: JSVal ;
25
26
use mozjs:: rust:: { Runtime , SIMPLE_GLOBAL_CLASS , define_methods} ;
26
27
use std:: ptr;
@@ -54,8 +55,19 @@ fn type_rooting() {
54
55
let runtime = Runtime :: new ( ) . unwrap ( ) ;
55
56
let cx = runtime. cx ( ) ;
56
57
57
- rooted ! ( in( cx) let root : JSVal ) ;
58
- assert_eq ! ( root. get( ) . is_undefined( ) , true ) ;
58
+ unsafe {
59
+ rooted ! ( in( cx) let root : JSVal ) ;
60
+ assert_eq ! ( root. get( ) . is_undefined( ) , true ) ;
61
+
62
+ rooted ! ( in( cx) let root : * mut JSObject ) ;
63
+ assert_eq ! ( root. get( ) . is_null( ) , true ) ;
64
+
65
+ rooted ! ( in( cx) let root : * mut JSString ) ;
66
+ assert_eq ! ( root. get( ) . is_null( ) , true ) ;
67
+
68
+ rooted ! ( in( cx) let root : * mut JSFunction ) ;
69
+ assert_eq ! ( root. get( ) . is_null( ) , true ) ;
70
+ }
59
71
}
60
72
61
73
unsafe extern "C" fn generic_method ( _: * mut JSContext , _: u32 , _: * mut Value ) -> bool {
You can’t perform that action at this time.
0 commit comments