add imports if they need it

This commit is contained in:
zongor 2024-05-27 19:08:52 -04:00
parent b04a243190
commit af15775e5e
1 changed files with 4 additions and 3 deletions

View File

@ -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);