This repository was archived by the owner on Nov 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -400,11 +400,11 @@ macro_rules! rooted {
400400 } ;
401401 ( in( $cx: expr) let $name: ident: $type: ty) => {
402402 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 ( ) ) ;
404404 } ;
405405 ( in( $cx: expr) let mut $name: ident: $type: ty) => {
406406 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 ( ) ) ;
408408 } ;
409409}
410410
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ use mozjs::jsapi::JSPROP_ENUMERATE;
2121use mozjs:: jsapi:: JS_SetGCZeal ;
2222use mozjs:: jsapi:: OnNewGlobalHookOption ;
2323use mozjs:: jsapi:: Value ;
24+ use mozjs:: jsapi:: { JSObject , JSString , JSFunction } ;
2425use mozjs:: jsval:: JSVal ;
2526use mozjs:: rust:: { Runtime , SIMPLE_GLOBAL_CLASS , define_methods} ;
2627use std:: ptr;
@@ -54,8 +55,19 @@ fn type_rooting() {
5455 let runtime = Runtime :: new ( ) . unwrap ( ) ;
5556 let cx = runtime. cx ( ) ;
5657
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+ }
5971}
6072
6173unsafe extern "C" fn generic_method ( _: * mut JSContext , _: u32 , _: * mut Value ) -> bool {
You can’t perform that action at this time.
0 commit comments