mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
[quickjs] toString functions
This commit is contained in:
parent
5698608b5a
commit
54d1263a6b
@ -114,9 +114,19 @@ js_attr_get_property_value(JSContext *ctx, JSValueConst this_val)
|
||||
RETURN_JS(r);
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_attr_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[attr object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_attr_proto_funcs[] = {
|
||||
JS_CGETSET_DEF("name", js_attr_get_property_name, nullptr),
|
||||
JS_CGETSET_DEF("value", js_attr_get_property_value, nullptr),
|
||||
JS_CFUNC_DEF("toString", 0, js_attr_toString)
|
||||
};
|
||||
|
||||
static std::map<void *, JSValueConst> map_attrs;
|
||||
|
@ -240,10 +240,20 @@ js_attributes_getNamedItem(JSContext *ctx, JSValueConst this_val, int argc, JSVa
|
||||
RETURN_JS(ret);
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_attributes_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[attributes object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_attributes_proto_funcs[] = {
|
||||
JS_CGETSET_DEF("length", js_attributes_get_property_length, nullptr),
|
||||
JS_CFUNC_DEF("item", 1, js_attributes_item),
|
||||
JS_CFUNC_DEF("getNamedItem", 1, js_attributes_getNamedItem),
|
||||
JS_CFUNC_DEF("toString", 0, js_attributes_toString)
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -229,13 +229,22 @@ js_htmlCollection_set_items(JSContext *ctx, JSValue this_val, void *node)
|
||||
}
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_htmlCollection_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[htmlCollection object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_htmlCollection_proto_funcs[] = {
|
||||
JS_CGETSET_DEF("length", js_htmlCollection_get_property_length, nullptr),
|
||||
JS_CFUNC_DEF("item", 1, js_htmlCollection_item),
|
||||
JS_CFUNC_DEF("namedItem", 1, js_htmlCollection_namedItem),
|
||||
JS_CFUNC_DEF("toString", 0, js_htmlCollection_toString)
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
js_htmlCollection_finalizer(JSRuntime *rt, JSValue val)
|
||||
{
|
||||
|
@ -87,9 +87,19 @@ js_console_error(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *
|
||||
return js_console_log_common(ctx, this_val, argc, argv, console_error_filename);
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_console_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[console object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_console_funcs[] = {
|
||||
JS_CFUNC_DEF("log", 1, js_console_log),
|
||||
JS_CFUNC_DEF("error", 1, js_console_error),
|
||||
JS_CFUNC_DEF("toString", 0, js_console_toString)
|
||||
};
|
||||
|
||||
static JSClassDef js_console_class = {
|
||||
|
@ -1580,6 +1580,15 @@ js_doctype_get_property_systemId(JSContext *ctx, JSValueConst this_val)
|
||||
RETURN_JS(r);
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_document_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[document object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_document_proto_funcs[] = {
|
||||
JS_CGETSET_DEF("anchors", js_document_get_property_anchors, nullptr),
|
||||
JS_CGETSET_DEF("baseURI", js_document_get_property_baseURI, nullptr),
|
||||
@ -1620,6 +1629,8 @@ static const JSCFunctionListEntry js_document_proto_funcs[] = {
|
||||
JS_CFUNC_DEF("getElementsByTagName", 1, js_document_getElementsByTagName),
|
||||
JS_CFUNC_DEF("querySelector", 1, js_document_querySelector),
|
||||
JS_CFUNC_DEF("querySelectorAll", 1, js_document_querySelectorAll),
|
||||
|
||||
JS_CFUNC_DEF("toString", 0, js_document_toString)
|
||||
};
|
||||
|
||||
static JSClassDef js_document_class = {
|
||||
@ -1677,10 +1688,20 @@ js_document_init(JSContext *ctx)
|
||||
RETURN_JS(document_proto);
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_doctype_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[doctype object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_doctype_proto_funcs[] = {
|
||||
JS_CGETSET_DEF("name", js_doctype_get_property_name, nullptr),
|
||||
JS_CGETSET_DEF("publicId", js_doctype_get_property_publicId, nullptr),
|
||||
JS_CGETSET_DEF("systemId", js_doctype_get_property_systemId, nullptr),
|
||||
JS_CFUNC_DEF("toString", 0, js_doctype_toString)
|
||||
};
|
||||
|
||||
static std::map<void *, JSValueConst> map_doctypes;
|
||||
|
@ -1674,6 +1674,14 @@ js_element_setAttribute(JSContext *ctx, JSValueConst this_val, int argc, JSValue
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_element_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[element object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_element_proto_funcs[] = {
|
||||
JS_CGETSET_DEF("attributes", js_element_get_property_attributes, nullptr),
|
||||
@ -1722,6 +1730,8 @@ static const JSCFunctionListEntry js_element_proto_funcs[] = {
|
||||
JS_CFUNC_DEF("remove", 0, js_element_remove),
|
||||
JS_CFUNC_DEF("removeChild",1, js_element_removeChild),
|
||||
JS_CFUNC_DEF("setAttribute",2, js_element_setAttribute),
|
||||
|
||||
JS_CFUNC_DEF("toString", 0, js_element_toString)
|
||||
};
|
||||
|
||||
static std::map<void *, JSValueConst> map_elements;
|
||||
|
@ -284,13 +284,22 @@ jsval_to_accesskey(JSContext *ctx, JS::MutableHandleValue hvp)
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSValue
|
||||
js_forms_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[forms object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_forms_proto_funcs[] = {
|
||||
JS_CGETSET_DEF("length", js_forms_get_property_length, nullptr),
|
||||
JS_CFUNC_DEF("item", 1, js_forms_item),
|
||||
JS_CFUNC_DEF("namedItem", 1, js_forms_namedItem),
|
||||
JS_CFUNC_DEF("toString", 0, js_forms_toString)
|
||||
};
|
||||
|
||||
|
||||
static
|
||||
void js_forms_finalizer(JSRuntime *rt, JSValue val)
|
||||
{
|
||||
|
@ -121,10 +121,20 @@ js_history_go(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *arg
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_history_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[history object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_history_funcs[] = {
|
||||
JS_CFUNC_DEF("back", 0, js_history_back ),
|
||||
JS_CFUNC_DEF("forward", 0, js_history_forward ),
|
||||
JS_CFUNC_DEF("go", 1, js_history_go ),
|
||||
JS_CFUNC_DEF("toString", 0, js_history_toString)
|
||||
};
|
||||
|
||||
static JSClassDef js_history_class = {
|
||||
|
@ -63,8 +63,18 @@ js_implementation_createHTMLDocument(JSContext *ctx, JSValueConst this_val, int
|
||||
return getDocument(ctx, docu);
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_implementation_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[implementation object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_implementation_proto_funcs[] = {
|
||||
JS_CFUNC_DEF("createHTMLDocument", 1, js_implementation_createHTMLDocument),
|
||||
JS_CFUNC_DEF("toString", 0, js_implementation_toString)
|
||||
};
|
||||
|
||||
static JSClassDef js_implementation_class = {
|
||||
|
@ -1323,6 +1323,16 @@ js_get_input_object(JSContext *ctx, struct form_state *fs)
|
||||
return getInput(ctx, fs);
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_input_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[input object]");
|
||||
}
|
||||
|
||||
|
||||
static const JSCFunctionListEntry js_input_proto_funcs[] = {
|
||||
JS_CGETSET_DEF("accessKey", js_input_get_property_accessKey, js_input_set_property_accessKey),
|
||||
JS_CGETSET_DEF("alt", js_input_get_property_alt, js_input_set_property_alt),
|
||||
@ -1344,9 +1354,9 @@ static const JSCFunctionListEntry js_input_proto_funcs[] = {
|
||||
JS_CFUNC_DEF("click", 0 , js_input_click),
|
||||
JS_CFUNC_DEF("focus", 0 , js_input_focus),
|
||||
JS_CFUNC_DEF("select", 0 , js_input_select),
|
||||
JS_CFUNC_DEF("toString", 0, js_input_toString)
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
quickjs_detach_form_state(struct form_state *fs)
|
||||
{
|
||||
|
@ -204,10 +204,20 @@ js_localstorage_setitem(JSContext *ctx, JSValueConst this_val, int argc, JSValue
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_localstorage_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[localstorage object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_localstorage_proto_funcs[] = {
|
||||
JS_CFUNC_DEF("getItem", 1, js_localstorage_getitem),
|
||||
JS_CFUNC_DEF("removeItem", 1, js_localstorage_removeitem),
|
||||
JS_CFUNC_DEF("setItem", 2, js_localstorage_setitem),
|
||||
JS_CFUNC_DEF("toString", 0, js_localstorage_toString)
|
||||
};
|
||||
|
||||
static JSClassDef js_localstorage_class = {
|
||||
|
@ -141,6 +141,15 @@ js_navigator_get_property_userAgent(JSContext *ctx, JSValueConst this_val)
|
||||
RETURN_JS(rr);
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_navigator_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[navigator object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_navigator_proto_funcs[] = {
|
||||
JS_CGETSET_DEF("appCodeName", js_navigator_get_property_appCodeName, nullptr),
|
||||
JS_CGETSET_DEF("appName", js_navigator_get_property_appName, nullptr),
|
||||
@ -148,6 +157,7 @@ static const JSCFunctionListEntry js_navigator_proto_funcs[] = {
|
||||
JS_CGETSET_DEF("language", js_navigator_get_property_language, nullptr),
|
||||
JS_CGETSET_DEF("platform", js_navigator_get_property_platform, nullptr),
|
||||
JS_CGETSET_DEF("userAgent", js_navigator_get_property_userAgent, nullptr),
|
||||
JS_CFUNC_DEF("toString", 0, js_navigator_toString)
|
||||
};
|
||||
|
||||
static JSClassDef js_navigator_class = {
|
||||
|
@ -162,9 +162,19 @@ js_nodeList_set_items(JSContext *ctx, JSValue this_val, void *node)
|
||||
}
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_nodeList_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[nodeList object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_nodeList_proto_funcs[] = {
|
||||
// JS_CGETSET_DEF("length", js_nodeList_get_property_length, nullptr),
|
||||
JS_CFUNC_DEF("item", 1, js_nodeList_item),
|
||||
JS_CFUNC_DEF("toString", 0, js_nodeList_toString)
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -133,11 +133,21 @@ js_screen_get_property_width(JSContext *ctx, JSValueConst this_val)
|
||||
return JS_NewInt32(ctx, ses->tab->term->width * 8);
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_screen_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[screen object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_screen_proto_funcs[] = {
|
||||
JS_CGETSET_DEF("availHeight", js_screen_get_property_availHeight, nullptr),
|
||||
JS_CGETSET_DEF("availWidth", js_screen_get_property_availWidth, nullptr),
|
||||
JS_CGETSET_DEF("height", js_screen_get_property_height, nullptr),
|
||||
JS_CGETSET_DEF("width", js_screen_get_property_width, nullptr),
|
||||
JS_CFUNC_DEF("toString", 0, js_screen_toString)
|
||||
};
|
||||
|
||||
static JSClassDef js_screen_class = {
|
||||
|
@ -110,20 +110,40 @@ js_unibar_set_property_visible(JSContext *ctx, JSValueConst this_val, JSValue va
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_menubar_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[menubar object]");
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_statusbar_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[statusbar object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_menubar_proto_funcs[] = {
|
||||
JS_CGETSET_MAGIC_DEF("visible", js_unibar_get_property_visible, js_unibar_set_property_visible, 1),
|
||||
JS_CGETSET_MAGIC_DEF("visible", js_unibar_get_property_visible, js_unibar_set_property_visible, 1),
|
||||
JS_CFUNC_DEF("toString", 0, js_menubar_toString)
|
||||
};
|
||||
|
||||
static const JSCFunctionListEntry js_statusbar_proto_funcs[] = {
|
||||
JS_CGETSET_MAGIC_DEF("visible", js_unibar_get_property_visible, js_unibar_set_property_visible, 0),
|
||||
JS_CGETSET_MAGIC_DEF("visible", js_unibar_get_property_visible, js_unibar_set_property_visible, 0),
|
||||
JS_CFUNC_DEF("toString", 0, js_statusbar_toString)
|
||||
};
|
||||
|
||||
static JSClassDef js_menubar_class = {
|
||||
"menubar",
|
||||
"menubar",
|
||||
};
|
||||
|
||||
static JSClassDef js_statusbar_class = {
|
||||
"statusbar",
|
||||
"statusbar",
|
||||
};
|
||||
|
||||
static JSValue
|
||||
|
@ -401,6 +401,15 @@ js_window_alert(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *a
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
||||
static JSValue
|
||||
js_window_toString(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
return JS_NewString(ctx, "[window object]");
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_window_proto_funcs[] = {
|
||||
JS_CGETSET_DEF("closed", js_window_get_property_closed, nullptr),
|
||||
JS_CGETSET_DEF("parent", js_window_get_property_parent, nullptr),
|
||||
@ -412,6 +421,7 @@ static const JSCFunctionListEntry js_window_proto_funcs[] = {
|
||||
JS_CFUNC_DEF("clearTimeout", 1, js_window_clearTimeout),
|
||||
JS_CFUNC_DEF("open", 3, js_window_open),
|
||||
JS_CFUNC_DEF("setTimeout", 2, js_window_setTimeout),
|
||||
JS_CFUNC_DEF("toString", 0, js_window_toString)
|
||||
};
|
||||
|
||||
static JSClassDef js_window_class = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user