1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[quickjs] static_cast

This commit is contained in:
Witold Filipczyk 2022-01-30 10:57:00 +01:00
parent 0a11f13fd0
commit f856784cea
4 changed files with 13 additions and 12 deletions

View File

@ -72,7 +72,7 @@ js_attr_get_property_name(JSContext *ctx, JSValueConst this_val)
return JS_EXCEPTION;
}
xmlpp::AttributeNode *attr = JS_GetOpaque(this_val, js_attr_class_id);
xmlpp::AttributeNode *attr = static_cast<xmlpp::AttributeNode *>(JS_GetOpaque(this_val, js_attr_class_id));
if (!attr) {
return JS_NULL;
@ -101,7 +101,7 @@ js_attr_get_property_value(JSContext *ctx, JSValueConst this_val)
return JS_EXCEPTION;
}
xmlpp::AttributeNode *attr = JS_GetOpaque(this_val, js_attr_class_id);
xmlpp::AttributeNode *attr = static_cast<xmlpp::AttributeNode *>(JS_GetOpaque(this_val, js_attr_class_id));
if (!attr) {
return JS_NULL;

View File

@ -81,8 +81,7 @@ js_htmlCollection_get_property_length(JSContext *ctx, JSValueConst this_val)
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
struct ecmascript_interpreter *interpreter = (struct ecmascript_interpreter *)JS_GetContextOpaque(ctx);
xmlpp::Node::NodeSet *ns = js_htmlCollection_GetOpaque(this_val);
xmlpp::Node::NodeSet *ns = static_cast<xmlpp::Node::NodeSet *>(js_htmlCollection_GetOpaque(this_val));
if (!ns) {
return JS_NewInt32(ctx, 0);
@ -97,7 +96,7 @@ js_htmlCollection_item2(JSContext *ctx, JSValueConst this_val, int idx)
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
xmlpp::Node::NodeSet *ns = js_htmlCollection_GetOpaque(this_val);
xmlpp::Node::NodeSet *ns = static_cast<xmlpp::Node::NodeSet *>(js_htmlCollection_GetOpaque(this_val));
if (!ns) {
return JS_UNDEFINED;
@ -107,7 +106,7 @@ js_htmlCollection_item2(JSContext *ctx, JSValueConst this_val, int idx)
try {
element = dynamic_cast<xmlpp::Element *>(ns->at(idx));
} catch (std::out_of_range e) { return JS_UNDEFINED;}
} catch (std::out_of_range &e) { return JS_UNDEFINED;}
if (!element) {
return JS_UNDEFINED;
@ -138,7 +137,7 @@ js_htmlCollection_namedItem2(JSContext *ctx, JSValueConst this_val, const char *
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
xmlpp::Node::NodeSet *ns = js_htmlCollection_GetOpaque(this_val);
xmlpp::Node::NodeSet *ns = static_cast<xmlpp::Node::NodeSet *>(js_htmlCollection_GetOpaque(this_val));
if (!ns) {
return JS_UNDEFINED;
@ -198,7 +197,7 @@ js_htmlCollection_set_items(JSContext *ctx, JSValue this_val, void *node)
#endif
int counter = 0;
xmlpp::Node::NodeSet *ns = js_htmlCollection_GetOpaque(this_val);
xmlpp::Node::NodeSet *ns = static_cast<xmlpp::Node::NodeSet *>(js_htmlCollection_GetOpaque(this_val));
if (!ns) {
return;
@ -209,7 +208,7 @@ js_htmlCollection_set_items(JSContext *ctx, JSValue this_val, void *node)
while (1) {
try {
element = dynamic_cast<xmlpp::Element *>(ns->at(counter));
} catch (std::out_of_range e) { return;}
} catch (std::out_of_range &e) { return;}
if (!element) {
return;
@ -254,10 +253,12 @@ js_htmlCollection_finalizer(JSRuntime *rt, JSValue val)
map_collections.erase(node);
}
#if 0
static JSClassDef js_htmlCollection_class = {
"htmlCollection",
js_htmlCollection_finalizer
};
#endif
#if 0
static JSValue

View File

@ -1767,7 +1767,7 @@ static const JSCFunctionListEntry js_element_proto_funcs[] = {
JS_CFUNC_DEF("toString", 0, js_element_toString)
};
static std::map<void *, JSValueConst> map_elements;
static std::map<const void *, JSValueConst> map_elements;
static
void js_element_finalizer(JSRuntime *rt, JSValue val)
@ -1834,7 +1834,7 @@ js_element_init(JSContext *ctx)
JSValue
getElement(JSContext *ctx, void *node)
getElement(JSContext *ctx, const void *node)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);

View File

@ -3,7 +3,7 @@
#include <quickjs/quickjs.h>
JSValue getElement(JSContext *ctx, void *node);
JSValue getElement(JSContext *ctx, const void *node);
int js_element_init(JSContext *ctx);
void walk_tree(struct string *buf, void *nod, bool start = true, bool toSortAttrs = false);