[seed] Add seed_make_gclosure, seed_closure_get_callable and seed_closure_invoke to the API



commit 646d18065bf3681ccc7b439689e76b45a73d70c7
Author: Robert Carr <racarr svn gnome org>
Date:   Sat May 9 18:16:01 2009 -0400

    Add seed_make_gclosure, seed_closure_get_callable and seed_closure_invoke to the API
---
 libseed/seed-closure.c |   18 ++++++++++++++++++
 libseed/seed-closure.h |    8 +++++++-
 libseed/seed.h         |   10 ++++++++++
 3 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/libseed/seed-closure.c b/libseed/seed-closure.c
index 7ed989b..978669e 100644
--- a/libseed/seed-closure.c
+++ b/libseed/seed-closure.c
@@ -340,6 +340,24 @@ seed_closure_get_callable (GClosure *c)
   return ((SeedClosure *)c)->function;
 }
 
+JSValueRef
+seed_closure_invoke (GClosure *closure, JSValueRef *args, guint argc, JSValueRef *exception)
+{
+  JSContextRef ctx = JSGlobalContextCreateInGroup (context_group, 0);
+  JSValueRef *real_args = g_newa (JSValueRef, argc +1);
+  JSValueRef ret;
+  guint i;
+  
+  seed_prepare_global_context (ctx);
+  for (i = 0; i < argc; i++)
+    real_args[i] = args[i];
+  args[argc] = ((SeedClosure *)closure)->user_data ? ((SeedClosure *)closure)->user_data : JSValueMakeNull (ctx);
+  
+  ret = JSObjectCallAsFunction (ctx, ((SeedClosure *)closure)->function, NULL, argc+1, real_args, exception);
+  JSGlobalContextRelease ((JSGlobalContextRef) ctx);
+  
+  return ret;
+}
 
 GClosure *
 seed_make_gclosure (JSContextRef ctx, JSObjectRef function, JSObjectRef user_data)
diff --git a/libseed/seed-closure.h b/libseed/seed-closure.h
index c371913..59bfcfd 100644
--- a/libseed/seed-closure.h
+++ b/libseed/seed-closure.h
@@ -52,11 +52,17 @@ SeedNativeClosure *seed_make_native_closure (JSContextRef ctx,
 					     GICallableInfo * info,
 					     JSValueRef function);
 GClosure *seed_make_gclosure (JSContextRef ctx,
-				 JSObjectRef function, JSObjectRef user_data);
+			      JSObjectRef function, 
+			      JSObjectRef user_data);
+
+
 
 JSObjectRef
 seed_closure_get_callable (GClosure *c);
 
+JSValueRef
+seed_closure_invoke (GClosure *closure, JSValueRef *args, guint argc, JSValueRef *exception);
+
 
 
 void seed_closures_init ();
diff --git a/libseed/seed.h b/libseed/seed.h
index 9831fd6..28353fb 100644
--- a/libseed/seed.h
+++ b/libseed/seed.h
@@ -390,5 +390,15 @@ seed_value_from_binary_string (SeedContext ctx,
 			       gint n_bytes,
 			       SeedException *exception);
 
+GClosure *seed_make_gclosure (SeedContext ctx,
+			      SeedObject function, 
+			      SeedObject user_data);
+
+SeedObject
+seed_closure_get_callable (GClosure *c);
+
+SeedValue
+seed_closure_invoke (GClosure *closure, SeedValue *args, guint argc, SeedException *exception);
+
 
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]