[gjs/wip/require: 27/29] native: Return NULL if the module isn't registered



commit ba3c3d851ec272f8b2ede7872b5f1744d416ac67
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Jan 2 17:52:57 2014 -0500

    native: Return NULL if the module isn't registered
    
    This can't ever happen in practice, since existing callers check
    gjs_is_registered_native_module, but with our new loader, it's a
    bit more convenient to simply check against NULL rather than have
    to do a precheck or catch an exception first.

 gjs/native.cpp |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/gjs/native.cpp b/gjs/native.cpp
index 65a528b..a313592 100644
--- a/gjs/native.cpp
+++ b/gjs/native.cpp
@@ -97,12 +97,10 @@ gjs_import_native_module(JSContext   *context,
     else
         func = NULL;
 
-    if (!func) {
-        gjs_throw(context,
-                  "No native module '%s' has registered itself",
-                  name);
-        return JS_FALSE;
+    if (func) {
+        return func (context, module_out);
+    } else {
+        *module_out = NULL;
+        return JS_TRUE;
     }
-
-    return func (context, module_out);
 }


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