@@ -44,10 +44,7 @@ export async function createInstantiator(options, swift) {
4444 i32Stack . push ( id ) ;
4545 i32Stack . push ( ( value . value | 0 ) ) ;
4646 i32Stack . push ( value . enabled ? 1 : 0 ) ;
47- const cleanup = ( ) => {
48- swift . memory . release ( id ) ;
49- } ;
50- return { cleanup } ;
47+ return { cleanup : undefined } ;
5148 } ,
5249 lift : ( ) => {
5350 const bool = i32Stack . pop ( ) !== 0 ;
@@ -96,6 +93,7 @@ export async function createInstantiator(options, swift) {
9693 }
9794 bjs [ "swift_js_init_memory" ] = function ( sourceId , bytesPtr ) {
9895 const source = swift . memory . getObject ( sourceId ) ;
96+ swift . memory . release ( sourceId ) ;
9997 const bytes = new Uint8Array ( memory . buffer , bytesPtr ) ;
10098 bytes . set ( source ) ;
10199 }
@@ -325,7 +323,6 @@ export async function createInstantiator(options, swift) {
325323 const nameBytes = textEncoder . encode ( name ) ;
326324 const nameId = swift . memory . retain ( nameBytes ) ;
327325 const ret = instance . exports . bjs_DefaultGreeter_init ( nameId , nameBytes . length ) ;
328- swift . memory . release ( nameId ) ;
329326 return DefaultGreeter . __construct ( ret ) ;
330327 }
331328 get name ( ) {
@@ -338,7 +335,6 @@ export async function createInstantiator(options, swift) {
338335 const valueBytes = textEncoder . encode ( value ) ;
339336 const valueId = swift . memory . retain ( valueBytes ) ;
340337 instance . exports . bjs_DefaultGreeter_name_set ( this . pointer , valueId , valueBytes . length ) ;
341- swift . memory . release ( valueId ) ;
342338 }
343339 }
344340 class EmptyGreeter extends SwiftHeapObject {
@@ -366,10 +362,6 @@ export async function createInstantiator(options, swift) {
366362 tagId = swift . memory . retain ( tagBytes ) ;
367363 }
368364 const ret = instance . exports . bjs_ConstructorDefaults_init ( nameId , nameBytes . length , count , enabled , status , + isSome , isSome ? tagId : 0 , isSome ? tagBytes . length : 0 ) ;
369- swift . memory . release ( nameId ) ;
370- if ( tagId != undefined ) {
371- swift . memory . release ( tagId ) ;
372- }
373365 return ConstructorDefaults . __construct ( ret ) ;
374366 }
375367 get name ( ) {
@@ -382,7 +374,6 @@ export async function createInstantiator(options, swift) {
382374 const valueBytes = textEncoder . encode ( value ) ;
383375 const valueId = swift . memory . retain ( valueBytes ) ;
384376 instance . exports . bjs_ConstructorDefaults_name_set ( this . pointer , valueId , valueBytes . length ) ;
385- swift . memory . release ( valueId ) ;
386377 }
387378 get count ( ) {
388379 const ret = instance . exports . bjs_ConstructorDefaults_count_get ( this . pointer ) ;
@@ -419,9 +410,6 @@ export async function createInstantiator(options, swift) {
419410 valueId = swift . memory . retain ( valueBytes ) ;
420411 }
421412 instance . exports . bjs_ConstructorDefaults_tag_set ( this . pointer , + isSome , isSome ? valueId : 0 , isSome ? valueBytes . length : 0 ) ;
422- if ( valueId != undefined ) {
423- swift . memory . release ( valueId ) ;
424- }
425413 }
426414 }
427415 const ConfigHelpers = __bjs_createConfigHelpers ( ) ( ) ;
@@ -440,7 +428,6 @@ export async function createInstantiator(options, swift) {
440428 instance . exports . bjs_testStringDefault ( messageId , messageBytes . length ) ;
441429 const ret = tmpRetString ;
442430 tmpRetString = undefined ;
443- swift . memory . release ( messageId ) ;
444431 return ret ;
445432 } ,
446433 testNegativeIntDefault : function bjs_testNegativeIntDefault ( value = - 42 ) {
@@ -469,9 +456,6 @@ export async function createInstantiator(options, swift) {
469456 instance . exports . bjs_testOptionalDefault ( + isSome , isSome ? nameId : 0 , isSome ? nameBytes . length : 0 ) ;
470457 const optResult = tmpRetString ;
471458 tmpRetString = undefined ;
472- if ( nameId != undefined ) {
473- swift . memory . release ( nameId ) ;
474- }
475459 return optResult ;
476460 } ,
477461 testOptionalStringDefault : function bjs_testOptionalStringDefault ( greeting = "Hi" ) {
@@ -484,9 +468,6 @@ export async function createInstantiator(options, swift) {
484468 instance . exports . bjs_testOptionalStringDefault ( + isSome , isSome ? greetingId : 0 , isSome ? greetingBytes . length : 0 ) ;
485469 const optResult = tmpRetString ;
486470 tmpRetString = undefined ;
487- if ( greetingId != undefined ) {
488- swift . memory . release ( greetingId ) ;
489- }
490471 return optResult ;
491472 } ,
492473 testMultipleDefaults : function bjs_testMultipleDefaults ( title = "Default Title" , count = 10 , enabled = false ) {
@@ -495,7 +476,6 @@ export async function createInstantiator(options, swift) {
495476 instance . exports . bjs_testMultipleDefaults ( titleId , titleBytes . length , count , enabled ) ;
496477 const ret = tmpRetString ;
497478 tmpRetString = undefined ;
498- swift . memory . release ( titleId ) ;
499479 return ret ;
500480 } ,
501481 testEnumDefault : function bjs_testEnumDefault ( status = StatusValues . Active ) {
@@ -526,7 +506,6 @@ export async function createInstantiator(options, swift) {
526506 } else {
527507 optResult = null ;
528508 }
529- if ( pointCleanup ) { pointCleanup ( ) ; }
530509 return optResult ;
531510 } ,
532511 testOptionalStructWithValueDefault : function bjs_testOptionalStructWithValueDefault ( point = { name : "default" , value : 42 , enabled : true } ) {
@@ -545,7 +524,6 @@ export async function createInstantiator(options, swift) {
545524 } else {
546525 optResult = null ;
547526 }
548- if ( pointCleanup ) { pointCleanup ( ) ; }
549527 return optResult ;
550528 } ,
551529 testIntArrayDefault : function bjs_testIntArrayDefault ( values = [ 1 , 2 , 3 ] ) {
@@ -562,7 +540,6 @@ export async function createInstantiator(options, swift) {
562540 arrayResult . push ( int ) ;
563541 }
564542 arrayResult . reverse ( ) ;
565- for ( const cleanup of arrayCleanups ) { cleanup ( ) ; }
566543 return arrayResult ;
567544 } ,
568545 testStringArrayDefault : function bjs_testStringArrayDefault ( names = [ "a" , "b" , "c" ] ) {
@@ -572,9 +549,6 @@ export async function createInstantiator(options, swift) {
572549 const id = swift . memory . retain ( bytes ) ;
573550 i32Stack . push ( bytes . length ) ;
574551 i32Stack . push ( id ) ;
575- arrayCleanups . push ( ( ) => {
576- swift . memory . release ( id ) ;
577- } ) ;
578552 }
579553 i32Stack . push ( names . length ) ;
580554 instance . exports . bjs_testStringArrayDefault ( ) ;
@@ -585,7 +559,6 @@ export async function createInstantiator(options, swift) {
585559 arrayResult . push ( string ) ;
586560 }
587561 arrayResult . reverse ( ) ;
588- for ( const cleanup of arrayCleanups ) { cleanup ( ) ; }
589562 return arrayResult ;
590563 } ,
591564 testDoubleArrayDefault : function bjs_testDoubleArrayDefault ( values = [ 1.5 , 2.5 , 3.5 ] ) {
@@ -602,7 +575,6 @@ export async function createInstantiator(options, swift) {
602575 arrayResult . push ( f64 ) ;
603576 }
604577 arrayResult . reverse ( ) ;
605- for ( const cleanup of arrayCleanups ) { cleanup ( ) ; }
606578 return arrayResult ;
607579 } ,
608580 testBoolArrayDefault : function bjs_testBoolArrayDefault ( flags = [ true , false , true ] ) {
@@ -619,7 +591,6 @@ export async function createInstantiator(options, swift) {
619591 arrayResult . push ( bool ) ;
620592 }
621593 arrayResult . reverse ( ) ;
622- for ( const cleanup of arrayCleanups ) { cleanup ( ) ; }
623594 return arrayResult ;
624595 } ,
625596 testEmptyArrayDefault : function bjs_testEmptyArrayDefault ( items = [ ] ) {
@@ -636,7 +607,6 @@ export async function createInstantiator(options, swift) {
636607 arrayResult . push ( int ) ;
637608 }
638609 arrayResult . reverse ( ) ;
639- for ( const cleanup of arrayCleanups ) { cleanup ( ) ; }
640610 return arrayResult ;
641611 } ,
642612 testMixedWithArrayDefault : function bjs_testMixedWithArrayDefault ( name = "test" , values = [ 10 , 20 , 30 ] , enabled = true ) {
@@ -650,8 +620,6 @@ export async function createInstantiator(options, swift) {
650620 instance . exports . bjs_testMixedWithArrayDefault ( nameId , nameBytes . length , enabled ) ;
651621 const ret = tmpRetString ;
652622 tmpRetString = undefined ;
653- swift . memory . release ( nameId ) ;
654- for ( const cleanup of arrayCleanups ) { cleanup ( ) ; }
655623 return ret ;
656624 } ,
657625 Status : StatusValues ,
0 commit comments