Added cwasm_arena.c and cwasm_debug.c. Arena API hasn't been tested well yet. There's also something wrong with our DebugOutputLineBuffer usage for splitting lines to multiple Javascript output calls. Also added an int level to jsStdPrint and a bunch of macros to cwasm.h

This commit is contained in:
2025-08-31 17:33:48 -07:00
parent d0aa7a1d0e
commit cca61ea163
9 changed files with 566 additions and 11 deletions

19
cwasm.c
View File

@@ -9,14 +9,17 @@ Description:
#include "cwasm.h"
#include "std/src/std_main.c"
#include "cwasm_arena.c"
#include "cwasm_debug.c"
WASM_EXPORT(HelloFromWasm) float HelloFromWasm(float value, float value2)
void InitializeCWasm(u32 scratchArenasSize)
{
printf("Called HelloFromWasm(%g)!\n", fmodf(value, value2));
for (int iIndex = 0; iIndex < 1024; iIndex++)
{
void* newMem = grow_mem(1024);
printf("mem[%d] = %p\n", iIndex, newMem);
}
return value*(value+1)*2;
// CwasmDebugOutput(__FILE__, __LINE__, __func__, DbgLevel_Warning, true, "Hello\nWorld!");
Write_D("Hello\nWorld!");
PrintLine_D(" Fuzzy %u Bunnies!\n%s", 31415926, "What");
WriteLine_D("");
WriteLine_I("When");
Write_D("\n");
WriteLine_E("Where");
InitGlobalArenas(scratchArenasSize);
}