-make tests working on web

-WebAssembly now is compiled with emscripten use (stdc functions bindings only)
-added python script to build WASM version
This commit is contained in:
Mergul 2019-11-05 09:21:02 +01:00
parent 015783bf5c
commit a8c74d5045
5 changed files with 158 additions and 23 deletions

View file

@ -7,15 +7,16 @@ import std.traits;
version(WebAssembly)
{
extern(C) int memcmp (const void *s1, const void *s2, size_t size);
extern(C) void exit (int status) nothrow @nogc;
extern(C) void __assert(const(char)* msg, const(char)* file, uint line) { exit(-20);}
extern(C) void free(void*) @nogc nothrow @system;
extern(C) void* malloc(size_t size) @nogc nothrow @system;
extern(C) void* realloc(void*, size_t size) @nogc nothrow @system;
extern(C) void* memcpy(return void*, scope const void*, size_t size) @nogc nothrow @system;
extern(C) void* memset(void*, int val, size_t size) @nogc nothrow @system;
extern(C) void qsort(void* base, size_t num, size_t size,
int function(const void*,const void*) compar) @nogc nothrow @system;
extern(C) int posix_memalign(void**, size_t, size_t) @nogc nothrow @system;
extern(C) void qsort(void* base, size_t num, size_t size, int function(const void*,const void*) compar) @nogc nothrow @system;
}
else
{
@ -142,7 +143,7 @@ static struct Mallocator
void* ret;
version(Posix)posix_memalign(&ret, alignment, length);//ret = aligned_alloc(alignment, length);
else version(Windows)ret = _aligned_malloc(length, alignment);
else version(WebAssembly)ret = malloc(length);
else version(WebAssembly)posix_memalign(&ret, alignment, length);//malloc(length);
else static assert(0, "Unimplemented platform!");
return ret;
}
@ -160,7 +161,6 @@ static struct Mallocator
else version(Windows)_aligned_free(cast(void*)object);
else version(WebAssembly)free(cast(void*)object);
else static assert(0, "Unimplemented platform!");
}
}

View file

@ -198,7 +198,7 @@ public:
}
export ref T opIndex(size_t elemNum) {
debug assert(elemNum < used, "Range violation [index]");
//debug assert(elemNum < used, "Range violation [index]");
return array.ptr[elemNum];
}
@ -221,12 +221,12 @@ public:
}
export void opOpAssign(string op)(T obj) {
static assert(op == "~");
//static assert(op == "~");
add(obj);
}
export void opOpAssign(string op, X)(X[] obj) {
static assert(op == "~");
//static assert(op == "~");
add(obj);
}