[gjs: 2/2] Merge branch 'olejorgenb/gjs-enumerate-ns'



commit 6c9419841552c910a25ad0d53c78396366a0195a
Merge: 8bace2a4 89c8a823
Author: Philip Chimento <philip chimento gmail com>
Date:   Mon Mar 9 21:04:07 2020 -0700

    Merge branch 'olejorgenb/gjs-enumerate-ns'
    
    https://gitlab.gnome.org/GNOME/gjs/-/merge_requests/401

 gi/ns.cpp                               | 34 ++++++++++++++++++++++++++++++++-
 installed-tests/js/testIntrospection.js |  9 +++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)
---
diff --cc gi/ns.cpp
index 7b692a57,1ceb610f..4f6f4f0f
--- a/gi/ns.cpp
+++ b/gi/ns.cpp
@@@ -117,6 -117,37 +117,36 @@@ ns_resolve(JSContext       *context
      return true;
  }
  
+ GJS_JSAPI_RETURN_CONVENTION
 -static bool
 -ns_new_enumerate(JSContext* cx, JS::HandleObject obj,
 -                 JS::MutableHandleIdVector properties,
 -                 bool only_enumerable G_GNUC_UNUSED) {
 -    Ns *priv = priv_from_js(cx, obj);
++static bool ns_new_enumerate(JSContext* cx, JS::HandleObject obj,
++                             JS::MutableHandleIdVector properties,
++                             bool only_enumerable G_GNUC_UNUSED) {
++    Ns* priv = priv_from_js(cx, obj);
+ 
+     if (!priv) {
+         return true;
+     }
+ 
+     int n = g_irepository_get_n_infos(nullptr, priv->gi_namespace);
+     if (!properties.reserve(properties.length() + n)) {
+         JS_ReportOutOfMemory(cx);
+         return false;
+     }
+ 
+     for (int k = 0; k < n; k++) {
+         GjsAutoBaseInfo info =
+             g_irepository_get_info(nullptr, priv->gi_namespace, k);
 -        const char *name = info.name();
++        const char* name = info.name();
+ 
+         jsid id = gjs_intern_string_to_id(cx, name);
+         if (id == JSID_VOID)
+             return false;
+         properties.infallibleAppend(id);
+     }
+ 
+     return true;
+ }
+ 
  GJS_JSAPI_RETURN_CONVENTION
  static bool
  get_name (JSContext *context,
@@@ -153,6 -184,6 +183,7 @@@ static void ns_finalize(JSFreeOp*, JSOb
   * instances of the object, and to the prototype that instances of the
   * class have.
   */
++// clang-format off
  static const struct JSClassOps gjs_ns_class_ops = {
      nullptr,  // addProperty
      nullptr,  // deleteProperty
@@@ -172,6 -203,6 +203,7 @@@ static JSPropertySpec gjs_ns_proto_prop
      JS_PSG("__name__", get_name, GJS_MODULE_PROP_FLAGS),
      JS_PS_END
  };
++// clang-format on
  
  static JSFunctionSpec *gjs_ns_proto_funcs = nullptr;
  static JSFunctionSpec *gjs_ns_static_funcs = nullptr;


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