Update API usage. Fix #193

extensions
Volodymyr Shymanskyy 3 years ago
parent 03e0ace86c
commit ead1ebd0e3

@ -36,6 +36,8 @@ if(EMSCRIPTEN OR EMSCRIPTEN_LIB)
set(CMAKE_C_COMPILER "emcc")
set(CMAKE_CXX_COMPILER "em++")
set(BUILD_WASI "none")
if (EMSCRIPTEN_LIB)
set(APP_DIR "platforms/emscripten_lib")
set(OUT_FILE "wasm3.wasm")

@ -47,11 +47,11 @@ void run_wasm()
result = m3_CallV (f, 40);
if (result) FATAL("m3_Call: %s", result);
uint64_t value = 0;
result = m3_GetResultsV (f, &result);
uint32_t value = 0;
result = m3_GetResultsV (f, &value);
if (result) FATAL("m3_GetResults: %s", result);
printf("Result: %lld\n", value);
printf("Result: %d\n", value);
}
int main()

@ -8,7 +8,6 @@
#include "Arduino.h"
#include "m3/wasm3.h"
#include "m3/m3_env.h"
#include "m3/extra/fib32.wasm.h"
@ -47,7 +46,9 @@ void run_wasm()
result = m3_CallV(f, 24);
if (result) FATAL("m3_Call", result);
long value = *(uint64_t*)(runtime->stack);
uint32_t value = 0;
result = m3_GetResultsV (f, &value);
if (result) FATAL("m3_GetResults: %s", result);
Serial.print("Result: ");
Serial.println(value);

@ -6,7 +6,6 @@
//
#include "m3/wasm3.h"
#include "m3/m3_env.h"
#include "m3/extra/fib32.wasm.h"
@ -47,9 +46,11 @@ void run_wasm()
result = m3_CallV (f, 24);
if (result) FATAL("m3_Call", result);
long value = *(uint64_t*)(runtime->stack);
uint32_t value = 0;
result = m3_GetResultsV (f, &value);
if (result) FATAL("m3_GetResults: %s", result);
printf("Result: %ld\n", value);
printf("Result: %d\n", value);
}
PinC<13> led;

@ -10,9 +10,6 @@
#include <time.h>
#include "wasm3.h"
#include "m3_api_wasi.h"
#include "m3_api_libc.h"
#include "m3_env.h"
#include "extra/fib32.wasm.h"
@ -38,14 +35,6 @@ void run_wasm()
result = m3_LoadModule (runtime, module);
if (result) FATAL("m3_LoadModule: %s", result);
/*
result = m3_LinkWASI (runtime->modules);
if (result) FATAL("m3_LinkWASI: %s", result);
result = m3_LinkLibC (runtime->modules);
if (result) FATAL("m3_LinkLibC: %s", result);
*/
IM3Function f;
result = m3_FindFunction (&f, runtime, "fib");
if (result) FATAL("m3_FindFunction: %s", result);
@ -54,8 +43,11 @@ void run_wasm()
if (result) FATAL("Call: %s", result);
uint64_t value = *(uint64_t*)(runtime->stack);
printf("Result: %ld\n", value);
uint32_t value = 0;
result = m3_GetResultsV (f, &value);
if (result) FATAL("m3_GetResults: %s", result);
printf("Result: %d\n", value);
}
int main (int i_argc, const char * i_argv [])

@ -9,7 +9,6 @@
#include <stdio.h>
#include "m3/wasm3.h"
#include "m3/m3_env.h"
#include "m3/extra/fib32.wasm.h"
@ -45,8 +44,11 @@ void run_wasm()
result = m3_CallV(f, 24);
if (result) FATAL("m3_Call: %s", result);
long value = *(uint64_t*)(runtime->stack);
printf("Result: %ld\n", value);
uint32_t value = 0;
result = m3_GetResultsV (f, &value);
if (result) FATAL("m3_GetResults: %s", result);
printf("Result: %d\n", value);
}
void setup()

@ -35,7 +35,6 @@ void uart_print(const char *str) {
}
#include "m3/wasm3.h"
#include "m3/m3_env.h"
#include "m3/extra/fib32.wasm.h"
@ -75,7 +74,10 @@ bool run_wasm()
result = m3_CallV (f, 24);
if (result) FATAL("m3_Call: %s", result);
long value = *(uint64_t*)(runtime->stack);
uint32_t value = 0;
result = m3_GetResultsV (f, &value);
if (result) FATAL("m3_GetResults: %s", result);
char buff[32];
ltoa(value, buff, 10);

@ -8,7 +8,6 @@
#include <stdio.h>
#include <time.h>
#include "m3/wasm3.h"
#include "m3/m3_env.h"
#include "m3/extra/fib32.wasm.h"
@ -44,8 +43,11 @@ void run_wasm()
result = m3_CallV (f, 24);
if (result) FATAL("m3_Call: %s", result);
long value = *(uint64_t*)(runtime->stack);
printf("Result: %ld\n", value);
uint32_t value = 0;
result = m3_GetResultsV (f, &value);
if (result) FATAL("m3_GetResults: %s", result);
printf("Result: %d\n", value);
}
int main() {

@ -86,11 +86,11 @@ void run_wasm()
if (result) FATAL("m3_Call: %s", result);
printf("Elapsed: %ld ms\n\n", (end - start) * 1000 / CLOCKS_PER_SEC);
uint64_t value = 0;
result = m3_GetResultsV (f, &result);
uint32_t value = 0;
result = m3_GetResultsV (f, &value);
if (result) FATAL("m3_GetResults: %s", result);
printf("Result: %lld\n", value);
printf("Result: %d\n", value);
}
static void* runMain(void* ctx)

@ -49,8 +49,8 @@ void run_wasm()
result = m3_CallV (f, 24);
if (result) FATAL("m3_Call: %s", result);
uint64_t value = 0;
result = m3_GetResultsV (f, &result);
uint32_t value = 0;
result = m3_GetResultsV (f, &value);
if (result) FATAL("m3_GetResults: %s", result);
Serial.print("Result: ");

@ -8,7 +8,6 @@
#include "wm_include.h"
#include "m3/wasm3.h"
//#include "m3/m3_env.h"
#include "m3/extra/fib32.wasm.h"
@ -49,8 +48,8 @@ void run_wasm()
result = m3_CallV (f, 24);
if (result) FATAL("m3_Call: %s", result);
uint64_t value = 0;
result = m3_GetResultsV (f, &result);
uint32_t value = 0;
result = m3_GetResultsV (f, &value);
if (result) FATAL("m3_GetResults: %s", result);
printf("Result: %lld\n", value);

@ -325,8 +325,6 @@ void * m3_GetUserData (IM3Runtime i_runtime)
return i_runtime ? i_runtime->userdata : NULL;
}
typedef void * (* ModuleVisitor) (IM3Module i_module, void * i_info);
void * ForEachModule (IM3Runtime i_runtime, ModuleVisitor i_visitor, void * i_info)
{
void * r = NULL;

Loading…
Cancel
Save