[gjs: 4/10] object: Remove simple wrapper for C++ method



commit 26b4edbe7c7526c20a9196c5845ac205475d49bc
Author: Philip Chimento <philip chimento gmail com>
Date:   Fri Nov 9 09:51:32 2018 -0500

    object: Remove simple wrapper for C++ method
    
    This removes a C function that only wrapped a public C++ method. It also
    allows us to make a more targeted error message (that would previously
    have been ignored) in gjs_callback_trampoline_new().

 gi/function.cpp | 12 +++++++++---
 gi/object.cpp   |  9 ---------
 gi/object.h     |  3 ---
 3 files changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/gi/function.cpp b/gi/function.cpp
index 8973b677..4491aa4b 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -512,9 +512,15 @@ GjsCallbackTrampoline* gjs_callback_trampoline_new(
     bool should_root = scope != GI_SCOPE_TYPE_NOTIFIED || !scope_object;
     trampoline->js_function = gjs_closure_new(
         context, function, g_base_info_get_name(callable_info), should_root);
-    if (!should_root && scope_object)
-        gjs_object_associate_closure(context, scope_object,
-                                     trampoline->js_function);
+    if (!should_root && scope_object) {
+        ObjectBase* scope_priv = ObjectBase::for_js(context, scope_object);
+        if (!scope_priv) {
+            gjs_throw(context, "Signal connected to wrong type of object");
+            return nullptr;
+        }
+
+        scope_priv->associate_closure(context, trampoline->js_function);
+    }
 
     /* Analyze param types and directions, similarly to init_cached_function_data */
     n_args = g_callable_info_get_n_args(trampoline->info);
diff --git a/gi/object.cpp b/gi/object.cpp
index 2c0dbf49..94ee8c07 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -2551,12 +2551,3 @@ gjs_lookup_object_constructor(JSContext             *context,
     value_p.setObject(*constructor);
     return true;
 }
-
-void gjs_object_associate_closure(JSContext* cx, JS::HandleObject object,
-                                  GClosure* closure) {
-    auto* priv = ObjectBase::for_js(cx, object);
-    if (!priv)
-        return;
-
-    priv->associate_closure(cx, closure);
-}
diff --git a/gi/object.h b/gi/object.h
index 72d6daf1..6353c196 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -573,9 +573,6 @@ bool gjs_object_define_static_methods(JSContext       *context,
                                       GType            gtype,
                                       GIObjectInfo    *object_info);
 
-void gjs_object_associate_closure(JSContext* cx, JS::HandleObject obj,
-                                  GClosure* closure);
-
 G_END_DECLS
 
 #endif  /* __GJS_OBJECT_H__ */


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