Browse Source

remove toString() and valueOf() from Thread prototype and inherit them from Object prototype instead; fix initial thread creation (had wrong class and internal prototype)

pull/1/head
Sami Vaarala 11 years ago
parent
commit
961b4b8ead
  1. 12
      src/duk_builtin_thread.c
  2. 5
      src/duk_heap_alloc.c
  3. 3
      src/genbuiltins.py

12
src/duk_builtin_thread.c

@ -285,15 +285,3 @@ int duk_builtin_thread_current(duk_context *ctx) {
return 1;
}
/*
* toString(), valueOf()
*/
int duk_builtin_thread_prototype_to_string(duk_context *ctx) {
return DUK_RET_UNIMPLEMENTED_ERROR;
}
int duk_builtin_thread_prototype_value_of(duk_context *ctx) {
return DUK_RET_UNIMPLEMENTED_ERROR;
}

5
src/duk_heap_alloc.c

@ -285,7 +285,7 @@ static int init_heap_thread(duk_heap *heap) {
thr = duk_hthread_alloc(heap,
DUK_HOBJECT_FLAG_EXTENSIBLE |
DUK_HOBJECT_FLAG_THREAD |
DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT));
DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_THREAD));
if (!thr) {
DUK_DPRINT("failed to alloc heap_thread");
return 0;
@ -305,6 +305,9 @@ static int init_heap_thread(duk_heap *heap) {
/* FIXME: this may now fail, and is not handled correctly */
duk_hthread_create_builtin_objects(thr);
/* default prototype (Note: 'thr' must be reachable) */
DUK_HOBJECT_SET_PROTOTYPE(thr, (duk_hobject *) thr, thr->builtins[DUK_BIDX_THREAD_PROTOTYPE]);
return 1;
}

3
src/genbuiltins.py

@ -1074,8 +1074,7 @@ bi_thread_prototype = {
'values': [
],
'functions': [
{ 'name': 'toString', 'native': 'duk_builtin_thread_prototype_to_string', 'length': 0 },
{ 'name': 'valueOf', 'native': 'duk_builtin_thread_prototype_value_of', 'length': 0 },
# toString() and valueOf() are inherited from Object.prototype
],
}

Loading…
Cancel
Save