@@ -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,17 @@ 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 , result1 ;
347343 if ( isSome ) {
348- tagBytes = textEncoder . encode ( tag ) ;
349- tagId = swift . memory . retain ( tagBytes ) ;
344+ const tagBytes = textEncoder . encode ( tag ) ;
345+ const tagId = swift . memory . retain ( tagBytes ) ;
346+ result = tagId ;
347+ result1 = tagBytes . length ;
348+ } else {
349+ result = 0 ;
350+ result1 = 0 ;
350351 }
351- const ret = instance . exports . bjs_ConstructorDefaults_init ( nameId , nameBytes . length , count , enabled , status , + isSome , isSome ? tagId : 0 , isSome ? tagBytes . length : 0 ) ;
352+ const ret = instance . exports . bjs_ConstructorDefaults_init ( nameId , nameBytes . length , count , enabled , status , + isSome , result , result1 ) ;
352353 return ConstructorDefaults . __construct ( ret ) ;
353354 }
354355 get name ( ) {
@@ -391,18 +392,23 @@ export async function createInstantiator(options, swift) {
391392 }
392393 set tag ( value ) {
393394 const isSome = value != null ;
394- let valueId , valueBytes ;
395+ let result , result1 ;
395396 if ( isSome ) {
396- valueBytes = textEncoder . encode ( value ) ;
397- valueId = swift . memory . retain ( valueBytes ) ;
397+ const valueBytes = textEncoder . encode ( value ) ;
398+ const valueId = swift . memory . retain ( valueBytes ) ;
399+ result = valueId ;
400+ result1 = valueBytes . length ;
401+ } else {
402+ result = 0 ;
403+ result1 = 0 ;
398404 }
399- instance . exports . bjs_ConstructorDefaults_tag_set ( this . pointer , + isSome , isSome ? valueId : 0 , isSome ? valueBytes . length : 0 ) ;
405+ instance . exports . bjs_ConstructorDefaults_tag_set ( this . pointer , + isSome , result , result1 ) ;
400406 }
401407 }
402- const ConfigHelpers = __bjs_createConfigHelpers ( ) ( ) ;
408+ const ConfigHelpers = __bjs_createConfigHelpers ( ) ;
403409 structHelpers . Config = ConfigHelpers ;
404410
405- const MathOperationsHelpers = __bjs_createMathOperationsHelpers ( ) ( ) ;
411+ const MathOperationsHelpers = __bjs_createMathOperationsHelpers ( ) ;
406412 structHelpers . MathOperations = MathOperationsHelpers ;
407413
408414 const exports = {
@@ -435,24 +441,34 @@ export async function createInstantiator(options, swift) {
435441 } ,
436442 testOptionalDefault : function bjs_testOptionalDefault ( name = null ) {
437443 const isSome = name != null ;
438- let nameId , nameBytes ;
444+ let result , result1 ;
439445 if ( isSome ) {
440- nameBytes = textEncoder . encode ( name ) ;
441- nameId = swift . memory . retain ( nameBytes ) ;
446+ const nameBytes = textEncoder . encode ( name ) ;
447+ const nameId = swift . memory . retain ( nameBytes ) ;
448+ result = nameId ;
449+ result1 = nameBytes . length ;
450+ } else {
451+ result = 0 ;
452+ result1 = 0 ;
442453 }
443- instance . exports . bjs_testOptionalDefault ( + isSome , isSome ? nameId : 0 , isSome ? nameBytes . length : 0 ) ;
454+ instance . exports . bjs_testOptionalDefault ( + isSome , result , result1 ) ;
444455 const optResult = tmpRetString ;
445456 tmpRetString = undefined ;
446457 return optResult ;
447458 } ,
448459 testOptionalStringDefault : function bjs_testOptionalStringDefault ( greeting = "Hi" ) {
449460 const isSome = greeting != null ;
450- let greetingId , greetingBytes ;
461+ let result , result1 ;
451462 if ( isSome ) {
452- greetingBytes = textEncoder . encode ( greeting ) ;
453- greetingId = swift . memory . retain ( greetingBytes ) ;
463+ const greetingBytes = textEncoder . encode ( greeting ) ;
464+ const greetingId = swift . memory . retain ( greetingBytes ) ;
465+ result = greetingId ;
466+ result1 = greetingBytes . length ;
467+ } else {
468+ result = 0 ;
469+ result1 = 0 ;
454470 }
455- instance . exports . bjs_testOptionalStringDefault ( + isSome , isSome ? greetingId : 0 , isSome ? greetingBytes . length : 0 ) ;
471+ instance . exports . bjs_testOptionalStringDefault ( + isSome , result , result1 ) ;
456472 const optResult = tmpRetString ;
457473 tmpRetString = undefined ;
458474 return optResult ;
@@ -485,12 +501,7 @@ export async function createInstantiator(options, swift) {
485501 i32Stack . push ( + isSome ) ;
486502 instance . exports . bjs_testOptionalStructDefault ( ) ;
487503 const isSome1 = i32Stack . pop ( ) ;
488- let optResult ;
489- if ( isSome1 ) {
490- optResult = structHelpers . Config . lift ( ) ;
491- } else {
492- optResult = null ;
493- }
504+ const optResult = isSome1 ? structHelpers . Config . lift ( ) : null ;
494505 return optResult ;
495506 } ,
496507 testOptionalStructWithValueDefault : function bjs_testOptionalStructWithValueDefault ( point = { name : "default" , value : 42 , enabled : true } ) {
@@ -501,12 +512,7 @@ export async function createInstantiator(options, swift) {
501512 i32Stack . push ( + isSome ) ;
502513 instance . exports . bjs_testOptionalStructWithValueDefault ( ) ;
503514 const isSome1 = i32Stack . pop ( ) ;
504- let optResult ;
505- if ( isSome1 ) {
506- optResult = structHelpers . Config . lift ( ) ;
507- } else {
508- optResult = null ;
509- }
515+ const optResult = isSome1 ? structHelpers . Config . lift ( ) : null ;
510516 return optResult ;
511517 } ,
512518 testIntArrayDefault : function bjs_testIntArrayDefault ( values = [ 1 , 2 , 3 ] ) {
0 commit comments