add imports if they need it
This commit is contained in:
parent
b04a243190
commit
af15775e5e
|
@ -93,6 +93,7 @@ for (const type of Object.keys(schema)) {
|
||||||
let containsString = false;
|
let containsString = false;
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
let size = 0;
|
let size = 0;
|
||||||
|
let importStatements = "";
|
||||||
let jsData = "";
|
let jsData = "";
|
||||||
const props = schema[type];
|
const props = schema[type];
|
||||||
cData += `typedef struct ${type} {`;
|
cData += `typedef struct ${type} {`;
|
||||||
|
@ -145,9 +146,9 @@ for (const type of Object.keys(schema)) {
|
||||||
set ${prop}(v) {
|
set ${prop}(v) {
|
||||||
this._data.set(v.bytes(), ${offset});
|
this._data.set(v.bytes(), ${offset});
|
||||||
}`;
|
}`;
|
||||||
|
importStatements += `import ${propType} from "./${propType}"\n\n`;
|
||||||
|
|
||||||
cData += `
|
cData += `\n\t\t${types[propType].c} ${prop};`;
|
||||||
${types[propType].c} ${prop};`;
|
|
||||||
break;
|
break;
|
||||||
case "array":
|
case "array":
|
||||||
break;
|
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);
|
await Bun.write(Bun.file(values.cout + "types.h"), cData);
|
||||||
|
|
Loading…
Reference in New Issue