mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 801712 part 3. Make object return values faster by only doing the JS_WrapValue if needed. r=peterv
This commit is contained in:
parent
2c0d8809e7
commit
5d16209106
@ -402,6 +402,17 @@ CreateInterfaceObjects(JSContext* cx, JSObject* global, JSObject* receiver,
|
||||
const NativeProperties* chromeProperties,
|
||||
const char* name);
|
||||
|
||||
inline bool
|
||||
MaybeWrapValue(JSContext* cx, JSObject* obj, JS::Value* vp)
|
||||
{
|
||||
if (vp->isObject() &&
|
||||
js::GetObjectCompartment(&vp->toObject()) != js::GetObjectCompartment(obj)) {
|
||||
return JS_WrapValue(cx, vp);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool
|
||||
WrapNewBindingObject(JSContext* cx, JSObject* scope, T* value, JS::Value* vp)
|
||||
|
@ -2752,17 +2752,17 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
||||
def setValue(value, callWrapValue=False):
|
||||
"""
|
||||
Returns the code to set the jsval to value. If "callWrapValue" is true
|
||||
JS_WrapValue will be called on the jsval.
|
||||
MaybeWrapValue will be called on the jsval.
|
||||
"""
|
||||
if not callWrapValue:
|
||||
tail = successCode
|
||||
elif haveSuccessCode:
|
||||
tail = ("if (!JS_WrapValue(cx, ${jsvalPtr})) {\n" +
|
||||
tail = ("if (!MaybeWrapValue(cx, ${obj}, ${jsvalPtr})) {\n" +
|
||||
" return false;\n" +
|
||||
"}\n" +
|
||||
successCode)
|
||||
else:
|
||||
tail = "return JS_WrapValue(cx, ${jsvalPtr});"
|
||||
tail = "return MaybeWrapValue(cx, ${obj}, ${jsvalPtr});"
|
||||
return ("${jsvalRef} = %s;\n" +
|
||||
tail) % (value)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user