Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for func_id rollover #94

Merged
merged 11 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions c/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ int QTS_BuildIsAsyncify() {
// -------------------
// function: C -> Host
#ifdef __EMSCRIPTEN__
EM_JS(MaybeAsync(JSValue *), qts_host_call_function, (JSContext * ctx, JSValueConst *this_ptr, int argc, JSValueConst *argv, int magic_func_id), {
EM_JS(MaybeAsync(JSValue *), qts_host_call_function, (JSContext * ctx, JSValueConst *this_ptr, int argc, JSValueConst *argv, uint32_t magic_func_id), {
#ifdef QTS_ASYNCIFY
const asyncify = {['handleSleep'] : Asyncify.handleSleep};
#else
Expand All @@ -563,7 +563,7 @@ EM_JS(MaybeAsync(JSValue *), qts_host_call_function, (JSContext * ctx, JSValueCo
#endif

// Function: QuickJS -> C
JSValue qts_call_function(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic) {
JSValue qts_call_function(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, uint32_t magic) {
JSValue *result_ptr = qts_host_call_function(ctx, &this_val, argc, argv, magic);
if (result_ptr == NULL) {
return JS_UNDEFINED;
Expand All @@ -574,7 +574,7 @@ JSValue qts_call_function(JSContext *ctx, JSValueConst this_val, int argc, JSVal
}

// Function: Host -> QuickJS
JSValue *QTS_NewFunction(JSContext *ctx, int func_id, const char *name) {
JSValue *QTS_NewFunction(JSContext *ctx, uint32_t func_id, const char *name) {
#ifdef QTS_DEBUG_MODE
char msg[500];
sprintf(msg, "new_function(name: %s, magic: %d)", name, func_id);
Expand Down
4 changes: 2 additions & 2 deletions generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ function buildSyncSymbols(matches: RegExpMatchArray[]) {
return filtered.map((fn) => "_" + fn.functionName)
}

// Input: EM_JS(MaybeAsync(JSValue *), qts_host_call_function, (JSContext * ctx, JSValueConst *this_ptr, int argc, JSValueConst *argv, int magic_func_id), {
// Match: MaybeAsync(JSValue *), qts_host_call_function, (JSContext * ctx, JSValueConst *this_ptr, int argc, JSValueConst *argv, int magic_func_id)
// Input: EM_JS(MaybeAsync(JSValue *), qts_host_call_function, (JSContext * ctx, JSValueConst *this_ptr, int argc, JSValueConst *argv, uint32_t magic_func_id), {
// Match: MaybeAsync(JSValue *), qts_host_call_function, (JSContext * ctx, JSValueConst *this_ptr, int argc, JSValueConst *argv, uint32_t magic_func_id)
function buildAsyncifySymbols(matches: RegExpMatchArray[]) {
const parsed = matches.map((match) => {
const [, contents] = match
Expand Down
4 changes: 2 additions & 2 deletions quickjs/examples/point.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static JSValue js_point_ctor(JSContext *ctx,
return JS_EXCEPTION;
}

static JSValue js_point_get_xy(JSContext *ctx, JSValueConst this_val, int magic)
static JSValue js_point_get_xy(JSContext *ctx, JSValueConst this_val, uint32_t magic)
{
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
if (!s)
Expand All @@ -85,7 +85,7 @@ static JSValue js_point_get_xy(JSContext *ctx, JSValueConst this_val, int magic)
return JS_NewInt32(ctx, s->y);
}

static JSValue js_point_set_xy(JSContext *ctx, JSValueConst this_val, JSValue val, int magic)
static JSValue js_point_set_xy(JSContext *ctx, JSValueConst this_val, JSValue val, uint32_t magic)
{
JSPointData *s = JS_GetOpaque2(ctx, this_val, js_point_class_id);
int v;
Expand Down
8 changes: 4 additions & 4 deletions quickjs/quickjs-libc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ static FILE *js_std_file_get(JSContext *ctx, JSValueConst obj)
}

static JSValue js_std_file_puts(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv, int magic)
int argc, JSValueConst *argv, uint32_t magic)
{
FILE *f;
int i;
Expand Down Expand Up @@ -1146,7 +1146,7 @@ static JSValue js_std_file_fileno(JSContext *ctx, JSValueConst this_val,
}

static JSValue js_std_file_read_write(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv, int magic)
int argc, JSValueConst *argv, uint32_t magic)
{
FILE *f = js_std_file_get(ctx, this_val);
uint64_t pos, len;
Expand Down Expand Up @@ -1631,7 +1631,7 @@ static JSValue js_os_seek(JSContext *ctx, JSValueConst this_val,
}

static JSValue js_os_read_write(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv, int magic)
int argc, JSValueConst *argv, uint32_t magic)
{
int fd;
uint64_t pos, len;
Expand Down Expand Up @@ -1847,7 +1847,7 @@ static void free_rw_handler(JSRuntime *rt, JSOSRWHandler *rh)
}

static JSValue js_os_setReadHandler(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv, int magic)
int argc, JSValueConst *argv, uint32_t magic)
{
JSRuntime *rt = JS_GetRuntime(ctx);
JSThreadState *ts = JS_GetRuntimeOpaque(rt);
Expand Down
Loading