[geary/wip/vala-js-bindings: 1/2] Clean up JS util API courtesy the new bindings.



commit 2a233376f5c75371c311c9f0095b207872af7a0e
Author: Michael James Gratton <mike vee net>
Date:   Sun May 20 19:07:56 2018 +1000

    Clean up JS util API courtesy the new bindings.

 src/client/util/util-webkit.vala |    2 +-
 src/engine/util/util-js.vala     |   12 +++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/src/client/util/util-webkit.vala b/src/client/util/util-webkit.vala
index cba9eaf..45a27c4 100644
--- a/src/client/util/util-webkit.vala
+++ b/src/client/util/util-webkit.vala
@@ -64,7 +64,7 @@ namespace WebKitUtil {
         JS.Value? err = null;
         JS.String js_str = js_str_value.to_string_copy(context, out err);
         Geary.JS.check_exception(context, err);
-        return Geary.JS.to_string_released((owned) js_str);
+        return Geary.JS.to_native_string(js_str);
     }
 
     /**
diff --git a/src/engine/util/util-js.vala b/src/engine/util/util-js.vala
index dcfac4b..48e6e13 100644
--- a/src/engine/util/util-js.vala
+++ b/src/engine/util/util-js.vala
@@ -72,7 +72,7 @@ namespace Geary.JS {
         global::JS.String js_str = value.to_string_copy(context, out err);
         Geary.JS.check_exception(context, err);
 
-        return Geary.JS.to_string_released((owned) js_str);
+        return to_native_string(js_str);
     }
 
     /**
@@ -101,7 +101,7 @@ namespace Geary.JS {
     /**
      * Returns a JSC {@link JS.String} as a Vala {@link string}.
      */
-    public inline string to_string_released(owned global::JS.String js) {
+    public inline string to_native_string(global::JS.String js) {
         size_t len = js.get_maximum_utf8_cstring_size();
         uint8[] str = new uint8[len];
         js.get_utf8_cstring(ref str);
@@ -124,10 +124,8 @@ namespace Geary.JS {
         global::JS.String js_name = new global::JS.String.create_with_utf8_cstring(name);
         global::JS.Value? err = null;
         global::JS.Value prop = object.get_property(context, js_name, out err);
-        try {
-            Geary.JS.check_exception(context, err);
-        } finally {
-        }
+        Geary.JS.check_exception(context, err);
+
         return prop;
     }
 
@@ -155,7 +153,7 @@ namespace Geary.JS {
 
             throw new Error.EXCEPTION(
                 "JS exception thrown [%s]: %s"
-                .printf(err_type.to_string(), to_string_released((owned) err_str))
+                .printf(err_type.to_string(), to_native_string(err_str))
             );
         }
     }


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