68 lines
2.3 KiB
Diff
68 lines
2.3 KiB
Diff
From: Michael James Gratton <mike@vee.net>
|
|
Date: Sun, 20 May 2018 19:07:56 +1000
|
|
Subject: 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 ea955e9..a98d798 100644
|
|
--- a/src/engine/util/util-js.vala
|
|
+++ b/src/engine/util/util-js.vala
|
|
@@ -82,7 +82,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);
|
|
}
|
|
|
|
/**
|
|
@@ -111,7 +111,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];
|
|
#if VALA_0_42
|
|
@@ -138,10 +138,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;
|
|
}
|
|
|
|
@@ -169,7 +167,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))
|
|
);
|
|
}
|
|
}
|
|
|