[geary/wip/vala-js-bindings: 2/2] Fix failing client tests caused by broken JSStringGetUTF8CString binding.



commit b60224c2fc0393b70d81a8d7a763a6ac27a96938
Author: Michael James Gratton <mike vee net>
Date:   Tue May 22 22:39:47 2018 +1000

    Fix failing client tests caused by broken JSStringGetUTF8CString binding.

 src/engine/util/util-js.vala |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/engine/util/util-js.vala b/src/engine/util/util-js.vala
index 48e6e13..8ce96f0 100644
--- a/src/engine/util/util-js.vala
+++ b/src/engine/util/util-js.vala
@@ -10,6 +10,15 @@
  */
 namespace Geary.JS {
 
+
+    // Workaround broken version of this in the vala bindings. See Bug
+    // 788113.
+    [CCode (cname = "JSStringGetUTF8CString")]
+    private static extern size_t get_utf8_cstring_impl(
+        global::JS.String js,
+        [CCode (array_length_type = "size_t")] char[] buffer
+    );
+
     /**
      * Errors produced by functions in {@link Geary.JS}.
      */
@@ -103,8 +112,8 @@ namespace Geary.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);
+        char[] str = new char[len];
+        get_utf8_cstring_impl(js, str);
         return (string) str;
     }
 


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