Skip to content

Commit

Permalink
generate function declarations with void pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Sep 10, 2023
1 parent 87f49c0 commit 337c61d
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions w2c2/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -3355,15 +3355,17 @@ wasmCWriteFileParameters(
const char* moduleName,
WasmFunctionType functionType,
bool writeParameterNames,
bool structInstanceType,
bool voidPointerInstanceType,
bool pretty
) {
fputc('(', file);
if (structInstanceType) {
fputs("struct ", file);
if (voidPointerInstanceType) {
fputs("void*", file);
} else {
fputs(moduleName, file);
fputs("Instance*", file);
}
fputs(moduleName, file);
fputs("Instance*", file);

if (writeParameterNames) {
if (pretty) {
fputs(" i", file);
Expand Down Expand Up @@ -3414,7 +3416,14 @@ wasmCWriteFileFunctionSignature(
fputc('_', file);
}
wasmCWriteFileFunctionNonImportName(file, functionIndex);
wasmCWriteFileParameters(file, moduleName, functionType, writeParameterNames, false, pretty);
wasmCWriteFileParameters(
file,
moduleName,
functionType,
writeParameterNames,
false,
pretty
);
}

static
Expand Down Expand Up @@ -3675,7 +3684,7 @@ void
wasmCWriteInitImportAssignment(
FILE* file,
const char* module,
const char* name,
const char* name,
bool pretty
) {
if (pretty) {
Expand Down Expand Up @@ -3894,7 +3903,14 @@ wasmCWriteFunctionExport(
fputs(wasmCGetReturnType(functionType), file);
fputc(' ', file);
wasmCWriteExportName(file, moduleName, export.name);
wasmCWriteFileParameters(file, moduleName, functionType, true, false, pretty);
wasmCWriteFileParameters(
file,
moduleName,
functionType,
true,
false,
pretty
);
if (writeBody) {
if (pretty) {
fputc(' ', file);
Expand Down

0 comments on commit 337c61d

Please sign in to comment.