@@ -1354,98 +1354,86 @@ pub mod wrappers {
13541354pub mod wrappers2 {
13551355 macro_rules! wrap {
13561356 // The invocation of @inner has the following form:
1357- // @inner (input args) <> (accumulator) <> unparsed tokens
1357+ // @inner (input args) <> (arg signture accumulator) <> (arg expr accumulator) <> unparsed tokens
13581358 // when `unparsed tokens == \eps`, accumulator contains the final result
13591359
1360- // create conversions for argument expressions
1361- ( @inner $saved: tt <> ( $( $acc: expr, ) * ) <> $arg: ident: * const Handle <$gentype: ty>, $( $rest: tt) * ) => {
1362- wrap!( @inner $saved <> ( $( $acc, ) * if $arg. is_null( ) { :: std:: ptr:: null( ) } else { & ( * $arg) . into( ) } , ) <> $( $rest) * ) ;
1360+ ( @inner $saved: tt <> ( $( $arg_sig_acc: tt) * ) <> ( $( $arg_expr_acc: expr, ) * ) <> $arg: ident: * const Handle <$gentype: ty>, $( $rest: tt) * ) => {
1361+ wrap!( @inner $saved <> ( $( $arg_sig_acc) * , $arg: * const Handle <$gentype>) <> ( $( $arg_expr_acc, ) * if $arg. is_null( ) { :: std:: ptr:: null( ) } else { & ( * $arg) . into( ) } , ) <> $( $rest) * ) ;
13631362 } ;
1364- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: Handle <$gentype: ty>, $( $rest: tt) * ) => {
1365- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1363+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: Handle <$gentype: ty>, $( $rest: tt) * ) => {
1364+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : Handle <$gentype> ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
13661365 } ;
1367- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: MutableHandle <$gentype: ty>, $( $rest: tt) * ) => {
1368- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1366+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: MutableHandle <$gentype: ty>, $( $rest: tt) * ) => {
1367+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : MutableHandle <$gentype> ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
13691368 } ;
1370- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: Handle , $( $rest: tt) * ) => {
1371- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1369+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: Handle , $( $rest: tt) * ) => {
1370+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : Handle ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
13721371 } ;
1373- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: MutableHandle , $( $rest: tt) * ) => {
1374- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1372+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: MutableHandle , $( $rest: tt) * ) => {
1373+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : MutableHandle ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
13751374 } ;
1376- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: HandleFunction , $( $rest: tt) * ) => {
1377- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1375+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: HandleFunction , $( $rest: tt) * ) => {
1376+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : HandleFunction ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
13781377 } ;
1379- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: HandleId , $( $rest: tt) * ) => {
1380- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1378+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: HandleId , $( $rest: tt) * ) => {
1379+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : HandleId ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
13811380 } ;
1382- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: HandleObject , $( $rest: tt) * ) => {
1383- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1381+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: HandleObject , $( $rest: tt) * ) => {
1382+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : HandleObject ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
13841383 } ;
1385- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: HandleScript , $( $rest: tt) * ) => {
1386- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1384+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: HandleScript , $( $rest: tt) * ) => {
1385+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : HandleScript ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
13871386 } ;
1388- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: HandleString , $( $rest: tt) * ) => {
1389- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1387+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: HandleString , $( $rest: tt) * ) => {
1388+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : HandleString ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
13901389 } ;
1391- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: HandleSymbol , $( $rest: tt) * ) => {
1392- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1390+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: HandleSymbol , $( $rest: tt) * ) => {
1391+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : HandleSymbol ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
13931392 } ;
1394- ( @inner $saved: tt <> ( $( $acc: expr, ) * ) <> $arg: ident: HandleValue , $( $rest: tt) * ) => {
1395- wrap!( @inner $saved <> ( $( $acc, ) * $arg. into( ) , ) <> $( $rest) * ) ;
1396- } ;
1397- ( @inner $saved: tt <> ( $( $acc: expr, ) * ) <> $arg: ident: MutableHandleFunction , $( $rest: tt) * ) => {
1398- wrap!( @inner $saved <> ( $( $acc, ) * $arg. into( ) , ) <> $( $rest) * ) ;
1393+ ( @inner $saved: tt <> ( $( $arg_sig_acc: tt) * ) <> ( $( $arg_expr_acc: expr, ) * ) <> $arg: ident: HandleValue , $( $rest: tt) * ) => {
1394+ wrap!( @inner $saved <> ( $( $arg_sig_acc) * , $arg: HandleValue ) <> ( $( $arg_expr_acc, ) * $arg. into( ) , ) <> $( $rest) * ) ;
13991395 } ;
1400- ( @inner $saved: tt <> ( $( $acc: expr, ) * ) <> $arg: ident: MutableHandleId , $( $rest: tt) * ) => {
1401- wrap!( @inner $saved <> ( $( $acc, ) * $arg. into( ) , ) <> $( $rest) * ) ;
1402- } ;
1403- ( @inner $saved: tt <> ( $( $acc: expr, ) * ) <> $arg: ident: MutableHandleObject , $( $rest: tt) * ) => {
1404- wrap!( @inner $saved <> ( $( $acc, ) * $arg. into( ) , ) <> $( $rest) * ) ;
1405- } ;
1406- ( @inner $saved: tt <> ( $( $acc: expr, ) * ) <> $arg: ident: MutableHandleScript , $( $rest: tt) * ) => {
1407- wrap!( @inner $saved <> ( $( $acc, ) * $arg. into( ) , ) <> $( $rest) * ) ;
1396+ ( @inner $saved: tt <> ( $( $arg_sig_acc: tt) * ) <> ( $( $arg_expr_acc: expr, ) * ) <> $arg: ident: MutableHandleFunction , $( $rest: tt) * ) => {
1397+ wrap!( @inner $saved <> ( $( $arg_sig_acc) * , $arg: MutableHandleFunction ) <> ( $( $arg_expr_acc, ) * $arg. into( ) , ) <> $( $rest) * ) ;
14081398 } ;
1409- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: MutableHandleString , $( $rest: tt) * ) => {
1410- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1399+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: MutableHandleId , $( $rest: tt) * ) => {
1400+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : MutableHandleId ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
14111401 } ;
1412- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: MutableHandleSymbol , $( $rest: tt) * ) => {
1413- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1402+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: MutableHandleObject , $( $rest: tt) * ) => {
1403+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : MutableHandleObject ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
14141404 } ;
1415- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: MutableHandleValue , $( $rest: tt) * ) => {
1416- wrap!( @inner $saved <> ( $( $acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
1405+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: MutableHandleScript , $( $rest: tt) * ) => {
1406+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : MutableHandleScript ) <> ( $ ( $arg_expr_acc , ) * $arg. into( ) , ) <> $( $rest) * ) ;
14171407 } ;
1418- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: & mut JSContext , $( $rest: tt) * ) => {
1419- wrap!( @inner $saved <> ( $( $acc , ) * $arg. raw_cx ( ) , ) <> $( $rest) * ) ;
1408+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: MutableHandleString , $( $rest: tt) * ) => {
1409+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : MutableHandleString ) <> ( $ ( $arg_expr_acc , ) * $arg. into ( ) , ) <> $( $rest) * ) ;
14201410 } ;
1421- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: & JSContext , $( $rest: tt) * ) => {
1422- wrap!( @inner $saved <> ( $( $acc , ) * $arg. raw_cx_no_gc ( ) , ) <> $( $rest) * ) ;
1411+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: MutableHandleSymbol , $( $rest: tt) * ) => {
1412+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : MutableHandleSymbol ) <> ( $ ( $arg_expr_acc , ) * $arg. into ( ) , ) <> $( $rest) * ) ;
14231413 } ;
1424- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: * const AutoRequireNoGC , $( $rest: tt) * ) => {
1425- wrap!( @inner $saved <> ( $( $acc , ) * :: std :: ptr :: null ( ) , ) <> $( $rest) * ) ;
1414+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: MutableHandleValue , $( $rest: tt) * ) => {
1415+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : MutableHandleValue ) <> ( $ ( $arg_expr_acc , ) * $arg . into ( ) , ) <> $( $rest) * ) ;
14261416 } ;
1427- ( @inner $saved: tt <> ( $( $acc : expr, ) * ) <> $arg: ident: $type : ty , $( $rest: tt) * ) => {
1428- wrap!( @inner $saved <> ( $( $acc , ) * $arg, ) <> $( $rest) * ) ;
1417+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt ) * ) <> ( $ ( $arg_expr_acc : expr, ) * ) <> $arg: ident: & mut JSContext , $( $rest: tt) * ) => {
1418+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg : & mut JSContext ) <> ( $ ( $arg_expr_acc , ) * $arg. raw_cx ( ) , ) <> $( $rest) * ) ;
14291419 } ;
1430- // here we transform arguments from signature of wrappers
1431- ( @inner ( $module: tt: $func_name: ident ( $( $args: tt) * ) -> $outtype: ty) <> ( $( $argexprs: expr, ) * ) <> ) => {
1432- wrap!( @inner2 ( $module: $func_name ( $( $argexprs, ) * ) -> $outtype) <> ( ) <> $( $args) * , ) ;
1420+ ( @inner $saved: tt <> ( $( $arg_sig_acc: tt) * ) <> ( $( $arg_expr_acc: expr, ) * ) <> $arg: ident: & JSContext , $( $rest: tt) * ) => {
1421+ wrap!( @inner $saved <> ( $( $arg_sig_acc) * , $arg: & JSContext ) <> ( $( $arg_expr_acc, ) * $arg. raw_cx_no_gc( ) , ) <> $( $rest) * ) ;
14331422 } ;
1434- // remove *const AutoRequireNoGC marker argument
1435- ( @inner2 $saved: tt <> ( $( $acc: tt) * ) <> $arg: ident: * const AutoRequireNoGC , $( $rest: tt) * ) => {
1436- wrap!( @inner2 $saved <> ( $( $acc) * ) <> $( $rest) * ) ;
1423+ ( @inner $saved: tt <> ( $( $arg_sig_acc: tt) * ) <> ( $( $arg_expr_acc: expr, ) * ) <> $arg: ident: * const AutoRequireNoGC , $( $rest: tt) * ) => {
1424+ wrap!( @inner $saved <> ( $( $arg_sig_acc) * ) <> ( $( $arg_expr_acc, ) * :: std:: ptr:: null( ) , ) <> $( $rest) * ) ;
14371425 } ;
1438- ( @inner2 $saved: tt <> ( $( $acc : tt) * ) <> $arg: ident: $type: ty, $( $rest: tt) * ) => {
1439- wrap!( @inner2 $saved <> ( $( $acc ) * , $arg: $type) <> $( $rest) * ) ;
1426+ ( @inner $saved: tt <> ( $( $arg_sig_acc : tt) * ) <> ( $ ( $arg_expr_acc : expr , ) * ) <> $arg: ident: $type: ty, $( $rest: tt) * ) => {
1427+ wrap!( @inner $saved <> ( $( $arg_sig_acc ) * , $arg: $type) <> ( $ ( $arg_expr_acc , ) * $arg , ) <> $( $rest) * ) ;
14401428 } ;
1441- ( @inner2 ( $module: tt: $func_name: ident ( $ ( $argexprs : expr , ) * ) -> $outtype: ty) <> ( , $( $args: tt) * ) <> ) => {
1429+ ( @inner ( $module: tt: $func_name: ident -> $outtype: ty) <> ( , $( $args: tt) * ) <> ( $ ( $argexprs : expr , ) * ) <> ) => {
14421430 #[ inline]
14431431 pub unsafe fn $func_name( $( $args) * ) -> $outtype {
14441432 $module:: $func_name( $( $argexprs) ,* )
14451433 }
14461434 } ;
14471435 ( $module: tt: pub fn $func_name: ident( $( $args: tt) * ) -> $outtype: ty) => {
1448- wrap!( @inner ( $module: $func_name ( $ ( $args ) * ) -> $outtype) <> ( ) <> $( $args) * , ) ;
1436+ wrap!( @inner ( $module: $func_name -> $outtype) <> ( ) <> ( ) <> $( $args) * , ) ;
14491437 } ;
14501438 ( $module: tt: pub fn $func_name: ident( $( $args: tt) * ) ) => {
14511439 wrap!( $module: pub fn $func_name( $( $args) * ) -> ( ) ) ;
0 commit comments