@@ -446,7 +446,7 @@ var LibraryEmbind = {
446446 if ( this . usedEmbindString ) {
447447 out . unshift ( 'type EmbindString = ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string;\n' ) ;
448448 }
449- console . log ( out . join ( '' ) ) ;
449+ return out . join ( '' ) ;
450450 }
451451 } ,
452452
@@ -468,10 +468,10 @@ var LibraryEmbind = {
468468 def . printJs ( out ) ;
469469 }
470470 out . push ( '}\n' ) ;
471- console . log ( JSON . stringify ( {
471+ return JSON . stringify ( {
472472 'invokers' : out . join ( '' ) ,
473473 publicSymbols,
474- } ) ) ;
474+ } ) ;
475475 }
476476 } ,
477477
@@ -843,27 +843,27 @@ var LibraryEmbind = {
843843 } ) ;
844844 } ,
845845
846+ $emitOutput__deps : [ '$awaitingDependencies' , '$throwBindingError' , '$getTypeName' , '$moduleDefinitions' ,
846847#if EMBIND_AOT
847- $embindEmitAotJs__deps : [ '$awaitingDependencies' , '$throwBindingError' , '$getTypeName' , '$moduleDefinitions' , '$JsPrinter' ] ,
848- $embindEmitAotJs__postset : ( ) => { addAtPostCtor ( 'embindEmitAotJs()' ) ; } ,
849- $embindEmitAotJs : ( ) => {
848+ '$JsPrinter' ,
849+ #else
850+ '$TsPrinter' ,
851+ #endif
852+ ] ,
853+ $emitOutput__postset : ( ) => { addAtPostCtor ( 'emitOutput()' ) ; } ,
854+ $emitOutput : ( ) => {
850855 for ( const typeId in awaitingDependencies ) {
851856 throwBindingError ( `Missing binding for type: '${ getTypeName ( typeId ) } ' typeId: ${ typeId } ` ) ;
852857 }
858+ #if EMBIND_AOT
853859 const printer = new JsPrinter ( moduleDefinitions ) ;
854- printer . print ( ) ;
855- } ,
856- #else // EMBIND_AOT
857- $embindEmitTypes__deps : [ '$awaitingDependencies' , '$throwBindingError' , '$getTypeName' , '$moduleDefinitions' , '$TsPrinter' ] ,
858- $embindEmitTypes__postset : ( ) => { addAtPostCtor ( 'embindEmitTypes()' ) ; } ,
859- $embindEmitTypes : ( ) => {
860- for ( const typeId in awaitingDependencies ) {
861- throwBindingError ( `Missing binding for type: '${ getTypeName ( typeId ) } ' typeId: ${ typeId } ` ) ;
862- }
860+ #else
863861 const printer = new TsPrinter ( moduleDefinitions ) ;
864- printer . print ( ) ;
865- } ,
866862#endif
863+ const output = printer . print ( ) ;
864+ var fs = require ( 'fs' ) ;
865+ fs . writeFileSync ( process . argv [ 2 ] , output + '\n' ) ;
866+ } ,
867867
868868 // Stub functions used by eval, but not needed for TS generation:
869869 $makeLegalFunctionName : ( ) => { throw new Error ( 'stub function should not be called' ) ; } ,
@@ -874,10 +874,6 @@ var LibraryEmbind = {
874874 $PureVirtualError : ( ) => { throw new Error ( 'stub function should not be called' ) ; } ,
875875} ;
876876
877- #if EMBIND_AOT
878- extraLibraryFuncs . push ( '$embindEmitAotJs' ) ;
879- #else
880- extraLibraryFuncs . push ( '$embindEmitTypes' ) ;
881- #endif
877+ extraLibraryFuncs . push ( '$emitOutput' ) ;
882878
883879addToLibrary ( LibraryEmbind ) ;
0 commit comments