[gjs: 3/21] interface: Move to C++-style API



commit da2c62c443a6d4a87d8e146900155aabb648b0a7
Author: Philip Chimento <philip chimento gmail com>
Date:   Sun Jan 20 23:49:51 2019 -0800

    interface: Move to C++-style API
    
    This allows cleaning up the public API in interface.h a bit, removing C
    API that only called C++ API.
    
    The idea is to gradually provide more typesafe, C++-style APIs for all
    of the GI wrapper classes, and change calling code to use them rather
    than the old C-style APIs.

 gi/interface.cpp | 12 ------------
 gi/interface.h   |  7 -------
 gi/private.cpp   |  6 +++---
 gi/repo.cpp      |  7 ++++---
 4 files changed, 7 insertions(+), 25 deletions(-)
---
diff --git a/gi/interface.cpp b/gi/interface.cpp
index ee3bcd6c..3bae1280 100644
--- a/gi/interface.cpp
+++ b/gi/interface.cpp
@@ -140,18 +140,6 @@ JSFunctionSpec InterfaceBase::static_methods[] = {
 };
 // clang-format on
 
-bool
-gjs_define_interface_class(JSContext              *context,
-                           JS::HandleObject        in_object,
-                           GIInterfaceInfo        *info,
-                           GType                   gtype,
-                           JS::MutableHandleObject constructor)
-{
-    JS::RootedObject prototype(context);
-    return !!InterfacePrototype::create_class(context, in_object, info, gtype,
-                                              constructor, &prototype);
-}
-
 bool
 gjs_lookup_interface_constructor(JSContext             *context,
                                  GType                  gtype,
diff --git a/gi/interface.h b/gi/interface.h
index dec7452a..f7fc4385 100644
--- a/gi/interface.h
+++ b/gi/interface.h
@@ -127,13 +127,6 @@ class InterfaceInstance
 
 G_BEGIN_DECLS
 
-GJS_JSAPI_RETURN_CONVENTION
-bool gjs_define_interface_class(JSContext              *context,
-                                JS::HandleObject        in_object,
-                                GIInterfaceInfo        *info,
-                                GType                   gtype,
-                                JS::MutableHandleObject constructor);
-
 GJS_JSAPI_RETURN_CONVENTION
 bool gjs_lookup_interface_constructor(JSContext             *context,
                                       GType                  gtype,
diff --git a/gi/private.cpp b/gi/private.cpp
index e53e2871..8125ac9e 100644
--- a/gi/private.cpp
+++ b/gi/private.cpp
@@ -229,9 +229,9 @@ static bool gjs_register_interface(JSContext* cx, unsigned argc,
     if (!module)
         return false;  // error will have been thrown already
 
-    JS::RootedObject constructor(cx);
-    if (!gjs_define_interface_class(cx, module, nullptr, interface_type,
-                                    &constructor))
+    JS::RootedObject constructor(cx), ignored_prototype(cx);
+    if (!InterfacePrototype::create_class(cx, module, nullptr, interface_type,
+                                          &constructor, &ignored_prototype))
         return false;
 
     args.rval().setObject(*constructor);
diff --git a/gi/repo.cpp b/gi/repo.cpp
index a0c29df0..40f0d7d3 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -484,10 +484,11 @@ gjs_define_info(JSContext       *context,
         break;
     case GI_INFO_TYPE_INTERFACE:
         {
-            JS::RootedObject ignored(context);
-            if (!gjs_define_interface_class(
+            JS::RootedObject ignored1(context), ignored2(context);
+            if (!InterfacePrototype::create_class(
                     context, in_object, info,
-                    g_registered_type_info_get_g_type(info), &ignored))
+                    g_registered_type_info_get_g_type(info), &ignored1,
+                    &ignored2))
                 return false;
         }
         break;


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