diff --git a/src/zjs_callbacks.c b/src/zjs_callbacks.c index c6e609812..c4d2bfd1b 100644 --- a/src/zjs_callbacks.c +++ b/src/zjs_callbacks.c @@ -46,9 +46,9 @@ #define SET_TYPE(f, b) f |= (b << TYPE_BIT) #define SET_JS_TYPE(f, b) f |= (b << JS_TYPE_BIT) // Macros to get the bits in flags -#define GET_ONCE(f) (f & (1 << ONCE_BIT)) -#define GET_TYPE(f) (f & (1 << TYPE_BIT)) -#define GET_JS_TYPE(f) (f & (1 << JS_TYPE_BIT)) +#define GET_ONCE(f) (f & (1 << ONCE_BIT)) >> ONCE_BIT +#define GET_TYPE(f) (f & (1 << TYPE_BIT)) >> TYPE_BIT +#define GET_JS_TYPE(f) (f & (1 << JS_TYPE_BIT)) >> JS_TYPE_BIT struct zjs_callback_t { zjs_callback_id id; @@ -277,8 +277,8 @@ zjs_callback_id add_callback(jerry_value_t js_func, cb_size++; } - DBG_PRINT("adding new callback id %ld, js_func=%lu, once=%u\n", - new_cb->id, new_cb->js->js_func, once); + DBG_PRINT("adding new callback id %d, js_func=%lu, once=%u\n", + new_cb->id, new_cb->js_func, once); return new_cb->id; } @@ -316,13 +316,13 @@ void zjs_remove_callback(zjs_callback_id id) } zjs_free(cb_map[id]); cb_map[id] = NULL; - DBG_PRINT("removing callback id %ld\n", id); + DBG_PRINT("removing callback id %d\n", id); } } void zjs_signal_callback(zjs_callback_id id, void* args, uint32_t size) { - DBG_PRINT("pushing item to ring buffer. id=%li, args=%p, size=%lu\n", id, args, size); + DBG_PRINT("pushing item to ring buffer. id=%d, args=%p, size=%lu\n", id, args, size); int ret = zjs_port_ring_buf_put(&ring_buffer, (uint16_t)id, 0, @@ -353,7 +353,7 @@ zjs_callback_id zjs_add_c_callback(void* handle, zjs_c_callback_func callback) if (new_cb->id >= cb_size - 1) { cb_size++; } - DBG_PRINT("adding new C callback id %ld\n", new_cb->id); + DBG_PRINT("adding new C callback id %d\n", new_cb->id); return new_cb->id; } @@ -364,17 +364,17 @@ void print_callbacks(void) int i; for (i = 0; i < cb_size; i++) { if (cb_map[i]) { - if (cb_map[i]->type == CALLBACK_TYPE_JS) { + if (GET_TYPE(cb_map[i]->flags) == CALLBACK_TYPE_JS) { ZJS_PRINT("[%u] JS Callback:\n\tType: ", i); - if (cb_map[i]->js->func_list == NULL && - jerry_value_is_function(cb_map[i]->js->js_func)) { + if (cb_map[i]->func_list == NULL && + jerry_value_is_function(cb_map[i]->js_func)) { ZJS_PRINT("Single Function\n"); - ZJS_PRINT("\tjs_func: %lu\n", cb_map[i]->js->js_func); - ZJS_PRINT("\tonce: %u\n", cb_map[i]->js->once); + ZJS_PRINT("\tjs_func: %lu\n", cb_map[i]->js_func); + ZJS_PRINT("\tonce: %u\n", GET_ONCE(cb_map[i]->flags)); } else { ZJS_PRINT("List\n"); - ZJS_PRINT("\tmax_funcs: %u\n", cb_map[i]->js->max_funcs); - ZJS_PRINT("\tmax_funcs: %u\n", cb_map[i]->js->num_funcs); + ZJS_PRINT("\tmax_funcs: %u\n", cb_map[i]->max_funcs); + ZJS_PRINT("\tmax_funcs: %u\n", cb_map[i]->num_funcs); } } } else { @@ -396,13 +396,13 @@ void zjs_call_callback(zjs_callback_id id, void* data, uint32_t sz) if (GET_JS_TYPE(cb_map[id]->flags) == JS_TYPE_SINGLE) { ret_val = jerry_call_function(cb_map[id]->js_func, cb_map[id]->this, data, sz); if (jerry_value_has_error_flag(ret_val)) { - DBG_PRINT("callback %ld returned an error for function\n", id); + DBG_PRINT("callback %d returned an error for function\n", id); } } else if (GET_JS_TYPE(cb_map[id]->flags) == JS_TYPE_LIST) { for (i = 0; i < cb_map[id]->num_funcs; ++i) { ret_val = jerry_call_function(cb_map[id]->func_list[i], cb_map[id]->this, data, sz); if (jerry_value_has_error_flag(ret_val)) { - DBG_PRINT("callback %ld returned an error for function[%i]\n", id, i); + DBG_PRINT("callback %d returned an error for function[%i]\n", id, i); } } } diff --git a/src/zjs_promise.c b/src/zjs_promise.c index 49bcaac66..54185f457 100644 --- a/src/zjs_promise.c +++ b/src/zjs_promise.c @@ -154,7 +154,7 @@ void zjs_fulfill_promise(jerry_value_t obj, jerry_value_t argv[], uint32_t argc) zjs_signal_callback(handle->then_id, argv, argc * sizeof(jerry_value_t)); - DBG_PRINT("fulfilling promise, obj=%lu, then_id=%lu, argv=%p, nargs=%lu\n", + DBG_PRINT("fulfilling promise, obj=%lu, then_id=%d, argv=%p, nargs=%lu\n", obj, handle->then_id, argv, argc); } else { ERR_PRINT("native handle not found\n"); @@ -188,7 +188,7 @@ void zjs_reject_promise(jerry_value_t obj, jerry_value_t argv[], uint32_t argc) zjs_signal_callback(handle->catch_id, argv, argc * sizeof(jerry_value_t)); - DBG_PRINT("rejecting promise, obj=%lu, catch_id=%ld, argv=%p, nargs=%lu\n", + DBG_PRINT("rejecting promise, obj=%lu, catch_id=%d, argv=%p, nargs=%lu\n", obj, handle->catch_id, argv, argc); } else { ERR_PRINT("native handle not found\n"); diff --git a/src/zjs_timers.c b/src/zjs_timers.c index feaf5c34a..fbb240ec1 100644 --- a/src/zjs_timers.c +++ b/src/zjs_timers.c @@ -81,7 +81,7 @@ static zjs_timer_t* add_timer(uint32_t interval, zjs_timers = tm; - DBG_PRINT("adding timer. id=%li, interval=%lu, repeat=%u, argv=%p, argc=%lu\n", + DBG_PRINT("adding timer. id=%d, interval=%lu, repeat=%u, argv=%p, argc=%lu\n", tm->callback_id, interval, repeat, argv, argc); zjs_port_timer_start(&tm->timer, interval); return tm; @@ -99,7 +99,7 @@ static bool delete_timer(int32_t id) for (zjs_timer_t **ptm = &zjs_timers; *ptm; ptm = &(*ptm)->next) { zjs_timer_t *tm = *ptm; if (id == tm->callback_id) { - DBG_PRINT("removing timer. id=%li\n", tm->callback_id); + DBG_PRINT("removing timer. id=%d\n", tm->callback_id); zjs_port_timer_stop(&tm->timer); *ptm = tm->next; for (int i = 0; i < tm->argc; ++i) { @@ -216,7 +216,7 @@ void zjs_timers_process_events() } else if (zjs_port_timer_test(&tm->timer, ZJS_TICKS_NONE)) { // timer has expired, signal the callback - DBG_PRINT("signaling timer. id=%li, argv=%p, argc=%lu\n", + DBG_PRINT("signaling timer. id=%d, argv=%p, argc=%lu\n", tm->callback_id, tm->argv, tm->argc); zjs_signal_callback(tm->callback_id, tm->argv, tm->argc * sizeof(jerry_value_t));