2005-09-15 15:58:31 +02:00
|
|
|
/* The SpiderMonkey ECMAScript backend. */
|
|
|
|
|
|
|
|
#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"
|
2020-10-23 22:34:58 +02:00
|
|
|
#include <jsprf.h>
|
2005-09-15 15:58:31 +02:00
|
|
|
|
|
|
|
#include "bfu/dialog.h"
|
|
|
|
#include "cache/cache.h"
|
2009-07-18 23:36:37 +00:00
|
|
|
#include "config/options.h"
|
2005-09-15 15:58:31 +02:00
|
|
|
#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/document.h"
|
|
|
|
#include "ecmascript/spidermonkey/form.h"
|
2009-07-18 23:41:01 +00:00
|
|
|
#include "ecmascript/spidermonkey/heartbeat.h"
|
2005-09-15 15:58:31 +02:00
|
|
|
#include "ecmascript/spidermonkey/location.h"
|
|
|
|
#include "ecmascript/spidermonkey/navigator.h"
|
|
|
|
#include "ecmascript/spidermonkey/unibar.h"
|
|
|
|
#include "ecmascript/spidermonkey/window.h"
|
|
|
|
#include "intl/gettext/libintl.h"
|
|
|
|
#include "main/select.h"
|
|
|
|
#include "osdep/newwin.h"
|
|
|
|
#include "osdep/sysname.h"
|
|
|
|
#include "protocol/http/http.h"
|
|
|
|
#include "protocol/uri.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/string.h"
|
|
|
|
#include "viewer/text/draw.h"
|
|
|
|
#include "viewer/text/form.h"
|
|
|
|
#include "viewer/text/link.h"
|
|
|
|
#include "viewer/text/vs.h"
|
|
|
|
|
|
|
|
/*** Global methods */
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO? Are there any which need to be implemented? */
|
|
|
|
|
2008-07-16 14:50:41 +03:00
|
|
|
static int js_module_init_ok;
|
2005-09-15 15:58:31 +02:00
|
|
|
|
2009-02-26 22:56:33 +02:00
|
|
|
static void
|
|
|
|
error_reporter(JSContext *ctx, const char *message, JSErrorReport *report)
|
2005-09-15 15:58:31 +02:00
|
|
|
{
|
|
|
|
struct ecmascript_interpreter *interpreter = JS_GetContextPrivate(ctx);
|
2007-08-30 21:11:51 +00:00
|
|
|
struct session *ses = interpreter->vs->doc_view->session;
|
2005-09-15 15:58:31 +02:00
|
|
|
struct terminal *term;
|
|
|
|
unsigned char *strict, *exception, *warning, *error;
|
2019-04-21 12:27:40 +02:00
|
|
|
struct string msg;
|
2005-09-15 15:58:31 +02:00
|
|
|
|
2020-10-23 22:34:58 +02:00
|
|
|
char *prefix = nullptr;
|
|
|
|
|
2005-09-15 15:58:31 +02:00
|
|
|
assert(interpreter && interpreter->vs && interpreter->vs->doc_view
|
2007-08-30 21:11:51 +00:00
|
|
|
&& ses && ses->tab);
|
2005-09-15 15:58:31 +02:00
|
|
|
if_assert_failed goto reported;
|
|
|
|
|
2007-08-30 21:11:51 +00:00
|
|
|
term = ses->tab->term;
|
2005-09-15 15:58:31 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_LEDS
|
2007-08-30 21:11:51 +00:00
|
|
|
set_led_value(ses->status.ecmascript_led, 'J');
|
2005-09-15 15:58:31 +02:00
|
|
|
#endif
|
|
|
|
|
2007-08-30 21:11:51 +00:00
|
|
|
if (!get_opt_bool("ecmascript.error_reporting", ses)
|
2005-09-15 15:58:31 +02:00
|
|
|
|| !init_string(&msg))
|
|
|
|
goto reported;
|
|
|
|
|
|
|
|
strict = JSREPORT_IS_STRICT(report->flags) ? " strict" : "";
|
|
|
|
exception = JSREPORT_IS_EXCEPTION(report->flags) ? " exception" : "";
|
|
|
|
warning = JSREPORT_IS_WARNING(report->flags) ? " warning" : "";
|
|
|
|
error = !report->flags ? " error" : "";
|
|
|
|
|
|
|
|
add_format_to_string(&msg, _("A script embedded in the current "
|
|
|
|
"document raised the following%s%s%s%s", term),
|
|
|
|
strict, exception, warning, error);
|
|
|
|
|
|
|
|
add_to_string(&msg, ":\n\n");
|
|
|
|
add_to_string(&msg, message);
|
|
|
|
|
2020-10-23 22:34:58 +02:00
|
|
|
if (report->filename) {
|
|
|
|
prefix = JS_smprintf("%s:", report->filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (report->lineno) {
|
|
|
|
char* tmp = prefix;
|
|
|
|
prefix = JS_smprintf("%s%u:%u ", tmp ? tmp : "", report->lineno, report->column);
|
|
|
|
JS_free(ctx, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prefix) {
|
|
|
|
add_to_string(&msg, prefix);
|
|
|
|
}
|
|
|
|
#if 0
|
2005-09-15 15:58:31 +02:00
|
|
|
if (report->linebuf && report->tokenptr) {
|
|
|
|
int pos = report->tokenptr - report->linebuf;
|
|
|
|
|
|
|
|
add_format_to_string(&msg, "\n\n%s\n.%*s^%*s.",
|
|
|
|
report->linebuf,
|
|
|
|
pos - 2, " ",
|
|
|
|
strlen(report->linebuf) - pos - 1, " ");
|
|
|
|
}
|
2020-10-23 22:34:58 +02:00
|
|
|
#endif
|
2005-09-15 15:58:31 +02:00
|
|
|
|
|
|
|
info_box(term, MSGBOX_FREE_TEXT, N_("JavaScript Error"), ALIGN_CENTER,
|
|
|
|
msg.source);
|
|
|
|
|
|
|
|
reported:
|
|
|
|
/* Im clu'les. --pasky */
|
|
|
|
JS_ClearPendingException(ctx);
|
|
|
|
}
|
|
|
|
|
2006-02-26 08:51:36 +00:00
|
|
|
static void
|
|
|
|
spidermonkey_init(struct module *xxx)
|
2005-09-15 15:58:31 +02:00
|
|
|
{
|
2008-07-16 14:50:41 +03:00
|
|
|
js_module_init_ok = spidermonkey_runtime_addref();
|
2005-09-15 15:58:31 +02:00
|
|
|
}
|
|
|
|
|
2006-02-26 08:51:36 +00:00
|
|
|
static void
|
|
|
|
spidermonkey_done(struct module *xxx)
|
2005-09-15 15:58:31 +02:00
|
|
|
{
|
2008-07-16 14:50:41 +03:00
|
|
|
if (js_module_init_ok)
|
|
|
|
spidermonkey_runtime_release();
|
2005-09-15 15:58:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void *
|
|
|
|
spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
|
|
|
{
|
|
|
|
JSContext *ctx;
|
2020-10-05 20:14:55 +02:00
|
|
|
JSObject *document_obj, *forms_obj, *history_obj, *location_obj,
|
2005-09-15 15:58:31 +02:00
|
|
|
*statusbar_obj, *menubar_obj, *navigator_obj;
|
2020-10-05 20:14:55 +02:00
|
|
|
JSAutoCompartment *ac = NULL;
|
2005-09-15 15:58:31 +02:00
|
|
|
|
|
|
|
assert(interpreter);
|
2008-07-16 14:50:41 +03:00
|
|
|
if (!js_module_init_ok) return NULL;
|
2005-09-15 15:58:31 +02:00
|
|
|
|
2008-07-16 14:50:41 +03:00
|
|
|
ctx = JS_NewContext(spidermonkey_runtime,
|
|
|
|
8192 /* Stack allocation chunk size */);
|
2005-09-15 15:58:31 +02:00
|
|
|
if (!ctx)
|
|
|
|
return NULL;
|
|
|
|
interpreter->backend_data = ctx;
|
2020-10-05 20:14:55 +02:00
|
|
|
JSAutoRequest ar(ctx);
|
2005-09-15 15:58:31 +02:00
|
|
|
JS_SetContextPrivate(ctx, interpreter);
|
2020-10-11 15:41:27 +02:00
|
|
|
//JS_SetOptions(ctx, JSOPTION_VAROBJFIX | JS_METHODJIT);
|
2020-10-16 19:54:02 +02:00
|
|
|
JS_SetErrorReporter(spidermonkey_runtime, error_reporter);
|
2020-10-11 15:41:27 +02:00
|
|
|
JS_SetInterruptCallback(spidermonkey_runtime, heartbeat_callback);
|
|
|
|
JS::RootedObject window_obj(ctx, JS_NewGlobalObject(ctx, &window_class, NULL, JS::DontFireOnNewGlobalHook));
|
2019-02-10 21:00:37 +01:00
|
|
|
|
2020-10-05 20:14:55 +02:00
|
|
|
if (window_obj) {
|
|
|
|
ac = new JSAutoCompartment(ctx, window_obj);
|
|
|
|
} else {
|
|
|
|
goto release_and_fail;
|
|
|
|
}
|
2019-02-10 21:00:37 +01:00
|
|
|
|
|
|
|
if (!JS_InitStandardClasses(ctx, window_obj)) {
|
2009-06-27 19:48:56 +03:00
|
|
|
goto release_and_fail;
|
2019-02-10 21:00:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!JS_DefineProperties(ctx, window_obj, window_props)) {
|
2009-06-27 19:48:56 +03:00
|
|
|
goto release_and_fail;
|
2019-02-10 21:00:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!spidermonkey_DefineFunctions(ctx, window_obj, window_funcs)) {
|
2009-06-27 19:48:56 +03:00
|
|
|
goto release_and_fail;
|
2019-02-10 21:00:37 +01:00
|
|
|
}
|
|
|
|
JS_SetPrivate(window_obj, interpreter->vs); /* to @window_class */
|
2005-09-15 15:58:31 +02:00
|
|
|
|
2008-06-17 00:25:59 +03:00
|
|
|
document_obj = spidermonkey_InitClass(ctx, window_obj, NULL,
|
2019-02-10 21:00:37 +01:00
|
|
|
&document_class, NULL, 0,
|
|
|
|
document_props,
|
2008-06-17 00:25:59 +03:00
|
|
|
document_funcs,
|
|
|
|
NULL, NULL);
|
2019-02-10 21:00:37 +01:00
|
|
|
if (!document_obj) {
|
|
|
|
goto release_and_fail;
|
|
|
|
}
|
2008-06-17 00:25:59 +03:00
|
|
|
|
|
|
|
forms_obj = spidermonkey_InitClass(ctx, document_obj, NULL,
|
2019-02-10 21:00:37 +01:00
|
|
|
&forms_class, NULL, 0,
|
|
|
|
forms_props,
|
2008-06-17 00:25:59 +03:00
|
|
|
forms_funcs,
|
|
|
|
NULL, NULL);
|
2019-02-10 21:00:37 +01:00
|
|
|
if (!forms_obj) {
|
|
|
|
goto release_and_fail;
|
|
|
|
}
|
2020-10-23 22:34:58 +02:00
|
|
|
// JS_SetPrivate(forms_obj, interpreter->vs);
|
2008-06-17 00:25:59 +03:00
|
|
|
|
|
|
|
history_obj = spidermonkey_InitClass(ctx, window_obj, NULL,
|
2019-02-10 21:00:37 +01:00
|
|
|
&history_class, NULL, 0,
|
2008-06-17 00:25:59 +03:00
|
|
|
(JSPropertySpec *) NULL,
|
|
|
|
history_funcs,
|
|
|
|
NULL, NULL);
|
2019-02-10 21:00:37 +01:00
|
|
|
if (!history_obj) {
|
|
|
|
goto release_and_fail;
|
|
|
|
}
|
2020-10-23 22:34:58 +02:00
|
|
|
// JS_SetPrivate(history_obj, interpreter->vs);
|
|
|
|
|
2008-06-17 00:25:59 +03:00
|
|
|
|
|
|
|
location_obj = spidermonkey_InitClass(ctx, window_obj, NULL,
|
2019-02-10 21:00:37 +01:00
|
|
|
&location_class, NULL, 0,
|
|
|
|
location_props,
|
2008-06-17 00:25:59 +03:00
|
|
|
location_funcs,
|
|
|
|
NULL, NULL);
|
2019-02-10 21:00:37 +01:00
|
|
|
if (!location_obj) {
|
|
|
|
goto release_and_fail;
|
|
|
|
}
|
2020-10-23 22:34:58 +02:00
|
|
|
// JS_SetPrivate(location_obj, interpreter->vs);
|
|
|
|
|
2005-09-15 15:58:31 +02:00
|
|
|
|
2020-10-23 22:34:58 +02:00
|
|
|
menubar_obj = JS_InitClass(ctx, window_obj, nullptr,
|
2019-02-10 21:00:37 +01:00
|
|
|
&menubar_class, NULL, 0,
|
|
|
|
unibar_props, NULL,
|
2005-09-15 15:58:31 +02:00
|
|
|
NULL, NULL);
|
2019-02-10 21:00:37 +01:00
|
|
|
if (!menubar_obj) {
|
2009-06-27 19:48:56 +03:00
|
|
|
goto release_and_fail;
|
2019-02-10 21:00:37 +01:00
|
|
|
}
|
|
|
|
JS_SetPrivate(menubar_obj, "t"); /* to @menubar_class */
|
2005-09-15 15:58:31 +02:00
|
|
|
|
2020-10-23 22:34:58 +02:00
|
|
|
statusbar_obj = JS_InitClass(ctx, window_obj, nullptr,
|
2019-02-10 21:00:37 +01:00
|
|
|
&statusbar_class, NULL, 0,
|
|
|
|
unibar_props, NULL,
|
2005-09-15 15:58:31 +02:00
|
|
|
NULL, NULL);
|
2019-02-10 21:00:37 +01:00
|
|
|
if (!statusbar_obj) {
|
2009-06-27 19:48:56 +03:00
|
|
|
goto release_and_fail;
|
2019-02-10 21:00:37 +01:00
|
|
|
}
|
|
|
|
JS_SetPrivate(statusbar_obj, "s"); /* to @statusbar_class */
|
2005-09-15 15:58:31 +02:00
|
|
|
|
2020-10-23 22:34:58 +02:00
|
|
|
navigator_obj = JS_InitClass(ctx, window_obj, nullptr,
|
2019-02-10 21:00:37 +01:00
|
|
|
&navigator_class, NULL, 0,
|
|
|
|
navigator_props, NULL,
|
2005-09-15 15:58:31 +02:00
|
|
|
NULL, NULL);
|
2019-02-10 21:00:37 +01:00
|
|
|
if (!navigator_obj) {
|
|
|
|
goto release_and_fail;
|
|
|
|
}
|
2020-10-23 22:34:58 +02:00
|
|
|
// JS_SetPrivate(navigator_obj, interpreter->vs);
|
2005-09-15 15:58:31 +02:00
|
|
|
|
|
|
|
return ctx;
|
2009-06-27 19:48:56 +03:00
|
|
|
|
|
|
|
release_and_fail:
|
|
|
|
spidermonkey_put_interpreter(interpreter);
|
|
|
|
return NULL;
|
2005-09-15 15:58:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
spidermonkey_put_interpreter(struct ecmascript_interpreter *interpreter)
|
|
|
|
{
|
|
|
|
JSContext *ctx;
|
|
|
|
|
|
|
|
assert(interpreter);
|
2008-07-16 14:50:41 +03:00
|
|
|
if (!js_module_init_ok) return;
|
2005-09-15 15:58:31 +02:00
|
|
|
ctx = interpreter->backend_data;
|
|
|
|
JS_DestroyContext(ctx);
|
|
|
|
interpreter->backend_data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
spidermonkey_eval(struct ecmascript_interpreter *interpreter,
|
2019-04-21 12:27:40 +02:00
|
|
|
struct string *code, struct string *ret)
|
2005-09-15 15:58:31 +02:00
|
|
|
{
|
|
|
|
JSContext *ctx;
|
2020-10-23 22:34:58 +02:00
|
|
|
JS::Value rval;
|
2005-09-15 15:58:31 +02:00
|
|
|
|
|
|
|
assert(interpreter);
|
2019-02-10 21:00:37 +01:00
|
|
|
if (!js_module_init_ok) {
|
|
|
|
return;
|
|
|
|
}
|
2005-09-15 15:58:31 +02:00
|
|
|
ctx = interpreter->backend_data;
|
2019-02-10 21:00:37 +01:00
|
|
|
|
2009-07-18 23:41:01 +00:00
|
|
|
interpreter->heartbeat = add_heartbeat(interpreter);
|
2006-01-27 12:07:45 +01:00
|
|
|
interpreter->ret = ret;
|
2019-02-10 21:00:37 +01:00
|
|
|
|
2020-10-11 15:41:27 +02:00
|
|
|
JS::RootedObject cg(ctx, JS::CurrentGlobalOrNull(ctx));
|
|
|
|
JS::RootedValue r_val(ctx, rval);
|
2020-10-16 19:54:02 +02:00
|
|
|
JS::CompileOptions options(ctx);
|
2020-10-11 15:41:27 +02:00
|
|
|
|
2020-10-23 22:34:58 +02:00
|
|
|
JS::Evaluate(ctx, options, code->source, code->length, &r_val);
|
2009-07-18 23:41:01 +00:00
|
|
|
done_heartbeat(interpreter->heartbeat);
|
2005-09-15 15:58:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char *
|
|
|
|
spidermonkey_eval_stringback(struct ecmascript_interpreter *interpreter,
|
2019-04-21 12:27:40 +02:00
|
|
|
struct string *code)
|
2005-09-15 15:58:31 +02:00
|
|
|
{
|
2020-10-11 15:41:27 +02:00
|
|
|
bool ret;
|
2005-09-15 15:58:31 +02:00
|
|
|
JSContext *ctx;
|
2020-10-23 22:34:58 +02:00
|
|
|
JS::Value rval;
|
2005-09-15 15:58:31 +02:00
|
|
|
|
|
|
|
assert(interpreter);
|
2008-07-16 14:50:41 +03:00
|
|
|
if (!js_module_init_ok) return NULL;
|
2005-09-15 15:58:31 +02:00
|
|
|
ctx = interpreter->backend_data;
|
2006-01-27 12:07:45 +01:00
|
|
|
interpreter->ret = NULL;
|
2009-07-18 23:41:01 +00:00
|
|
|
interpreter->heartbeat = add_heartbeat(interpreter);
|
2019-02-10 21:00:37 +01:00
|
|
|
|
2020-10-11 15:41:27 +02:00
|
|
|
JS::RootedObject cg(ctx, JS::CurrentGlobalOrNull(ctx));
|
|
|
|
JS::RootedValue r_rval(ctx, rval);
|
2020-10-16 19:54:02 +02:00
|
|
|
JS::CompileOptions options(ctx);
|
|
|
|
|
|
|
|
// options.setIntroductionType("js shell load")
|
|
|
|
// .setUTF8(true)
|
|
|
|
// .setCompileAndGo(true)
|
|
|
|
// .setNoScriptRval(true);
|
|
|
|
|
2020-10-23 22:34:58 +02:00
|
|
|
ret = JS::Evaluate(ctx, options, code->source, code->length, &r_rval);
|
2009-07-18 23:41:01 +00:00
|
|
|
done_heartbeat(interpreter->heartbeat);
|
2020-10-05 20:14:55 +02:00
|
|
|
|
2020-10-11 15:41:27 +02:00
|
|
|
if (ret == false) {
|
2005-09-15 15:58:31 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2020-10-11 15:41:27 +02:00
|
|
|
if (r_rval.isNullOrUndefined()) {
|
2005-09-15 15:58:31 +02:00
|
|
|
/* Undefined value. */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-10-16 19:54:02 +02:00
|
|
|
return stracpy(JS_EncodeString(ctx, r_rval.toString()));
|
2005-09-15 15:58:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
spidermonkey_eval_boolback(struct ecmascript_interpreter *interpreter,
|
2019-04-21 12:27:40 +02:00
|
|
|
struct string *code)
|
2005-09-15 15:58:31 +02:00
|
|
|
{
|
|
|
|
JSContext *ctx;
|
2020-10-23 22:34:58 +02:00
|
|
|
JS::Value rval;
|
2005-09-15 15:58:31 +02:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
assert(interpreter);
|
2008-07-16 14:50:41 +03:00
|
|
|
if (!js_module_init_ok) return 0;
|
2005-09-15 15:58:31 +02:00
|
|
|
ctx = interpreter->backend_data;
|
2006-01-27 12:07:45 +01:00
|
|
|
interpreter->ret = NULL;
|
2019-02-10 21:00:37 +01:00
|
|
|
|
2020-10-23 22:34:58 +02:00
|
|
|
JS::RootedFunction fun(ctx);
|
|
|
|
|
2020-10-11 15:41:27 +02:00
|
|
|
JS::CompileOptions options(ctx);
|
2020-10-16 19:54:02 +02:00
|
|
|
JS::AutoObjectVector ag(ctx);
|
2020-10-23 22:34:58 +02:00
|
|
|
if (!JS::CompileFunction(ctx, ag, options, "aaa", 0, nullptr, code->source,
|
2020-10-16 19:54:02 +02:00
|
|
|
code->length, &fun)) {
|
2007-05-19 20:54:08 +02:00
|
|
|
return -1;
|
2020-10-16 19:54:02 +02:00
|
|
|
};
|
2007-05-19 20:54:08 +02:00
|
|
|
|
2009-07-18 23:41:01 +00:00
|
|
|
interpreter->heartbeat = add_heartbeat(interpreter);
|
2020-10-11 15:41:27 +02:00
|
|
|
JS::RootedValue r_val(ctx, rval);
|
2020-10-16 19:54:02 +02:00
|
|
|
JS::RootedObject cg(ctx, JS::CurrentGlobalOrNull(ctx));
|
|
|
|
ret = JS_CallFunction(ctx, cg, fun, JS::HandleValueArray::empty(), &r_val);
|
2009-07-18 23:41:01 +00:00
|
|
|
done_heartbeat(interpreter->heartbeat);
|
2020-10-05 20:14:55 +02:00
|
|
|
|
2005-09-15 15:58:31 +02:00
|
|
|
if (ret == 2) { /* onClick="history.back()" */
|
|
|
|
return 0;
|
|
|
|
}
|
2020-10-11 15:41:27 +02:00
|
|
|
if (ret == false) {
|
2005-09-15 15:58:31 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2020-10-16 19:54:02 +02:00
|
|
|
if (r_val.isUndefined()) {
|
2005-09-15 15:58:31 +02:00
|
|
|
/* Undefined value. */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-10-16 19:54:02 +02:00
|
|
|
return r_val.toBoolean();
|
2005-09-15 15:58:31 +02:00
|
|
|
}
|
2006-01-16 14:14:14 +01:00
|
|
|
|
|
|
|
struct module spidermonkey_module = struct_module(
|
2007-03-21 11:01:06 +01:00
|
|
|
/* name: */ N_("SpiderMonkey"),
|
2006-01-16 14:14:14 +01:00
|
|
|
/* options: */ NULL,
|
|
|
|
/* events: */ NULL,
|
|
|
|
/* submodules: */ NULL,
|
|
|
|
/* data: */ NULL,
|
2006-02-26 08:51:36 +00:00
|
|
|
/* init: */ spidermonkey_init,
|
|
|
|
/* done: */ spidermonkey_done
|
2006-01-16 14:14:14 +01:00
|
|
|
);
|