1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04:00

[quickjs] nodelist fixes

This commit is contained in:
Witold Filipczyk 2022-01-30 13:27:58 +01:00
parent 0cb61fcbe1
commit c350650cc4

View File

@ -75,13 +75,14 @@ js_nodeList_SetOpaque(JSValueConst this_val, void *node)
} }
} }
#if 0
static JSValue static JSValue
js_nodeList_get_property_length(JSContext *ctx, JSValueConst this_val) js_nodeList_get_property_length(JSContext *ctx, JSValueConst this_val)
{ {
#ifdef ECMASCRIPT_DEBUG #ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif #endif
xmlpp::Node::NodeList *nl = js_nodeList_GetOpaque(this_val); xmlpp::Node::NodeList *nl = static_cast<xmlpp::Node::NodeList *>(js_nodeList_GetOpaque(this_val));
if (!nl) { if (!nl) {
return JS_NewInt32(ctx, 0); return JS_NewInt32(ctx, 0);
@ -89,6 +90,7 @@ js_nodeList_get_property_length(JSContext *ctx, JSValueConst this_val)
return JS_NewInt32(ctx, nl->size()); return JS_NewInt32(ctx, nl->size());
} }
#endif
static JSValue static JSValue
js_nodeList_item2(JSContext *ctx, JSValueConst this_val, int idx) js_nodeList_item2(JSContext *ctx, JSValueConst this_val, int idx)
@ -96,13 +98,13 @@ js_nodeList_item2(JSContext *ctx, JSValueConst this_val, int idx)
#ifdef ECMASCRIPT_DEBUG #ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif #endif
xmlpp::Node::NodeList *nl = js_nodeList_GetOpaque(this_val); xmlpp::Node::NodeList *nl = static_cast<xmlpp::Node::NodeList *>(js_nodeList_GetOpaque(this_val));
if (!nl) { if (!nl) {
return JS_UNDEFINED; return JS_UNDEFINED;
} }
xmlpp::Element *element = nullptr; xmlpp::Node *element = nullptr;
auto it = nl->begin(); auto it = nl->begin();
auto end = nl->end(); auto end = nl->end();
@ -143,7 +145,7 @@ js_nodeList_set_items(JSContext *ctx, JSValue this_val, void *node)
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif #endif
xmlpp::Node::NodeList *nl = node; xmlpp::Node::NodeList *nl = static_cast<xmlpp::Node::NodeList *>(node);
if (!nl) { if (!nl) {
return; return;
@ -152,7 +154,7 @@ js_nodeList_set_items(JSContext *ctx, JSValue this_val, void *node)
auto it = nl->begin(); auto it = nl->begin();
auto end = nl->end(); auto end = nl->end();
for (int i = 0; it != end; ++it, ++i) { for (int i = 0; it != end; ++it, ++i) {
xmlpp::Element *element = *it; xmlpp::Node *element = *it;
if (element) { if (element) {
JSValue obj = getElement(ctx, element); JSValue obj = getElement(ctx, element);
@ -177,6 +179,7 @@ static const JSCFunctionListEntry js_nodeList_proto_funcs[] = {
JS_CFUNC_DEF("toString", 0, js_nodeList_toString) JS_CFUNC_DEF("toString", 0, js_nodeList_toString)
}; };
#if 0
static void static void
js_nodeList_finalizer(JSRuntime *rt, JSValue val) js_nodeList_finalizer(JSRuntime *rt, JSValue val)
{ {
@ -190,6 +193,7 @@ static JSClassDef js_nodeList_class = {
"nodeList", "nodeList",
js_nodeList_finalizer js_nodeList_finalizer
}; };
#endif
JSValue JSValue
getNodeList(JSContext *ctx, void *node) getNodeList(JSContext *ctx, void *node)