Backed out changeset 9017975d0201 (bug 1132187)

This commit is contained in:
Wes Kocher 2015-02-13 13:25:32 -08:00
parent f46e783bd1
commit 2ab517f73f
5 changed files with 41 additions and 3 deletions

View File

@ -977,6 +977,16 @@ nsDOMClassInfo::Resolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
NS_IMETHODIMP
nsDOMClassInfo::Convert(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, uint32_t type, jsval *vp,
bool *_retval)
{
NS_WARNING("nsDOMClassInfo::Convert Don't call me!");
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
nsDOMClassInfo::Finalize(nsIXPConnectWrappedNative *wrapper, JSFreeOp *fop,
JSObject *obj)

View File

@ -32,7 +32,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(402bf112-6d3b-431f-bb0f-d05ec183ee7b)]
[uuid(bdefff68-b286-449c-af13-bebc7dd25af7)]
interface nsIXPCScriptable : nsISupports
{
/* bitflags used for 'flags' (only 32 bits available!) */
@ -47,7 +47,7 @@ interface nsIXPCScriptable : nsISupports
const uint32_t WANT_ENUMERATE = 1 << 7;
const uint32_t WANT_NEWENUMERATE = 1 << 8;
const uint32_t WANT_RESOLVE = 1 << 9;
// unused bit here
const uint32_t WANT_CONVERT = 1 << 10;
const uint32_t WANT_FINALIZE = 1 << 11;
// unused bit here!
const uint32_t WANT_CALL = 1 << 13;
@ -104,6 +104,10 @@ interface nsIXPCScriptable : nsISupports
in JSContextPtr cx, in JSObjectPtr obj, in jsid id,
out boolean resolvedp);
boolean convert(in nsIXPConnectWrappedNative wrapper,
in JSContextPtr cx, in JSObjectPtr obj,
in uint32_t type, in JSValPtr vp);
void finalize(in nsIXPConnectWrappedNative wrapper,
in JSFreeOpPtr fop, in JSObjectPtr obj);

View File

@ -52,6 +52,9 @@ XPC_MAP_CLASSNAME::GetScriptableFlags()
#ifdef XPC_MAP_WANT_RESOLVE
nsIXPCScriptable::WANT_RESOLVE |
#endif
#ifdef XPC_MAP_WANT_CONVERT
nsIXPCScriptable::WANT_CONVERT |
#endif
#ifdef XPC_MAP_WANT_FINALIZE
nsIXPCScriptable::WANT_FINALIZE |
#endif
@ -108,6 +111,11 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::Resolve(nsIXPConnectWrappedNative *wrapper, JSC
{NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
#endif
#ifndef XPC_MAP_WANT_CONVERT
NS_IMETHODIMP XPC_MAP_CLASSNAME::Convert(nsIXPConnectWrappedNative *wrapper, JSContext * cx, JSObject * obj, uint32_t type, JS::Value * vp, bool *_retval)
{NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
#endif
#ifndef XPC_MAP_WANT_FINALIZE
NS_IMETHODIMP XPC_MAP_CLASSNAME::Finalize(nsIXPConnectWrappedNative *wrapper, JSFreeOp * fop, JSObject * obj)
{NS_ERROR("never called"); return NS_ERROR_NOT_IMPLEMENTED;}
@ -166,6 +174,10 @@ NS_IMETHODIMP XPC_MAP_CLASSNAME::PostCreatePrototype(JSContext *cx, JSObject *pr
#undef XPC_MAP_WANT_RESOLVE
#endif
#ifdef XPC_MAP_WANT_CONVERT
#undef XPC_MAP_WANT_CONVERT
#endif
#ifdef XPC_MAP_WANT_FINALIZE
#undef XPC_MAP_WANT_FINALIZE
#endif

View File

@ -780,6 +780,14 @@ XPC_WN_Helper_SetProperty(JSContext *cx, HandleObject obj, HandleId id, bool str
POST_HELPER_STUB
}
static bool
XPC_WN_Helper_Convert(JSContext *cx, HandleObject obj, JSType type, MutableHandleValue vp)
{
PRE_HELPER_STUB
Convert(wrapper, cx, obj, type, vp.address(), &retval);
POST_HELPER_STUB
}
static bool
XPC_WN_Helper_Call(JSContext *cx, unsigned argc, jsval *vp)
{
@ -1048,7 +1056,10 @@ XPCNativeScriptableShared::PopulateJSClass()
// We have to figure out resolve strategy at call time
mJSClass.base.resolve = XPC_WN_Helper_Resolve;
mJSClass.base.convert = XPC_WN_Shared_Convert;
if (mFlags.WantConvert())
mJSClass.base.convert = XPC_WN_Helper_Convert;
else
mJSClass.base.convert = XPC_WN_Shared_Convert;
if (mFlags.WantFinalize())
mJSClass.base.finalize = XPC_WN_Helper_Finalize;

View File

@ -1619,6 +1619,7 @@ public:
bool WantEnumerate() GET_IT(WANT_ENUMERATE)
bool WantNewEnumerate() GET_IT(WANT_NEWENUMERATE)
bool WantResolve() GET_IT(WANT_RESOLVE)
bool WantConvert() GET_IT(WANT_CONVERT)
bool WantFinalize() GET_IT(WANT_FINALIZE)
bool WantCall() GET_IT(WANT_CALL)
bool WantConstruct() GET_IT(WANT_CONSTRUCT)