mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 09:50:34 +00:00
more fixes to Emscripten CLI
This commit is contained in:
parent
15dcbc188a
commit
bb5ac04875
@ -86,7 +86,7 @@ int arg::readCommon() {
|
||||
else if(argis("-pattern")) {
|
||||
PHASE(3);
|
||||
shift();
|
||||
char *c = args();
|
||||
const char *c = args();
|
||||
using namespace patterns;
|
||||
subpattern_flags = 0;
|
||||
whichPattern = 0;
|
||||
@ -523,7 +523,7 @@ purehookset hooks_config;
|
||||
hookset<int()> *hooks_args;
|
||||
|
||||
namespace arg {
|
||||
int argc; char **argv;
|
||||
int argc; const char **argv;
|
||||
int curphase;
|
||||
|
||||
auto ah = addHook(hooks_args, 0, readCommon);
|
||||
|
@ -40,10 +40,10 @@ void moreStack() {
|
||||
}
|
||||
#endif
|
||||
|
||||
hookset<bool(int argc, char** argv)> *hooks_main;
|
||||
hookset<bool(int argc, const char** argv)> *hooks_main;
|
||||
|
||||
#ifndef NOMAIN
|
||||
int main(int argc, char **argv) {
|
||||
int main(int argc, const char **argv) {
|
||||
#if ISWEB
|
||||
emscripten_get_commandline(argc, argv);
|
||||
#endif
|
||||
|
8
hyper.h
8
hyper.h
@ -1506,7 +1506,7 @@ extern int cshpos;
|
||||
|
||||
namespace arg {
|
||||
#if CAP_COMMANDLINE
|
||||
extern int argc; extern char **argv;
|
||||
extern int argc; extern const char **argv;
|
||||
|
||||
inline void lshift() {
|
||||
argc--; argv++;
|
||||
@ -1516,12 +1516,12 @@ namespace arg {
|
||||
lshift(); if(!argc) { printf("Missing parameter\n"); exit(1); }
|
||||
}
|
||||
|
||||
inline char* args() { return *argv; }
|
||||
inline const char* args() { return *argv; }
|
||||
inline int argi() { return atoi(*argv); }
|
||||
inline ld argf() { return atof(*argv); }
|
||||
inline bool argis(const char *s) { return strcmp(*argv, s) == 0; }
|
||||
|
||||
inline void init(int _argc, char **_argv) { argc=_argc-1; argv=_argv+1; }
|
||||
inline void init(int _argc, const char **_argv) { argc=_argc-1; argv=_argv+1; }
|
||||
|
||||
extern int curphase;
|
||||
|
||||
@ -1761,7 +1761,7 @@ template<class T, class V, class... U> V callhandlers(V zero, hookset<T> *h, U&.
|
||||
|
||||
extern hookset<bool(int sym, int uni)> *hooks_handleKey;
|
||||
extern hookset<void(cell *c, const transmatrix& V)> *hooks_drawcell;
|
||||
extern hookset<bool(int argc, char** argv)> *hooks_main;
|
||||
extern hookset<bool(int argc, const char** argv)> *hooks_main;
|
||||
extern hookset<int()> *hooks_args;
|
||||
extern hookset<eLand(eLand)> *hooks_nextland;
|
||||
|
||||
|
@ -24,7 +24,7 @@ template<class A, class B, class C> void emscripten_set_main_loop(A a, B b, C c)
|
||||
#endif
|
||||
|
||||
void initweb();
|
||||
void emscripten_get_commandline(int argc, char ** argv);
|
||||
void emscripten_get_commandline(int& argc, const char **& argv);
|
||||
|
||||
void loadCompressedChar(int &otwidth, int &otheight, int *tpix);
|
||||
|
||||
@ -153,10 +153,9 @@ transmatrix getOrientation() {
|
||||
vector<string> emscripten_args;
|
||||
vector<const char*> emscripten_args_c;
|
||||
|
||||
void emscripten_get_commandline(int argc, const char ** argv) {
|
||||
void emscripten_get_commandline(int& argc, const 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);
|
||||
|
Loading…
Reference in New Issue
Block a user