diff --git a/tools/js-class-c-struct-transpiler/transpile.js b/tools/js-class-c-struct-transpiler/transpile.js index 6d7235d..3261161 100644 --- a/tools/js-class-c-struct-transpiler/transpile.js +++ b/tools/js-class-c-struct-transpiler/transpile.js @@ -93,6 +93,7 @@ for (const type of Object.keys(schema)) { let containsString = false; let offset = 0; let size = 0; + let importStatements = ""; let jsData = ""; const props = schema[type]; cData += `typedef struct ${type} {`; @@ -145,9 +146,9 @@ for (const type of Object.keys(schema)) { set ${prop}(v) { this._data.set(v.bytes(), ${offset}); }`; + importStatements += `import ${propType} from "./${propType}"\n\n`; - cData += ` - ${types[propType].c} ${prop};`; + cData += `\n\t\t${types[propType].c} ${prop};`; break; case "array": break; @@ -178,6 +179,6 @@ export default ${type}`; `; - await Bun.write(Bun.file(values.jsout + type + ".js"), jsData); + await Bun.write(Bun.file(values.jsout + type + ".js"), (importStatements + jsData)); } await Bun.write(Bun.file(values.cout + "types.h"), cData);