Skip to content

Commit cb29b27

Browse files
committed
iterate on build
1 parent 7820830 commit cb29b27

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"lsan_interface.h": "c",
99
"math.h": "c",
1010
"stdbool.h": "c",
11-
"emscripten.h": "c"
11+
"emscripten.h": "c",
12+
"quickjs-atom.h": "c"
1213
}
1314
}

c/interface.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ MaybeAsync(JSValue *) QTS_GetOwnPropertyNames(JSContext *ctx, JSValue **out_ptrs
600600
}
601601
*out_ptrs = malloc(sizeof(JSValue) * *out_len);
602602
for (int i = 0; i < *out_len; i++) {
603-
(*out_ptrs)[i] = jsvalue_to_heap(JS_AtomToValue(ctx, tab[i].atom));
603+
out_ptrs[i] = jsvalue_to_heap(JS_AtomToValue(ctx, tab[i].atom));
604604
JS_FreeAtom(ctx, tab[i].atom);
605605
}
606606
js_free(ctx, tab);
@@ -840,6 +840,7 @@ OwnedHeapChar *QTS_Typeof(JSContext *ctx, JSValueConst *value) {
840840
return out;
841841
}
842842

843+
JSAtom QTS_AtomLength = 0;
843844
int QTS_GetLength(JSContext *ctx, uint32_t *out_len, JSValueConst *value) {
844845
JSValue len_val;
845846
int result;
@@ -848,7 +849,13 @@ int QTS_GetLength(JSContext *ctx, uint32_t *out_len, JSValueConst *value) {
848849
return -1;
849850
}
850851

851-
len_val = JS_GetProperty(ctx, *value, JS_ATOM_length);
852+
if (QTS_AtomLength == 0) {
853+
// This should result in a constant static atom we don't actually need to
854+
// free, since it's interned within quickjs.c
855+
QTS_AtomLength = JS_NewAtom(ctx, "length");
856+
}
857+
858+
len_val = JS_GetProperty(ctx, *value, QTS_AtomLength);
852859
if (JS_IsException(len_val)) {
853860
return -1;
854861
}
@@ -865,6 +872,9 @@ typedef enum IsEqualOp {
865872
} IsEqualOp;
866873

867874
int QTS_IsEqual(JSContext *ctx, JSValueConst *a, JSValueConst *b, IsEqualOp op) {
875+
#ifdef QTS_USE_QUICKJS_NG
876+
return -1;
877+
#else
868878
switch (op) {
869879
case QTS_EqualOp_SameValue:
870880
return JS_SameValue(ctx, *a, *b);
@@ -874,6 +884,7 @@ int QTS_IsEqual(JSContext *ctx, JSValueConst *a, JSValueConst *b, IsEqualOp op)
874884
case QTS_EqualOp_StrictEq:
875885
return JS_StrictEq(ctx, *a, *b);
876886
}
887+
#endif
877888
}
878889

879890
JSValue *QTS_GetGlobalObject(JSContext *ctx) {

packages/internal-tsconfig/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
3636
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
3737
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
38+
// "emitDeclarationOnly": true,
3839

3940
/* Strict Type-Checking Options */
4041
"strict": true /* Enable all strict type-checking options. */,

packages/quickjs-emscripten-core/src/context.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ import type { JSPromiseState } from "./deferred-promise"
1717
import { QuickJSDeferredPromise } from "./deferred-promise"
1818
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1919
import type { shouldInterruptAfterDeadline } from "./interrupt-helpers"
20-
import { QuickJSPromisePending, QuickJSUnwrapError } from "./errors"
20+
import {
21+
QuickJSEmscriptenModuleError,
22+
QuickJSNotImplemented,
23+
QuickJSPromisePending,
24+
QuickJSUnwrapError,
25+
} from "./errors"
2126
import type { Disposable, DisposableArray, DisposableFail, DisposableSuccess } from "./lifetime"
2227
import {
2328
DisposableResult,
@@ -791,7 +796,11 @@ export class QuickJSContext
791796
}
792797
this.runtime.assertOwned(a)
793798
this.runtime.assertOwned(b)
794-
return Boolean(this.ffi.QTS_IsEqual(this.ctx.value, a.value, b.value, equalityType))
799+
const result = this.ffi.QTS_IsEqual(this.ctx.value, a.value, b.value, equalityType)
800+
if (result === -1) {
801+
throw new QuickJSNotImplemented("WASM variant does not expose equality")
802+
}
803+
return Boolean(result)
795804
}
796805

797806
/**

packages/quickjs-emscripten-core/tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
"extends": "@jitl/tsconfig/tsconfig.json",
33
"include": ["src/**/*"],
44
"compilerOptions": {
5-
"rootDir": "src",
6-
"outDir": "dist",
75
"paths": {
86
"@jitl/quickjs-ffi-types": ["../quickjs-ffi-types/src"],
97
"@jitl/quickjs-ffi-types/*": ["../quickjs-ffi-types/src/*"]

packages/quickjs-emscripten/tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
"extends": "@jitl/tsconfig/tsconfig.json",
33
"include": ["src/*.*ts"],
44
"compilerOptions": {
5-
"outDir": ".output",
6-
"rootDir": "src",
75
"paths": {
86
"#variants": ["./src/variants.ts", "./src/variants.js"],
97
"quickjs-emscripten-core": ["../quickjs-emscripten-core/src"],

0 commit comments

Comments
 (0)