diff --git a/Makefile b/Makefile index 7b3ec75b..da7a1fb6 100644 --- a/Makefile +++ b/Makefile @@ -83,8 +83,14 @@ distclean: stats: $(QJS) $(QJS) -qd -# implicitly .PHONY because it doesn't generate output -cxxtest: CXXFLAGS+=-std=c++11 -fsyntax-only -Wall -Wextra -Werror -Wno-unused-parameter +# effectively .PHONY because it doesn't generate output +ctest: CFLAGS=-std=c11 -fsyntax-only -Wall -Wextra -Werror -pedantic +ctest: ctest.c quickjs.h + $(CC) $(CFLAGS) -DJS_NAN_BOXING=0 $< + $(CC) $(CFLAGS) -DJS_NAN_BOXING=1 $< + +# effectively .PHONY because it doesn't generate output +cxxtest: CXXFLAGS=-std=c++11 -fsyntax-only -Wall -Wextra -Werror -pedantic cxxtest: cxxtest.cc quickjs.h $(CXX) $(CXXFLAGS) -DJS_NAN_BOXING=0 $< $(CXX) $(CXXFLAGS) -DJS_NAN_BOXING=1 $< @@ -116,4 +122,4 @@ unicode_gen: $(BUILD_DIR) libunicode-table.h: unicode_gen $(BUILD_DIR)/unicode_gen unicode $@ -.PHONY: all cxxtest debug fuzz install clean codegen distclean stats test test262 test262-update test262-check microbench unicode_gen $(QJS) $(QJSC) +.PHONY: all ctest cxxtest debug fuzz install clean codegen distclean stats test test262 test262-update test262-check microbench unicode_gen $(QJS) $(QJSC) diff --git a/ctest.c b/ctest.c new file mode 100644 index 00000000..eeb03e86 --- /dev/null +++ b/ctest.c @@ -0,0 +1,17 @@ +// note: file is not actually compiled, only checked for C syntax errors +#include "quickjs.h" + +int main(void) +{ + JSRuntime *rt = JS_NewRuntime(); + JSContext *ctx = JS_NewContext(rt); + JS_FreeValue(ctx, JS_NAN); + JS_FreeValue(ctx, JS_UNDEFINED); + JS_FreeValue(ctx, JS_NewFloat64(ctx, 42)); + // not a legal way of using JS_MKPTR but this is here + // to have the compiler syntax-check its definition + JS_FreeValue(ctx, JS_MKPTR(JS_TAG_UNINITIALIZED, 0)); + JS_FreeContext(ctx); + JS_FreeRuntime(rt); + return 0; +} diff --git a/cxxtest.cc b/cxxtest.cc index 6488533d..b6151009 100644 --- a/cxxtest.cc +++ b/cxxtest.cc @@ -1,17 +1,2 @@ // note: file is not actually compiled, only checked for C++ syntax errors -#include "quickjs.h" - -int main(void) -{ - JSRuntime *rt = JS_NewRuntime(); - JSContext *ctx = JS_NewContext(rt); - JS_FreeValue(ctx, JS_NAN); - JS_FreeValue(ctx, JS_UNDEFINED); - JS_FreeValue(ctx, JS_NewFloat64(ctx, 42)); - // not a legal way of using JS_MKPTR but this is here - // to have the compiler syntax-check its definition - JS_FreeValue(ctx, JS_MKPTR(JS_TAG_UNINITIALIZED, 0)); - JS_FreeContext(ctx); - JS_FreeRuntime(rt); - return 0; -} +#include "ctest.c" diff --git a/quickjs.h b/quickjs.h index 12111f80..f08a85c6 100644 --- a/quickjs.h +++ b/quickjs.h @@ -514,21 +514,25 @@ JS_EXTERN int JS_IsRegisteredClass(JSRuntime *rt, JSClassID class_id); static js_force_inline JSValue JS_NewBool(JSContext *ctx, JS_BOOL val) { + (void)&ctx; return JS_MKVAL(JS_TAG_BOOL, (val != 0)); } static js_force_inline JSValue JS_NewInt32(JSContext *ctx, int32_t val) { + (void)&ctx; return JS_MKVAL(JS_TAG_INT, val); } static js_force_inline JSValue JS_NewFloat64(JSContext *ctx, double val) { + (void)&ctx; return __JS_NewFloat64(val); } static js_force_inline JSValue JS_NewCatchOffset(JSContext *ctx, int32_t val) { + (void)&ctx; return JS_MKVAL(JS_TAG_CATCH_OFFSET, val); } @@ -566,8 +570,8 @@ static inline JS_BOOL JS_IsNumber(JSValue v) static inline JS_BOOL JS_IsBigInt(JSContext *ctx, JSValue v) { - int tag = JS_VALUE_GET_TAG(v); - return tag == JS_TAG_BIG_INT; + (void)&ctx; + return JS_VALUE_GET_TAG(v) == JS_TAG_BIG_INT; } static inline JS_BOOL JS_IsBool(JSValue v)