mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 993026 - Change XPIDLScriptable NewResolve to simpler Resolve. r=bholley
This commit is contained in:
parent
a46612ac87
commit
29374ed725
@ -192,13 +192,13 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
NS_DEFINE_CLASSINFO_DATA(DOMPrototype, nsDOMConstructorSH,
|
||||
DOM_BASE_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_PRECREATE |
|
||||
nsIXPCScriptable::WANT_NEWRESOLVE |
|
||||
nsIXPCScriptable::WANT_RESOLVE |
|
||||
nsIXPCScriptable::WANT_HASINSTANCE |
|
||||
nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE)
|
||||
NS_DEFINE_CLASSINFO_DATA(DOMConstructor, nsDOMConstructorSH,
|
||||
DOM_BASE_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_PRECREATE |
|
||||
nsIXPCScriptable::WANT_NEWRESOLVE |
|
||||
nsIXPCScriptable::WANT_RESOLVE |
|
||||
nsIXPCScriptable::WANT_HASINSTANCE |
|
||||
nsIXPCScriptable::WANT_CALL |
|
||||
nsIXPCScriptable::WANT_CONSTRUCT |
|
||||
@ -1015,10 +1015,15 @@ nsDOMClassInfo::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDOMClassInfo::ResolveConstructor(JSContext *cx, JSObject *aObj,
|
||||
JSObject **objp)
|
||||
NS_IMETHODIMP
|
||||
nsDOMClassInfo::Resolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *aObj, jsid id, bool *resolvedp, bool *_retval)
|
||||
{
|
||||
if (id != sConstructor_id) {
|
||||
*resolvedp = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> obj(cx, aObj);
|
||||
JS::Rooted<JSObject*> global(cx, ::JS_GetGlobalForObject(cx, obj));
|
||||
|
||||
@ -1040,19 +1045,7 @@ nsDOMClassInfo::ResolveConstructor(JSContext *cx, JSObject *aObj,
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
*objp = obj;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMClassInfo::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, JSObject **objp,
|
||||
bool *_retval)
|
||||
{
|
||||
if (id == sConstructor_id) {
|
||||
return ResolveConstructor(cx, obj, objp);
|
||||
*resolvedp = true;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -2622,9 +2615,9 @@ nsDOMConstructorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMConstructorSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *aObj, jsid aId, JSObject **objp,
|
||||
bool *_retval)
|
||||
nsDOMConstructorSH::Resolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *aObj, jsid aId, bool *resolvedp,
|
||||
bool *_retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(cx, aObj);
|
||||
JS::Rooted<jsid> id(cx, aId);
|
||||
@ -2645,7 +2638,7 @@ nsDOMConstructorSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx
|
||||
// Now re-lookup the ID to see if we should report back that we resolved the
|
||||
// looked-for constant. Note that we don't have to worry about infinitely
|
||||
// recurring back here because the Xray wrapper's holder object doesn't call
|
||||
// NewResolve hooks.
|
||||
// Resolve hooks.
|
||||
bool found;
|
||||
if (!JS_HasPropertyById(cx, nativePropsObj, id, &found)) {
|
||||
*_retval = false;
|
||||
@ -2653,7 +2646,7 @@ nsDOMConstructorSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx
|
||||
}
|
||||
|
||||
if (found) {
|
||||
*objp = obj;
|
||||
*resolvedp = true;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -138,8 +138,6 @@ protected:
|
||||
|
||||
static nsresult RegisterClassProtos(int32_t aDOMClassInfoID);
|
||||
static nsresult RegisterExternalClasses();
|
||||
nsresult ResolveConstructor(JSContext *cx, JSObject *obj,
|
||||
JSObject **objp);
|
||||
|
||||
static nsIXPConnect *sXPConnect;
|
||||
|
||||
@ -276,9 +274,9 @@ public:
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, JSObject **objp,
|
||||
bool *_retval) MOZ_OVERRIDE;
|
||||
NS_IMETHOD Resolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, jsid id, bool *resolvedp,
|
||||
bool *_retval) MOZ_OVERRIDE;
|
||||
NS_IMETHOD Call(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
JSObject *obj, const JS::CallArgs &args, bool *_retval) MOZ_OVERRIDE;
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#define DEFAULT_SCRIPTABLE_FLAGS \
|
||||
(DOM_BASE_SCRIPTABLE_FLAGS | \
|
||||
nsIXPCScriptable::WANT_NEWRESOLVE | \
|
||||
nsIXPCScriptable::WANT_RESOLVE | \
|
||||
nsIXPCScriptable::WANT_PRECREATE)
|
||||
|
||||
#define DOM_DEFAULT_SCRIPTABLE_FLAGS \
|
||||
|
@ -11878,8 +11878,7 @@ class CGResolveSystemBinding(CGAbstractMethod):
|
||||
[Argument('JSContext*', 'aCx'),
|
||||
Argument('JS::Handle<JSObject*>', 'aObj'),
|
||||
Argument('JS::Handle<jsid>', 'aId'),
|
||||
Argument('JS::MutableHandle<JSObject*>',
|
||||
'aObjp')])
|
||||
Argument('bool*', 'aResolvedp')])
|
||||
self.config = config
|
||||
|
||||
def definition_body(self):
|
||||
@ -11912,7 +11911,7 @@ class CGResolveSystemBinding(CGAbstractMethod):
|
||||
defineCode = "!%s::GetConstructorObject(aCx, aObj)" % bindingNS
|
||||
defineCode = CGIfWrapper(CGGeneric("return false;\n"), defineCode)
|
||||
defineCode = CGList([defineCode,
|
||||
CGGeneric("aObjp.set(aObj);\n")])
|
||||
CGGeneric("*aResolvedp = true;\n")])
|
||||
|
||||
condition = "JSID_IS_VOID(aId) || aId == %s" % descNameToId(desc.name)
|
||||
if desc.isExposedConditionally():
|
||||
|
@ -31,7 +31,7 @@ interface nsIXPConnectWrappedNative;
|
||||
* boolean to PR_TRUE before making the call. Implementations may skip writing
|
||||
* to *_retval unless they want to return PR_FALSE.
|
||||
*/
|
||||
[uuid(d945a647-a60e-462d-9635-c79d5fa694ce)]
|
||||
[uuid(e7dee706-1286-4a22-954b-f0d8a9821bc9)]
|
||||
interface nsIXPCScriptable : nsISupports
|
||||
{
|
||||
/* bitflags used for 'flags' (only 32 bits available!) */
|
||||
@ -45,7 +45,7 @@ interface nsIXPCScriptable : nsISupports
|
||||
const uint32_t WANT_SETPROPERTY = 1 << 6;
|
||||
const uint32_t WANT_ENUMERATE = 1 << 7;
|
||||
const uint32_t WANT_NEWENUMERATE = 1 << 8;
|
||||
const uint32_t WANT_NEWRESOLVE = 1 << 9;
|
||||
const uint32_t WANT_RESOLVE = 1 << 9;
|
||||
const uint32_t WANT_CONVERT = 1 << 10;
|
||||
const uint32_t WANT_FINALIZE = 1 << 11;
|
||||
// unused bit here!
|
||||
@ -115,9 +115,9 @@ interface nsIXPCScriptable : nsISupports
|
||||
in JSContextPtr cx, in JSObjectPtr obj,
|
||||
in uint32_t enum_op, in JSValPtr statep, out jsid idp);
|
||||
|
||||
boolean newResolve(in nsIXPConnectWrappedNative wrapper,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
|
||||
out JSObjectPtr objp);
|
||||
boolean resolve(in nsIXPConnectWrappedNative wrapper,
|
||||
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
|
||||
out boolean resolvedp);
|
||||
|
||||
boolean convert(in nsIXPConnectWrappedNative wrapper,
|
||||
in JSContextPtr cx, in JSObjectPtr obj,
|
||||
|
@ -58,8 +58,8 @@ XPC_MAP_CLASSNAME::GetScriptableFlags()
|
||||
#ifdef XPC_MAP_WANT_NEWENUMERATE
|
||||
nsIXPCScriptable::WANT_NEWENUMERATE |
|
||||
#endif
|
||||
#ifdef XPC_MAP_WANT_NEWRESOLVE
|
||||
nsIXPCScriptable::WANT_NEWRESOLVE |
|
||||
#ifdef XPC_MAP_WANT_RESOLVE
|
||||
nsIXPCScriptable::WANT_RESOLVE |
|
||||
#endif
|
||||
#ifdef XPC_MAP_WANT_CONVERT
|
||||
nsIXPCScriptable::WANT_CONVERT |
|
||||
@ -133,8 +133,8 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::Enumerate(nsIXPConnectWrappedNative *wrapper, J
|
||||
{NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
|
||||
#endif
|
||||
|
||||
#ifndef XPC_MAP_WANT_NEWRESOLVE
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsid id, JSObject * *objp, bool *_retval)
|
||||
#ifndef XPC_MAP_WANT_RESOLVE
|
||||
NS_IMETHODIMP XPC_MAP_CLASSNAME::Resolve(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, jsid id, bool *resolvedp, bool *_retval)
|
||||
{NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
|
||||
#endif
|
||||
|
||||
@ -209,8 +209,8 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::PostCreatePrototype(JSContext *cx, JSObject *pr
|
||||
#undef XPC_MAP_WANT_NEWENUMERATE
|
||||
#endif
|
||||
|
||||
#ifdef XPC_MAP_WANT_NEWRESOLVE
|
||||
#undef XPC_MAP_WANT_NEWRESOLVE
|
||||
#ifdef XPC_MAP_WANT_RESOLVE
|
||||
#undef XPC_MAP_WANT_RESOLVE
|
||||
#endif
|
||||
|
||||
#ifdef XPC_MAP_WANT_CONVERT
|
||||
|
@ -233,7 +233,7 @@ NS_IMPL_RELEASE(nsXPCComponents_Interfaces)
|
||||
// The nsIXPCScriptable map declaration that will generate stubs for us...
|
||||
#define XPC_MAP_CLASSNAME nsXPCComponents_Interfaces
|
||||
#define XPC_MAP_QUOTED_CLASSNAME "nsXPCComponents_Interfaces"
|
||||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_RESOLVE
|
||||
#define XPC_MAP_WANT_NEWENUMERATE
|
||||
#define XPC_MAP_FLAGS nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |\
|
||||
nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
|
||||
@ -291,12 +291,11 @@ nsXPCComponents_Interfaces::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
||||
}
|
||||
}
|
||||
|
||||
/* bool newResolve (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval id, out JSObjectPtr objp); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Interfaces::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *objArg,
|
||||
jsid idArg, JSObject **objp,
|
||||
bool *_retval)
|
||||
nsXPCComponents_Interfaces::Resolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *objArg,
|
||||
jsid idArg, bool *resolvedp,
|
||||
bool *_retval)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
RootedId id(cx, idArg);
|
||||
@ -331,7 +330,7 @@ nsXPCComponents_Interfaces::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
if (holder &&
|
||||
// Assign, not compare
|
||||
(idobj = holder->GetJSObject())) {
|
||||
*objp = obj;
|
||||
*resolvedp = true;
|
||||
*_retval = JS_DefinePropertyById(cx, obj, id, idobj,
|
||||
JSPROP_ENUMERATE |
|
||||
JSPROP_READONLY |
|
||||
@ -484,7 +483,7 @@ NS_IMPL_RELEASE(nsXPCComponents_InterfacesByID)
|
||||
// The nsIXPCScriptable map declaration that will generate stubs for us...
|
||||
#define XPC_MAP_CLASSNAME nsXPCComponents_InterfacesByID
|
||||
#define XPC_MAP_QUOTED_CLASSNAME "nsXPCComponents_InterfacesByID"
|
||||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_RESOLVE
|
||||
#define XPC_MAP_WANT_NEWENUMERATE
|
||||
#define XPC_MAP_FLAGS nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |\
|
||||
nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
|
||||
@ -542,12 +541,11 @@ nsXPCComponents_InterfacesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
||||
}
|
||||
}
|
||||
|
||||
/* bool newResolve (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval id, out JSObjectPtr objp); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_InterfacesByID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *objArg,
|
||||
jsid idArg, JSObject **objp,
|
||||
bool *_retval)
|
||||
nsXPCComponents_InterfacesByID::Resolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *objArg,
|
||||
jsid idArg, bool *resolvedp,
|
||||
bool *_retval)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
RootedId id(cx, idArg);
|
||||
@ -586,7 +584,7 @@ nsXPCComponents_InterfacesByID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
if (holder &&
|
||||
// Assign, not compare
|
||||
(idobj = holder->GetJSObject())) {
|
||||
*objp = obj;
|
||||
*resolvedp = true;
|
||||
*_retval =
|
||||
JS_DefinePropertyById(cx, obj, id, idobj,
|
||||
JSPROP_ENUMERATE |
|
||||
@ -737,7 +735,7 @@ NS_IMPL_RELEASE(nsXPCComponents_Classes)
|
||||
// The nsIXPCScriptable map declaration that will generate stubs for us...
|
||||
#define XPC_MAP_CLASSNAME nsXPCComponents_Classes
|
||||
#define XPC_MAP_QUOTED_CLASSNAME "nsXPCComponents_Classes"
|
||||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_RESOLVE
|
||||
#define XPC_MAP_WANT_NEWENUMERATE
|
||||
#define XPC_MAP_FLAGS nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |\
|
||||
nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
|
||||
@ -802,12 +800,11 @@ nsXPCComponents_Classes::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
||||
}
|
||||
}
|
||||
|
||||
/* bool newResolve (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval id, out JSObjectPtr objp); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Classes::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *objArg,
|
||||
jsid idArg, JSObject **objp,
|
||||
bool *_retval)
|
||||
nsXPCComponents_Classes::Resolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *objArg,
|
||||
jsid idArg, bool *resolvedp,
|
||||
bool *_retval)
|
||||
|
||||
{
|
||||
RootedId id(cx, idArg);
|
||||
@ -829,7 +826,7 @@ nsXPCComponents_Classes::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
if (holder &&
|
||||
// Assign, not compare
|
||||
(idobj = holder->GetJSObject())) {
|
||||
*objp = obj;
|
||||
*resolvedp = true;
|
||||
*_retval = JS_DefinePropertyById(cx, obj, id, idobj,
|
||||
JSPROP_ENUMERATE |
|
||||
JSPROP_READONLY |
|
||||
@ -978,7 +975,7 @@ NS_IMPL_RELEASE(nsXPCComponents_ClassesByID)
|
||||
// The nsIXPCScriptable map declaration that will generate stubs for us...
|
||||
#define XPC_MAP_CLASSNAME nsXPCComponents_ClassesByID
|
||||
#define XPC_MAP_QUOTED_CLASSNAME "nsXPCComponents_ClassesByID"
|
||||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_RESOLVE
|
||||
#define XPC_MAP_WANT_NEWENUMERATE
|
||||
#define XPC_MAP_FLAGS nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |\
|
||||
nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
|
||||
@ -1060,12 +1057,11 @@ IsRegisteredCLSID(const char* str)
|
||||
return registered;
|
||||
}
|
||||
|
||||
/* bool newResolve (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval id, out JSObjectPtr objp); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_ClassesByID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *objArg,
|
||||
jsid idArg, JSObject **objp,
|
||||
bool *_retval)
|
||||
nsXPCComponents_ClassesByID::Resolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *objArg,
|
||||
jsid idArg, bool *resolvedp,
|
||||
bool *_retval)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
RootedId id(cx, idArg);
|
||||
@ -1090,7 +1086,7 @@ nsXPCComponents_ClassesByID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
if (holder &&
|
||||
// Assign, not compare
|
||||
(idobj = holder->GetJSObject())) {
|
||||
*objp = obj;
|
||||
*resolvedp = true;
|
||||
*_retval = JS_DefinePropertyById(cx, obj, id, idobj,
|
||||
JSPROP_ENUMERATE |
|
||||
JSPROP_READONLY |
|
||||
@ -1243,7 +1239,7 @@ NS_IMPL_RELEASE(nsXPCComponents_Results)
|
||||
// The nsIXPCScriptable map declaration that will generate stubs for us...
|
||||
#define XPC_MAP_CLASSNAME nsXPCComponents_Results
|
||||
#define XPC_MAP_QUOTED_CLASSNAME "nsXPCComponents_Results"
|
||||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_RESOLVE
|
||||
#define XPC_MAP_WANT_NEWENUMERATE
|
||||
#define XPC_MAP_FLAGS nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |\
|
||||
nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
|
||||
@ -1294,13 +1290,11 @@ nsXPCComponents_Results::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* bool newResolve (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval id, out JSObjectPtr objp); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Results::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *objArg,
|
||||
jsid idArg, JSObject * *objp,
|
||||
bool *_retval)
|
||||
nsXPCComponents_Results::Resolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext *cx, JSObject *objArg,
|
||||
jsid idArg, bool *resolvedp,
|
||||
bool *_retval)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
RootedId id(cx, idArg);
|
||||
@ -1312,7 +1306,7 @@ nsXPCComponents_Results::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
nsresult rv;
|
||||
while (nsXPCException::IterateNSResults(&rv, &rv_name, nullptr, &iter)) {
|
||||
if (!strcmp(name.ptr(), rv_name)) {
|
||||
*objp = obj;
|
||||
*resolvedp = true;
|
||||
if (!JS_DefinePropertyById(cx, obj, id, (uint32_t)rv,
|
||||
JSPROP_ENUMERATE |
|
||||
JSPROP_READONLY |
|
||||
|
@ -295,7 +295,7 @@ NS_IMPL_CI_INTERFACE_GETTER(nsJSIID, nsIJSID, nsIJSIID)
|
||||
// The nsIXPCScriptable map declaration that will generate stubs for us...
|
||||
#define XPC_MAP_CLASSNAME nsJSIID
|
||||
#define XPC_MAP_QUOTED_CLASSNAME "nsJSIID"
|
||||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_RESOLVE
|
||||
#define XPC_MAP_WANT_ENUMERATE
|
||||
#define XPC_MAP_WANT_HASINSTANCE
|
||||
#define XPC_MAP_FLAGS nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |\
|
||||
@ -382,12 +382,11 @@ nsJSIID::NewID(nsIInterfaceInfo* aInfo)
|
||||
}
|
||||
|
||||
|
||||
/* bool resolve (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval id); */
|
||||
NS_IMETHODIMP
|
||||
nsJSIID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * objArg,
|
||||
jsid idArg, JSObject * *objp,
|
||||
bool *_retval)
|
||||
nsJSIID::Resolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * objArg,
|
||||
jsid idArg, bool *resolvedp,
|
||||
bool *_retval)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
RootedId id(cx, idArg);
|
||||
@ -406,7 +405,7 @@ nsJSIID::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
if (!member->GetConstantValue(ccx, iface, val.address()))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*objp = obj;
|
||||
*resolvedp = true;
|
||||
*_retval = JS_DefinePropertyById(cx, obj, id, val,
|
||||
JSPROP_ENUMERATE | JSPROP_READONLY |
|
||||
JSPROP_PERMANENT);
|
||||
|
@ -31,7 +31,7 @@ NS_IMPL_RELEASE(BackstagePass)
|
||||
// The nsIXPCScriptable map declaration that will generate stubs for us...
|
||||
#define XPC_MAP_CLASSNAME BackstagePass
|
||||
#define XPC_MAP_QUOTED_CLASSNAME "BackstagePass"
|
||||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_RESOLVE
|
||||
#define XPC_MAP_WANT_ENUMERATE
|
||||
#define XPC_MAP_WANT_FINALIZE
|
||||
#define XPC_MAP_WANT_PRECREATE
|
||||
@ -62,34 +62,29 @@ BackstagePass::SetGlobalObject(JSObject* global)
|
||||
mWrapper = static_cast<XPCWrappedNative*>(p);
|
||||
}
|
||||
|
||||
/* bool newResolve (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval id, out JSObjectPtr objp); */
|
||||
NS_IMETHODIMP
|
||||
BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * objArg,
|
||||
jsid idArg, JSObject * *objpArg,
|
||||
bool *_retval)
|
||||
BackstagePass::Resolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JSContext * cx, JSObject * objArg,
|
||||
jsid idArg, bool *resolvedp,
|
||||
bool *_retval)
|
||||
{
|
||||
JS::RootedObject obj(cx, objArg);
|
||||
JS::RootedId id(cx, idArg);
|
||||
|
||||
bool resolved;
|
||||
*objpArg = nullptr;
|
||||
|
||||
*_retval = !!JS_ResolveStandardClass(cx, obj, id, &resolved);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
if (resolved) {
|
||||
*objpArg = obj;
|
||||
*resolvedp = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JS::RootedObject objp(cx, *objpArg);
|
||||
|
||||
*_retval = ResolveSystemBinding(cx, obj, id, &objp);
|
||||
*_retval = ResolveSystemBinding(cx, obj, id, &resolved);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
if (objp) {
|
||||
*objpArg = objp;
|
||||
if (resolved) {
|
||||
*resolvedp = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -105,7 +100,7 @@ BackstagePass::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
|
||||
*_retval = JS_EnumerateStandardClasses(cx, obj);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
JS::RootedObject ignored(cx);
|
||||
bool ignored = false;
|
||||
*_retval = ResolveSystemBinding(cx, obj, JSID_VOIDHANDLE, &ignored);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
|
@ -861,7 +861,7 @@ XPC_WN_Helper_NewResolve(JSContext *cx, HandleObject obj, HandleId id,
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
bool retval = true;
|
||||
RootedObject obj2FromScriptable(cx);
|
||||
bool resolved = false;
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
||||
@ -869,15 +869,14 @@ XPC_WN_Helper_NewResolve(JSContext *cx, HandleObject obj, HandleId id,
|
||||
RootedId old(cx, ccx.SetResolveName(id));
|
||||
|
||||
XPCNativeScriptableInfo* si = wrapper->GetScriptableInfo();
|
||||
if (si && si->GetFlags().WantNewResolve()) {
|
||||
if (si && si->GetFlags().WantResolve()) {
|
||||
XPCWrappedNative* oldResolvingWrapper;
|
||||
bool allowPropMods = si->GetFlags().AllowPropModsDuringResolve();
|
||||
|
||||
if (allowPropMods)
|
||||
oldResolvingWrapper = ccx.SetResolvingWrapper(wrapper);
|
||||
|
||||
rv = si->GetCallback()->NewResolve(wrapper, cx, obj, id,
|
||||
obj2FromScriptable.address(), &retval);
|
||||
rv = si->GetCallback()->Resolve(wrapper, cx, obj, id, &resolved, &retval);
|
||||
|
||||
if (allowPropMods)
|
||||
(void)ccx.SetResolvingWrapper(oldResolvingWrapper);
|
||||
@ -890,8 +889,8 @@ XPC_WN_Helper_NewResolve(JSContext *cx, HandleObject obj, HandleId id,
|
||||
return Throw(rv, cx);
|
||||
}
|
||||
|
||||
if (obj2FromScriptable) {
|
||||
objp.set(obj2FromScriptable);
|
||||
if (resolved) {
|
||||
objp.set(obj);
|
||||
} else if (wrapper->HasMutatedSet()) {
|
||||
// We are here if scriptable did not resolve this property and
|
||||
// it *might* be in the instance set but not the proto set.
|
||||
|
@ -1614,7 +1614,7 @@ public:
|
||||
bool WantSetProperty() GET_IT(WANT_SETPROPERTY)
|
||||
bool WantEnumerate() GET_IT(WANT_ENUMERATE)
|
||||
bool WantNewEnumerate() GET_IT(WANT_NEWENUMERATE)
|
||||
bool WantNewResolve() GET_IT(WANT_NEWRESOLVE)
|
||||
bool WantResolve() GET_IT(WANT_RESOLVE)
|
||||
bool WantConvert() GET_IT(WANT_CONVERT)
|
||||
bool WantFinalize() GET_IT(WANT_FINALIZE)
|
||||
bool WantCall() GET_IT(WANT_CALL)
|
||||
|
@ -40,7 +40,7 @@ NS_IMPL_ISUPPORTS(
|
||||
#define XPC_MAP_CLASSNAME AsyncStatementParams
|
||||
#define XPC_MAP_QUOTED_CLASSNAME "AsyncStatementParams"
|
||||
#define XPC_MAP_WANT_SETPROPERTY
|
||||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_RESOLVE
|
||||
#define XPC_MAP_FLAGS nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
|
||||
#include "xpc_map_end.h"
|
||||
|
||||
@ -87,14 +87,12 @@ AsyncStatementParams::SetProperty(
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
AsyncStatementParams::NewResolve(
|
||||
nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsid aId,
|
||||
JSObject **_objp,
|
||||
bool *_retval
|
||||
)
|
||||
AsyncStatementParams::Resolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsid aId,
|
||||
bool *aResolvedp,
|
||||
bool *_retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> scopeObj(aCtx, aScopeObj);
|
||||
|
||||
@ -121,7 +119,7 @@ AsyncStatementParams::NewResolve(
|
||||
}
|
||||
|
||||
*_retval = ok;
|
||||
*_objp = resolved && ok ? scopeObj.get() : nullptr;
|
||||
*aResolvedp = resolved && ok;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ NS_INTERFACE_MAP_END
|
||||
#define XPC_MAP_CLASSNAME StatementJSHelper
|
||||
#define XPC_MAP_QUOTED_CLASSNAME "StatementJSHelper"
|
||||
#define XPC_MAP_WANT_GETPROPERTY
|
||||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_RESOLVE
|
||||
#define XPC_MAP_FLAGS nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
|
||||
#include "xpc_map_end.h"
|
||||
|
||||
@ -212,12 +212,10 @@ StatementJSHelper::GetProperty(nsIXPConnectWrappedNative *aWrapper,
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
StatementJSHelper::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsid aId,
|
||||
JSObject **_objp,
|
||||
bool *_retval)
|
||||
StatementJSHelper::Resolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx, JSObject *aScopeObj,
|
||||
jsid aId, bool *aResolvedp,
|
||||
bool *_retval)
|
||||
{
|
||||
if (!JSID_IS_STRING(aId))
|
||||
return NS_OK;
|
||||
@ -226,7 +224,7 @@ StatementJSHelper::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
if (::JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(aId), "step")) {
|
||||
*_retval = ::JS_DefineFunction(aCtx, scope, "step", stepFunc,
|
||||
0, 0) != nullptr;
|
||||
*_objp = scope.get();
|
||||
*aResolvedp = true;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -40,7 +40,7 @@ NS_IMPL_ISUPPORTS(
|
||||
#define XPC_MAP_QUOTED_CLASSNAME "StatementParams"
|
||||
#define XPC_MAP_WANT_SETPROPERTY
|
||||
#define XPC_MAP_WANT_NEWENUMERATE
|
||||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_RESOLVE
|
||||
#define XPC_MAP_FLAGS nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
|
||||
#include "xpc_map_end.h"
|
||||
|
||||
@ -156,12 +156,12 @@ StatementParams::NewEnumerate(nsIXPConnectWrappedNative *aWrapper,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StatementParams::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsid aId,
|
||||
JSObject **_objp,
|
||||
bool *_retval)
|
||||
StatementParams::Resolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsid aId,
|
||||
bool *resolvedp,
|
||||
bool *_retval)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStatement, NS_ERROR_NOT_INITIALIZED);
|
||||
// We do not throw at any point after this unless our index is out of range
|
||||
@ -202,7 +202,7 @@ StatementParams::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
}
|
||||
|
||||
*_retval = ok;
|
||||
*_objp = resolved && ok ? scope.get() : nullptr;
|
||||
*resolvedp = resolved && ok;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ NS_IMPL_ISUPPORTS(
|
||||
#define XPC_MAP_CLASSNAME StatementRow
|
||||
#define XPC_MAP_QUOTED_CLASSNAME "StatementRow"
|
||||
#define XPC_MAP_WANT_GETPROPERTY
|
||||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_RESOLVE
|
||||
#define XPC_MAP_FLAGS nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
|
||||
#include "xpc_map_end.h"
|
||||
|
||||
@ -113,12 +113,12 @@ StatementRow::GetProperty(nsIXPConnectWrappedNative *aWrapper,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StatementRow::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsid aId,
|
||||
JSObject **_objp,
|
||||
bool *_retval)
|
||||
StatementRow::Resolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCtx,
|
||||
JSObject *aScopeObj,
|
||||
jsid aId,
|
||||
bool *aResolvedp,
|
||||
bool *_retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> scopeObj(aCtx, aScopeObj);
|
||||
|
||||
@ -137,13 +137,13 @@ StatementRow::NewResolve(nsIXPConnectWrappedNative *aWrapper,
|
||||
// It's highly likely that the name doesn't exist, so let the JS engine
|
||||
// check the prototype chain and throw if that doesn't have the property
|
||||
// either.
|
||||
*_objp = nullptr;
|
||||
*aResolvedp = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JS::Rooted<jsid> id(aCtx, aId);
|
||||
*_retval = ::JS_DefinePropertyById(aCtx, scopeObj, id, JS::UndefinedHandleValue, 0);
|
||||
*_objp = scopeObj;
|
||||
*aResolvedp = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user