[seed] Feature Request #612590 - permit initialization using an existing JSGlobalContext
- From: Alan Knowles <alank src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seed] Feature Request #612590 - permit initialization using an existing JSGlobalContext
- Date: Fri, 12 Mar 2010 04:20:18 +0000 (UTC)
commit 675adddd0711902892de9b4b9366f83cce939b4c
Author: Alexandre Mazari <scaroo gmail com>
Date: Fri Mar 12 12:17:24 2010 +0800
Feature Request #612590 - permit initialization using an existing JSGlobalContext
Usage example:
SeedEngine *eng;
void window_object_cleared (WebKitWebView *web_view,
WebKitWebFrame *frame,
gpointer context,
gpointer arg3,
gpointer user_data) {
eng = seed_init_with_context(NULL, NULL, context);
}
....
g_signal_connect(G_OBJECT(web_view), "window-object-cleared",
G_CALLBACK(window_object_cleared), NULL);
libseed/seed-engine.c | 56 +++++++++++++++++++++++++++++++++---------------
libseed/seed.h | 6 ++++-
2 files changed, 43 insertions(+), 19 deletions(-)
---
diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
index 5caa79f..bc89f8a 100644
--- a/libseed/seed-engine.c
+++ b/libseed/seed-engine.c
@@ -1448,24 +1448,10 @@ seed_engine_destroy (SeedEngine *eng)
g_free (eng);
}
-/**
- * seed_init_with_context_group:
- * @argc: A reference to the number of arguments remaining to parse.
- * @argv: A reference to an array of string arguments remaining to parse.
- * @group: A #SeedContextGroup within which to create the initial context.
- *
- * Initializes a new #SeedEngine. This involves initializing GLib, creating
- * an initial context (in #group) with all of the default globals, and
- * initializing various internal parts of Seed.
- *
- * This function should only be called once within a single Seed application.
- *
- * Return value: The newly created and initialized #SeedEngine.
- *
- */
+
SeedEngine *
-seed_init_with_context_group (gint * argc,
- gchar *** argv, JSContextGroupRef group)
+seed_init_with_context_and_group (gint * argc,
+ gchar *** argv, JSGlobalContextRef context, JSContextGroupRef group)
{
g_type_init ();
@@ -1491,7 +1477,7 @@ seed_init_with_context_group (gint * argc,
context_group = group;
- eng->context = JSGlobalContextCreateInGroup (context_group, NULL);
+ eng->context = context;
eng->global = JSContextGetGlobalObject (eng->context);
eng->group = context_group;
eng->search_path = NULL;
@@ -1548,6 +1534,30 @@ seed_init_with_context_group (gint * argc,
return eng;
}
+
+
+/**
+ * seed_init_with_context_group:
+ * @argc: A reference to the number of arguments remaining to parse.
+ * @argv: A reference to an array of string arguments remaining to parse.
+ * @group: A #SeedContextGroup within which to create the initial context.
+ *
+ * Initializes a new #SeedEngine. This involves initializing GLib, creating
+ * an initial context (in #group) with all of the default globals, and
+ * initializing various internal parts of Seed.
+ *
+ * This function should only be called once within a single Seed application.
+ *
+ * Return value: The newly created and initialized #SeedEngine.
+ *
+ */
+SeedEngine *
+seed_init_with_context_group (gint * argc,
+ gchar *** argv, JSContextGroupRef group)
+{
+ return seed_init_with_context_and_group (argc, argv, JSGlobalContextCreateInGroup (group, NULL), group);
+}
+
/**
* seed_init:
* @argc: A reference to the number of arguments remaining to parse.
@@ -1571,3 +1581,13 @@ seed_init (gint * argc, gchar *** argv)
return seed_init_with_context_group (argc, argv, context_group);
}
+SeedEngine *
+seed_init_with_context (gint * argc, gchar *** argv, JSGlobalContextRef context)
+{
+ context_group = JSContextGroupCreate ();
+ pthread_key_create(&seed_next_gobject_wrapper_key, NULL);
+
+ return seed_init_with_context_and_group (argc, argv, context, context_group);
+}
+
+
diff --git a/libseed/seed.h b/libseed/seed.h
index 11c3473..a5824df 100644
--- a/libseed/seed.h
+++ b/libseed/seed.h
@@ -73,9 +73,13 @@ typedef struct _SeedEngine
* seed-engine.c
*/
SeedEngine *seed_init (gint *argc, gchar ***argv);
+SeedEngine *
+seed_init_with_context (gint * argc, gchar *** argv, SeedGlobalContext context);
+
SeedEngine *seed_init_with_context_group (gint *argc, gchar ***argv,
SeedContextGroup group);
-
+SeedEngine *seed_init_with_context_and_group (gint * argc,gchar *** argv,
+ SeedGlobalContext context, SeedContextGroup group);
void seed_engine_destroy (SeedEngine *eng);
SeedValue seed_simple_evaluate (SeedContext ctx,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]