diff --git a/hyper.cpp b/hyper.cpp index acaad4c2..3775529d 100644 --- a/hyper.cpp +++ b/hyper.cpp @@ -44,6 +44,9 @@ hookset *hooks_main; #ifndef NOMAIN int main(int argc, char **argv) { +#if ISWEB + emscripten_get_commandline(argc, argv); +#endif if(callhandlers(false, hooks_main, argc, argv)) return 0; #if !ISWEB #if ISLINUX diff --git a/hyperweb.cpp b/hyperweb.cpp index 55d14820..d61b8cb4 100644 --- a/hyperweb.cpp +++ b/hyperweb.cpp @@ -24,6 +24,7 @@ template void emscripten_set_main_loop(A a, B b, C c) #endif void initweb(); +void emscripten_get_commandline(int argc, char ** argv); void loadCompressedChar(int &otwidth, int &otheight, int *tpix); @@ -148,3 +149,43 @@ transmatrix getOrientation() { rotmatrix(1, 2, beta * M_PI / 180) * rotmatrix(0, 2, gamma * M_PI / 180); } + +vector emscripten_args; +vector emscripten_args_c; + +void emscripten_get_commandline(int argc, char ** argv) { + char *str = (char*)EM_ASM_INT({ + var jsString = document.location.href; + alert(jsString); + var lengthBytes = lengthBytesUTF8(jsString)+1; + var stringOnWasmHeap = _malloc(lengthBytes); + stringToUTF8(jsString, stringOnWasmHeap, lengthBytes+1); + return stringOnWasmHeap; + }); + string s = str; + s += "+xxxxxx"; + for(int i=0; i