duk_ret_t duv_setup_request(duk_context *ctx, uv_req_t* req, int callback) { // Create a new container object for the request with request methods duk_push_object(ctx); duk_push_heap_stash(ctx); duk_get_prop_string(ctx, -1, "req-prototype"); duk_remove(ctx, -2); duk_set_prototype(ctx, -2); // Set buffer as uv-data internal property. duk_insert(ctx, -2); duk_put_prop_string(ctx, -2, "\xff""uv-data"); // Store the request type. duk_push_int(ctx, req->type); duk_put_prop_string(ctx, -2, "\xff""req-type"); // Store a reference to the lua callback duk_dup(ctx, callback); duk_put_prop_string(ctx, -2, "\xff""uv-callback"); // Store this object in the heap stack keyed by the request's pointer address. // This will prevent it from being garbage collected and allow us to find // it with nothing more than the request's address. duv_store_handle(ctx, req); // Store the context in the handle so it can use duktape APIs. req->data = ctx; // TODO: is this still on the stack? return 1; }
duk_ret_t dukky_before_unload_event___proto(duk_context *ctx) { /* Set this prototype's prototype (left-parent) */ /* get prototype */ duk_get_global_string(ctx, dukky_magic_string_prototypes); duk_get_prop_string(ctx, -1, "\xFF\xFFNETSURF_DUKTAPE_PROTOTYPE_EVENT"); duk_replace(ctx, -2); duk_set_prototype(ctx, 0); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "returnValue"); duk_push_c_function(ctx, dukky_before_unload_event_returnValue_getter, 0); duk_push_c_function(ctx, dukky_before_unload_event_returnValue_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Set the destructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_before_unload_event___destructor, 1); duk_set_finalizer(ctx, -2); duk_pop(ctx); /* Set the constructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_before_unload_event___constructor, 2); duk_put_prop_string(ctx, -2, "\xFF\xFFNETSURF_DUKTAPE_INIT"); duk_pop(ctx); return 1; /* The prototype object */ }
void PushWeakObject(duk_context* ctx, Object* object) { if (!object) { duk_push_null(ctx); return; } duk_push_heap_stash(ctx); // Check if the wrapper for the object already exists in stash // This is required so that comparisons of object references (e.g. against the me property) work properly if (duk_has_prop_index(ctx, -1, (size_t)object)) { duk_get_prop_index(ctx, -1, (size_t)object); WeakPtr<Object>* oldPtr = GetWeakPtr(ctx, -1); if (oldPtr && oldPtr->Get() == object) { duk_remove(ctx, -2); // Remove stash return; } else duk_pop(ctx); // Valid existing wrapper not found } duk_push_object(ctx); WeakPtr<Object>* ptr = new WeakPtr<Object>(object); duk_push_pointer(ctx, ptr); duk_put_prop_string(ctx, -2, "\xff""weak"); duk_push_c_function(ctx, WeakPtr_Finalizer, 1); duk_set_finalizer(ctx, -2); // Set prototype. If not found, use base class prototype (e.g. IComponent) duk_get_global_string(ctx, object->GetTypeName().CString()); if (!duk_is_object(ctx, -1)) { duk_pop(ctx); duk_get_global_string(ctx, object->GetTypeInfo()->GetBaseTypeInfo()->GetTypeName().CString()); } duk_get_prop_string(ctx, -1, "prototype"); duk_set_prototype(ctx, -3); duk_pop(ctx); // Proxied property access handling for scene, entity & component if (object->GetType() == Scene::GetTypeStatic()) SetupProxy(ctx, SceneProxyFunctions); if (object->GetType() == Entity::GetTypeStatic()) SetupProxy(ctx, EntityProxyFunctions); else if (dynamic_cast<IComponent*>(object)) SetupProxy(ctx, ComponentProxyFunctions); // Store to stash duk_dup(ctx, -1); duk_put_prop_index(ctx, -3, (size_t)object); duk_remove(ctx, -2); // Remove stash }
static void prep(duk_context *ctx) { duk_set_top(ctx, 0); duk_push_object(ctx); duk_push_object(ctx); duk_push_int(ctx, 123); duk_put_prop_string(ctx, 0, "foo"); duk_push_int(ctx, 321); duk_put_prop_string(ctx, 1, "bar"); duk_dup(ctx, 0); duk_set_prototype(ctx, 1); duk_dup(ctx, 1); duk_set_prototype(ctx, 0); /* Two objects on stack, in a prototype loop with each other. * One object has a 'foo' property, the other a 'bar' property. */ }
void Context::pushObject(void* ptr, const char* className) { duk_push_object(m_handle); duk_push_pointer(m_handle, ptr); duk_put_prop_string(m_handle, -2, "\xFF" "\xFF" "ptr"); duk_get_global_string(m_handle, className); duk_get_prop_string(m_handle, -1, "prototype"); duk_set_prototype(m_handle, -3); duk_pop(m_handle); }
void Context::pushThis(void* ptr, const char* className) { duk_push_this(m_handle); duk_push_pointer(m_handle, ptr); duk_put_prop_string(m_handle, -2, kPtrId); // TODO classes in modules isn't supported yet duk_get_global_string(m_handle, className); duk_get_prototype(m_handle, -1); duk_set_prototype(m_handle, -3); duk_pop_2(m_handle); }
static void dukzip_push_unzfile(duk_context *ctx, unzFile archive, const char *filename) { /* create object with readable Dukzip archive prototype */ duk_push_object(ctx); duk_get_global_string(ctx, DUKZIP_UNZ_PROTOTYPE); duk_set_prototype(ctx, -2); /* set the archive pointer data */ duk_push_pointer(ctx, archive); duk_put_prop_string(ctx, -2, ZIPHANDLE_PROP); /* set path property */ duk_push_string(ctx, filename); duk_put_prop_string(ctx, -2, ZIPFILENAME_PROP); }
index_t Context::pushObject(void* ptr, const char* className) { index_t obj = duk_push_object(m_handle); duk_push_pointer(m_handle, ptr); duk_put_prop_string(m_handle, obj, kPtrId); // TODO classes in modules isn't supported yet duk_get_global_string(m_handle, className); duk_get_prototype(m_handle, -1); duk_set_prototype(m_handle, obj); duk_pop(m_handle); return obj; }
void Context::registerClass(index_t idx, const char* id, Function ctorFunc, int ctorNargs, const FunctionEntry* methods, const PropertyEntry* props) { ASSERT(ctorFunc); duk_push_c_function(m_handle, ctorFunc, ctorNargs); duk_push_object(m_handle); // Prototype object if (methods) duk_put_function_list(m_handle, -1, (const duk_function_list_entry*)methods); if (props) registerProps(-1, props); duk_set_prototype(m_handle, -2); duk_put_prop_string(m_handle, idx-1, id); }
duk_ret_t dukky_html_head_element___proto(duk_context *ctx) { /* Set this prototype's prototype (left-parent) */ /* get prototype */ duk_get_global_string(ctx, dukky_magic_string_prototypes); duk_get_prop_string(ctx, -1, "\xFF\xFFNETSURF_DUKTAPE_PROTOTYPE_HTMLELEMENT"); duk_replace(ctx, -2); duk_set_prototype(ctx, 0); /* Set the destructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_html_head_element___destructor, 1); duk_set_finalizer(ctx, -2); duk_pop(ctx); /* Set the constructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_html_head_element___constructor, 2); duk_put_prop_string(ctx, -2, "\xFF\xFFNETSURF_DUKTAPE_INIT"); duk_pop(ctx); return 1; /* The prototype object */ }
static duk_ret_t duv_require(duk_context *ctx) { int is_main = 0; const duv_schema_entry schema[] = { { "id", duk_is_string }, { NULL, NULL } }; dschema_check(ctx, schema); // push Duktape duk_get_global_string(ctx, "Duktape"); // id = Duktape.modResolve(this, id); duk_get_prop_string(ctx, -1, "modResolve"); duk_push_this(ctx); { // Check if we're in main duk_get_prop_string(ctx, -1, "exports"); if (duk_is_undefined(ctx, -1)) { is_main = 1; } duk_pop(ctx); } duk_dup(ctx, 0); duk_call_method(ctx, 1); duk_replace(ctx, 0); // push Duktape.modLoaded duk_get_prop_string(ctx, -1, "modLoaded"); // push Duktape.modLoaded[id]; duk_dup(ctx, 0); duk_get_prop(ctx, -2); // if (typeof Duktape.modLoaded[id] === 'object') { // return Duktape.modLoaded[id].exports; // } if (duk_is_object(ctx, -1)) { duk_get_prop_string(ctx, -1, "exports"); return 1; } // pop Duktape.modLoaded[id] duk_pop(ctx); // push module = { id: id, exports: {} } duk_push_object(ctx); duk_dup(ctx, 0); duk_put_prop_string(ctx, -2, "id"); duk_push_object(ctx); duk_put_prop_string(ctx, -2, "exports"); // Set module.main = true if we're the first script if (is_main) { duk_push_boolean(ctx, 1); duk_put_prop_string(ctx, -2, "main"); } // Or set module.parent = parent if we're a child. else { duk_push_this(ctx); duk_put_prop_string(ctx, -2, "parent"); } // Set the prototype for the module to access require. duk_push_global_stash(ctx); duk_get_prop_string(ctx, -1, "modulePrototype"); duk_set_prototype(ctx, -3); duk_pop(ctx); // Duktape.modLoaded[id] = module duk_dup(ctx, 0); duk_dup(ctx, -2); duk_put_prop(ctx, -4); // remove Duktape.modLoaded duk_remove(ctx, -2); // push Duktape.modLoad(module) duk_get_prop_string(ctx, -2, "modLoad"); duk_dup(ctx, -2); duk_call_method(ctx, 0); // if ret !== undefined module.exports = ret; if (duk_is_undefined(ctx, -1)) { duk_pop(ctx); } else { duk_put_prop_string(ctx, -2, "exports"); } duk_get_prop_string(ctx, -1, "exports"); return 1; }
static duk_ret_t test_func(duk_context *ctx, void *udata) { (void) udata; if (ctx) { printf("dummy - return here\n"); fflush(stdout); return 0; } /* Up-to-date for Duktape 1.3.0, alphabetical order: * $ cd website/api; ls *.yaml */ (void) duk_alloc_raw(ctx, 0); (void) duk_alloc(ctx, 0); (void) duk_base64_decode(ctx, 0); (void) duk_base64_encode(ctx, 0); (void) duk_buffer_to_string(ctx, 0); (void) duk_call_method(ctx, 0); (void) duk_call_prop(ctx, 0, 0); (void) duk_call(ctx, 0); (void) duk_char_code_at(ctx, 0, 0); (void) duk_check_stack_top(ctx, 0); (void) duk_check_stack(ctx, 0); (void) duk_check_type_mask(ctx, 0, 0); (void) duk_check_type(ctx, 0, 0); (void) duk_compact(ctx, 0); (void) duk_compile_lstring_filename(ctx, 0, "dummy", 0); (void) duk_compile_lstring(ctx, 0, "dummy", 0); (void) duk_compile_string_filename(ctx, 0, "dummy"); (void) duk_compile_string(ctx, 0, "dummy"); (void) duk_compile(ctx, 0); (void) duk_concat(ctx, 0); (void) duk_config_buffer(ctx, 0, NULL, 0); (void) duk_copy(ctx, 0, 0); (void) duk_create_heap_default(); (void) duk_create_heap(NULL, NULL, NULL, NULL, NULL); (void) duk_debugger_attach(ctx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); (void) duk_debugger_cooperate(ctx); (void) duk_debugger_detach(ctx); (void) duk_debugger_notify(ctx, 0); (void) duk_debugger_pause(ctx); (void) duk_decode_string(ctx, 0, NULL, NULL); (void) duk_def_prop(ctx, 0, 0); (void) duk_del_prop_index(ctx, 0, 0); (void) duk_del_prop_string(ctx, 0, "dummy"); (void) duk_del_prop(ctx, 0); (void) duk_destroy_heap(ctx); (void) duk_dump_function(ctx); (void) duk_dup_top(ctx); (void) duk_dup(ctx, 0); (void) duk_enum(ctx, 0, 0); (void) duk_equals(ctx, 0, 0); duk_error_va(ctx, 0, NULL, NULL); duk_error(ctx, 0, "dummy"); /* (void) cast won't work without variadic macros */ (void) duk_eval_lstring_noresult(ctx, "dummy", 0); (void) duk_eval_lstring(ctx, "dummy", 0); (void) duk_eval_noresult(ctx); (void) duk_eval_string_noresult(ctx, "dummy"); (void) duk_eval_string(ctx, "dummy"); (void) duk_eval(ctx); (void) duk_fatal(ctx, "dummy"); (void) duk_free_raw(ctx, NULL); (void) duk_free(ctx, NULL); (void) duk_gc(ctx, 0); (void) duk_get_boolean(ctx, 0); (void) duk_get_buffer_data(ctx, 0, NULL); (void) duk_get_buffer(ctx, 0, NULL); (void) duk_get_c_function(ctx, 0); (void) duk_get_context(ctx, 0); (void) duk_get_current_magic(ctx); (void) duk_get_error_code(ctx, 0); (void) duk_get_finalizer(ctx, 0); (void) duk_get_global_string(ctx, 0); (void) duk_get_heapptr(ctx, 0); (void) duk_get_int(ctx, 0); (void) duk_get_length(ctx, 0); (void) duk_get_lstring(ctx, 0, NULL); (void) duk_get_magic(ctx, 0); (void) duk_get_memory_functions(ctx, NULL); (void) duk_get_number(ctx, 0); (void) duk_get_pointer(ctx, 0); (void) duk_get_prop_index(ctx, 0, 0); (void) duk_get_prop_string(ctx, 0, "dummy"); (void) duk_get_prop(ctx, 0); (void) duk_get_prototype(ctx, 0); (void) duk_get_string(ctx, 0); (void) duk_get_top_index(ctx); (void) duk_get_top(ctx); (void) duk_get_type_mask(ctx, 0); (void) duk_get_type(ctx, 0); (void) duk_get_uint(ctx, 0); (void) duk_has_prop_index(ctx, 0, 0); (void) duk_has_prop_string(ctx, 0, "dummy"); (void) duk_has_prop(ctx, 0); (void) duk_hex_decode(ctx, 0); (void) duk_hex_encode(ctx, 0); (void) duk_insert(ctx, 0); (void) duk_instanceof(ctx, 0, 0); (void) duk_is_array(ctx, 0); (void) duk_is_boolean(ctx, 0); (void) duk_is_bound_function(ctx, 0); (void) duk_is_buffer(ctx, 0); (void) duk_is_callable(ctx, 0); (void) duk_is_c_function(ctx, 0); (void) duk_is_constructor_call(ctx); (void) duk_is_dynamic_buffer(ctx, 0); (void) duk_is_ecmascript_function(ctx, 0); (void) duk_is_error(ctx, 0); (void) duk_is_eval_error(ctx, 0); (void) duk_is_fixed_buffer(ctx, 0); (void) duk_is_function(ctx, 0); (void) duk_is_lightfunc(ctx, 0); (void) duk_is_nan(ctx, 0); (void) duk_is_null_or_undefined(ctx, 0); (void) duk_is_null(ctx, 0); (void) duk_is_number(ctx, 0); (void) duk_is_object_coercible(ctx, 0); (void) duk_is_object(ctx, 0); (void) duk_is_pointer(ctx, 0); (void) duk_is_primitive(ctx, 0); (void) duk_is_range_error(ctx, 0); (void) duk_is_reference_error(ctx, 0); (void) duk_is_strict_call(ctx); (void) duk_is_string(ctx, 0); (void) duk_is_syntax_error(ctx, 0); (void) duk_is_thread(ctx, 0); (void) duk_is_type_error(ctx, 0); (void) duk_is_undefined(ctx, 0); (void) duk_is_uri_error(ctx, 0); (void) duk_is_valid_index(ctx, 0); (void) duk_join(ctx, 0); (void) duk_json_decode(ctx, 0); (void) duk_json_encode(ctx, 0); (void) duk_load_function(ctx); (void) duk_map_string(ctx, 0, NULL, NULL); (void) duk_new(ctx, 0); (void) duk_next(ctx, 0, 0); (void) duk_normalize_index(ctx, 0); (void) duk_pcall_method(ctx, 0); (void) duk_pcall_prop(ctx, 0, 0); (void) duk_pcall(ctx, 0); (void) duk_pcompile_lstring_filename(ctx, 0, "dummy", 0); (void) duk_pcompile_lstring(ctx, 0, "dummy", 0); (void) duk_pcompile_string_filename(ctx, 0, "dummy"); (void) duk_pcompile_string(ctx, 0, "dummy"); (void) duk_pcompile(ctx, 0); (void) duk_peval_lstring_noresult(ctx, "dummy", 0); (void) duk_peval_lstring(ctx, "dummy", 0); (void) duk_peval_noresult(ctx); (void) duk_peval_string_noresult(ctx, "dummy"); (void) duk_peval_string(ctx, "dummy"); (void) duk_peval(ctx); (void) duk_pnew(ctx, 0); (void) duk_pop_2(ctx); (void) duk_pop_3(ctx); (void) duk_pop_n(ctx, 0); (void) duk_pop(ctx); (void) duk_push_array(ctx); (void) duk_push_boolean(ctx, 0); (void) duk_push_buffer_object(ctx, 0, 0, 0, 0); (void) duk_push_buffer(ctx, 0, 0); (void) duk_push_c_function(ctx, NULL, 0); (void) duk_push_c_lightfunc(ctx, NULL, 0, 0, 0); (void) duk_push_context_dump(ctx); (void) duk_push_current_function(ctx); (void) duk_push_current_thread(ctx); (void) duk_push_dynamic_buffer(ctx, 0); (void) duk_push_error_object_va(ctx, 0, NULL, NULL); (void) duk_push_error_object(ctx, 0, "dummy"); (void) duk_push_external_buffer(ctx); (void) duk_push_false(ctx); (void) duk_push_fixed_buffer(ctx, 0); (void) duk_push_global_object(ctx); (void) duk_push_global_stash(ctx); (void) duk_push_heap_stash(ctx); (void) duk_push_heapptr(ctx, NULL); (void) duk_push_int(ctx, 0); (void) duk_push_lstring(ctx, "dummy", 0); (void) duk_push_nan(ctx); (void) duk_push_null(ctx); (void) duk_push_number(ctx, 0.0); (void) duk_push_object(ctx); (void) duk_push_pointer(ctx, NULL); (void) duk_push_sprintf(ctx, "dummy"); (void) duk_push_string(ctx, "dummy"); (void) duk_push_this(ctx); (void) duk_push_thread_new_globalenv(ctx); (void) duk_push_thread_stash(ctx, NULL); (void) duk_push_thread(ctx); (void) duk_push_true(ctx); (void) duk_push_uint(ctx, 0); (void) duk_push_undefined(ctx); (void) duk_push_vsprintf(ctx, "dummy", NULL); (void) duk_put_function_list(ctx, 0, NULL); (void) duk_put_global_string(ctx, NULL); (void) duk_put_number_list(ctx, 0, NULL); (void) duk_put_prop_index(ctx, 0, 0); (void) duk_put_prop_string(ctx, 0, "dummy"); (void) duk_put_prop(ctx, 0); (void) duk_realloc_raw(ctx, NULL, 0); (void) duk_realloc(ctx, NULL, 0); (void) duk_remove(ctx, 0); (void) duk_replace(ctx, 0); (void) duk_require_boolean(ctx, 0); (void) duk_require_buffer_data(ctx, 0, NULL); (void) duk_require_buffer(ctx, 0, NULL); (void) duk_require_c_function(ctx, 0); (void) duk_require_callable(ctx, 0); (void) duk_require_context(ctx, 0); (void) duk_require_function(ctx, 0); (void) duk_require_heapptr(ctx, 0); (void) duk_require_int(ctx, 0); (void) duk_require_lstring(ctx, 0, NULL); (void) duk_require_normalize_index(ctx, 0); (void) duk_require_null(ctx, 0); (void) duk_require_number(ctx, 0); (void) duk_require_object_coercible(ctx, 0); (void) duk_require_pointer(ctx, 0); (void) duk_require_stack_top(ctx, 0); (void) duk_require_stack(ctx, 0); (void) duk_require_string(ctx, 0); (void) duk_require_top_index(ctx); (void) duk_require_type_mask(ctx, 0, 0); (void) duk_require_uint(ctx, 0); (void) duk_require_undefined(ctx, 0); (void) duk_require_valid_index(ctx, 0); (void) duk_resize_buffer(ctx, 0, 0); (void) duk_safe_call(ctx, NULL, NULL, 0, 0); (void) duk_safe_to_lstring(ctx, 0, NULL); (void) duk_safe_to_string(ctx, 0); (void) duk_set_finalizer(ctx, 0); (void) duk_set_global_object(ctx); (void) duk_set_magic(ctx, 0, 0); (void) duk_set_prototype(ctx, 0); (void) duk_set_top(ctx, 0); (void) duk_steal_buffer(ctx, 0, NULL); (void) duk_strict_equals(ctx, 0, 0); (void) duk_substring(ctx, 0, 0, 0); (void) duk_swap_top(ctx, 0); (void) duk_swap(ctx, 0, 0); (void) duk_throw(ctx); (void) duk_to_boolean(ctx, 0); (void) duk_to_buffer(ctx, 0, NULL); (void) duk_to_defaultvalue(ctx, 0, 0); (void) duk_to_dynamic_buffer(ctx, 0, NULL); (void) duk_to_fixed_buffer(ctx, 0, NULL); (void) duk_to_int32(ctx, 0); (void) duk_to_int(ctx, 0); (void) duk_to_lstring(ctx, 0, NULL); (void) duk_to_null(ctx, 0); (void) duk_to_number(ctx, 0); (void) duk_to_object(ctx, 0); (void) duk_to_pointer(ctx, 0); (void) duk_to_primitive(ctx, 0, 0); (void) duk_to_string(ctx, 0); (void) duk_to_uint16(ctx, 0); (void) duk_to_uint32(ctx, 0); (void) duk_to_uint(ctx, 0); (void) duk_to_undefined(ctx, 0); (void) duk_trim(ctx, 0); (void) duk_xcopy_top(ctx, NULL, 0); (void) duk_xmove_top(ctx, NULL, 0); printf("never here\n"); fflush(stdout); return 0; }
duk_ret_t dukky_storage_event___proto(duk_context *ctx) { /* Set this prototype's prototype (left-parent) */ /* get prototype */ duk_get_global_string(ctx, dukky_magic_string_prototypes); duk_get_prop_string(ctx, -1, "\xFF\xFFNETSURF_DUKTAPE_PROTOTYPE_EVENT"); duk_replace(ctx, -2); duk_set_prototype(ctx, 0); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "key"); duk_push_c_function(ctx, dukky_storage_event_key_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "oldValue"); duk_push_c_function(ctx, dukky_storage_event_oldValue_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "newValue"); duk_push_c_function(ctx, dukky_storage_event_newValue_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "url"); duk_push_c_function(ctx, dukky_storage_event_url_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "storageArea"); duk_push_c_function(ctx, dukky_storage_event_storageArea_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Set the destructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_storage_event___destructor, 1); duk_set_finalizer(ctx, -2); duk_pop(ctx); /* Set the constructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_storage_event___constructor, 2); duk_put_prop_string(ctx, -2, "\xFF\xFFNETSURF_DUKTAPE_INIT"); duk_pop(ctx); return 1; /* The prototype object */ }
duk_ret_t dukky_application_cache___proto(duk_context *ctx) { /* Set this prototype's prototype (left-parent) */ /* get prototype */ duk_get_global_string(ctx, dukky_magic_string_prototypes); duk_get_prop_string(ctx, -1, "\xFF\xFFNETSURF_DUKTAPE_PROTOTYPE_EVENTTARGET"); duk_replace(ctx, -2); duk_set_prototype(ctx, 0); /* Add a method */ duk_dup(ctx, 0); duk_push_string(ctx, "update"); duk_push_c_function(ctx, dukky_application_cache_update, DUK_VARARGS); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add a method */ duk_dup(ctx, 0); duk_push_string(ctx, "abort"); duk_push_c_function(ctx, dukky_application_cache_abort, DUK_VARARGS); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add a method */ duk_dup(ctx, 0); duk_push_string(ctx, "swapCache"); duk_push_c_function(ctx, dukky_application_cache_swapCache, DUK_VARARGS); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "status"); duk_push_c_function(ctx, dukky_application_cache_status_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onchecking"); duk_push_c_function(ctx, dukky_application_cache_onchecking_getter, 0); duk_push_c_function(ctx, dukky_application_cache_onchecking_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onerror"); duk_push_c_function(ctx, dukky_application_cache_onerror_getter, 0); duk_push_c_function(ctx, dukky_application_cache_onerror_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onnoupdate"); duk_push_c_function(ctx, dukky_application_cache_onnoupdate_getter, 0); duk_push_c_function(ctx, dukky_application_cache_onnoupdate_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "ondownloading"); duk_push_c_function(ctx, dukky_application_cache_ondownloading_getter, 0); duk_push_c_function(ctx, dukky_application_cache_ondownloading_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onprogress"); duk_push_c_function(ctx, dukky_application_cache_onprogress_getter, 0); duk_push_c_function(ctx, dukky_application_cache_onprogress_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onupdateready"); duk_push_c_function(ctx, dukky_application_cache_onupdateready_getter, 0); duk_push_c_function(ctx, dukky_application_cache_onupdateready_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "oncached"); duk_push_c_function(ctx, dukky_application_cache_oncached_getter, 0); duk_push_c_function(ctx, dukky_application_cache_oncached_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onobsolete"); duk_push_c_function(ctx, dukky_application_cache_onobsolete_getter, 0); duk_push_c_function(ctx, dukky_application_cache_onobsolete_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); duk_dup(ctx, 0); duk_push_string(ctx, "UNCACHED"); duk_push_int(ctx, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); duk_dup(ctx, 0); duk_push_string(ctx, "IDLE"); duk_push_int(ctx, 1); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); duk_dup(ctx, 0); duk_push_string(ctx, "CHECKING"); duk_push_int(ctx, 2); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); duk_dup(ctx, 0); duk_push_string(ctx, "DOWNLOADING"); duk_push_int(ctx, 3); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); duk_dup(ctx, 0); duk_push_string(ctx, "UPDATEREADY"); duk_push_int(ctx, 4); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); duk_dup(ctx, 0); duk_push_string(ctx, "OBSOLETE"); duk_push_int(ctx, 5); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Set the destructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_application_cache___destructor, 1); duk_set_finalizer(ctx, -2); duk_pop(ctx); /* Set the constructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_application_cache___constructor, 1); duk_put_prop_string(ctx, -2, "\xFF\xFFNETSURF_DUKTAPE_INIT"); duk_pop(ctx); return 1; /* The prototype object */ }
duk_ret_t dukky_html_embed_element___proto(duk_context *ctx) { /* Set this prototype's prototype (left-parent) */ /* get prototype */ duk_get_global_string(ctx, dukky_magic_string_prototypes); duk_get_prop_string(ctx, -1, "\xFF\xFFNETSURF_DUKTAPE_PROTOTYPE_HTMLELEMENT"); duk_replace(ctx, -2); duk_set_prototype(ctx, 0); /* Add a method */ duk_dup(ctx, 0); duk_push_string(ctx, "getSVGDocument"); duk_push_c_function(ctx, dukky_html_embed_element_getSVGDocument, DUK_VARARGS); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "src"); duk_push_c_function(ctx, dukky_html_embed_element_src_getter, 0); duk_push_c_function(ctx, dukky_html_embed_element_src_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "type"); duk_push_c_function(ctx, dukky_html_embed_element_type_getter, 0); duk_push_c_function(ctx, dukky_html_embed_element_type_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "width"); duk_push_c_function(ctx, dukky_html_embed_element_width_getter, 0); duk_push_c_function(ctx, dukky_html_embed_element_width_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "height"); duk_push_c_function(ctx, dukky_html_embed_element_height_getter, 0); duk_push_c_function(ctx, dukky_html_embed_element_height_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "align"); duk_push_c_function(ctx, dukky_html_embed_element_align_getter, 0); duk_push_c_function(ctx, dukky_html_embed_element_align_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "name"); duk_push_c_function(ctx, dukky_html_embed_element_name_getter, 0); duk_push_c_function(ctx, dukky_html_embed_element_name_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Set the destructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_html_embed_element___destructor, 1); duk_set_finalizer(ctx, -2); duk_pop(ctx); /* Set the constructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_html_embed_element___constructor, 2); duk_put_prop_string(ctx, -2, "\xFF\xFFNETSURF_DUKTAPE_INIT"); duk_pop(ctx); return 1; /* The prototype object */ }
duk_ret_t dukky_html_anchor_element___proto(duk_context *ctx) { /* Set this prototype's prototype (left-parent) */ /* get prototype */ duk_get_global_string(ctx, dukky_magic_string_prototypes); duk_get_prop_string(ctx, -1, "\xFF\xFFNETSURF_DUKTAPE_PROTOTYPE_HTMLELEMENT"); duk_replace(ctx, -2); duk_set_prototype(ctx, 0); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "target"); duk_push_c_function(ctx, dukky_html_anchor_element_target_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_target_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "download"); duk_push_c_function(ctx, dukky_html_anchor_element_download_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_download_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "ping"); duk_push_c_function(ctx, dukky_html_anchor_element_ping_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_ping_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "rel"); duk_push_c_function(ctx, dukky_html_anchor_element_rel_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_rel_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "relList"); duk_push_c_function(ctx, dukky_html_anchor_element_relList_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "hreflang"); duk_push_c_function(ctx, dukky_html_anchor_element_hreflang_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_hreflang_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "type"); duk_push_c_function(ctx, dukky_html_anchor_element_type_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_type_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "text"); duk_push_c_function(ctx, dukky_html_anchor_element_text_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_text_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "coords"); duk_push_c_function(ctx, dukky_html_anchor_element_coords_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_coords_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "charset"); duk_push_c_function(ctx, dukky_html_anchor_element_charset_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_charset_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "name"); duk_push_c_function(ctx, dukky_html_anchor_element_name_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_name_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "rev"); duk_push_c_function(ctx, dukky_html_anchor_element_rev_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_rev_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "shape"); duk_push_c_function(ctx, dukky_html_anchor_element_shape_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_shape_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "href"); duk_push_c_function(ctx, dukky_html_anchor_element_href_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_href_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "origin"); duk_push_c_function(ctx, dukky_html_anchor_element_origin_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "protocol"); duk_push_c_function(ctx, dukky_html_anchor_element_protocol_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_protocol_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "username"); duk_push_c_function(ctx, dukky_html_anchor_element_username_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_username_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "password"); duk_push_c_function(ctx, dukky_html_anchor_element_password_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_password_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "host"); duk_push_c_function(ctx, dukky_html_anchor_element_host_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_host_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "hostname"); duk_push_c_function(ctx, dukky_html_anchor_element_hostname_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_hostname_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "port"); duk_push_c_function(ctx, dukky_html_anchor_element_port_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_port_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "pathname"); duk_push_c_function(ctx, dukky_html_anchor_element_pathname_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_pathname_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "search"); duk_push_c_function(ctx, dukky_html_anchor_element_search_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_search_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "hash"); duk_push_c_function(ctx, dukky_html_anchor_element_hash_getter, 0); duk_push_c_function(ctx, dukky_html_anchor_element_hash_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Set the destructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_html_anchor_element___destructor, 1); duk_set_finalizer(ctx, -2); duk_pop(ctx); /* Set the constructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_html_anchor_element___constructor, 2); duk_put_prop_string(ctx, -2, "\xFF\xFFNETSURF_DUKTAPE_INIT"); duk_pop(ctx); return 1; /* The prototype object */ }
duk_ret_t dukky_document_fragment___proto(duk_context *ctx) { /* Set this prototype's prototype (left-parent) */ /* get prototype */ duk_get_global_string(ctx, dukky_magic_string_prototypes); duk_get_prop_string(ctx, -1, "\xFF\xFFNETSURF_DUKTAPE_PROTOTYPE_NODE"); duk_replace(ctx, -2); duk_set_prototype(ctx, 0); /* Add a method */ duk_dup(ctx, 0); duk_push_string(ctx, "getElementById"); duk_push_c_function(ctx, dukky_document_fragment_getElementById, DUK_VARARGS); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add a method */ duk_dup(ctx, 0); duk_push_string(ctx, "prepend"); duk_push_c_function(ctx, dukky_document_fragment_prepend, DUK_VARARGS); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add a method */ duk_dup(ctx, 0); duk_push_string(ctx, "append"); duk_push_c_function(ctx, dukky_document_fragment_append, DUK_VARARGS); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add a method */ duk_dup(ctx, 0); duk_push_string(ctx, "query"); duk_push_c_function(ctx, dukky_document_fragment_query, DUK_VARARGS); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add a method */ duk_dup(ctx, 0); duk_push_string(ctx, "queryAll"); duk_push_c_function(ctx, dukky_document_fragment_queryAll, DUK_VARARGS); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add a method */ duk_dup(ctx, 0); duk_push_string(ctx, "querySelector"); duk_push_c_function(ctx, dukky_document_fragment_querySelector, DUK_VARARGS); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add a method */ duk_dup(ctx, 0); duk_push_string(ctx, "querySelectorAll"); duk_push_c_function(ctx, dukky_document_fragment_querySelectorAll, DUK_VARARGS); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "children"); duk_push_c_function(ctx, dukky_document_fragment_children_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "firstElementChild"); duk_push_c_function(ctx, dukky_document_fragment_firstElementChild_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "lastElementChild"); duk_push_c_function(ctx, dukky_document_fragment_lastElementChild_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "childElementCount"); duk_push_c_function(ctx, dukky_document_fragment_childElementCount_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Set the destructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_document_fragment___destructor, 1); duk_set_finalizer(ctx, -2); duk_pop(ctx); /* Set the constructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_document_fragment___constructor, 2); duk_put_prop_string(ctx, -2, "\xFF\xFFNETSURF_DUKTAPE_INIT"); duk_pop(ctx); return 1; /* The prototype object */ }
duk_ret_t dukky_html_table_cell_element___proto(duk_context *ctx) { /* Set this prototype's prototype (left-parent) */ /* get prototype */ duk_get_global_string(ctx, dukky_magic_string_prototypes); duk_get_prop_string(ctx, -1, "\xFF\xFFNETSURF_DUKTAPE_PROTOTYPE_HTMLELEMENT"); duk_replace(ctx, -2); duk_set_prototype(ctx, 0); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "colSpan"); duk_push_c_function(ctx, dukky_html_table_cell_element_colSpan_getter, 0); duk_push_c_function(ctx, dukky_html_table_cell_element_colSpan_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "rowSpan"); duk_push_c_function(ctx, dukky_html_table_cell_element_rowSpan_getter, 0); duk_push_c_function(ctx, dukky_html_table_cell_element_rowSpan_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "headers"); duk_push_c_function(ctx, dukky_html_table_cell_element_headers_getter, 0); duk_push_c_function(ctx, dukky_html_table_cell_element_headers_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "cellIndex"); duk_push_c_function(ctx, dukky_html_table_cell_element_cellIndex_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "align"); duk_push_c_function(ctx, dukky_html_table_cell_element_align_getter, 0); duk_push_c_function(ctx, dukky_html_table_cell_element_align_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "axis"); duk_push_c_function(ctx, dukky_html_table_cell_element_axis_getter, 0); duk_push_c_function(ctx, dukky_html_table_cell_element_axis_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "height"); duk_push_c_function(ctx, dukky_html_table_cell_element_height_getter, 0); duk_push_c_function(ctx, dukky_html_table_cell_element_height_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "width"); duk_push_c_function(ctx, dukky_html_table_cell_element_width_getter, 0); duk_push_c_function(ctx, dukky_html_table_cell_element_width_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "ch"); duk_push_c_function(ctx, dukky_html_table_cell_element_ch_getter, 0); duk_push_c_function(ctx, dukky_html_table_cell_element_ch_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "chOff"); duk_push_c_function(ctx, dukky_html_table_cell_element_chOff_getter, 0); duk_push_c_function(ctx, dukky_html_table_cell_element_chOff_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "noWrap"); duk_push_c_function(ctx, dukky_html_table_cell_element_noWrap_getter, 0); duk_push_c_function(ctx, dukky_html_table_cell_element_noWrap_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "vAlign"); duk_push_c_function(ctx, dukky_html_table_cell_element_vAlign_getter, 0); duk_push_c_function(ctx, dukky_html_table_cell_element_vAlign_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "bgColor"); duk_push_c_function(ctx, dukky_html_table_cell_element_bgColor_getter, 0); duk_push_c_function(ctx, dukky_html_table_cell_element_bgColor_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Set the destructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_html_table_cell_element___destructor, 1); duk_set_finalizer(ctx, -2); duk_pop(ctx); /* Set the constructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_html_table_cell_element___constructor, 2); duk_put_prop_string(ctx, -2, "\xFF\xFFNETSURF_DUKTAPE_INIT"); duk_pop(ctx); return 1; /* The prototype object */ }
duk_ret_t dukky_html_frame_set_element___proto(duk_context *ctx) { /* Set this prototype's prototype (left-parent) */ /* get prototype */ duk_get_global_string(ctx, dukky_magic_string_prototypes); duk_get_prop_string(ctx, -1, "\xFF\xFFNETSURF_DUKTAPE_PROTOTYPE_HTMLELEMENT"); duk_replace(ctx, -2); duk_set_prototype(ctx, 0); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "cols"); duk_push_c_function(ctx, dukky_html_frame_set_element_cols_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_cols_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "rows"); duk_push_c_function(ctx, dukky_html_frame_set_element_rows_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_rows_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onafterprint"); duk_push_c_function(ctx, dukky_html_frame_set_element_onafterprint_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_onafterprint_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onbeforeprint"); duk_push_c_function(ctx, dukky_html_frame_set_element_onbeforeprint_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_onbeforeprint_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onbeforeunload"); duk_push_c_function(ctx, dukky_html_frame_set_element_onbeforeunload_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_onbeforeunload_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onhashchange"); duk_push_c_function(ctx, dukky_html_frame_set_element_onhashchange_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_onhashchange_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onlanguagechange"); duk_push_c_function(ctx, dukky_html_frame_set_element_onlanguagechange_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_onlanguagechange_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onmessage"); duk_push_c_function(ctx, dukky_html_frame_set_element_onmessage_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_onmessage_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onoffline"); duk_push_c_function(ctx, dukky_html_frame_set_element_onoffline_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_onoffline_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "ononline"); duk_push_c_function(ctx, dukky_html_frame_set_element_ononline_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_ononline_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onpagehide"); duk_push_c_function(ctx, dukky_html_frame_set_element_onpagehide_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_onpagehide_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onpageshow"); duk_push_c_function(ctx, dukky_html_frame_set_element_onpageshow_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_onpageshow_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onpopstate"); duk_push_c_function(ctx, dukky_html_frame_set_element_onpopstate_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_onpopstate_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onstorage"); duk_push_c_function(ctx, dukky_html_frame_set_element_onstorage_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_onstorage_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onunload"); duk_push_c_function(ctx, dukky_html_frame_set_element_onunload_getter, 0); duk_push_c_function(ctx, dukky_html_frame_set_element_onunload_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Set the destructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_html_frame_set_element___destructor, 1); duk_set_finalizer(ctx, -2); duk_pop(ctx); /* Set the constructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_html_frame_set_element___constructor, 2); duk_put_prop_string(ctx, -2, "\xFF\xFFNETSURF_DUKTAPE_INIT"); duk_pop(ctx); return 1; /* The prototype object */ }
DUK_EXTERNAL void duk_new(duk_context *ctx, duk_idx_t nargs) { /* * There are two [[Construct]] operations in the specification: * * - E5 Section 13.2.2: for Function objects * - E5 Section 15.3.4.5.2: for "bound" Function objects * * The chain of bound functions is resolved in Section 15.3.4.5.2, * with arguments "piling up" until the [[Construct]] internal * method is called on the final, actual Function object. Note * that the "prototype" property is looked up *only* from the * final object, *before* calling the constructor. * * Since Duktape 2.2 bound functions are represented with the * duk_hboundfunc internal type, and bound function chains are * collapsed when a bound function is created. As a result, the * direct target of a duk_hboundfunc is always non-bound and the * this/argument lists have been resolved. * * When constructing new Array instances, an unnecessary object is * created and discarded now: the standard [[Construct]] creates an * object, and calls the Array constructor. The Array constructor * returns an Array instance, which is used as the result value for * the "new" operation; the object created before the Array constructor * call is discarded. * * This would be easy to fix, e.g. by knowing that the Array constructor * will always create a replacement object and skip creating the fallback * object in that case. * * Note: functions called via "new" need to know they are called as a * constructor. For instance, built-in constructors behave differently * depending on how they are called. */ /* XXX: merge this with duk_js_call.c, as this function implements * core semantics (or perhaps merge the two files altogether). */ duk_hthread *thr = (duk_hthread *) ctx; duk_hobject *proto; duk_hobject *cons; duk_hobject *fallback; duk_idx_t idx_cons; duk_small_uint_t call_flags; DUK_ASSERT_CTX_VALID(ctx); /* [... constructor arg1 ... argN] */ idx_cons = duk_require_normalize_index(ctx, -nargs - 1); DUK_DDD(DUK_DDDPRINT("top=%ld, nargs=%ld, idx_cons=%ld", (long) duk_get_top(ctx), (long) nargs, (long) idx_cons)); /* XXX: code duplication */ /* * Figure out the final, non-bound constructor, to get "prototype" * property. */ duk_dup(ctx, idx_cons); duk_resolve_nonbound_function(ctx); duk_require_callable(ctx, -1); cons = duk_get_hobject(ctx, -1); /* Result is a lightfunc or a callable actual function. */ DUK_ASSERT(cons == NULL || DUK_HOBJECT_IS_CALLABLE(cons)); if (cons != NULL && !DUK_HOBJECT_HAS_CONSTRUCTABLE(cons)) { /* Check constructability from the final, non-bound object. * The constructable flag is 1:1 for the bound function and * its target so this should be sufficient. Lightfuncs are * always constructable. */ goto not_constructable; } DUK_ASSERT(duk_is_callable(ctx, -1)); DUK_ASSERT(duk_is_lightfunc(ctx, -1) || (duk_get_hobject(ctx, -1) != NULL && !DUK_HOBJECT_HAS_BOUNDFUNC(duk_get_hobject(ctx, -1)))); /* [... constructor arg1 ... argN final_cons] */ /* * Create "fallback" object to be used as the object instance, * unless the constructor returns a replacement value. * Its internal prototype needs to be set based on "prototype" * property of the constructor. */ duk_push_object(ctx); /* class Object, extensible */ /* [... constructor arg1 ... argN final_cons fallback] */ duk_get_prop_stridx_short(ctx, -2, DUK_STRIDX_PROTOTYPE); proto = duk_get_hobject(ctx, -1); if (!proto) { DUK_DDD(DUK_DDDPRINT("constructor has no 'prototype' property, or value not an object " "-> leave standard Object prototype as fallback prototype")); } else { DUK_DDD(DUK_DDDPRINT("constructor has 'prototype' property with object value " "-> set fallback prototype to that value: %!iO", (duk_heaphdr *) proto)); fallback = duk_known_hobject(ctx, -2); DUK_ASSERT(fallback != NULL); DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, fallback, proto); } duk_pop(ctx); #if 0 /* XXX: smaller alternative */ if (duk_is_object(ctx, -1)) { DUK_DDD(DUK_DDDPRINT("constructor has 'prototype' property with object value " "-> set fallback prototype to that value: %!iT", duk_get_tval(ctx, -1))); duk_set_prototype(ctx, -2); } else { DUK_DDD(DUK_DDDPRINT("constructor has no 'prototype' property, or value not an object " "-> leave standard Object prototype as fallback prototype")); duk_pop(ctx); } #endif /* [... constructor arg1 ... argN final_cons fallback] */ /* * Manipulate value stack for the call. */ duk_dup_top(ctx); duk_insert(ctx, idx_cons + 1); /* use fallback as 'this' value */ duk_insert(ctx, idx_cons); /* also stash it before constructor, * in case we need it (as the fallback value) */ duk_pop(ctx); /* pop final_cons */ /* [... fallback constructor fallback(this) arg1 ... argN]; * Note: idx_cons points to first 'fallback', not 'constructor'. */ DUK_DDD(DUK_DDDPRINT("before call, idx_cons+1 (constructor) -> %!T, idx_cons+2 (fallback/this) -> %!T, " "nargs=%ld, top=%ld", (duk_tval *) duk_get_tval(ctx, idx_cons + 1), (duk_tval *) duk_get_tval(ctx, idx_cons + 2), (long) nargs, (long) duk_get_top(ctx))); /* * Call the constructor function (called in "constructor mode"). */ call_flags = DUK_CALL_FLAG_CONSTRUCTOR_CALL; /* not protected, respect reclimit, is a constructor call */ duk_handle_call_unprotected(thr, /* thread */ nargs, /* num_stack_args */ call_flags); /* call_flags */ /* [... fallback retval] */ DUK_DDD(DUK_DDDPRINT("constructor call finished, fallback=%!iT, retval=%!iT", (duk_tval *) duk_get_tval(ctx, -2), (duk_tval *) duk_get_tval(ctx, -1))); /* * Determine whether to use the constructor return value as the created * object instance or not. */ if (duk_check_type_mask(ctx, -1, DUK_TYPE_MASK_OBJECT | DUK_TYPE_MASK_BUFFER | DUK_TYPE_MASK_LIGHTFUNC)) { duk_remove_m2(ctx); } else { duk_pop(ctx); } /* * Augment created errors upon creation (not when they are thrown or * rethrown). __FILE__ and __LINE__ are not desirable here; the call * stack reflects the caller which is correct. */ #if defined(DUK_USE_AUGMENT_ERROR_CREATE) duk_hthread_sync_currpc(thr); duk_err_augment_error_create(thr, thr, NULL, 0, 1 /*noblame_fileline*/); #endif /* [... retval] */ return; not_constructable: #if defined(DUK_USE_VERBOSE_ERRORS) #if defined(DUK_USE_PARANOID_ERRORS) DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "%s not constructable", duk_get_type_name(ctx, -1)); #else DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "%s not constructable", duk_push_string_readable(ctx, -1)); #endif #else DUK_ERROR_TYPE(thr, "not constructable"); #endif }
duk_ret_t dukky_video_track_list___proto(duk_context *ctx) { /* Set this prototype's prototype (left-parent) */ /* get prototype */ duk_get_global_string(ctx, dukky_magic_string_prototypes); duk_get_prop_string(ctx, -1, "\xFF\xFFNETSURF_DUKTAPE_PROTOTYPE_EVENTTARGET"); duk_replace(ctx, -2); duk_set_prototype(ctx, 0); /* Add a method */ duk_dup(ctx, 0); duk_push_string(ctx, "getTrackById"); duk_push_c_function(ctx, dukky_video_track_list_getTrackById, DUK_VARARGS); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "length"); duk_push_c_function(ctx, dukky_video_track_list_length_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add readonly property */ duk_dup(ctx, 0); duk_push_string(ctx, "selectedIndex"); duk_push_c_function(ctx, dukky_video_track_list_selectedIndex_getter, 0); duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onchange"); duk_push_c_function(ctx, dukky_video_track_list_onchange_getter, 0); duk_push_c_function(ctx, dukky_video_track_list_onchange_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onaddtrack"); duk_push_c_function(ctx, dukky_video_track_list_onaddtrack_getter, 0); duk_push_c_function(ctx, dukky_video_track_list_onaddtrack_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Add read/write property */ duk_dup(ctx, 0); duk_push_string(ctx, "onremovetrack"); duk_push_c_function(ctx, dukky_video_track_list_onremovetrack_getter, 0); duk_push_c_function(ctx, dukky_video_track_list_onremovetrack_setter, 1); duk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE); duk_pop(ctx); /* Set the destructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_video_track_list___destructor, 1); duk_set_finalizer(ctx, -2); duk_pop(ctx); /* Set the constructor */ duk_dup(ctx, 0); duk_push_c_function(ctx, dukky_video_track_list___constructor, 1); duk_put_prop_string(ctx, -2, "\xFF\xFFNETSURF_DUKTAPE_INIT"); duk_pop(ctx); return 1; /* The prototype object */ }
//void duk_set_prototype(duk_context *ctx, duk_idx_t index); void aperl_duk_set_prototype(duk_context *ctx, duk_idx_t index) { duk_set_prototype(ctx, index); }