forked from cory/tildefriends
Ugg, my print() was destructive to its arguments.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3933 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
f764007fc6
commit
41afc3bdd6
2
Makefile
2
Makefile
@ -21,7 +21,7 @@ windebug winrelease: CFLAGS += -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -DNTDDI_VER
|
||||
windebug winrelease: LDFLAGS += -static
|
||||
|
||||
ifeq ($(UNAME_M),x86_64)
|
||||
debug: CFLAGS += -fsanitize=address -fsanitize=undefined
|
||||
debug: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer -fno-common
|
||||
debug: LDFLAGS += -fsanitize=address -fsanitize=undefined
|
||||
endif
|
||||
|
||||
|
22
src/task.c
22
src/task.c
@ -154,6 +154,7 @@ static void _tf_task_sendPromiseExportMessage(tf_task_t* from, tf_taskstub_t* to
|
||||
static JSValue _tf_task_executeSource(tf_task_t* task, const char* source, const char* name);
|
||||
static tf_taskstub_t* _tf_task_get_stub(tf_task_t* task, taskid_t id);
|
||||
static void _tf_task_release_export(tf_taskstub_t* stub, exportid_t exportId);
|
||||
static bool _tf_task_run_jobs(tf_task_t* task);
|
||||
static void _tf_task_run_jobs_idle(uv_idle_t* idle);
|
||||
static void _tf_task_run_jobs_prepare(uv_prepare_t* prepare);
|
||||
|
||||
@ -370,7 +371,7 @@ static tf_taskstub_t* _tf_task_get_stub(tf_task_t* task, taskid_t id)
|
||||
}
|
||||
|
||||
|
||||
static JSValue _import_call(JSContext* context, JSValueConst func_obj, JSValueConst this_val, int argc, JSValueConst *argv, int flags)
|
||||
static JSValue _import_call(JSContext* context, JSValueConst func_obj, JSValueConst this_val, int argc, JSValueConst* argv, int flags)
|
||||
{
|
||||
import_record_t* import = JS_GetOpaque(func_obj, _import_class_id);
|
||||
if (!import)
|
||||
@ -729,6 +730,15 @@ static JSValue _tf_task_getFile(JSContext* context, JSValueConst this_val, int a
|
||||
return result;
|
||||
}
|
||||
|
||||
static JSValue _tf_task_promiseTest(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
|
||||
{
|
||||
tf_task_t* task = JS_GetContextOpaque(context);
|
||||
promiseid_t promise_id = -1;
|
||||
JSValue promise = tf_task_allocate_promise(task, &promise_id);
|
||||
tf_task_resolve_promise(task, promise_id, argv[0]);
|
||||
return promise;
|
||||
}
|
||||
|
||||
const char* _tf_task_get_message_type(tf_task_message_t type)
|
||||
{
|
||||
switch (type)
|
||||
@ -1041,16 +1051,21 @@ void tf_task_reject_promise(tf_task_t* task, promiseid_t promise, JSValue value)
|
||||
free_arg = true;
|
||||
}
|
||||
JSValue result = JS_Call(task->_context, it->values[1], JS_UNDEFINED, 1, &arg);
|
||||
tf_util_report_error(task->_context, result);
|
||||
if (free_arg)
|
||||
{
|
||||
JS_FreeValue(task->_context, arg);
|
||||
}
|
||||
tf_util_report_error(task->_context, result);
|
||||
JS_FreeValue(task->_context, it->values[0]);
|
||||
JS_FreeValue(task->_context, it->values[1]);
|
||||
JS_FreeValue(task->_context, result);
|
||||
_tf_task_free_promise(task, promise);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Didn't find promise %d to reject.\n", promise);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
taskid_t tf_task_allocate_task_id(tf_task_t* task, tf_taskstub_t* stub)
|
||||
@ -1381,6 +1396,7 @@ void tf_task_activate(tf_task_t* task)
|
||||
JS_SetPropertyStr(context, global, "exit", JS_NewCFunction(context, _tf_task_exit, "exit", 1));
|
||||
JS_SetPropertyStr(context, global, "version", JS_NewCFunction(context, _tf_task_version, "version", 0));
|
||||
JS_SetPropertyStr(context, global, "getFile", JS_NewCFunction(context, _tf_task_getFile, "getFile", 1));
|
||||
JS_SetPropertyStr(context, global, "promiseTest", JS_NewCFunction(context, _tf_task_promiseTest, "promiseTest", 1));
|
||||
JS_FreeValue(context, global);
|
||||
}
|
||||
|
||||
@ -1534,7 +1550,7 @@ void tf_task_print(tf_task_t* task, int argc, JSValueConst* argv)
|
||||
JSValue array = JS_NewArray(task->_context);
|
||||
for (int i = 0; i < argc; i++)
|
||||
{
|
||||
JS_SetPropertyUint32(task->_context, array, i, argv[i]);
|
||||
JS_SetPropertyUint32(task->_context, array, i, JS_DupValue(task->_context, argv[i]));
|
||||
}
|
||||
|
||||
void* buffer;
|
||||
|
Loading…
Reference in New Issue
Block a user