[seed] Add support for NULL value in init function



commit cfec9907ca6063f2574ac6f8a000ede87550a441
Author: Peter Rustler <peter rustler basyskom com>
Date:   Mon Dec 7 11:55:13 2015 +0000

    Add support for NULL value in init function
    
    In gjs it is possible to provide NULL to init functions.
    With this patch seed is also able to handle NULL as empty array in
    init functions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759171

 libseed/seed-engine.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
index 117475b..d72a341 100644
--- a/libseed/seed-engine.c
+++ b/libseed/seed-engine.c
@@ -414,8 +414,8 @@ seed_gobject_init_method_invoked (JSContextRef ctx,
 
   if (argumentCount == 1)
     {
-      if (JSValueIsNull (ctx, arguments[0])
-         || !JSValueIsObject (ctx, arguments[0]))
+      if (!JSValueIsNull (ctx, arguments[0])
+         && !JSValueIsObject (ctx, arguments[0]))
 
        {
          seed_make_exception (ctx, exception,
@@ -423,6 +423,10 @@ seed_gobject_init_method_invoked (JSContextRef ctx,
                               "init method expects an array object as argument");
          return JSValueMakeUndefined (ctx);
        }
+      if (JSValueIsNull (ctx, arguments[0]))
+    {
+      priv = NULL;
+    } else
       if (JSValueIsObjectOfClass (ctx, arguments[0], seed_argv_class))
        {
          priv = JSObjectGetPrivate ((JSObjectRef) arguments[0]);


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