mirror of
https://github.com/rkd77/elinks.git
synced 2025-06-30 22:19:29 -04:00
[mujs] Node constants
This commit is contained in:
parent
93e6e8bdc1
commit
e20bf0fc07
@ -43,6 +43,7 @@
|
||||
#include "ecmascript/mujs/mapa.h"
|
||||
#include "ecmascript/mujs/message.h"
|
||||
#include "ecmascript/mujs/navigator.h"
|
||||
#include "ecmascript/mujs/node.h"
|
||||
#include "ecmascript/mujs/screen.h"
|
||||
#include "ecmascript/mujs/unibar.h"
|
||||
#include "ecmascript/mujs/url.h"
|
||||
@ -154,6 +155,7 @@ mujs_get_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
mjs_customEvent_init(J);
|
||||
mjs_url_init(J);
|
||||
mjs_domparser_init(J);
|
||||
mjs_node_init(J);
|
||||
|
||||
mjs_push_document(J, document->dom);
|
||||
|
||||
|
@ -3,6 +3,6 @@ include $(top_builddir)/Makefile.config
|
||||
|
||||
OBJS = attr.o attributes.o collection.o collection2.o console.o css.o customevent.o dataset.o document.o domparser.o domrect.o element.o event.o form.o forms.o fragment.o \
|
||||
history.o implementation.o input.o \
|
||||
keyboard.o localstorage.o location.o mapa.o message.o navigator.o nodelist.o nodelist2.o screen.o style.o tokenlist.o unibar.o url.o window.o xhr.o
|
||||
keyboard.o localstorage.o location.o mapa.o message.o navigator.o node.o nodelist.o nodelist2.o screen.o style.o tokenlist.o unibar.o url.o window.o xhr.o
|
||||
|
||||
include $(top_srcdir)/Makefile.lib
|
||||
|
@ -1,3 +1,3 @@
|
||||
srcs += files('attr.c', 'attributes.c', 'collection.c', 'collection2.c', 'console.c', 'css.c', 'customevent.c', 'dataset.c', 'document.c', 'domparser.c', 'domrect.c',
|
||||
'element.c', 'event.c', 'form.c', 'forms.c', 'fragment.c', 'history.c', 'implementation.c', 'input.c', 'keyboard.c',
|
||||
'localstorage.c', 'location.c', 'mapa.c', 'message.c', 'navigator.c', 'nodelist.c', 'nodelist2.c', 'screen.c', 'style.c', 'tokenlist.c', 'unibar.c', 'url.c', 'window.c', 'xhr.c')
|
||||
'localstorage.c', 'location.c', 'mapa.c', 'message.c', 'navigator.c', 'node.c', 'nodelist.c', 'nodelist2.c', 'screen.c', 'style.c', 'tokenlist.c', 'unibar.c', 'url.c', 'window.c', 'xhr.c')
|
||||
|
181
src/ecmascript/mujs/node.c
Normal file
181
src/ecmascript/mujs/node.c
Normal file
@ -0,0 +1,181 @@
|
||||
/* The MuJS Node implementation. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "elinks.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/mujs/mapa.h"
|
||||
#include "ecmascript/mujs.h"
|
||||
#include "ecmascript/mujs/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
|
||||
};
|
||||
|
||||
static void
|
||||
mjs_node_static_get_property_ELEMENT_NODE(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
js_pushnumber(J, ELEMENT_NODE);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_node_static_get_property_ATTRIBUTE_NODE(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
js_pushnumber(J, ATTRIBUTE_NODE);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_node_static_get_property_TEXT_NODE(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
js_pushnumber(J, TEXT_NODE);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_node_static_get_property_CDATA_SECTION_NODE(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
js_pushnumber(J, CDATA_SECTION_NODE);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_node_static_get_property_PROCESSING_INSTRUCTION_NODE(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
js_pushnumber(J, PROCESSING_INSTRUCTION_NODE);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_node_static_get_property_COMMENT_NODE(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
js_pushnumber(J, COMMENT_NODE);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_node_static_get_property_DOCUMENT_NODE(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
js_pushnumber(J, DOCUMENT_NODE);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_node_static_get_property_DOCUMENT_TYPE_NODE(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
js_pushnumber(J, DOCUMENT_TYPE_NODE);
|
||||
}
|
||||
static void
|
||||
mjs_node_static_get_property_DOCUMENT_FRAGMENT_NODE(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
js_pushnumber(J, DOCUMENT_FRAGMENT_NODE);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_node_fun(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
js_pushundefined(J);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_node_constructor(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
js_newobject(J);
|
||||
{
|
||||
addproperty(J, "ELEMENT_NODE", mjs_node_static_get_property_ELEMENT_NODE, NULL);
|
||||
addproperty(J, "ATTRIBUTE_NODE", mjs_node_static_get_property_ATTRIBUTE_NODE, NULL);
|
||||
addproperty(J, "TEXT_NODE", mjs_node_static_get_property_TEXT_NODE, NULL);
|
||||
addproperty(J, "CDATA_SECTION_NODE", mjs_node_static_get_property_CDATA_SECTION_NODE, NULL);
|
||||
addproperty(J, "PROCESSING_INSTRUCTION_NODE", mjs_node_static_get_property_PROCESSING_INSTRUCTION_NODE, NULL);
|
||||
addproperty(J, "COMMENT_NODE", mjs_node_static_get_property_COMMENT_NODE, NULL);
|
||||
addproperty(J, "DOCUMENT_NODE", mjs_node_static_get_property_DOCUMENT_NODE, NULL);
|
||||
addproperty(J, "DOCUMENT_TYPE_NODE", mjs_node_static_get_property_DOCUMENT_TYPE_NODE, NULL);
|
||||
addproperty(J, "DOCUMENT_FRAGMENT_NODE", mjs_node_static_get_property_DOCUMENT_FRAGMENT_NODE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
mjs_node_init(js_State *J)
|
||||
{
|
||||
js_pushglobal(J);
|
||||
//js_newcconstructor(J, mjs_node_fun, mjs_node_constructor, "Node", 0);
|
||||
mjs_node_constructor(J);
|
||||
js_defglobal(J, "Node", JS_DONTENUM);
|
||||
return 0;
|
||||
}
|
18
src/ecmascript/mujs/node.h
Normal file
18
src/ecmascript/mujs/node.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef EL__ECMASCRIPT_MUJS_NODE_H
|
||||
#define EL__ECMASCRIPT_MUJS_NODE_H
|
||||
|
||||
#include <mujs.h>
|
||||
#include "session/download.h"
|
||||
#include "util/lists.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int mjs_node_init(js_State *J);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -13,7 +13,7 @@
|
||||
function myFunction() {
|
||||
var x = document.documentElement;
|
||||
console.assert(x.nodeType === 1, 'element is 1');
|
||||
console.assert(x.nodeType === Node.ELEMENT_NODE, 'element is 1');
|
||||
console.assert(x.nodeType === Node.ELEMENT_NODE, 'second element is 1');
|
||||
}
|
||||
|
||||
console.error('node.nodeType.html');
|
||||
|
Loading…
x
Reference in New Issue
Block a user