@@ -34,46 +34,42 @@ export async function createInstantiator(options, swift) {
3434
3535 let _exports = null ;
3636 let bjs = null ;
37- const __bjs_createConfigHelpers = ( ) => {
38- return ( ) => ( {
39- lower : ( value ) => {
40- const bytes = textEncoder . encode ( value . name ) ;
41- const id = swift . memory . retain ( bytes ) ;
42- i32Stack . push ( bytes . length ) ;
43- i32Stack . push ( id ) ;
44- i32Stack . push ( ( value . value | 0 ) ) ;
45- i32Stack . push ( value . enabled ? 1 : 0 ) ;
46- } ,
47- lift : ( ) => {
48- const bool = i32Stack . pop ( ) !== 0 ;
49- const int = i32Stack . pop ( ) ;
50- const string = strStack . pop ( ) ;
51- return { name : string , value : int , enabled : bool } ;
52- }
53- } ) ;
54- } ;
55- const __bjs_createMathOperationsHelpers = ( ) => {
56- return ( ) => ( {
57- lower : ( value ) => {
58- f64Stack . push ( value . baseValue ) ;
59- } ,
60- lift : ( ) => {
61- const f64 = f64Stack . pop ( ) ;
62- const instance1 = { baseValue : f64 } ;
63- instance1 . add = function ( a , b = 10.0 ) {
64- structHelpers . MathOperations . lower ( this ) ;
65- const ret = instance . exports . bjs_MathOperations_add ( a , b ) ;
66- return ret ;
67- } . bind ( instance1 ) ;
68- instance1 . multiply = function ( a , b ) {
69- structHelpers . MathOperations . lower ( this ) ;
70- const ret = instance . exports . bjs_MathOperations_multiply ( a , b ) ;
71- return ret ;
72- } . bind ( instance1 ) ;
73- return instance1 ;
74- }
75- } ) ;
76- } ;
37+ const __bjs_createConfigHelpers = ( ) => ( {
38+ lower : ( value ) => {
39+ const bytes = textEncoder . encode ( value . name ) ;
40+ const id = swift . memory . retain ( bytes ) ;
41+ i32Stack . push ( bytes . length ) ;
42+ i32Stack . push ( id ) ;
43+ i32Stack . push ( ( value . value | 0 ) ) ;
44+ i32Stack . push ( value . enabled ? 1 : 0 ) ;
45+ } ,
46+ lift : ( ) => {
47+ const bool = i32Stack . pop ( ) !== 0 ;
48+ const int = i32Stack . pop ( ) ;
49+ const string = strStack . pop ( ) ;
50+ return { name : string , value : int , enabled : bool } ;
51+ }
52+ } ) ;
53+ const __bjs_createMathOperationsHelpers = ( ) => ( {
54+ lower : ( value ) => {
55+ f64Stack . push ( value . baseValue ) ;
56+ } ,
57+ lift : ( ) => {
58+ const f64 = f64Stack . pop ( ) ;
59+ const instance1 = { baseValue : f64 } ;
60+ instance1 . add = function ( a , b = 10.0 ) {
61+ structHelpers . MathOperations . lower ( this ) ;
62+ const ret = instance . exports . bjs_MathOperations_add ( a , b ) ;
63+ return ret ;
64+ } . bind ( instance1 ) ;
65+ instance1 . multiply = function ( a , b ) {
66+ structHelpers . MathOperations . lower ( this ) ;
67+ const ret = instance . exports . bjs_MathOperations_multiply ( a , b ) ;
68+ return ret ;
69+ } . bind ( instance1 ) ;
70+ return instance1 ;
71+ }
72+ } ) ;
7773
7874 return {
7975 /**
@@ -343,12 +339,18 @@ export async function createInstantiator(options, swift) {
343339 const nameBytes = textEncoder . encode ( name ) ;
344340 const nameId = swift . memory . retain ( nameBytes ) ;
345341 const isSome = tag != null ;
346- let tagId , tagBytes ;
342+ let result ;
343+ let result1 ;
347344 if ( isSome ) {
348- tagBytes = textEncoder . encode ( tag ) ;
349- tagId = swift . memory . retain ( tagBytes ) ;
345+ const tagBytes = textEncoder . encode ( tag ) ;
346+ const tagId = swift . memory . retain ( tagBytes ) ;
347+ result = tagId ;
348+ result1 = tagBytes . length ;
349+ } else {
350+ result = 0 ;
351+ result1 = 0 ;
350352 }
351- const ret = instance . exports . bjs_ConstructorDefaults_init ( nameId , nameBytes . length , count , enabled , status , + isSome , isSome ? tagId : 0 , isSome ? tagBytes . length : 0 ) ;
353+ const ret = instance . exports . bjs_ConstructorDefaults_init ( nameId , nameBytes . length , count , enabled , status , + isSome , result , result1 ) ;
352354 return ConstructorDefaults . __construct ( ret ) ;
353355 }
354356 get name ( ) {
@@ -391,18 +393,24 @@ export async function createInstantiator(options, swift) {
391393 }
392394 set tag ( value ) {
393395 const isSome = value != null ;
394- let valueId , valueBytes ;
396+ let result ;
397+ let result1 ;
395398 if ( isSome ) {
396- valueBytes = textEncoder . encode ( value ) ;
397- valueId = swift . memory . retain ( valueBytes ) ;
399+ const valueBytes = textEncoder . encode ( value ) ;
400+ const valueId = swift . memory . retain ( valueBytes ) ;
401+ result = valueId ;
402+ result1 = valueBytes . length ;
403+ } else {
404+ result = 0 ;
405+ result1 = 0 ;
398406 }
399- instance . exports . bjs_ConstructorDefaults_tag_set ( this . pointer , + isSome , isSome ? valueId : 0 , isSome ? valueBytes . length : 0 ) ;
407+ instance . exports . bjs_ConstructorDefaults_tag_set ( this . pointer , + isSome , result , result1 ) ;
400408 }
401409 }
402- const ConfigHelpers = __bjs_createConfigHelpers ( ) ( ) ;
410+ const ConfigHelpers = __bjs_createConfigHelpers ( ) ;
403411 structHelpers . Config = ConfigHelpers ;
404412
405- const MathOperationsHelpers = __bjs_createMathOperationsHelpers ( ) ( ) ;
413+ const MathOperationsHelpers = __bjs_createMathOperationsHelpers ( ) ;
406414 structHelpers . MathOperations = MathOperationsHelpers ;
407415
408416 const exports = {
@@ -435,24 +443,36 @@ export async function createInstantiator(options, swift) {
435443 } ,
436444 testOptionalDefault : function bjs_testOptionalDefault ( name = null ) {
437445 const isSome = name != null ;
438- let nameId , nameBytes ;
446+ let result ;
447+ let result1 ;
439448 if ( isSome ) {
440- nameBytes = textEncoder . encode ( name ) ;
441- nameId = swift . memory . retain ( nameBytes ) ;
449+ const nameBytes = textEncoder . encode ( name ) ;
450+ const nameId = swift . memory . retain ( nameBytes ) ;
451+ result = nameId ;
452+ result1 = nameBytes . length ;
453+ } else {
454+ result = 0 ;
455+ result1 = 0 ;
442456 }
443- instance . exports . bjs_testOptionalDefault ( + isSome , isSome ? nameId : 0 , isSome ? nameBytes . length : 0 ) ;
457+ instance . exports . bjs_testOptionalDefault ( + isSome , result , result1 ) ;
444458 const optResult = tmpRetString ;
445459 tmpRetString = undefined ;
446460 return optResult ;
447461 } ,
448462 testOptionalStringDefault : function bjs_testOptionalStringDefault ( greeting = "Hi" ) {
449463 const isSome = greeting != null ;
450- let greetingId , greetingBytes ;
464+ let result ;
465+ let result1 ;
451466 if ( isSome ) {
452- greetingBytes = textEncoder . encode ( greeting ) ;
453- greetingId = swift . memory . retain ( greetingBytes ) ;
467+ const greetingBytes = textEncoder . encode ( greeting ) ;
468+ const greetingId = swift . memory . retain ( greetingBytes ) ;
469+ result = greetingId ;
470+ result1 = greetingBytes . length ;
471+ } else {
472+ result = 0 ;
473+ result1 = 0 ;
454474 }
455- instance . exports . bjs_testOptionalStringDefault ( + isSome , isSome ? greetingId : 0 , isSome ? greetingBytes . length : 0 ) ;
475+ instance . exports . bjs_testOptionalStringDefault ( + isSome , result , result1 ) ;
456476 const optResult = tmpRetString ;
457477 tmpRetString = undefined ;
458478 return optResult ;
@@ -485,12 +505,7 @@ export async function createInstantiator(options, swift) {
485505 i32Stack . push ( + isSome ) ;
486506 instance . exports . bjs_testOptionalStructDefault ( ) ;
487507 const isSome1 = i32Stack . pop ( ) ;
488- let optResult ;
489- if ( isSome1 ) {
490- optResult = structHelpers . Config . lift ( ) ;
491- } else {
492- optResult = null ;
493- }
508+ const optResult = isSome1 ? structHelpers . Config . lift ( ) : null ;
494509 return optResult ;
495510 } ,
496511 testOptionalStructWithValueDefault : function bjs_testOptionalStructWithValueDefault ( point = { name : "default" , value : 42 , enabled : true } ) {
@@ -501,12 +516,7 @@ export async function createInstantiator(options, swift) {
501516 i32Stack . push ( + isSome ) ;
502517 instance . exports . bjs_testOptionalStructWithValueDefault ( ) ;
503518 const isSome1 = i32Stack . pop ( ) ;
504- let optResult ;
505- if ( isSome1 ) {
506- optResult = structHelpers . Config . lift ( ) ;
507- } else {
508- optResult = null ;
509- }
519+ const optResult = isSome1 ? structHelpers . Config . lift ( ) : null ;
510520 return optResult ;
511521 } ,
512522 testIntArrayDefault : function bjs_testIntArrayDefault ( values = [ 1 , 2 , 3 ] ) {
0 commit comments