diff --git a/SCsub b/SCsub index 347ab56a..69aef7f1 100644 --- a/SCsub +++ b/SCsub @@ -46,7 +46,8 @@ if JS_ENGINE == "quickjs": quickjs_env.Append(CPPDEFINES=["CONFIG_BIGNUM"]) if "release" not in (quickjs_env["target"] or ""): quickjs_env.Append(CPPDEFINES={"DUMP_LEAKS": 1}) - quickjs_env.Append(CPPDEFINES={"QUICKJS_WITH_DEBUGGER": 1}) + if not env.msvc: + env_module.Append(CPPDEFINES={"QUICKJS_WITH_DEBUGGER": 1}) quickjs_env.Append(CPPPATH=["thirdparty/quickjs/quickjs"]) quickjs_env.Append(CPPPATH=["thirdparty/quickjs"]) quickjs_env.disable_warnings() @@ -54,8 +55,15 @@ if JS_ENGINE == "quickjs": quickjs_env.add_source_files(env.modules_sources, "tools/editor_tools.cpp") quickjs_env.add_source_files(env.modules_sources, "thirdparty/quickjs/quickjs_builtin_binder.gen.cpp") quickjs_env.add_source_files(env.modules_sources, "thirdparty/quickjs/*.cpp") - quickjs_env.add_source_files(env.modules_sources, "thirdparty/quickjs/quickjs/*.c") + env_thirdparty = quickjs_env.Clone() + if env.msvc: + env_thirdparty.AppendUnique(CCFLAGS=["/TC"]) + + # TODO: find a better way to remove /std:c++17 + del env_thirdparty["CCFLAGS"][0] + env_thirdparty.Prepend(CCFLAGS=["/std:c11"]) + env_thirdparty.add_source_files(env.modules_sources, "thirdparty/quickjs/quickjs/*.c") # Binding script to run at engine initializing with open("misc/godot.binding_script.gen.cpp", "w") as f: diff --git a/config.py b/config.py index 6e8d6202..b846f342 100644 --- a/config.py +++ b/config.py @@ -1,5 +1,5 @@ def can_build(env, platform): - return (platform == "windows" and env["use_mingw"]) or platform == "linux" or platform == "macos" + return True #(platform == "windows" and env["use_mingw"]) or platform == "linux" or platform == "macos" def configure(env): diff --git a/register_types.cpp b/register_types.cpp index b055a364..1ca45654 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -52,7 +52,7 @@ class EditorExportJavaScript : public EditorExportPlugin { return; } } - virtual String get_name() const override { return "JavaScript"; } + virtual String _get_name() const override { return "JavaScript"; } }; #endif diff --git a/thirdparty/quickjs/quickjs/cutils.h b/thirdparty/quickjs/quickjs/cutils.h index a7839984..b0c7a262 100644 --- a/thirdparty/quickjs/quickjs/cutils.h +++ b/thirdparty/quickjs/quickjs/cutils.h @@ -119,6 +119,53 @@ static inline int64_t min_int64(int64_t a, int64_t b) return b; } + + +#ifdef _MSC_VER +#include + +static inline int __builtin_ctz(unsigned x) +{ + return (int)_tzcnt_u32(x); +} + +static inline int __builtin_ctzll(unsigned long long x) +{ +#ifdef _WIN64 + return (int)_tzcnt_u64(x); +#else + return !!unsigned(x) ? __builtin_ctz((unsigned)x) : 32 + __builtin_ctz((unsigned)(x >> 32)); +#endif +} + +static inline int __builtin_ctzl(unsigned long x) +{ + return sizeof(x) == 8 ? __builtin_ctzll(x) : __builtin_ctz((unsigned)x); +} + +static inline int __builtin_clz(unsigned x) +{ + return (int)_lzcnt_u32(x); +} + +static inline int __builtin_clzll(unsigned long long x) +{ +#ifdef _WIN64 + return (int)_lzcnt_u64(x); +#else + return !!unsigned(x >> 32) ? __builtin_clz((unsigned)(x >> 32)) : 32 + __builtin_clz((unsigned)x); +#endif +} + +static inline int __builtin_clzl(unsigned long x) +{ + return sizeof(x) == 8 ? __builtin_clzll(x) : __builtin_clz((unsigned)x); +} +#endif + + + + /* WARNING: undefined if a = 0 */ static inline int clz32(unsigned int a) { diff --git a/thirdparty/quickjs/quickjs/quickjs-debugger.c b/thirdparty/quickjs/quickjs/quickjs-debugger.c index 94246f47..0fd2ce96 100644 --- a/thirdparty/quickjs/quickjs/quickjs-debugger.c +++ b/thirdparty/quickjs/quickjs/quickjs-debugger.c @@ -36,12 +36,14 @@ static int js_transport_write_fully(JSDebuggerInfo *info, const char *buffer, si return 1; } +#define JS_TRANSPORT_WRITE_MESSAGE_NEWLINE_MESSAGE_LENGTH 10 + static int js_transport_write_message_newline(JSDebuggerInfo *info, const char* value, size_t len) { // length prefix is 8 hex followed by newline = 012345678\n // not efficient, but protocol is then human readable. - char message_length[10]; + char message_length[JS_TRANSPORT_WRITE_MESSAGE_NEWLINE_MESSAGE_LENGTH]; message_length[9] = '\0'; - sprintf(message_length, "%08x\n", (int)len + 1); + sprintf_s(message_length, JS_TRANSPORT_WRITE_MESSAGE_NEWLINE_MESSAGE_LENGTH, "%08x\n", (int)len + 1); if (!js_transport_write_fully(info, message_length, 9)) return 0; int ret = js_transport_write_fully(info, value, len); diff --git a/thirdparty/quickjs/quickjs/quickjs.c b/thirdparty/quickjs/quickjs/quickjs.c index 99b6be9e..3c131a52 100644 --- a/thirdparty/quickjs/quickjs/quickjs.c +++ b/thirdparty/quickjs/quickjs/quickjs.c @@ -28,7 +28,12 @@ #include #include #include +#if defined(_WIN32) +// import struct timeval +#include +#else #include +#endif #include #include #include @@ -51,7 +56,7 @@ #define OPTIMIZE 1 #define SHORT_OPCODES 1 -#if defined(EMSCRIPTEN) +#if defined(EMSCRIPTEN) || defined(_MSC_VER) #define DIRECT_DISPATCH 0 #else #define DIRECT_DISPATCH 1 @@ -70,7 +75,7 @@ /* define to include Atomics.* operations which depend on the OS threads */ -#if !defined(EMSCRIPTEN) +#if !(defined(EMSCRIPTEN) || defined(_MSC_VER)) #define CONFIG_ATOMICS #endif @@ -205,7 +210,11 @@ typedef enum JSErrorEnum { #define JS_STACK_SIZE_MAX 65536 #define JS_STRING_LEN_MAX ((1 << 30) - 1) +#if defined(_MSC_VER) +#define __exception +#else #define __exception __attribute__((warn_unused_result)) +#endif typedef struct JSShape JSShape; typedef struct JSString JSString; @@ -1013,7 +1022,9 @@ static __exception int JS_ToArrayLengthFree(JSContext *ctx, uint32_t *plen, JSValue val); static JSValue JS_EvalObject(JSContext *ctx, JSValueConst this_obj, JSValueConst val, int flags, int scope_idx); -JSValue __attribute__((format(printf, 2, 3))) JS_ThrowInternalError(JSContext *ctx, const char *fmt, ...); + +JSValue __js_printf_like(2, 3) JS_ThrowInternalError(JSContext *ctx, const char *fmt, ...); + static __maybe_unused void JS_DumpAtoms(JSRuntime *rt); static __maybe_unused void JS_DumpString(JSRuntime *rt, const JSString *p); @@ -6181,7 +6192,7 @@ void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt) "BigNum " #endif "2020-09-06" " version, %d-bit, malloc limit: %"PRId64"\n\n", - (int)sizeof(void *) * 8, (int64_t)(ssize_t)s->malloc_limit); + (int)sizeof(void *) * 8, s->malloc_limit); #if 1 if (rt) { static const struct { @@ -6593,7 +6604,7 @@ static JSValue JS_ThrowError(JSContext *ctx, JSErrorEnum error_num, return JS_ThrowError2(ctx, error_num, fmt, ap, add_backtrace); } -JSValue __attribute__((format(printf, 2, 3))) JS_ThrowSyntaxError(JSContext *ctx, const char *fmt, ...) +JSValue __js_printf_like(2, 3) JS_ThrowSyntaxError(JSContext *ctx, const char *fmt, ...) { JSValue val; va_list ap; @@ -6604,7 +6615,7 @@ JSValue __attribute__((format(printf, 2, 3))) JS_ThrowSyntaxError(JSContext *ctx return val; } -JSValue __attribute__((format(printf, 2, 3))) JS_ThrowTypeError(JSContext *ctx, const char *fmt, ...) +JSValue __js_printf_like(2, 3) JS_ThrowTypeError(JSContext *ctx, const char *fmt, ...) { JSValue val; va_list ap; @@ -6615,7 +6626,7 @@ JSValue __attribute__((format(printf, 2, 3))) JS_ThrowTypeError(JSContext *ctx, return val; } -static int __attribute__((format(printf, 3, 4))) JS_ThrowTypeErrorOrFalse(JSContext *ctx, int flags, const char *fmt, ...) +static int __js_printf_like(3, 4) JS_ThrowTypeErrorOrFalse(JSContext *ctx, int flags, const char *fmt, ...) { va_list ap; @@ -6631,7 +6642,7 @@ static int __attribute__((format(printf, 3, 4))) JS_ThrowTypeErrorOrFalse(JSCont } /* never use it directly */ -static JSValue __attribute__((format(printf, 3, 4))) __JS_ThrowTypeErrorAtom(JSContext *ctx, JSAtom atom, const char *fmt, ...) +static JSValue __js_printf_like(3, 4) __JS_ThrowTypeErrorAtom(JSContext *ctx, JSAtom atom, const char *fmt, ...) { char buf[ATOM_GET_STR_BUF_SIZE]; return JS_ThrowTypeError(ctx, fmt, @@ -6639,7 +6650,7 @@ static JSValue __attribute__((format(printf, 3, 4))) __JS_ThrowTypeErrorAtom(JSC } /* never use it directly */ -static JSValue __attribute__((format(printf, 3, 4))) __JS_ThrowSyntaxErrorAtom(JSContext *ctx, JSAtom atom, const char *fmt, ...) +static JSValue __js_printf_like(3, 4) __JS_ThrowSyntaxErrorAtom(JSContext *ctx, JSAtom atom, const char *fmt, ...) { char buf[ATOM_GET_STR_BUF_SIZE]; return JS_ThrowSyntaxError(ctx, fmt, @@ -6662,7 +6673,7 @@ static int JS_ThrowTypeErrorReadOnly(JSContext *ctx, int flags, JSAtom atom) } } -JSValue __attribute__((format(printf, 2, 3))) JS_ThrowReferenceError(JSContext *ctx, const char *fmt, ...) +JSValue __js_printf_like(2, 3) JS_ThrowReferenceError(JSContext *ctx, const char *fmt, ...) { JSValue val; va_list ap; @@ -6673,7 +6684,7 @@ JSValue __attribute__((format(printf, 2, 3))) JS_ThrowReferenceError(JSContext * return val; } -JSValue __attribute__((format(printf, 2, 3))) JS_ThrowRangeError(JSContext *ctx, const char *fmt, ...) +JSValue __js_printf_like(2, 3) JS_ThrowRangeError(JSContext *ctx, const char *fmt, ...) { JSValue val; va_list ap; @@ -6684,7 +6695,7 @@ JSValue __attribute__((format(printf, 2, 3))) JS_ThrowRangeError(JSContext *ctx, return val; } -JSValue __attribute__((format(printf, 2, 3))) JS_ThrowInternalError(JSContext *ctx, const char *fmt, ...) +JSValue __js_printf_like(2, 3) JS_ThrowInternalError(JSContext *ctx, const char *fmt, ...) { JSValue val; va_list ap; @@ -7209,7 +7220,7 @@ static int JS_DefinePrivateField(JSContext *ctx, JSValueConst obj, JS_ThrowTypeErrorNotASymbol(ctx); goto fail; } - prop = js_symbol_to_atom(ctx, (JSValue)name); + prop = js_symbol_to_atom(ctx, name); p = JS_VALUE_GET_OBJ(obj); prs = find_own_property(&pr, p, prop); if (prs) { @@ -7240,7 +7251,7 @@ static JSValue JS_GetPrivateField(JSContext *ctx, JSValueConst obj, /* safety check */ if (unlikely(JS_VALUE_GET_TAG(name) != JS_TAG_SYMBOL)) return JS_ThrowTypeErrorNotASymbol(ctx); - prop = js_symbol_to_atom(ctx, (JSValue)name); + prop = js_symbol_to_atom(ctx, name); p = JS_VALUE_GET_OBJ(obj); prs = find_own_property(&pr, p, prop); if (!prs) { @@ -7267,7 +7278,7 @@ static int JS_SetPrivateField(JSContext *ctx, JSValueConst obj, JS_ThrowTypeErrorNotASymbol(ctx); goto fail; } - prop = js_symbol_to_atom(ctx, (JSValue)name); + prop = js_symbol_to_atom(ctx, name); p = JS_VALUE_GET_OBJ(obj); prs = find_own_property(&pr, p, prop); if (!prs) { @@ -7357,7 +7368,7 @@ static int JS_CheckBrand(JSContext *ctx, JSValueConst obj, JSValueConst func) if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT)) goto not_obj; p = JS_VALUE_GET_OBJ(obj); - prs = find_own_property(&pr, p, js_symbol_to_atom(ctx, (JSValue)brand)); + prs = find_own_property(&pr, p, js_symbol_to_atom(ctx, brand)); if (!prs) { JS_ThrowTypeError(ctx, "invalid brand on object"); return -1; @@ -10192,7 +10203,7 @@ static JSValue js_atof(JSContext *ctx, const char *str, const char **pp, } else #endif { - double d = 1.0 / 0.0; + double d = HUGE_VAL; if (is_neg) d = -d; val = JS_NewFloat64(ctx, d); @@ -15947,7 +15958,7 @@ static JSValue js_call_c_function(JSContext *ctx, JSValueConst func_obj, #else sf->js_mode = 0; #endif - sf->cur_func = (JSValue)func_obj; + sf->cur_func = func_obj; sf->arg_count = argc; arg_buf = argv; @@ -16211,7 +16222,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj, sf->js_mode = b->js_mode; arg_buf = argv; sf->arg_count = argc; - sf->cur_func = (JSValue)func_obj; + sf->cur_func = func_obj; init_list_head(&sf->var_ref_list); var_refs = p->u.func.var_refs; @@ -20176,7 +20187,7 @@ static void free_token(JSParseState *s, JSToken *token) } } -static void __attribute((unused)) dump_token(JSParseState *s, +static void __js_unused dump_token(JSParseState *s, const JSToken *token) { switch(token->val) { @@ -20237,7 +20248,7 @@ static void __attribute((unused)) dump_token(JSParseState *s, } } -int __attribute__((format(printf, 2, 3))) js_parse_error(JSParseState *s, const char *fmt, ...) +int __js_printf_like(2, 3) js_parse_error(JSParseState *s, const char *fmt, ...) { JSContext *ctx = s->ctx; va_list ap; @@ -34505,7 +34516,7 @@ typedef struct BCReaderState { } BCReaderState; #ifdef DUMP_READ_OBJECT -static void __attribute__((format(printf, 2, 3))) bc_read_trace(BCReaderState *s, const char *fmt, ...) { +static void __js_printf_like(2, 3) bc_read_trace(BCReaderState *s, const char *fmt, ...) { va_list ap; int i, n, n0; @@ -38885,8 +38896,8 @@ static int64_t JS_FlattenIntoArray(JSContext *ctx, JSValueConst target, if (!JS_IsUndefined(mapperFunction)) { JSValueConst args[3] = { element, JS_NewInt64(ctx, sourceIndex), source }; element = JS_Call(ctx, mapperFunction, thisArg, 3, args); - JS_FreeValue(ctx, (JSValue)args[0]); - JS_FreeValue(ctx, (JSValue)args[1]); + JS_FreeValue(ctx, args[0]); + JS_FreeValue(ctx, args[1]); if (JS_IsException(element)) return -1; } @@ -40344,7 +40355,7 @@ static JSValue js_string_match(JSContext *ctx, JSValueConst this_val, str = JS_NewString(ctx, "g"); if (JS_IsException(str)) goto fail; - args[args_len++] = (JSValueConst)str; + args[args_len++] = str; } rx = JS_CallConstructor(ctx, ctx->regexp_ctor, args_len, args); JS_FreeValue(ctx, str); @@ -41400,7 +41411,7 @@ static JSValue js_math_min_max(JSContext *ctx, JSValueConst this_val, uint32_t tag; if (unlikely(argc == 0)) { - return __JS_NewFloat64(ctx, is_max ? -1.0 / 0.0 : 1.0 / 0.0); + return __JS_NewFloat64(ctx, is_max ? DBL_MAX : HUGE_VAL); } tag = JS_VALUE_GET_TAG(argv[0]); @@ -41640,6 +41651,30 @@ static JSValue js___date_now(JSContext *ctx, JSValueConst this_val, } #endif +#if defined(_MSC_VER) +int gettimeofday(struct timeval * tp, struct timezone * tzp) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) + // until 00:00:00 January 1, 1970 + static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + + GetSystemTime( &system_time ); + SystemTimeToFileTime( &system_time, &file_time ); + time = ((uint64_t)file_time.dwLowDateTime ) ; + time += ((uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long) ((time - EPOCH) / 10000000L); + tp->tv_usec = (long) (system_time.wMilliseconds * 1000); + return 0; +} +#endif + + /* OS dependent: return the UTC time in microseconds since 1970. */ static JSValue js___date_clock(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) @@ -45365,7 +45400,7 @@ static JSMapRecord *map_add_record(JSContext *ctx, JSMapState *s, } else { JS_DupValue(ctx, key); } - mr->key = (JSValue)key; + mr->key = key; h = map_hash_key(ctx, key) & (s->hash_size - 1); list_add_tail(&mr->hash_link, &s->hash_table[h]); list_add_tail(&mr->link, &s->records); @@ -45587,7 +45622,7 @@ static JSValue js_map_forEach(JSContext *ctx, JSValueConst this_val, args[0] = args[1]; else args[0] = JS_DupValue(ctx, mr->value); - args[2] = (JSValue)this_val; + args[2] = this_val; ret = JS_Call(ctx, func, this_arg, 3, (JSValueConst *)args); JS_FreeValue(ctx, args[0]); if (!magic) @@ -46565,7 +46600,7 @@ static JSValue js_promise_all(JSContext *ctx, JSValueConst this_val, goto fail_reject; } resolve_element_data[0] = JS_NewBool(ctx, FALSE); - resolve_element_data[1] = (JSValueConst)JS_NewInt32(ctx, index); + resolve_element_data[1] = JS_NewInt32(ctx, index); resolve_element_data[2] = values; resolve_element_data[3] = resolving_funcs[is_promise_any]; resolve_element_data[4] = resolve_element_env; @@ -46935,7 +46970,7 @@ static JSValue js_async_from_sync_iterator_unwrap_func_create(JSContext *ctx, { JSValueConst func_data[1]; - func_data[0] = (JSValueConst)JS_NewBool(ctx, done); + func_data[0] = JS_NewBool(ctx, done); return JS_NewCFunctionData(ctx, js_async_from_sync_iterator_unwrap, 1, 0, 1, func_data); } @@ -47240,7 +47275,7 @@ static int isURIReserved(int c) { return c < 0x100 && memchr(";/?:@&=+$,#", c, sizeof(";/?:@&=+$,#") - 1) != NULL; } -static int __attribute__((format(printf, 2, 3))) js_throw_URIError(JSContext *ctx, const char *fmt, ...) +static int __js_printf_like(2, 3) js_throw_URIError(JSContext *ctx, const char *fmt, ...) { va_list ap; @@ -52286,8 +52321,8 @@ static int js_TA_cmp_generic(const void *a, const void *b, void *opaque) { psc->exception = 1; } done: - JS_FreeValue(ctx, (JSValue)argv[0]); - JS_FreeValue(ctx, (JSValue)argv[1]); + JS_FreeValue(ctx, argv[0]); + JS_FreeValue(ctx, argv[1]); } return cmp; } diff --git a/thirdparty/quickjs/quickjs/quickjs.h b/thirdparty/quickjs/quickjs/quickjs.h index 6d130152..ca1c48a4 100644 --- a/thirdparty/quickjs/quickjs/quickjs.h +++ b/thirdparty/quickjs/quickjs/quickjs.h @@ -43,11 +43,13 @@ extern "C" { #define js_unlikely(x) __builtin_expect(!!(x), 0) #define js_force_inline inline __attribute__((always_inline)) #define __js_printf_like(f, a) __attribute__((format(printf, f, a))) +#define __js_unused __attribute((unused)) #else #define js_likely(x) (x) #define js_unlikely(x) (x) #define js_force_inline INLINE_FUNC #define __js_printf_like(a, b) +#define __js_unused #endif #define JS_BOOL int @@ -221,8 +223,26 @@ typedef struct JSValue { #define JS_VALUE_GET_FLOAT64(v) ((v).u.float64) #define JS_VALUE_GET_PTR(v) ((v).u.ptr) -#define JS_MKVAL(tag, val) (JSValue){ (JSValueUnion){ .int32 = val }, tag } -#define JS_MKPTR(tag, p) (JSValue){ (JSValueUnion){ .ptr = p }, tag } +JSValue INLINE_FUNC _JS_MKVAL_INT32(int64_t tag, int32_t val) { + JSValue v; + + v.u.int32 = val; + v.tag = tag; + + return v; +} + +JSValue INLINE_FUNC _JS_MKPTR(int64_t tag, void* ptr) { + JSValue v; + + v.u.ptr = ptr; + v.tag = tag; + + return v; +} + +#define JS_MKVAL(tag, val) _JS_MKVAL_INT32(tag, val) +#define JS_MKPTR(tag, p) _JS_MKPTR(tag, p) #define JS_TAG_IS_FLOAT64(tag) ((unsigned)(tag) == JS_TAG_FLOAT64) @@ -668,7 +688,7 @@ static inline JSValue JS_DupValue(JSContext *ctx, JSValueConst v) JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v); p->ref_count++; } - return (JSValue)v; + return v; } static inline JSValue JS_DupValueRT(JSRuntime *rt, JSValueConst v) @@ -677,7 +697,7 @@ static inline JSValue JS_DupValueRT(JSRuntime *rt, JSValueConst v) JSRefCountHeader *p = (JSRefCountHeader *)JS_VALUE_GET_PTR(v); p->ref_count++; } - return (JSValue)v; + return v; } int JS_ToBool(JSContext *ctx, JSValueConst val); /* return -1 for JS_EXCEPTION */ diff --git a/thirdparty/quickjs/quickjs_binder.cpp b/thirdparty/quickjs/quickjs_binder.cpp index c517228b..35b54985 100644 --- a/thirdparty/quickjs/quickjs_binder.cpp +++ b/thirdparty/quickjs/quickjs_binder.cpp @@ -1100,7 +1100,7 @@ void QuickJSBinder::add_godot_globals() { const int value = CoreConstants::get_global_constant_value(i); JSAtom js_const_name = JS_NewAtom(ctx, const_name); - JS_DefinePropertyValue(ctx, godot_object, js_const_name, JS_MKVAL(JS_TAG_INT, value), QuickJSBinder::PROP_DEF_DEFAULT); + JS_DefinePropertyValue(ctx, godot_object, js_const_name, JS_NewInt64(ctx, value), QuickJSBinder::PROP_DEF_DEFAULT); JS_FreeAtom(ctx, js_const_name); if (HashMap *consts = global_constants.getptr(enum_name)) { @@ -1485,7 +1485,9 @@ Error QuickJSBinder::safe_eval_text(const String &p_source, EvalType type, const } JSValue ret = JS_Eval(ctx, code, utf8_str.length(), filename, flags); r_ret.context = ctx; - r_ret.javascript_object = JS_VALUE_GET_PTR(ret); + if (JS_VALUE_GET_TAG(ret) == JS_TAG_OBJECT) { + r_ret.javascript_object = JS_VALUE_GET_PTR(ret); + } if (JS_IsException(ret)) { JSValue e = JS_GetException(ctx); JavaScriptError err; diff --git a/thirdparty/quickjs/quickjs_binder.h b/thirdparty/quickjs/quickjs_binder.h index 1d003dd1..831e960c 100644 --- a/thirdparty/quickjs/quickjs_binder.h +++ b/thirdparty/quickjs/quickjs_binder.h @@ -80,7 +80,7 @@ class QuickJSBinder : public JavaScriptBinder { enum { __JS_ATOM_NULL = JS_ATOM_NULL, -#if !defined(EMSCRIPTEN) +#if !(defined(EMSCRIPTEN) || defined(_MSC_VER)) #define CONFIG_ATOMICS #endif #define DEF(name, str) JS_ATOM_##name,