@@ -394,18 +394,9 @@ export async function createInstantiator(options, swift) {
394394 setException ( error ) ;
395395 }
396396 }
397- TestModule [ "bjs_WithOptionalJSClass_childOrNull_set" ] = function bjs_WithOptionalJSClass_childOrNull_set ( self , newValue ) {
397+ TestModule [ "bjs_WithOptionalJSClass_childOrNull_set" ] = function bjs_WithOptionalJSClass_childOrNull_set ( self , newValueIsSome , newValueObjectId ) {
398398 try {
399- let optResult ;
400- if ( newValue ) {
401- const objId = i32Stack . pop ( ) ;
402- const obj = swift . memory . getObject ( objId ) ;
403- swift . memory . release ( objId ) ;
404- optResult = obj ;
405- } else {
406- optResult = null ;
407- }
408- swift . memory . getObject ( self ) . childOrNull = optResult ;
399+ swift . memory . getObject ( self ) . childOrNull = newValueIsSome ? swift . memory . getObject ( newValueObjectId ) : null ;
409400 } catch ( error ) {
410401 setException ( error ) ;
411402 }
@@ -496,22 +487,13 @@ export async function createInstantiator(options, swift) {
496487 setException ( error ) ;
497488 }
498489 }
499- TestModule [ "bjs_WithOptionalJSClass_roundTripChildOrNull" ] = function bjs_WithOptionalJSClass_roundTripChildOrNull ( self , value ) {
490+ TestModule [ "bjs_WithOptionalJSClass_roundTripChildOrNull" ] = function bjs_WithOptionalJSClass_roundTripChildOrNull ( self , valueIsSome , valueObjectId ) {
500491 try {
501- let optResult ;
502- if ( value ) {
503- const objId = i32Stack . pop ( ) ;
504- const obj = swift . memory . getObject ( objId ) ;
505- swift . memory . release ( objId ) ;
506- optResult = obj ;
507- } else {
508- optResult = null ;
509- }
510- let ret = swift . memory . getObject ( self ) . roundTripChildOrNull ( optResult ) ;
492+ let ret = swift . memory . getObject ( self ) . roundTripChildOrNull ( valueIsSome ? swift . memory . getObject ( valueObjectId ) : null ) ;
511493 const isSome = ret != null ;
512494 if ( isSome ) {
513- const objId1 = swift . memory . retain ( ret ) ;
514- i32Stack . push ( objId1 ) ;
495+ const objId = swift . memory . retain ( ret ) ;
496+ i32Stack . push ( objId ) ;
515497 }
516498 i32Stack . push ( isSome ? 1 : 0 ) ;
517499 } catch ( error ) {
@@ -732,6 +714,48 @@ export async function createInstantiator(options, swift) {
732714 const optResult = pointer === null ? null : OptionalPropertyHolder . __construct ( pointer ) ;
733715 return optResult ;
734716 } ,
717+ roundTripExportedOptionalJSObject : function bjs_roundTripExportedOptionalJSObject ( value ) {
718+ const isSome = value != null ;
719+ let result ;
720+ if ( isSome ) {
721+ result = swift . memory . retain ( value ) ;
722+ } else {
723+ result = 0 ;
724+ }
725+ instance . exports . bjs_roundTripExportedOptionalJSObject ( + isSome , result ) ;
726+ const isSome1 = i32Stack . pop ( ) ;
727+ let optResult ;
728+ if ( isSome1 ) {
729+ const objId = i32Stack . pop ( ) ;
730+ const obj = swift . memory . getObject ( objId ) ;
731+ swift . memory . release ( objId ) ;
732+ optResult = obj ;
733+ } else {
734+ optResult = null ;
735+ }
736+ return optResult ;
737+ } ,
738+ roundTripExportedOptionalJSClass : function bjs_roundTripExportedOptionalJSClass ( value ) {
739+ const isSome = value != null ;
740+ let result ;
741+ if ( isSome ) {
742+ result = swift . memory . retain ( value ) ;
743+ } else {
744+ result = 0 ;
745+ }
746+ instance . exports . bjs_roundTripExportedOptionalJSClass ( + isSome , result ) ;
747+ const isSome1 = i32Stack . pop ( ) ;
748+ let optResult ;
749+ if ( isSome1 ) {
750+ const objId = i32Stack . pop ( ) ;
751+ const obj = swift . memory . getObject ( objId ) ;
752+ swift . memory . release ( objId ) ;
753+ optResult = obj ;
754+ } else {
755+ optResult = null ;
756+ }
757+ return optResult ;
758+ } ,
735759 roundTripString : function bjs_roundTripString ( name ) {
736760 const isSome = name != null ;
737761 let result , result1 ;
0 commit comments