[seed] libseed: Pass this as an argument to constructors in addition to as this. Calling it self provides a



commit e7e80ea703391d970230b210f6298b2f3989644e
Author: Robert Carr <racarr svn gnome org>
Date:   Sat May 23 20:21:34 2009 -0400

    libseed: Pass this as an argument to constructors in addition to as this. Calling it self provides a quick solution to capturing this in closures.
---
 libseed/seed-gtype.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libseed/seed-gtype.c b/libseed/seed-gtype.c
index 0a6c673..02760d5 100644
--- a/libseed/seed-gtype.c
+++ b/libseed/seed-gtype.c
@@ -297,7 +297,7 @@ seed_gtype_construct (GType type,
 {
   JSContextRef ctx;
   JSObjectRef func, this_object;
-  JSValueRef exception = NULL;
+  JSValueRef exception = NULL, args[1];
   GObject *object;
   GType parent;
   GObjectClass *parent_class;
@@ -318,8 +318,9 @@ seed_gtype_construct (GType type,
       SEED_NOTE (GTYPE, "Handling constructor for: %p with type: %s",
 		 object, g_type_name (type));
       this_object = (JSObjectRef) seed_value_from_object (ctx, object, NULL);
+      args[0] = this_object;
       
-      JSObjectCallAsFunction (ctx, func, this_object, 0, 0, &exception);
+      JSObjectCallAsFunction (ctx, func, this_object, 1, args, &exception);
       if (exception)
 	{
 	  gchar *mes = seed_exception_to_string (ctx, exception);



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