Bug 996474. Add a ToJSValue overload that takes a Handle<Value>. r=bholley
☠☠ backed out by 5b54654e26cd ☠ ☠
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 16 Apr 2014 15:13:41 -0400
changeset 179247 1845b09c7578b57d8c16f7fa4a82f4a26b23557e
parent 179246 30c536b1ee3400ff73c54d4e1bb27249b9b6ced6
child 179248 7acce569bd84bc5b264c28df67c6066f527a27fb
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersbholley
bugs996474
milestone31.0a1
Bug 996474. Add a ToJSValue overload that takes a Handle<Value>. r=bholley
dom/bindings/ToJSValue.h
--- a/dom/bindings/ToJSValue.h
+++ b/dom/bindings/ToJSValue.h
@@ -198,16 +198,25 @@ template <class T>
 typename EnableIf<IsBaseOf<DictionaryBase, T>::value, bool>::Type
 ToJSValue(JSContext* aCx,
           const T& aArgument,
           JS::MutableHandle<JS::Value> aValue)
 {
   return aArgument.ToObject(aCx, aValue);
 }
 
+// Accept existing JS values (which may not be same-compartment with us
+inline bool
+ToJSValue(JSContext* aCx, JS::Handle<JS::Value> aArgument,
+          JS::MutableHandle<JS::Value> aValue)
+{
+  aValue.set(aArgument);
+  return MaybeWrapValue(aCx, aValue);
+}
+
 // Accept arrays of other things we accept
 template <typename T>
 bool
 ToJSValue(JSContext* aCx,
           T* aArguments,
           size_t aLength,
           JS::MutableHandle<JS::Value> aValue)
 {