mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
[spidermonkey] Node constants
This commit is contained in:
parent
b5eb791ec4
commit
93e6e8bdc1
@ -40,6 +40,7 @@
|
||||
#include "ecmascript/spidermonkey/localstorage.h"
|
||||
#include "ecmascript/spidermonkey/message.h"
|
||||
#include "ecmascript/spidermonkey/navigator.h"
|
||||
#include "ecmascript/spidermonkey/node.h"
|
||||
#include "ecmascript/spidermonkey/screen.h"
|
||||
#include "ecmascript/spidermonkey/unibar.h"
|
||||
#include "ecmascript/spidermonkey/url.h"
|
||||
@ -234,7 +235,7 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
{
|
||||
JSContext *ctx;
|
||||
JSObject *console_obj, *document_obj, /* *forms_obj,*/ *history_obj,
|
||||
*statusbar_obj, *menubar_obj, *navigator_obj, *localstorage_obj, *screen_obj,
|
||||
*statusbar_obj, *menubar_obj, *navigator_obj, *node_obj, *localstorage_obj, *screen_obj,
|
||||
*xhr_obj, *event_obj, *keyboardEvent_obj, *messageEvent_obj, *customEvent_obj,
|
||||
*url_obj, *urlSearchParams_obj, *domparser_obj;
|
||||
|
||||
@ -455,6 +456,17 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
goto release_and_fail;
|
||||
}
|
||||
|
||||
node_obj = spidermonkey_InitClass(ctx, global, NULL,
|
||||
&node_class, node_constructor, 0,
|
||||
NULL,
|
||||
NULL,
|
||||
node_static_props, NULL, "Node");
|
||||
|
||||
if (!node_obj) {
|
||||
goto release_and_fail;
|
||||
}
|
||||
|
||||
|
||||
#if 1
|
||||
// Register a hook in order to provide modules
|
||||
JS::SetModuleResolveHook(JS_GetRuntime(ctx), ExampleResolveHook);
|
||||
|
@ -4,6 +4,6 @@ INCLUDES += $(SPIDERMONKEY_CFLAGS)
|
||||
|
||||
OBJS = attr.obj attributes.obj collection.obj console.obj css.obj customevent.obj dataset.obj document.obj domparser.obj domrect.obj \
|
||||
element.obj event.obj form.obj forms.obj fragment.obj heartbeat.obj history.obj implementation.obj input.obj \
|
||||
keyboard.obj localstorage.obj location.obj message.obj navigator.obj nodelist.obj nodelist2.obj screen.obj style.obj tokenlist.obj unibar.obj url.obj urlsearchparams.obj window.obj xhr.obj
|
||||
keyboard.obj localstorage.obj location.obj message.obj navigator.obj node.obj nodelist.obj nodelist2.obj screen.obj style.obj tokenlist.obj unibar.obj url.obj urlsearchparams.obj window.obj xhr.obj
|
||||
|
||||
include $(top_srcdir)/Makefile.lib
|
||||
|
@ -1,4 +1,4 @@
|
||||
srcs += files('attr.cpp', 'attributes.cpp', 'collection.cpp', 'console.cpp', 'css.cpp', 'customevent.cpp', 'dataset.cpp', 'document.cpp', 'domparser.cpp', 'domrect.cpp', 'element.cpp', 'event.cpp',
|
||||
'form.cpp', 'forms.cpp', 'fragment.cpp', 'heartbeat.cpp', 'history.cpp', 'implementation.cpp', 'input.cpp', 'keyboard.cpp',
|
||||
'localstorage.cpp', 'location.cpp', 'message.cpp', 'navigator.cpp', 'nodelist.cpp', 'nodelist2.cpp', 'screen.cpp', 'style.cpp', 'tokenlist.cpp', 'unibar.cpp', 'url.cpp',
|
||||
'localstorage.cpp', 'location.cpp', 'message.cpp', 'navigator.cpp', 'node.cpp', 'nodelist.cpp', 'nodelist2.cpp', 'screen.cpp', 'style.cpp', 'tokenlist.cpp', 'unibar.cpp', 'url.cpp',
|
||||
'urlsearchparams.cpp', 'window.cpp', 'xhr.cpp')
|
||||
|
217
src/ecmascript/spidermonkey/node.cpp
Normal file
217
src/ecmascript/spidermonkey/node.cpp
Normal file
@ -0,0 +1,217 @@
|
||||
/* The SpiderMonkey Node implementation. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include "ecmascript/spidermonkey/util.h"
|
||||
#include <js/BigInt.h>
|
||||
#include <js/Conversions.h>
|
||||
|
||||
#include "bfu/dialog.h"
|
||||
#include "cache/cache.h"
|
||||
#include "cookies/cookies.h"
|
||||
#include "dialogs/menu.h"
|
||||
#include "dialogs/status.h"
|
||||
#include "document/html/frames.h"
|
||||
#include "document/document.h"
|
||||
#include "document/forms.h"
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/spidermonkey.h"
|
||||
#include "ecmascript/spidermonkey/heartbeat.h"
|
||||
#include "ecmascript/spidermonkey/node.h"
|
||||
#include "ecmascript/timer.h"
|
||||
#include "intl/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "main/timer.h"
|
||||
#include "network/connection.h"
|
||||
#include "osdep/newwin.h"
|
||||
#include "osdep/sysname.h"
|
||||
#include "protocol/http/http.h"
|
||||
#include "protocol/uri.h"
|
||||
#include "session/download.h"
|
||||
#include "session/history.h"
|
||||
#include "session/location.h"
|
||||
#include "session/session.h"
|
||||
#include "session/task.h"
|
||||
#include "terminal/tab.h"
|
||||
#include "terminal/terminal.h"
|
||||
#include "util/conv.h"
|
||||
#include "util/memory.h"
|
||||
#include "util/string.h"
|
||||
#include "viewer/text/draw.h"
|
||||
#include "viewer/text/form.h"
|
||||
#include "viewer/text/link.h"
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
enum {
|
||||
ELEMENT_NODE = 1,
|
||||
ATTRIBUTE_NODE = 2,
|
||||
TEXT_NODE = 3,
|
||||
CDATA_SECTION_NODE = 4,
|
||||
PROCESSING_INSTRUCTION_NODE = 7,
|
||||
COMMENT_NODE = 8,
|
||||
DOCUMENT_NODE = 9,
|
||||
DOCUMENT_TYPE_NODE = 10,
|
||||
DOCUMENT_FRAGMENT_NODE = 11
|
||||
};
|
||||
|
||||
|
||||
JSClassOps node_ops = {
|
||||
nullptr, // addProperty
|
||||
nullptr, // deleteProperty
|
||||
nullptr, // enumerate
|
||||
nullptr, // newEnumerate
|
||||
nullptr, // resolve
|
||||
nullptr, // mayResolve
|
||||
nullptr, // finalize
|
||||
nullptr, // call
|
||||
nullptr, // construct
|
||||
JS_GlobalObjectTraceHook // trace
|
||||
};
|
||||
|
||||
JSClass node_class = {
|
||||
"NULL",
|
||||
JSCLASS_HAS_RESERVED_SLOTS(0),
|
||||
&node_ops
|
||||
};
|
||||
|
||||
bool
|
||||
node_constructor(JSContext* ctx, unsigned argc, JS::Value* vp)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setNull();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
node_static_get_property_ELEMENT_NODE(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(ELEMENT_NODE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
node_static_get_property_ATTRIBUTE_NODE(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(ATTRIBUTE_NODE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
node_static_get_property_TEXT_NODE(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(TEXT_NODE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
node_static_get_property_CDATA_SECTION_NODE(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(CDATA_SECTION_NODE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
node_static_get_property_PROCESSING_INSTRUCTION_NODE(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(PROCESSING_INSTRUCTION_NODE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
node_static_get_property_COMMENT_NODE(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(COMMENT_NODE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
node_static_get_property_DOCUMENT_NODE(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(DOCUMENT_NODE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
node_static_get_property_DOCUMENT_TYPE_NODE(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(DOCUMENT_TYPE_NODE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
node_static_get_property_DOCUMENT_FRAGMENT_NODE(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||
args.rval().setInt32(DOCUMENT_FRAGMENT_NODE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
JSPropertySpec node_static_props[] = {
|
||||
JS_PSG("ELEMENT_NODE", node_static_get_property_ELEMENT_NODE, JSPROP_PERMANENT),
|
||||
JS_PSG("ATTRIBUTE_NODE", node_static_get_property_ATTRIBUTE_NODE, JSPROP_PERMANENT),
|
||||
JS_PSG("TEXT_NODE", node_static_get_property_TEXT_NODE, JSPROP_PERMANENT),
|
||||
JS_PSG("CDATA_SECTION_NODE", node_static_get_property_CDATA_SECTION_NODE, JSPROP_PERMANENT),
|
||||
JS_PSG("PROCESSING_INSTRUCTION_NODE", node_static_get_property_PROCESSING_INSTRUCTION_NODE, JSPROP_PERMANENT),
|
||||
JS_PSG("COMMENT_NODE", node_static_get_property_COMMENT_NODE, JSPROP_PERMANENT),
|
||||
JS_PSG("DOCUMENT_NODE", node_static_get_property_DOCUMENT_NODE, JSPROP_PERMANENT),
|
||||
JS_PSG("DOCUMENT_TYPE_NODE", node_static_get_property_DOCUMENT_TYPE_NODE, JSPROP_PERMANENT),
|
||||
JS_PSG("DOCUMENT_FRAGMENT_NODE", node_static_get_property_DOCUMENT_FRAGMENT_NODE, JSPROP_PERMANENT),
|
||||
JS_PS_END
|
||||
};
|
10
src/ecmascript/spidermonkey/node.h
Normal file
10
src/ecmascript/spidermonkey/node.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef EL__ECMASCRIPT_SPIDERMONKEY_NODE_H
|
||||
#define EL__ECMASCRIPT_SPIDERMONKEY_NODE_H
|
||||
|
||||
#include "ecmascript/spidermonkey/util.h"
|
||||
|
||||
extern JSClass node_class;
|
||||
extern JSPropertySpec node_static_props[];
|
||||
bool node_constructor(JSContext* ctx, unsigned argc, JS::Value* vp);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user