Bug 996474. Add a ToJSValue overload that takes a Handle<Value>. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 16 Apr 2014 15:13:41 -0400
changeset 179367 5f6b38f0b281ed6d1629097bf0ea53024310f9bf
parent 179366 4bb76e736c87fc96dad339d6d1733fbc0e728c1b
child 179368 5d75982d37a537f2b686243a4d336bbf2c9c83cd
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)
 {