mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backout bug 792215 for suspected Windows m-oth leaks.
CLOSED TREE
This commit is contained in:
parent
38f08637b8
commit
dbf93bfaec
@ -63,26 +63,26 @@ XPCOMUtils.defineLazyGetter(window, "gFindBar", function() {
|
||||
return findbar;
|
||||
});
|
||||
|
||||
this.__defineGetter__("gPrefService", function() {
|
||||
__defineGetter__("gPrefService", function() {
|
||||
delete this.gPrefService;
|
||||
return this.gPrefService = Services.prefs;
|
||||
});
|
||||
|
||||
this.__defineGetter__("AddonManager", function() {
|
||||
__defineGetter__("AddonManager", function() {
|
||||
let tmp = {};
|
||||
Cu.import("resource://gre/modules/AddonManager.jsm", tmp);
|
||||
return this.AddonManager = tmp.AddonManager;
|
||||
});
|
||||
this.__defineSetter__("AddonManager", function (val) {
|
||||
__defineSetter__("AddonManager", function (val) {
|
||||
delete this.AddonManager;
|
||||
return this.AddonManager = val;
|
||||
});
|
||||
|
||||
this.__defineGetter__("PluralForm", function() {
|
||||
__defineGetter__("PluralForm", function() {
|
||||
Cu.import("resource://gre/modules/PluralForm.jsm");
|
||||
return this.PluralForm;
|
||||
});
|
||||
this.__defineSetter__("PluralForm", function (val) {
|
||||
__defineSetter__("PluralForm", function (val) {
|
||||
delete this.PluralForm;
|
||||
return this.PluralForm = val;
|
||||
});
|
||||
@ -1539,7 +1539,7 @@ var gBrowserInit = {
|
||||
if (!gStartupRan)
|
||||
return;
|
||||
|
||||
if (!window.__lookupGetter__("InspectorUI"))
|
||||
if (!__lookupGetter__("InspectorUI"))
|
||||
InspectorUI.destroy();
|
||||
|
||||
// First clean up services initialized in gBrowserInit.onLoad (or those whose
|
||||
@ -3614,7 +3614,7 @@ function BrowserToolboxCustomizeDone(aToolboxChanged) {
|
||||
// Hacky: update the PopupNotifications' object's reference to the iconBox,
|
||||
// if it already exists, since it may have changed if the URL bar was
|
||||
// added/removed.
|
||||
if (!window.__lookupGetter__("PopupNotifications"))
|
||||
if (!__lookupGetter__("PopupNotifications"))
|
||||
PopupNotifications.iconBox = document.getElementById("notification-popup-box");
|
||||
}
|
||||
|
||||
@ -4073,7 +4073,7 @@ var XULBrowserWindow = {
|
||||
// Only need to call locationChange if the PopupNotifications object
|
||||
// for this window has already been initialized (i.e. its getter no
|
||||
// longer exists)
|
||||
if (!window.__lookupGetter__("PopupNotifications"))
|
||||
if (!__lookupGetter__("PopupNotifications"))
|
||||
PopupNotifications.locationChange();
|
||||
}
|
||||
}
|
||||
|
@ -18,25 +18,19 @@ typedef NS_STDCALL_FUNCPROTO(nsresult, CanvasStyleGetterType, nsIDOMCanvasRender
|
||||
GetStrokeStyle_multi, (nsAString &, nsISupports **, int32_t *));
|
||||
|
||||
static JSBool
|
||||
Canvas2D_SetStyleHelper(JSContext *cx, unsigned argc, JS::Value *vp,
|
||||
const char* propName, CanvasStyleSetterType setfunc)
|
||||
Canvas2D_SetStyleHelper(JSContext *cx, JSObject *obj, jsid id, JSMutableHandleValue vp,
|
||||
CanvasStyleSetterType setfunc)
|
||||
{
|
||||
XPC_QS_ASSERT_CONTEXT_OK(cx);
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
nsIDOMCanvasRenderingContext2D *self;
|
||||
xpc_qsSelfRef selfref;
|
||||
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, &vp[1], nullptr))
|
||||
JS::AutoValueRooter tvr(cx);
|
||||
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, tvr.jsval_addr(), nullptr))
|
||||
return JS_FALSE;
|
||||
|
||||
if (argc < 1)
|
||||
return xpc_qsThrow(cx, NS_ERROR_XPC_NOT_ENOUGH_ARGS);
|
||||
jsval *argv = JS_ARGV(cx, vp);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (JSVAL_IS_STRING(argv[0])) {
|
||||
xpc_qsDOMString arg0(cx, argv[0], &argv[0],
|
||||
if (JSVAL_IS_STRING(vp)) {
|
||||
xpc_qsDOMString arg0(cx, vp, vp.address(),
|
||||
xpc_qsDOMString::eDefaultNullBehavior,
|
||||
xpc_qsDOMString::eDefaultUndefinedBehavior);
|
||||
if (!arg0.IsValid())
|
||||
@ -46,9 +40,9 @@ Canvas2D_SetStyleHelper(JSContext *cx, unsigned argc, JS::Value *vp,
|
||||
} else {
|
||||
nsISupports *arg0;
|
||||
xpc_qsSelfRef arg0ref;
|
||||
rv = xpc_qsUnwrapArg<nsISupports>(cx, argv[0], &arg0, &arg0ref.ptr, &argv[0]);
|
||||
rv = xpc_qsUnwrapArg<nsISupports>(cx, vp, &arg0, &arg0ref.ptr, vp.address());
|
||||
if (NS_FAILED(rv)) {
|
||||
xpc_qsThrowBadSetterValue(cx, rv, JSVAL_TO_OBJECT(vp[1]), propName);
|
||||
xpc_qsThrowBadSetterValue(cx, rv, JSVAL_TO_OBJECT(*tvr.jsval_addr()), id);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
@ -56,24 +50,20 @@ Canvas2D_SetStyleHelper(JSContext *cx, unsigned argc, JS::Value *vp,
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return xpc_qsThrowGetterSetterFailed(cx, rv, JSVAL_TO_OBJECT(vp[1]),
|
||||
propName);
|
||||
return xpc_qsThrowGetterSetterFailed(cx, rv, JSVAL_TO_OBJECT(*tvr.jsval_addr()), id);
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
Canvas2D_GetStyleHelper(JSContext *cx, unsigned argc, JS::Value *vp,
|
||||
const char* propName, CanvasStyleGetterType getfunc)
|
||||
Canvas2D_GetStyleHelper(JSContext *cx, JSObject *obj, jsid id, JSMutableHandleValue vp,
|
||||
CanvasStyleGetterType getfunc)
|
||||
{
|
||||
XPC_QS_ASSERT_CONTEXT_OK(cx);
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
if (!obj)
|
||||
return JS_FALSE;
|
||||
nsIDOMCanvasRenderingContext2D *self;
|
||||
xpc_qsSelfRef selfref;
|
||||
XPCLazyCallContext lccx(JS_CALLER, cx, obj);
|
||||
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, &vp[1], &lccx))
|
||||
if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, vp.address(), &lccx))
|
||||
return JS_FALSE;
|
||||
nsresult rv;
|
||||
|
||||
@ -82,12 +72,11 @@ Canvas2D_GetStyleHelper(JSContext *cx, unsigned argc, JS::Value *vp,
|
||||
int32_t resultType;
|
||||
rv = (self->*getfunc)(resultString, getter_AddRefs(resultInterface), &resultType);
|
||||
if (NS_FAILED(rv))
|
||||
return xpc_qsThrowGetterSetterFailed(cx, rv, JSVAL_TO_OBJECT(vp[1]),
|
||||
propName);
|
||||
return xpc_qsThrowGetterSetterFailed(cx, rv, JSVAL_TO_OBJECT(vp), id);
|
||||
|
||||
switch (resultType) {
|
||||
case nsIDOMCanvasRenderingContext2D::CMG_STYLE_STRING:
|
||||
return xpc::StringToJsval(cx, resultString, vp);
|
||||
return xpc::StringToJsval(cx, resultString, vp.address());
|
||||
|
||||
case nsIDOMCanvasRenderingContext2D::CMG_STYLE_PATTERN:
|
||||
{
|
||||
@ -95,7 +84,7 @@ Canvas2D_GetStyleHelper(JSContext *cx, unsigned argc, JS::Value *vp,
|
||||
xpc_qsGetWrapperCache(resultInterface));
|
||||
return xpc_qsXPCOMObjectToJsval(lccx, helper,
|
||||
&NS_GET_IID(nsIDOMCanvasPattern),
|
||||
&interfaces[k_nsIDOMCanvasPattern], vp);
|
||||
&interfaces[k_nsIDOMCanvasPattern], vp.address());
|
||||
}
|
||||
case nsIDOMCanvasRenderingContext2D::CMG_STYLE_GRADIENT:
|
||||
{
|
||||
@ -103,40 +92,35 @@ Canvas2D_GetStyleHelper(JSContext *cx, unsigned argc, JS::Value *vp,
|
||||
xpc_qsGetWrapperCache(resultInterface));
|
||||
return xpc_qsXPCOMObjectToJsval(lccx, helper,
|
||||
&NS_GET_IID(nsIDOMCanvasGradient),
|
||||
&interfaces[k_nsIDOMCanvasGradient], vp);
|
||||
&interfaces[k_nsIDOMCanvasGradient], vp.address());
|
||||
}
|
||||
default:
|
||||
return xpc_qsThrowGetterSetterFailed(cx, NS_ERROR_FAILURE,
|
||||
JSVAL_TO_OBJECT(vp[1]), propName);
|
||||
return xpc_qsThrowGetterSetterFailed(cx, NS_ERROR_FAILURE, JSVAL_TO_OBJECT(vp), id);
|
||||
}
|
||||
}
|
||||
|
||||
static JSBool
|
||||
nsIDOMCanvasRenderingContext2D_SetStrokeStyle(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
nsIDOMCanvasRenderingContext2D_SetStrokeStyle(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, JSMutableHandleValue vp)
|
||||
{
|
||||
return Canvas2D_SetStyleHelper(cx, argc, vp, "strokeStyle",
|
||||
&nsIDOMCanvasRenderingContext2D::SetStrokeStyle_multi);
|
||||
return Canvas2D_SetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::SetStrokeStyle_multi);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
nsIDOMCanvasRenderingContext2D_GetStrokeStyle(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
nsIDOMCanvasRenderingContext2D_GetStrokeStyle(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp)
|
||||
{
|
||||
return Canvas2D_GetStyleHelper(cx, argc, vp, "strokeStyle",
|
||||
&nsIDOMCanvasRenderingContext2D::GetStrokeStyle_multi);
|
||||
return Canvas2D_GetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::GetStrokeStyle_multi);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
nsIDOMCanvasRenderingContext2D_SetFillStyle(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
nsIDOMCanvasRenderingContext2D_SetFillStyle(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, JSMutableHandleValue vp)
|
||||
{
|
||||
return Canvas2D_SetStyleHelper(cx, argc, vp, "fillStyle",
|
||||
&nsIDOMCanvasRenderingContext2D::SetFillStyle_multi);
|
||||
return Canvas2D_SetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::SetFillStyle_multi);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
nsIDOMCanvasRenderingContext2D_GetFillStyle(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
nsIDOMCanvasRenderingContext2D_GetFillStyle(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp)
|
||||
{
|
||||
return Canvas2D_GetStyleHelper(cx, argc, vp, "fillStyle",
|
||||
&nsIDOMCanvasRenderingContext2D::GetFillStyle_multi);
|
||||
return Canvas2D_GetStyleHelper(cx, obj, id, vp, &nsIDOMCanvasRenderingContext2D::GetFillStyle_multi);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -439,9 +439,11 @@
|
||||
"NodeFilter interface: operation acceptNode(Node)": true,
|
||||
"NodeList interface: existence and properties of interface object": true,
|
||||
"NodeList interface: existence and properties of interface prototype object": true,
|
||||
"NodeList interface: attribute length": true,
|
||||
"NodeList interface: calling item(unsigned long) on document.querySelectorAll(\"script\") with too few arguments must throw TypeError": true,
|
||||
"HTMLCollection interface: existence and properties of interface object": true,
|
||||
"HTMLCollection interface: existence and properties of interface prototype object": true,
|
||||
"HTMLCollection interface: attribute length": true,
|
||||
"HTMLCollection interface: calling item(unsigned long) on document.body.children with too few arguments must throw TypeError": true,
|
||||
"HTMLCollection interface: calling namedItem(DOMString) on document.body.children with too few arguments must throw TypeError": true,
|
||||
"DOMStringList interface: existence and properties of interface object": true,
|
||||
@ -450,6 +452,7 @@
|
||||
"DOMStringList interface: attribute length": true,
|
||||
"DOMTokenList interface: existence and properties of interface object": true,
|
||||
"DOMTokenList interface: existence and properties of interface prototype object": true,
|
||||
"DOMTokenList interface: attribute length": true,
|
||||
"Stringification of document.body.classList": true,
|
||||
"DOMTokenList interface: calling item(unsigned long) on document.body.classList with too few arguments must throw TypeError": true,
|
||||
"DOMTokenList interface: calling contains(DOMString) on document.body.classList with too few arguments must throw TypeError": true,
|
||||
@ -457,5 +460,6 @@
|
||||
"DOMTokenList interface: calling remove(DOMString) on document.body.classList with too few arguments must throw TypeError": true,
|
||||
"DOMTokenList interface: calling toggle(DOMString) on document.body.classList with too few arguments must throw TypeError": true,
|
||||
"DOMSettableTokenList interface: existence and properties of interface object": true,
|
||||
"DOMSettableTokenList interface: existence and properties of interface prototype object": true
|
||||
"DOMSettableTokenList interface: existence and properties of interface prototype object": true,
|
||||
"DOMSettableTokenList interface: attribute value": true
|
||||
}
|
||||
|
@ -825,6 +825,7 @@ PropDesc::initFromPropertyDescriptor(const PropertyDescriptor &desc)
|
||||
isUndefined_ = false;
|
||||
pd_.setUndefined();
|
||||
attrs = uint8_t(desc.attrs);
|
||||
JS_ASSERT_IF(attrs & JSPROP_READONLY, !(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
|
||||
if (desc.attrs & (JSPROP_GETTER | JSPROP_SETTER)) {
|
||||
hasGet_ = true;
|
||||
get_ = ((desc.attrs & JSPROP_GETTER) && desc.getter)
|
||||
|
@ -16,8 +16,6 @@
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
extern const char* xpc_qsStringTable;
|
||||
|
||||
static inline QITableEntry *
|
||||
GetOffsets(nsISupports *identity, XPCWrappedNativeProto* proto)
|
||||
{
|
||||
@ -99,6 +97,182 @@ PointerHolderClass = {
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, PointerFinalize
|
||||
};
|
||||
|
||||
static JSBool
|
||||
ReifyPropertyOps(JSContext *cx, JSObject *obj, jsid id, unsigned orig_attrs,
|
||||
JSPropertyOp getter, JSStrictPropertyOp setter,
|
||||
JSObject **getterobjp, JSObject **setterobjp)
|
||||
{
|
||||
// Generate both getter and setter and stash them in the prototype.
|
||||
jsval roots[2] = { JSVAL_NULL, JSVAL_NULL };
|
||||
JS::AutoArrayRooter tvr(cx, ArrayLength(roots), roots);
|
||||
|
||||
unsigned attrs = JSPROP_SHARED | (orig_attrs & JSPROP_ENUMERATE);
|
||||
JSObject *getterobj;
|
||||
if (getter) {
|
||||
getterobj = GeneratePropertyOp(cx, obj, id, 0, getter);
|
||||
if (!getterobj)
|
||||
return false;
|
||||
roots[0] = OBJECT_TO_JSVAL(getterobj);
|
||||
attrs |= JSPROP_GETTER;
|
||||
} else
|
||||
getterobj = nullptr;
|
||||
|
||||
JSObject *setterobj;
|
||||
if (setter) {
|
||||
setterobj = GeneratePropertyOp(cx, obj, id, 1, setter);
|
||||
if (!setterobj)
|
||||
return false;
|
||||
roots[1] = OBJECT_TO_JSVAL(setterobj);
|
||||
attrs |= JSPROP_SETTER;
|
||||
} else
|
||||
setterobj = nullptr;
|
||||
|
||||
if (getterobjp)
|
||||
*getterobjp = getterobj;
|
||||
if (setterobjp)
|
||||
*setterobjp = setterobj;
|
||||
return JS_DefinePropertyById(cx, obj, id, JSVAL_VOID,
|
||||
JS_DATA_TO_FUNC_PTR(JSPropertyOp, getterobj),
|
||||
JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, setterobj),
|
||||
attrs);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
LookupGetterOrSetter(JSContext *cx, JSBool wantGetter, unsigned argc, jsval *vp)
|
||||
{
|
||||
XPC_QS_ASSERT_CONTEXT_OK(cx);
|
||||
|
||||
if (argc == 0) {
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return true;
|
||||
}
|
||||
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
jsval idval = JS_ARGV(cx, vp)[0];
|
||||
jsid id;
|
||||
JSPropertyDescriptor desc;
|
||||
if (!JS_ValueToId(cx, idval, &id) ||
|
||||
!JS_GetPropertyDescriptorById(cx, obj, id, JSRESOLVE_QUALIFIED, &desc))
|
||||
return false;
|
||||
|
||||
// No property at all means no getters or setters possible.
|
||||
if (!desc.obj) {
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Inline obj_lookup[GS]etter here.
|
||||
if (wantGetter) {
|
||||
if (desc.attrs & JSPROP_GETTER) {
|
||||
JS_SET_RVAL(cx, vp,
|
||||
OBJECT_TO_JSVAL(JS_FUNC_TO_DATA_PTR(JSObject *, desc.getter)));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (desc.attrs & JSPROP_SETTER) {
|
||||
JS_SET_RVAL(cx, vp,
|
||||
OBJECT_TO_JSVAL(JS_FUNC_TO_DATA_PTR(JSObject *, desc.setter)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Since XPConnect doesn't use JSPropertyOps in any other contexts,
|
||||
// ensuring that we have an XPConnect prototype object ensures that
|
||||
// we are only going to expose quickstubbed properties to script.
|
||||
// Also be careful not to overwrite existing properties!
|
||||
|
||||
if (!JSID_IS_STRING(id) ||
|
||||
!IS_PROTO_CLASS(js::GetObjectClass(desc.obj)) ||
|
||||
(desc.attrs & (JSPROP_GETTER | JSPROP_SETTER)) ||
|
||||
!(desc.getter || desc.setter) ||
|
||||
desc.setter == js::GetObjectJSClass(desc.obj)->setProperty) {
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return true;
|
||||
}
|
||||
|
||||
JSObject *getterobj, *setterobj;
|
||||
if (!ReifyPropertyOps(cx, desc.obj, id, desc.attrs, desc.getter, desc.setter,
|
||||
&getterobj, &setterobj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
JSObject *wantedobj = wantGetter ? getterobj : setterobj;
|
||||
jsval v = wantedobj ? OBJECT_TO_JSVAL(wantedobj) : JSVAL_VOID;
|
||||
JS_SET_RVAL(cx, vp, v);
|
||||
return true;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
SharedLookupGetter(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
return LookupGetterOrSetter(cx, true, argc, vp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
SharedLookupSetter(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
return LookupGetterOrSetter(cx, false, argc, vp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
DefineGetterOrSetter(JSContext *cx, unsigned argc, JSBool wantGetter, jsval *vp)
|
||||
{
|
||||
unsigned attrs;
|
||||
JSBool found;
|
||||
JSPropertyOp getter;
|
||||
JSStrictPropertyOp setter;
|
||||
JSObject *obj2;
|
||||
jsval v;
|
||||
jsid id;
|
||||
|
||||
XPC_QS_ASSERT_CONTEXT_OK(cx);
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
if (!obj)
|
||||
return false;
|
||||
JSNative forward = wantGetter ? js::obj_defineGetter : js::obj_defineSetter;
|
||||
jsval idval = (argc >= 1) ? JS_ARGV(cx, vp)[0] : JSVAL_VOID;
|
||||
if (!JSVAL_IS_STRING(idval))
|
||||
return forward(cx, argc, vp);
|
||||
|
||||
if (!JS_ValueToId(cx, idval, &id) ||
|
||||
!JS_LookupPropertyWithFlagsById(cx, obj, id,
|
||||
JSRESOLVE_QUALIFIED, &obj2, &v) ||
|
||||
(obj2 &&
|
||||
!JS_GetPropertyAttrsGetterAndSetterById(cx, obj2, id, &attrs,
|
||||
&found, &getter, &setter)))
|
||||
return false;
|
||||
|
||||
// The property didn't exist, already has a getter or setter, or is not
|
||||
// our property, then just forward now.
|
||||
if (!obj2 ||
|
||||
(attrs & (JSPROP_GETTER | JSPROP_SETTER)) ||
|
||||
!(getter || setter) ||
|
||||
!IS_PROTO_CLASS(js::GetObjectClass(obj2)))
|
||||
return forward(cx, argc, vp);
|
||||
|
||||
// Reify the getter and setter...
|
||||
if (!ReifyPropertyOps(cx, obj2, id, attrs, getter, setter, nullptr, nullptr))
|
||||
return false;
|
||||
|
||||
return forward(cx, argc, vp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
SharedDefineGetter(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
return DefineGetterOrSetter(cx, argc, true, vp);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
SharedDefineSetter(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
return DefineGetterOrSetter(cx, argc, false, vp);
|
||||
}
|
||||
|
||||
|
||||
JSBool
|
||||
xpc_qsDefineQuickStubs(JSContext *cx, JSObject *proto, unsigned flags,
|
||||
uint32_t ifacec, const nsIID **interfaces,
|
||||
@ -130,10 +304,8 @@ xpc_qsDefineQuickStubs(JSContext *cx, JSObject *proto, unsigned flags,
|
||||
definedProperty = true;
|
||||
if (!JS_DefineProperty(cx, proto,
|
||||
stringTable + ps->name_index,
|
||||
JSVAL_VOID,
|
||||
(JSPropertyOp)ps->getter,
|
||||
(JSStrictPropertyOp)ps->setter,
|
||||
flags | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS))
|
||||
JSVAL_VOID, ps->getter, ps->setter,
|
||||
flags | JSPROP_SHARED))
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -157,6 +329,17 @@ xpc_qsDefineQuickStubs(JSContext *cx, JSObject *proto, unsigned flags,
|
||||
}
|
||||
}
|
||||
|
||||
static JSFunctionSpec getterfns[] = {
|
||||
JS_FN("__lookupGetter__", SharedLookupGetter, 1, 0),
|
||||
JS_FN("__lookupSetter__", SharedLookupSetter, 1, 0),
|
||||
JS_FN("__defineGetter__", SharedDefineGetter, 2, 0),
|
||||
JS_FN("__defineSetter__", SharedDefineSetter, 2, 0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
if (definedProperty && !JS_DefineFunctions(cx, proto, getterfns))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -280,26 +463,6 @@ xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv, JSObject *obj,
|
||||
return ThrowCallFailed(cx, rv, ifaceName, memberId, NULL);
|
||||
}
|
||||
|
||||
JSBool
|
||||
xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv, JSObject *obj,
|
||||
const char* memberName)
|
||||
{
|
||||
JSString *str = JS_InternString(cx, memberName);
|
||||
if (!str) {
|
||||
return false;
|
||||
}
|
||||
return xpc_qsThrowGetterSetterFailed(cx, rv, obj,
|
||||
INTERNED_STRING_TO_JSID(cx, str));
|
||||
}
|
||||
|
||||
JSBool
|
||||
xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv, JSObject *obj,
|
||||
uint16_t memberIndex)
|
||||
{
|
||||
return xpc_qsThrowGetterSetterFailed(cx, rv, obj,
|
||||
xpc_qsStringTable + memberIndex);
|
||||
}
|
||||
|
||||
JSBool
|
||||
xpc_qsThrowMethodFailed(JSContext *cx, nsresult rv, jsval *vp)
|
||||
{
|
||||
@ -384,24 +547,6 @@ xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv,
|
||||
ThrowBadArg(cx, rv, ifaceName, propId, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv,
|
||||
JSObject *obj, const char* propName)
|
||||
{
|
||||
JSString *str = JS_InternString(cx, propName);
|
||||
if (!str) {
|
||||
return;
|
||||
}
|
||||
xpc_qsThrowBadSetterValue(cx, rv, obj, INTERNED_STRING_TO_JSID(cx, str));
|
||||
}
|
||||
|
||||
void
|
||||
xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv, JSObject *obj,
|
||||
uint16_t name_index)
|
||||
{
|
||||
xpc_qsThrowBadSetterValue(cx, rv, obj, xpc_qsStringTable + name_index);
|
||||
}
|
||||
|
||||
JSBool
|
||||
xpc_qsGetterOnlyPropertyStub(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict,
|
||||
JSMutableHandleValue vp)
|
||||
@ -413,16 +558,6 @@ xpc_qsGetterOnlyPropertyStub(JSContext *cx, JSHandleObject obj, JSHandleId id, J
|
||||
JSMSG_GETTER_ONLY);
|
||||
}
|
||||
|
||||
JSBool
|
||||
xpc_qsGetterOnlyNativeStub(JSContext *cx, unsigned argc, jsval *vp)
|
||||
{
|
||||
return JS_ReportErrorFlagsAndNumber(cx,
|
||||
JSREPORT_WARNING | JSREPORT_STRICT |
|
||||
JSREPORT_STRICT_MODE_ERROR,
|
||||
js_GetErrorMessage, NULL,
|
||||
JSMSG_GETTER_ONLY);
|
||||
}
|
||||
|
||||
xpc_qsDOMString::xpc_qsDOMString(JSContext *cx, jsval v, jsval *pval,
|
||||
StringificationBehavior nullBehavior,
|
||||
StringificationBehavior undefinedBehavior)
|
||||
|
@ -19,8 +19,8 @@ class XPCCallContext;
|
||||
|
||||
struct xpc_qsPropertySpec {
|
||||
uint16_t name_index;
|
||||
JSNative getter;
|
||||
JSNative setter;
|
||||
JSPropertyOp getter;
|
||||
JSStrictPropertyOp setter;
|
||||
};
|
||||
|
||||
struct xpc_qsFunctionSpec {
|
||||
@ -70,13 +70,6 @@ xpc_qsThrow(JSContext *cx, nsresult rv);
|
||||
JSBool
|
||||
xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv,
|
||||
JSObject *obj, jsid memberId);
|
||||
// And variants using strings and string tables
|
||||
JSBool
|
||||
xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv,
|
||||
JSObject *obj, const char* memberName);
|
||||
JSBool
|
||||
xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv,
|
||||
JSObject *obj, uint16_t memberIndex);
|
||||
|
||||
/**
|
||||
* Fail after an XPCOM method returned rv.
|
||||
@ -117,21 +110,11 @@ xpc_qsThrowBadArgWithDetails(JSContext *cx, nsresult rv, unsigned paramnum,
|
||||
void
|
||||
xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv, JSObject *obj,
|
||||
jsid propId);
|
||||
// And variants using strings and string tables
|
||||
void
|
||||
xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv, JSObject *obj,
|
||||
const char* propName);
|
||||
void
|
||||
xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv, JSObject *obj,
|
||||
uint16_t name_index);
|
||||
|
||||
|
||||
JSBool
|
||||
xpc_qsGetterOnlyPropertyStub(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict, JSMutableHandleValue vp);
|
||||
|
||||
JSBool
|
||||
xpc_qsGetterOnlyNativeStub(JSContext *cx, unsigned argc, jsval *vp);
|
||||
|
||||
/* Functions for converting values between COM and JS. */
|
||||
|
||||
inline JSBool
|
||||
|
@ -178,8 +178,8 @@ def writeArgumentUnboxing(f, i, name, type, optional, rvdeclared,
|
||||
isSetter = (i is None)
|
||||
|
||||
if isSetter:
|
||||
argPtr = "argv"
|
||||
argVal = "*argv"
|
||||
argPtr = "vp"
|
||||
argVal = "*vp"
|
||||
elif optional:
|
||||
if typeName == "[jsval]":
|
||||
val = "JSVAL_VOID"
|
||||
@ -429,8 +429,16 @@ def writeStub(f, customMethodCalls, member, stubName, writeThisUnwrapping, write
|
||||
isNotxpcom = isMethod and member.notxpcom
|
||||
isGetter = isAttr and not isSetter
|
||||
|
||||
signature = ("static JSBool\n"
|
||||
"%s(JSContext *cx, unsigned argc,%s jsval *vp)\n")
|
||||
signature = "static JSBool\n"
|
||||
if isAttr:
|
||||
# JSPropertyOp signature.
|
||||
if isSetter:
|
||||
signature += "%s(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict,%s JSMutableHandleValue vp_)\n"
|
||||
else:
|
||||
signature += "%s(JSContext *cx, JSHandleObject obj, JSHandleId id,%s JSMutableHandleValue vp_)\n"
|
||||
else:
|
||||
# JSFastNative.
|
||||
signature += "%s(JSContext *cx, unsigned argc,%s jsval *vp)\n"
|
||||
|
||||
customMethodCall = customMethodCalls.get(stubName, None)
|
||||
|
||||
@ -462,7 +470,7 @@ def writeStub(f, customMethodCalls, member, stubName, writeThisUnwrapping, write
|
||||
argumentValues = (customMethodCall['additionalArgumentValues']
|
||||
% header.methodNativeName(member))
|
||||
if isAttr:
|
||||
callTemplate += (" return %s(cx, obj, id%s, %s, vp);\n"
|
||||
callTemplate += (" return %s(cx, obj, id%s, %s, vp_);\n"
|
||||
% (templateName, ", strict" if isSetter else "", argumentValues))
|
||||
else:
|
||||
callTemplate += (" return %s(cx, argc, %s, vp);\n"
|
||||
@ -496,10 +504,15 @@ def writeStub(f, customMethodCalls, member, stubName, writeThisUnwrapping, write
|
||||
f.write("{\n")
|
||||
f.write(" XPC_QS_ASSERT_CONTEXT_OK(cx);\n")
|
||||
|
||||
# Compute "this".
|
||||
f.write(" JSObject *obj = JS_THIS_OBJECT(cx, vp);\n"
|
||||
" if (!obj)\n"
|
||||
" return JS_FALSE;\n")
|
||||
# Convert JSMutableHandleValue to jsval*
|
||||
if isAttr:
|
||||
f.write(" jsval *vp = vp_.address();\n")
|
||||
|
||||
# For methods, compute "this".
|
||||
if isMethod:
|
||||
f.write(" JSObject *obj = JS_THIS_OBJECT(cx, vp);\n"
|
||||
" if (!obj)\n"
|
||||
" return JS_FALSE;\n")
|
||||
|
||||
selfname = writeThisUnwrapping(f, member, isMethod, isGetter, customMethodCall)
|
||||
|
||||
@ -510,20 +523,14 @@ def writeStub(f, customMethodCalls, member, stubName, writeThisUnwrapping, write
|
||||
requiredArgs = inArgs
|
||||
while requiredArgs and member.params[requiredArgs-1].optional:
|
||||
requiredArgs -= 1
|
||||
elif isSetter:
|
||||
inArgs = requiredArgs = 1
|
||||
else:
|
||||
inArgs = requiredArgs = 0
|
||||
if requiredArgs:
|
||||
f.write(" if (argc < %d)\n" % requiredArgs)
|
||||
f.write(" return xpc_qsThrow(cx, "
|
||||
"NS_ERROR_XPC_NOT_ENOUGH_ARGS);\n")
|
||||
|
||||
if requiredArgs:
|
||||
f.write(" if (argc < %d)\n" % requiredArgs)
|
||||
f.write(" return xpc_qsThrow(cx, "
|
||||
"NS_ERROR_XPC_NOT_ENOUGH_ARGS);\n")
|
||||
|
||||
# Convert in-parameters.
|
||||
if inArgs > 0:
|
||||
f.write(" jsval *argv = JS_ARGV(cx, vp);\n")
|
||||
if isMethod:
|
||||
# Convert in-parameters.
|
||||
if inArgs > 0:
|
||||
f.write(" jsval *argv = JS_ARGV(cx, vp);\n")
|
||||
for i in range(inArgs):
|
||||
param = member.params[i]
|
||||
argName = 'arg%d' % i
|
||||
@ -625,8 +632,7 @@ def writeStub(f, customMethodCalls, member, stubName, writeThisUnwrapping, write
|
||||
if isMethod or isGetter:
|
||||
writeResultWrapping(f, member, 'vp', '*vp')
|
||||
else:
|
||||
f.write(" JS_SET_RVAL(cx, vp, JS::UndefinedValue());\n"
|
||||
" return JS_TRUE;\n")
|
||||
f.write(" return JS_TRUE;\n")
|
||||
|
||||
# Epilog.
|
||||
f.write("}\n\n")
|
||||
|
@ -210,17 +210,14 @@ ListBase<LC>::instanceIsListObject(JSContext *cx, JSObject *obj, JSObject *calle
|
||||
|
||||
template<class LC>
|
||||
JSBool
|
||||
ListBase<LC>::length_getter(JSContext *cx, unsigned argc, JS::Value *vp)
|
||||
ListBase<LC>::length_getter(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp)
|
||||
{
|
||||
JSObject *obj = JS_THIS_OBJECT(cx, vp);
|
||||
if (!obj)
|
||||
return false;
|
||||
if (!instanceIsListObject(cx, obj, NULL))
|
||||
return false;
|
||||
uint32_t length;
|
||||
getListObject(obj)->GetLength(&length);
|
||||
MOZ_ASSERT(int32_t(length) >= 0);
|
||||
JS_SET_RVAL(cx, vp, UINT_TO_JSVAL(length));
|
||||
vp.set(UINT_TO_JSVAL(length));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -364,16 +361,12 @@ ListBase<LC>::getPrototype(JSContext *cx, XPCWrappedNativeScope *scope,
|
||||
for (size_t n = 0; n < sProtoPropertiesCount; ++n) {
|
||||
MOZ_ASSERT(sProtoProperties[n].getter);
|
||||
jsid id = sProtoProperties[n].id;
|
||||
unsigned attrs = JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS;
|
||||
unsigned attrs = JSPROP_ENUMERATE | JSPROP_SHARED;
|
||||
if (!sProtoProperties[n].setter)
|
||||
attrs |= JSPROP_READONLY;
|
||||
if (!JS_DefinePropertyById(cx, interfacePrototype, id, JSVAL_VOID,
|
||||
(JSPropertyOp) sProtoProperties[n].getter,
|
||||
(JSStrictPropertyOp) sProtoProperties[n].setter,
|
||||
attrs))
|
||||
{
|
||||
sProtoProperties[n].getter, sProtoProperties[n].setter, attrs))
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t n = 0; n < sProtoMethodsCount; ++n) {
|
||||
@ -770,12 +763,12 @@ ListBase<LC>::resolveNativeName(JSContext *cx, JSObject *proxy, jsid id, JSPrope
|
||||
|
||||
for (size_t n = 0; n < sProtoPropertiesCount; ++n) {
|
||||
if (id == sProtoProperties[n].id) {
|
||||
desc->attrs = JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS;
|
||||
desc->attrs = JSPROP_ENUMERATE | JSPROP_SHARED;
|
||||
if (!sProtoProperties[n].setter)
|
||||
desc->attrs |= JSPROP_READONLY;
|
||||
desc->obj = proxy;
|
||||
desc->setter = (JSStrictPropertyOp) sProtoProperties[n].setter;
|
||||
desc->getter = (JSPropertyOp) sProtoProperties[n].getter;
|
||||
desc->setter = sProtoProperties[n].setter;
|
||||
desc->getter = sProtoProperties[n].getter;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -117,8 +117,8 @@ private:
|
||||
|
||||
struct Properties {
|
||||
jsid &id;
|
||||
JSNative getter;
|
||||
JSNative setter;
|
||||
JSPropertyOp getter;
|
||||
JSStrictPropertyOp setter;
|
||||
};
|
||||
struct Methods {
|
||||
jsid &id;
|
||||
@ -133,7 +133,7 @@ private:
|
||||
|
||||
static JSObject *ensureExpandoObject(JSContext *cx, JSObject *obj);
|
||||
|
||||
static JSBool length_getter(JSContext *cx, unsigned argc, JS::Value *vp);
|
||||
static JSBool length_getter(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp);
|
||||
|
||||
static inline bool getItemAt(ListType *list, uint32_t i, IndexGetterType &item);
|
||||
static inline bool setItemAt(JSContext *cx, ListType *list, uint32_t i, IndexSetterType item);
|
||||
|
@ -599,7 +599,7 @@ def writeAttrStubs(f, classname, attr):
|
||||
getterName = classname + '_' + header.attributeNativeName(attr, True)
|
||||
writeBindingStub(f, classname, attr, getterName)
|
||||
if attr.readonly:
|
||||
setterName = 'xpc_qsGetterOnlyNativeStub'
|
||||
setterName = 'xpc_qsGetterOnlyPropertyStub'
|
||||
else:
|
||||
setterName = (classname + '_'
|
||||
+ header.attributeNativeName(attr, False))
|
||||
|
@ -385,7 +385,6 @@ class StringTable:
|
||||
% (offset, explodeToCharArray(string)))
|
||||
f.write(" /* %5d */ %s, '\\0' };\n\n"
|
||||
% (entries[-1][1], explodeToCharArray(entries[-1][0])))
|
||||
f.write("const char* xpc_qsStringTable = %s;\n\n" % name);
|
||||
|
||||
def substitute(template, vals):
|
||||
""" Simple replacement for string.Template, which isn't in Python 2.3. """
|
||||
@ -492,11 +491,10 @@ argumentUnboxingTemplates = {
|
||||
# however, defaults to 'undefined'.
|
||||
#
|
||||
def writeArgumentUnboxing(f, i, name, type, optional, rvdeclared,
|
||||
nullBehavior, undefinedBehavior,
|
||||
propIndex=None):
|
||||
nullBehavior, undefinedBehavior):
|
||||
# f - file to write to
|
||||
# i - int or None - Indicates the source jsval. If i is an int, the source
|
||||
# jsval is argv[i]; otherwise it is argv[0]. But if Python i >= C++ argc,
|
||||
# jsval is argv[i]; otherwise it is *vp. But if Python i >= C++ argc,
|
||||
# which can only happen if optional is True, the argument is missing;
|
||||
# use JSVAL_NULL as the source jsval instead.
|
||||
# name - str - name of the native C++ variable to create.
|
||||
@ -509,8 +507,8 @@ def writeArgumentUnboxing(f, i, name, type, optional, rvdeclared,
|
||||
isSetter = (i is None)
|
||||
|
||||
if isSetter:
|
||||
argPtr = "argv"
|
||||
argVal = "argv[0]"
|
||||
argPtr = "vp"
|
||||
argVal = "*vp"
|
||||
elif optional:
|
||||
if typeName == "[jsval]":
|
||||
val = "JSVAL_VOID"
|
||||
@ -561,9 +559,8 @@ def writeArgumentUnboxing(f, i, name, type, optional, rvdeclared,
|
||||
% (type.name, argVal, name, name, argPtr))
|
||||
f.write(" if (NS_FAILED(rv)) {\n")
|
||||
if isSetter:
|
||||
assert(propIndex is not None)
|
||||
f.write(" xpc_qsThrowBadSetterValue(cx, rv, JSVAL_TO_OBJECT(vp[1]), (uint16_t)%s);\n" %
|
||||
propIndex)
|
||||
f.write(" xpc_qsThrowBadSetterValue("
|
||||
"cx, rv, JSVAL_TO_OBJECT(*tvr.jsval_addr()), id);\n")
|
||||
else:
|
||||
f.write(" xpc_qsThrowBadArg(cx, rv, vp, %d);\n" % i)
|
||||
f.write(" return JS_FALSE;\n"
|
||||
@ -572,7 +569,7 @@ def writeArgumentUnboxing(f, i, name, type, optional, rvdeclared,
|
||||
|
||||
warn("Unable to unbox argument of type %s (native type %s)" % (type.name, typeName))
|
||||
if i is None:
|
||||
src = 'argv[0]'
|
||||
src = '*vp'
|
||||
else:
|
||||
src = 'argv[%d]' % i
|
||||
f.write(" !; // TODO - Unbox argument %s = %s\n" % (name, src))
|
||||
@ -744,8 +741,7 @@ def validateParam(member, param):
|
||||
if param.const or param.array or param.shared:
|
||||
pfail("I am a simple caveman.")
|
||||
|
||||
def writeQuickStub(f, customMethodCalls, stringtable, member, stubName,
|
||||
isSetter=False):
|
||||
def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
|
||||
""" Write a single quick stub (a custom SpiderMonkey getter/setter/method)
|
||||
for the specified XPCOM interface-member.
|
||||
"""
|
||||
@ -754,8 +750,16 @@ def writeQuickStub(f, customMethodCalls, stringtable, member, stubName,
|
||||
assert isAttr or isMethod
|
||||
isGetter = isAttr and not isSetter
|
||||
|
||||
signature = ("static JSBool\n" +
|
||||
"%s(JSContext *cx, unsigned argc,%s jsval *vp)\n")
|
||||
signature = "static JSBool\n"
|
||||
if isAttr:
|
||||
# JSPropertyOp signature.
|
||||
if isSetter:
|
||||
signature += "%s(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict,%s JSMutableHandleValue vp_)\n"
|
||||
else:
|
||||
signature += "%s(JSContext *cx, JSHandleObject obj, JSHandleId id,%s JSMutableHandleValue vp_)\n"
|
||||
else:
|
||||
# JSFastNative.
|
||||
signature += "%s(JSContext *cx, unsigned argc,%s jsval *vp)\n"
|
||||
|
||||
customMethodCall = customMethodCalls.get(stubName, None)
|
||||
|
||||
@ -788,8 +792,12 @@ def writeQuickStub(f, customMethodCalls, stringtable, member, stubName,
|
||||
or header.firstCap(member.name))
|
||||
argumentValues = (customMethodCall['additionalArgumentValues']
|
||||
% nativeName)
|
||||
callTemplate += (" return %s(cx, argc, %s, vp);\n"
|
||||
% (templateName, argumentValues))
|
||||
if isAttr:
|
||||
callTemplate += (" return %s(cx, obj, id%s, %s, vp_);\n"
|
||||
% (templateName, ", strict" if isSetter else "", argumentValues))
|
||||
else:
|
||||
callTemplate += (" return %s(cx, argc, %s, vp);\n"
|
||||
% (templateName, argumentValues))
|
||||
callTemplate += "}\n\n"
|
||||
|
||||
# Fall through and create the template function stub called from the
|
||||
@ -825,10 +833,15 @@ def writeQuickStub(f, customMethodCalls, stringtable, member, stubName,
|
||||
f.write("{\n")
|
||||
f.write(" XPC_QS_ASSERT_CONTEXT_OK(cx);\n")
|
||||
|
||||
# Compute "this".
|
||||
f.write(" JSObject *obj = JS_THIS_OBJECT(cx, vp);\n"
|
||||
" if (!obj)\n"
|
||||
" return JS_FALSE;\n")
|
||||
# Convert JSMutableHandleValue to jsval*
|
||||
if isAttr:
|
||||
f.write(" jsval *vp = vp_.address();\n")
|
||||
|
||||
# For methods, compute "this".
|
||||
if isMethod:
|
||||
f.write(" JSObject *obj = JS_THIS_OBJECT(cx, vp);\n"
|
||||
" if (!obj)\n"
|
||||
" return JS_FALSE;\n")
|
||||
|
||||
# Get the 'self' pointer.
|
||||
if customMethodCall is None or not 'thisType' in customMethodCall:
|
||||
@ -836,7 +849,13 @@ def writeQuickStub(f, customMethodCalls, stringtable, member, stubName,
|
||||
else:
|
||||
f.write(" %s *self;\n" % customMethodCall['thisType'])
|
||||
f.write(" xpc_qsSelfRef selfref;\n")
|
||||
pthisval = '&vp[1]' # as above, ok to overwrite vp[1]
|
||||
if isGetter:
|
||||
pthisval = 'vp'
|
||||
elif isSetter:
|
||||
f.write(" JS::AutoValueRooter tvr(cx);\n")
|
||||
pthisval = 'tvr.jsval_addr()'
|
||||
else:
|
||||
pthisval = '&vp[1]' # as above, ok to overwrite vp[1]
|
||||
|
||||
if unwrapThisFailureFatal:
|
||||
unwrapFatalArg = "true"
|
||||
@ -864,14 +883,10 @@ def writeQuickStub(f, customMethodCalls, stringtable, member, stubName,
|
||||
requiredArgs = len(member.params)
|
||||
while requiredArgs and member.params[requiredArgs-1].optional:
|
||||
requiredArgs -= 1
|
||||
elif isSetter:
|
||||
requiredArgs = 1
|
||||
else:
|
||||
requiredArgs = 0
|
||||
if requiredArgs:
|
||||
f.write(" if (argc < %d)\n" % requiredArgs)
|
||||
f.write(" return xpc_qsThrow(cx, "
|
||||
"NS_ERROR_XPC_NOT_ENOUGH_ARGS);\n")
|
||||
if requiredArgs:
|
||||
f.write(" if (argc < %d)\n" % requiredArgs)
|
||||
f.write(" return xpc_qsThrow(cx, "
|
||||
"NS_ERROR_XPC_NOT_ENOUGH_ARGS);\n")
|
||||
|
||||
# Convert in-parameters.
|
||||
rvdeclared = False
|
||||
@ -895,13 +910,11 @@ def writeQuickStub(f, customMethodCalls, stringtable, member, stubName,
|
||||
nullBehavior=param.null,
|
||||
undefinedBehavior=param.undefined)
|
||||
elif isSetter:
|
||||
f.write(" jsval *argv = JS_ARGV(cx, vp);\n")
|
||||
rvdeclared = writeArgumentUnboxing(f, None, 'arg0', member.realtype,
|
||||
optional=False,
|
||||
rvdeclared=rvdeclared,
|
||||
nullBehavior=member.null,
|
||||
undefinedBehavior=member.undefined,
|
||||
propIndex=stringtable.stringIndex(member.name))
|
||||
undefinedBehavior=member.undefined)
|
||||
|
||||
canFail = customMethodCall is None or customMethodCall.get('canFail', True)
|
||||
if canFail and not rvdeclared:
|
||||
@ -974,9 +987,12 @@ def writeQuickStub(f, customMethodCalls, stringtable, member, stubName,
|
||||
f.write(" return xpc_qsThrowMethodFailed("
|
||||
"cx, rv, vp);\n")
|
||||
else:
|
||||
if isGetter:
|
||||
thisval = '*vp'
|
||||
else:
|
||||
thisval = '*tvr.jsval_addr()'
|
||||
f.write(" return xpc_qsThrowGetterSetterFailed(cx, rv, " +
|
||||
"JSVAL_TO_OBJECT(vp[1]), (uint16_t)%d);\n" %
|
||||
stringtable.stringIndex(member.name))
|
||||
"JSVAL_TO_OBJECT(%s), id);\n" % thisval)
|
||||
|
||||
# Convert the return value.
|
||||
if isMethod or isGetter:
|
||||
@ -998,15 +1014,14 @@ def writeAttrStubs(f, customMethodCalls, stringtable, attr):
|
||||
getterName = (attr.iface.name + '_'
|
||||
+ header.attributeNativeName(attr, True))
|
||||
if not custom:
|
||||
writeQuickStub(f, customMethodCalls, stringtable, attr, getterName)
|
||||
writeQuickStub(f, customMethodCalls, attr, getterName)
|
||||
if attr.readonly:
|
||||
setterName = 'xpc_qsGetterOnlyNativeStub'
|
||||
setterName = 'xpc_qsGetterOnlyPropertyStub'
|
||||
else:
|
||||
setterName = (attr.iface.name + '_'
|
||||
+ header.attributeNativeName(attr, False))
|
||||
if not custom:
|
||||
writeQuickStub(f, customMethodCalls, stringtable, attr, setterName,
|
||||
isSetter=True)
|
||||
writeQuickStub(f, customMethodCalls, attr, setterName, isSetter=True)
|
||||
|
||||
ps = ('{%d, %s, %s}'
|
||||
% (stringtable.stringIndex(attr.name), getterName, setterName))
|
||||
@ -1020,7 +1035,7 @@ def writeMethodStub(f, customMethodCalls, stringtable, method):
|
||||
|
||||
stubName = method.iface.name + '_' + header.methodNativeName(method)
|
||||
if not custom:
|
||||
writeQuickStub(f, customMethodCalls, stringtable, method, stubName)
|
||||
writeQuickStub(f, customMethodCalls, method, stubName)
|
||||
fs = '{%d, %d, %s}' % (stringtable.stringIndex(method.name),
|
||||
len(method.params), stubName)
|
||||
return fs
|
||||
|
Loading…
Reference in New Issue
Block a user