[seed] seed-importer: set empty search path on init.



commit 692b87b8b0eebab3443eda6f1701453c24bfaa39
Author: Mathieu Duponchelle <mathieu duponchelle opencreed com>
Date:   Fri Sep 16 11:07:16 2016 +0200

    seed-importer: set empty search path on init.
    
    If `imports` is available, there's no reason to error out with
    a cryptic message (`searchPath` is not an array), it's better to
    just let the import attempt happen, with the user obtaining
    an undefined object instead of an exception.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771520

 libseed/seed-importer.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/libseed/seed-importer.c b/libseed/seed-importer.c
index f23b175..8213735 100644
--- a/libseed/seed-importer.c
+++ b/libseed/seed-importer.c
@@ -1218,6 +1218,7 @@ void
 seed_initialize_importer(JSContextRef ctx, JSObjectRef global)
 {
     JSObjectRef dir_constructor;
+    JSObjectRef imports, array;
 
     importer_class = JSClassCreate(&importer_class_def);
     importer = JSObjectMake(ctx, importer_class, NULL);
@@ -1243,4 +1244,11 @@ seed_initialize_importer(JSContextRef ctx, JSObjectRef global)
     seed_object_set_property(ctx, importer, "Directory", dir_constructor);
 
     seed_object_set_property(ctx, global, "imports", importer);
+
+    imports
+      = (JSObjectRef) seed_object_get_property(ctx,
+                                               global,
+                                               "imports");
+    array = JSObjectMakeArray(ctx, 0, NULL, NULL);
+    seed_object_set_property(ctx, imports, "searchPath", array);
 }


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