summaryrefslogtreecommitdiffstats
path: root/dom/bindings/BindingUtils.h
diff options
context:
space:
mode:
authorJustOff <Off.Just.Off@gmail.com>2019-03-13 20:07:10 +0200
committerJustOff <Off.Just.Off@gmail.com>2019-03-13 20:07:10 +0200
commit8525a292b0806d258576c2cfc5363b2c44dcaf22 (patch)
treefdf2131fcacf7ab678ee111570690b3318bfe60b /dom/bindings/BindingUtils.h
parentb586a191ec085d2c6c5c4fdfb1b12102fb5de4c4 (diff)
downloadUXP-8525a292b0806d258576c2cfc5363b2c44dcaf22.tar
UXP-8525a292b0806d258576c2cfc5363b2c44dcaf22.tar.gz
UXP-8525a292b0806d258576c2cfc5363b2c44dcaf22.tar.lz
UXP-8525a292b0806d258576c2cfc5363b2c44dcaf22.tar.xz
UXP-8525a292b0806d258576c2cfc5363b2c44dcaf22.zip
Add ConvertJSValueTo*String functions that just take a value and hand out a string, without extra complications
Diffstat (limited to 'dom/bindings/BindingUtils.h')
-rw-r--r--dom/bindings/BindingUtils.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h
index e017b986a..a3ec70f47 100644
--- a/dom/bindings/BindingUtils.h
+++ b/dom/bindings/BindingUtils.h
@@ -2127,11 +2127,30 @@ ConvertJSValueToString(JSContext* cx, JS::Handle<JS::Value> v,
return AssignJSString(cx, result, s);
}
+template<typename T>
+static inline bool
+ConvertJSValueToString(JSContext* cx, JS::Handle<JS::Value> v, T& result)
+{
+ return ConvertJSValueToString(cx, v, eStringify, eStringify, result);
+}
+
void
-NormalizeUSVString(JSContext* aCx, nsAString& aString);
+NormalizeUSVString(nsAString& aString);
void
-NormalizeUSVString(JSContext* aCx, binding_detail::FakeString& aString);
+NormalizeUSVString(binding_detail::FakeString& aString);
+
+template<typename T>
+static inline bool
+ConvertJSValueToUSVString(JSContext* cx, JS::Handle<JS::Value> v, T& result)
+{
+ if (!ConvertJSValueToString(cx, v, eStringify, eStringify, result)) {
+ return false;
+ }
+
+ NormalizeUSVString(result);
+ return true;
+}
template<typename T>
inline bool
@@ -2158,6 +2177,13 @@ bool
ConvertJSValueToByteString(JSContext* cx, JS::Handle<JS::Value> v,
bool nullable, nsACString& result);
+inline bool
+ConvertJSValueToByteString(JSContext* cx, JS::Handle<JS::Value> v,
+ nsACString& result)
+{
+ return ConvertJSValueToByteString(cx, v, false, result);
+}
+
template<typename T>
void DoTraceSequence(JSTracer* trc, FallibleTArray<T>& seq);
template<typename T>