mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[mujs] implementation.c
This commit is contained in:
parent
374f97759c
commit
a033ef49a0
@ -1,6 +1,6 @@
|
||||
top_builddir=../../../..
|
||||
include $(top_builddir)/Makefile.config
|
||||
|
||||
OBJS = attr.o attributes.o collection.o console.o forms.o history.o mapa.obj
|
||||
OBJS = attr.o attributes.o collection.o console.o forms.o history.o implementation.o mapa.obj
|
||||
|
||||
include $(top_srcdir)/Makefile.lib
|
||||
|
67
src/ecmascript/libdom/mujs/implementation.c
Normal file
67
src/ecmascript/libdom/mujs/implementation.c
Normal file
@ -0,0 +1,67 @@
|
||||
/* The MuJS domimplementation object. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/mujs.h"
|
||||
#include "ecmascript/mujs/document.h"
|
||||
#include "ecmascript/mujs/implementation.h"
|
||||
#include "util/conv.h"
|
||||
|
||||
static void
|
||||
mjs_implementation_createHTMLDocument(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
const char *title = js_tostring(J, 1);
|
||||
|
||||
if (!title) {
|
||||
js_error(J, "!title");
|
||||
return;
|
||||
}
|
||||
struct string str;
|
||||
|
||||
if (!init_string(&str)) {
|
||||
js_error(J, "out of memory");
|
||||
return;
|
||||
}
|
||||
add_to_string(&str, "<!doctype html>\n<html><head><title>");
|
||||
add_html_to_string(&str, title, strlen(title));
|
||||
add_to_string(&str, "</title></head><body></body></html>");
|
||||
|
||||
void *docu = document_parse_text(str.source, str.length);
|
||||
done_string(&str);
|
||||
mjs_push_document(J, docu);
|
||||
}
|
||||
|
||||
static void
|
||||
mjs_implementation_toString(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
js_pushstring(J, "[implementation object]");
|
||||
}
|
||||
|
||||
void
|
||||
mjs_push_implementation(js_State *J)
|
||||
{
|
||||
#ifdef ECMASCRIPT_DEBUG
|
||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||
#endif
|
||||
|
||||
js_newobject(J);
|
||||
{
|
||||
addmethod(J, "createHTMLDocument", mjs_implementation_createHTMLDocument, 1);
|
||||
addmethod(J, "toString", mjs_implementation_toString, 0);
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
srcs += files('attr.c', 'attributes.c', 'collection.c', 'console.c', 'forms.c', 'history.c', 'mapa.cpp')
|
||||
srcs += files('attr.c', 'attributes.c', 'collection.c', 'console.c', 'forms.c', 'history.c', 'implementation.c', 'mapa.cpp')
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include <libxml/HTMLparser.h>
|
||||
#include <libxml++/libxml++.h>
|
||||
|
||||
#ifndef CONFIG_LIBDOM
|
||||
|
||||
static void
|
||||
mjs_implementation_createHTMLDocument(js_State *J)
|
||||
{
|
||||
@ -73,3 +75,4 @@ mjs_push_implementation(js_State *J)
|
||||
addmethod(J, "toString", mjs_implementation_toString, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -3,8 +3,16 @@
|
||||
|
||||
#include <mujs.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void mjs_push_implementation(js_State *J);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user