mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[viewer] vs.cpp -> vs.c
This commit is contained in:
parent
9dedc5779b
commit
8f431a126f
@ -11,6 +11,15 @@
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/ecmascript-c.h"
|
||||
#ifdef CONFIG_MUJS
|
||||
#include "ecmascript/mujs.h"
|
||||
#endif
|
||||
#ifdef CONFIG_QUICKJS
|
||||
#include "ecmascript/quickjs.h"
|
||||
#endif
|
||||
#ifdef CONFIG_ECMASCRIPT_SMJS
|
||||
#include "ecmascript/spidermonkey.h"
|
||||
#endif
|
||||
#include "intl/libintl.h"
|
||||
#include "protocol/uri.h"
|
||||
#include "session/session.h"
|
||||
@ -289,3 +298,37 @@ kill_ecmascript_timeouts(struct document *document)
|
||||
done_string(&t->code);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
{
|
||||
assert(interpreter);
|
||||
assert(interpreter->backend_nesting == 0);
|
||||
/* If the assertion fails, it is better to leak the
|
||||
* interpreter than to corrupt memory. */
|
||||
if_assert_failed return;
|
||||
#ifdef CONFIG_MUJS
|
||||
mujs_put_interpreter(interpreter);
|
||||
#elif defined(CONFIG_QUICKJS)
|
||||
quickjs_put_interpreter(interpreter);
|
||||
#else
|
||||
spidermonkey_put_interpreter(interpreter);
|
||||
#endif
|
||||
free_ecmascript_string_list(&interpreter->onload_snippets);
|
||||
done_string(&interpreter->code);
|
||||
free_ecmascript_string_list(&interpreter->writecode);
|
||||
/* Is it superfluous? */
|
||||
if (interpreter->vs->doc_view) {
|
||||
struct ecmascript_timeout *t;
|
||||
|
||||
foreach (t, interpreter->vs->doc_view->document->timeouts) {
|
||||
kill_timer(&t->tid);
|
||||
done_string(&t->code);
|
||||
}
|
||||
free_list(interpreter->vs->doc_view->document->timeouts);
|
||||
}
|
||||
interpreter->vs->ecmascript = NULL;
|
||||
interpreter->vs->ecmascript_fragile = 1;
|
||||
mem_free(interpreter);
|
||||
--interpreter_count;
|
||||
}
|
||||
|
@ -9,11 +9,13 @@ extern "C" {
|
||||
|
||||
struct document_options;
|
||||
struct document;
|
||||
struct ecmascript_interpreter;
|
||||
struct session;
|
||||
struct uri;
|
||||
struct view_state;
|
||||
|
||||
int ecmascript_get_interpreter_count(void);
|
||||
void ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter);
|
||||
void toggle_ecmascript(struct session *ses);
|
||||
|
||||
/* Takes line with the syntax javascript:<ecmascript code>. Activated when user
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "document/renderer.h"
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/ecmascript-c.h"
|
||||
#include "ecmascript/libdom/parse.h"
|
||||
#ifdef CONFIG_MUJS
|
||||
#include "ecmascript/mujs.h"
|
||||
@ -253,40 +254,6 @@ ecmascript_get_interpreter(struct view_state *vs)
|
||||
return interpreter;
|
||||
}
|
||||
|
||||
void
|
||||
ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
{
|
||||
assert(interpreter);
|
||||
assert(interpreter->backend_nesting == 0);
|
||||
/* If the assertion fails, it is better to leak the
|
||||
* interpreter than to corrupt memory. */
|
||||
if_assert_failed return;
|
||||
#ifdef CONFIG_MUJS
|
||||
mujs_put_interpreter(interpreter);
|
||||
#elif defined(CONFIG_QUICKJS)
|
||||
quickjs_put_interpreter(interpreter);
|
||||
#else
|
||||
spidermonkey_put_interpreter(interpreter);
|
||||
#endif
|
||||
free_ecmascript_string_list(&interpreter->onload_snippets);
|
||||
done_string(&interpreter->code);
|
||||
free_ecmascript_string_list(&interpreter->writecode);
|
||||
/* Is it superfluous? */
|
||||
if (interpreter->vs->doc_view) {
|
||||
struct ecmascript_timeout *t;
|
||||
|
||||
foreach (t, interpreter->vs->doc_view->document->timeouts) {
|
||||
kill_timer(&t->tid);
|
||||
done_string(&t->code);
|
||||
}
|
||||
free_list(interpreter->vs->doc_view->document->timeouts);
|
||||
}
|
||||
interpreter->vs->ecmascript = NULL;
|
||||
interpreter->vs->ecmascript_fragile = 1;
|
||||
mem_free(interpreter);
|
||||
--interpreter_count;
|
||||
}
|
||||
|
||||
static void
|
||||
delayed_reload(void *data)
|
||||
{
|
||||
|
@ -155,7 +155,6 @@ int ecmascript_check_url(char *url, char *frame);
|
||||
void ecmascript_free_urls(struct module *module);
|
||||
|
||||
struct ecmascript_interpreter *ecmascript_get_interpreter(struct view_state*vs);
|
||||
void ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter);
|
||||
|
||||
void ecmascript_detach_form_view(struct form_view *fv);
|
||||
void ecmascript_detach_form_state(struct form_state *fs);
|
||||
|
@ -5,6 +5,6 @@ INCLUDES += $(TRE_CFLAGS)
|
||||
|
||||
OBJS-$(CONFIG_MARKS) += marks.o
|
||||
|
||||
OBJS = draw.o form.obj link.obj search.o textarea.o view.obj vs.obj
|
||||
OBJS = draw.o form.obj link.obj search.o textarea.o view.obj vs.o
|
||||
|
||||
include $(top_srcdir)/Makefile.lib
|
||||
|
@ -4,4 +4,4 @@ if conf_data.get('CONFIG_MARKS')
|
||||
srcs += files('marks.c')
|
||||
endif
|
||||
|
||||
srcs += files('draw.c', 'form.cpp', 'link.cpp', 'search.c', 'textarea.c', 'view.cpp', 'vs.cpp')
|
||||
srcs += files('draw.c', 'form.cpp', 'link.cpp', 'search.c', 'textarea.c', 'view.cpp', 'vs.c')
|
||||
|
@ -12,7 +12,9 @@
|
||||
|
||||
#include "document/document.h"
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#ifdef CONFIG_ECMASCRIPT
|
||||
#include "ecmascript/ecmascript-c.h"
|
||||
#endif
|
||||
#include "protocol/uri.h"
|
||||
#ifdef CONFIG_SCRIPTING_SPIDERMONKEY
|
||||
# include "scripting/smjs/smjs.h"
|
||||
@ -131,7 +133,7 @@ copy_vs(struct view_state *dst, struct view_state *src)
|
||||
struct form_state *dstfs = &dst->form_info[i];
|
||||
|
||||
#ifdef CONFIG_ECMASCRIPT_SMJS
|
||||
dstfs->ecmascript_obj = nullptr;
|
||||
dstfs->ecmascript_obj = NULL;
|
||||
#endif
|
||||
#ifdef CONFIG_QUICKJS
|
||||
dstfs->ecmascript_obj = JS_NULL;
|
Loading…
Reference in New Issue
Block a user