summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <none@none>2012-12-27 02:23:10 +0100
committerportix <none@none>2012-12-27 02:23:10 +0100
commit6964518fd0cdeadff2f64181f5f9c265b6952536 (patch)
tree830ae0c06e9b5dde600ce1f869b791f056fa65df /src
parentc5f1bfa90cb1133307d95c8152acc35ee3cbbe3b (diff)
downloaddwb-6964518fd0cdeadff2f64181f5f9c265b6952536.zip
New global property 'global' that refers to the global object; don't change the execution context in signals.emit
Diffstat (limited to 'src')
-rw-r--r--src/scripts.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/scripts.c b/src/scripts.c
index c9de8edd..db3a06a8 100644
--- a/src/scripts.c
+++ b/src/scripts.c
@@ -1031,6 +1031,11 @@ error_out:
return JSValueMakeBoolean(ctx, ret);
}/*}}}*/
+static JSValueRef
+global_get(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception)
+{
+ return JSContextGetGlobalObject(ctx);
+}
/* global_execute {{{*/
static JSValueRef
global_execute(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exc)
@@ -2616,6 +2621,11 @@ create_global_object()
{
s_ref_quark = g_quark_from_static_string("dwb_js_ref");
+ JSStaticValue global_values[] = {
+ { "global", global_get, NULL, kJSDefaultAttributes },
+ { 0, 0, 0, 0 },
+ };
+
JSStaticFunction global_functions[] = {
{ "execute", global_execute, kJSDefaultAttributes },
{ "exit", global_exit, kJSDefaultAttributes },
@@ -2631,7 +2641,7 @@ create_global_object()
{ 0, 0, 0 },
};
- JSClassRef class = create_class("dwb", global_functions, NULL);
+ JSClassRef class = create_class("dwb", global_functions, global_values);
s_global_context = JSGlobalContextCreate(class);
JSClassRelease(class);