mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 14:25:52 +00:00
Bug 1444745 - Part 5: Update consumers of nsIInterfaceInfo to use the nsXPTInterfaceInfo directly, r=mccr8
Due to the decision to keep the old API on nsXPTInterfaceInfo in part 4, this is a fairly straightforward patch. 1. I had to change a couple of consumers of `IsRetval()` due to the movement of that flag. 2. I changed all code which held a nsIInterfaceInfo to hold an `const nsXPTInterfaceInfo*` instead. 3. I changed code which used the nsIInterfaceInfoManager to instead call the static methods on nsXPTInterfaceInfo.
This commit is contained in:
parent
04547a4a00
commit
14da321a67
@ -34,6 +34,7 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsTextNode.h"
|
||||
#include "nsIScriptError.h"
|
||||
|
||||
#include "nsXBLResourceLoader.h"
|
||||
@ -707,13 +708,6 @@ nsresult
|
||||
nsXBLPrototypeBinding::ConstructInterfaceTable(const nsAString& aImpls)
|
||||
{
|
||||
if (!aImpls.IsEmpty()) {
|
||||
// Obtain the interface info manager that can tell us the IID
|
||||
// for a given interface name.
|
||||
nsCOMPtr<nsIInterfaceInfoManager>
|
||||
infoManager(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
||||
if (!infoManager)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// The user specified at least one attribute.
|
||||
NS_ConvertUTF16toUTF8 utf8impl(aImpls);
|
||||
char* str = utf8impl.BeginWriting();
|
||||
@ -724,8 +718,7 @@ nsXBLPrototypeBinding::ConstructInterfaceTable(const nsAString& aImpls)
|
||||
char* token = nsCRT::strtok( str, ", ", &newStr );
|
||||
while( token != nullptr ) {
|
||||
// get the InterfaceInfo for the name
|
||||
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
||||
infoManager->GetInfoForName(token, getter_AddRefs(iinfo));
|
||||
const nsXPTInterfaceInfo* iinfo = nsXPTInterfaceInfo::ByName(token);
|
||||
|
||||
if (iinfo) {
|
||||
// obtain an IID.
|
||||
@ -738,9 +731,9 @@ nsXBLPrototypeBinding::ConstructInterfaceTable(const nsAString& aImpls)
|
||||
|
||||
// this block adds the parent interfaces of each interface
|
||||
// defined in the xbl definition (implements="nsI...")
|
||||
nsCOMPtr<nsIInterfaceInfo> parentInfo;
|
||||
const nsXPTInterfaceInfo* parentInfo;
|
||||
// if it has a parent, add it to the table
|
||||
while (NS_SUCCEEDED(iinfo->GetParent(getter_AddRefs(parentInfo))) && parentInfo) {
|
||||
while (NS_SUCCEEDED(iinfo->GetParent(&parentInfo)) && parentInfo) {
|
||||
// get the iid
|
||||
parentInfo->GetIIDShared(&iid);
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "jspubtd.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "xptinfo.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsWrapperCache;
|
||||
@ -26,11 +27,11 @@ class nsWrapperCache;
|
||||
[ptr] native JSScriptPtr(JSScript);
|
||||
[ptr] native nsWrapperCachePtr(nsWrapperCache);
|
||||
native JSHandleId(JS::Handle<jsid>);
|
||||
[ptr] native InterfaceInfoPtr(const nsXPTInterfaceInfo);
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
// forward declarations...
|
||||
interface nsIInterfaceInfo;
|
||||
interface nsIPrincipal;
|
||||
interface nsIClassInfo;
|
||||
interface nsIVariant;
|
||||
@ -87,7 +88,7 @@ do_QueryWrappedNative(nsIXPConnectWrappedNative *aWrappedNative,
|
||||
interface nsIXPConnectWrappedJS : nsIXPConnectJSObjectHolder
|
||||
{
|
||||
/* attribute 'JSObject' inherited from nsIXPConnectJSObjectHolder */
|
||||
readonly attribute nsIInterfaceInfo InterfaceInfo;
|
||||
readonly attribute InterfaceInfoPtr InterfaceInfo;
|
||||
readonly attribute nsIIDPtr InterfaceIID;
|
||||
|
||||
void debugDump(in short depth);
|
||||
|
@ -199,39 +199,33 @@ nsXPCComponents_Interfaces::NewEnumerate(nsIXPConnectWrappedNative* wrapper,
|
||||
bool* _retval)
|
||||
{
|
||||
|
||||
// Lazily init the list of interfaces when someone tries to
|
||||
// enumerate them.
|
||||
if (mInterfaces.IsEmpty()) {
|
||||
XPTInterfaceInfoManager::GetSingleton()->
|
||||
GetScriptableInterfaces(mInterfaces);
|
||||
}
|
||||
|
||||
if (!properties.reserve(mInterfaces.Length())) {
|
||||
if (!properties.reserve(nsXPTInterfaceInfo::InterfaceCount())) {
|
||||
*_retval = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
for (uint32_t index = 0; index < mInterfaces.Length(); index++) {
|
||||
nsIInterfaceInfo* interface = mInterfaces.SafeElementAt(index);
|
||||
for (uint32_t index = 0; index < nsXPTInterfaceInfo::InterfaceCount(); index++) {
|
||||
const nsXPTInterfaceInfo* interface = nsXPTInterfaceInfo::ByIndex(index);
|
||||
if (!interface)
|
||||
continue;
|
||||
|
||||
const char* name;
|
||||
if (NS_SUCCEEDED(interface->GetNameShared(&name)) && name) {
|
||||
RootedString idstr(cx, JS_NewStringCopyZ(cx, name));
|
||||
if (!idstr) {
|
||||
*_retval = false;
|
||||
return NS_OK;
|
||||
}
|
||||
const char* name = interface->Name();
|
||||
if (!name)
|
||||
continue;
|
||||
|
||||
RootedId id(cx);
|
||||
if (!JS_StringToId(cx, idstr, &id)) {
|
||||
*_retval = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
properties.infallibleAppend(id);
|
||||
RootedString idstr(cx, JS_NewStringCopyZ(cx, name));
|
||||
if (!idstr) {
|
||||
*_retval = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RootedId id(cx);
|
||||
if (!JS_StringToId(cx, idstr, &id)) {
|
||||
*_retval = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
properties.infallibleAppend(id);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -254,12 +248,7 @@ nsXPCComponents_Interfaces::Resolve(nsIXPConnectWrappedNative* wrapper,
|
||||
|
||||
// we only allow interfaces by name here
|
||||
if (name.encodeLatin1(cx, str) && name.ptr()[0] != '{') {
|
||||
nsCOMPtr<nsIInterfaceInfo> info =
|
||||
ShimInterfaceInfo::MaybeConstruct(name.ptr(), cx);
|
||||
if (!info) {
|
||||
XPTInterfaceInfoManager::GetSingleton()->
|
||||
GetInfoForName(name.ptr(), getter_AddRefs(info));
|
||||
}
|
||||
const nsXPTInterfaceInfo* info = nsXPTInterfaceInfo::ByName(name.ptr());
|
||||
if (!info)
|
||||
return NS_OK;
|
||||
|
||||
@ -393,39 +382,31 @@ nsXPCComponents_InterfacesByID::NewEnumerate(nsIXPConnectWrappedNative* wrapper,
|
||||
bool* _retval)
|
||||
{
|
||||
|
||||
if (mInterfaces.IsEmpty()) {
|
||||
XPTInterfaceInfoManager::GetSingleton()->
|
||||
GetScriptableInterfaces(mInterfaces);
|
||||
}
|
||||
|
||||
if (!properties.reserve(mInterfaces.Length())) {
|
||||
if (!properties.reserve(nsXPTInterfaceInfo::InterfaceCount())) {
|
||||
*_retval = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
for (uint32_t index = 0; index < mInterfaces.Length(); index++) {
|
||||
nsIInterfaceInfo* interface = mInterfaces.SafeElementAt(index);
|
||||
for (uint32_t index = 0; index < nsXPTInterfaceInfo::InterfaceCount(); index++) {
|
||||
const nsXPTInterfaceInfo* interface = nsXPTInterfaceInfo::ByIndex(index);
|
||||
if (!interface)
|
||||
continue;
|
||||
|
||||
nsIID const* iid;
|
||||
if (NS_SUCCEEDED(interface->GetIIDShared(&iid))) {
|
||||
char idstr[NSID_LENGTH];
|
||||
iid->ToProvidedString(idstr);
|
||||
RootedString jsstr(cx, JS_NewStringCopyZ(cx, idstr));
|
||||
if (!jsstr) {
|
||||
*_retval = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RootedId id(cx);
|
||||
if (!JS_StringToId(cx, jsstr, &id)) {
|
||||
*_retval = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
properties.infallibleAppend(id);
|
||||
char idstr[NSID_LENGTH];
|
||||
interface->IID().ToProvidedString(idstr);
|
||||
RootedString jsstr(cx, JS_NewStringCopyZ(cx, idstr));
|
||||
if (!jsstr) {
|
||||
*_retval = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RootedId id(cx);
|
||||
if (!JS_StringToId(cx, jsstr, &id)) {
|
||||
*_retval = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
properties.infallibleAppend(id);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -453,9 +434,7 @@ nsXPCComponents_InterfacesByID::Resolve(nsIXPConnectWrappedNative* wrapper,
|
||||
if (!iid.Parse(utf8str.ptr()))
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
XPTInterfaceInfoManager::GetSingleton()->
|
||||
GetInfoForIID(&iid, getter_AddRefs(info));
|
||||
const nsXPTInterfaceInfo* info = nsXPTInterfaceInfo::ByIID(iid);
|
||||
if (!info)
|
||||
return NS_OK;
|
||||
|
||||
@ -1932,8 +1911,8 @@ nsXPCComponents_Constructor::CallOrConstruct(nsIXPConnectWrappedNative* wrapper,
|
||||
return ThrowAndFail(NS_ERROR_XPC_UNEXPECTED, cx, _retval);
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
xpc->GetInfoForIID(&NS_GET_IID(nsISupports), getter_AddRefs(info));
|
||||
const nsXPTInterfaceInfo* info =
|
||||
nsXPTInterfaceInfo::ByIID(NS_GET_IID(nsISupports));
|
||||
|
||||
if (info) {
|
||||
cInterfaceID = nsJSIID::NewID(info);
|
||||
|
@ -1365,7 +1365,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
|
||||
switch (JS_GetArrayBufferViewType(jsArray)) {
|
||||
case js::Scalar::Int8:
|
||||
output = CheckTargetAndPopulate(nsXPTType::T_I8, type,
|
||||
output = CheckTargetAndPopulate({ nsXPTType::T_I8 }, type,
|
||||
sizeof(int8_t), count,
|
||||
jsArray, pErr);
|
||||
if (!output) {
|
||||
@ -1375,7 +1375,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
|
||||
case js::Scalar::Uint8:
|
||||
case js::Scalar::Uint8Clamped:
|
||||
output = CheckTargetAndPopulate(nsXPTType::T_U8, type,
|
||||
output = CheckTargetAndPopulate({ nsXPTType::T_U8 }, type,
|
||||
sizeof(uint8_t), count,
|
||||
jsArray, pErr);
|
||||
if (!output) {
|
||||
@ -1384,7 +1384,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
break;
|
||||
|
||||
case js::Scalar::Int16:
|
||||
output = CheckTargetAndPopulate(nsXPTType::T_I16, type,
|
||||
output = CheckTargetAndPopulate({ nsXPTType::T_I16 }, type,
|
||||
sizeof(int16_t), count,
|
||||
jsArray, pErr);
|
||||
if (!output) {
|
||||
@ -1393,7 +1393,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
break;
|
||||
|
||||
case js::Scalar::Uint16:
|
||||
output = CheckTargetAndPopulate(nsXPTType::T_U16, type,
|
||||
output = CheckTargetAndPopulate({ nsXPTType::T_U16 }, type,
|
||||
sizeof(uint16_t), count,
|
||||
jsArray, pErr);
|
||||
if (!output) {
|
||||
@ -1402,7 +1402,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
break;
|
||||
|
||||
case js::Scalar::Int32:
|
||||
output = CheckTargetAndPopulate(nsXPTType::T_I32, type,
|
||||
output = CheckTargetAndPopulate({ nsXPTType::T_I32 }, type,
|
||||
sizeof(int32_t), count,
|
||||
jsArray, pErr);
|
||||
if (!output) {
|
||||
@ -1411,7 +1411,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
break;
|
||||
|
||||
case js::Scalar::Uint32:
|
||||
output = CheckTargetAndPopulate(nsXPTType::T_U32, type,
|
||||
output = CheckTargetAndPopulate({ nsXPTType::T_U32 }, type,
|
||||
sizeof(uint32_t), count,
|
||||
jsArray, pErr);
|
||||
if (!output) {
|
||||
@ -1420,7 +1420,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
break;
|
||||
|
||||
case js::Scalar::Float32:
|
||||
output = CheckTargetAndPopulate(nsXPTType::T_FLOAT, type,
|
||||
output = CheckTargetAndPopulate({ nsXPTType::T_FLOAT }, type,
|
||||
sizeof(float), count,
|
||||
jsArray, pErr);
|
||||
if (!output) {
|
||||
@ -1429,7 +1429,7 @@ XPCConvert::JSTypedArray2Native(void** d,
|
||||
break;
|
||||
|
||||
case js::Scalar::Float64:
|
||||
output = CheckTargetAndPopulate(nsXPTType::T_DOUBLE, type,
|
||||
output = CheckTargetAndPopulate({ nsXPTType::T_DOUBLE }, type,
|
||||
sizeof(double), count,
|
||||
jsArray, pErr);
|
||||
if (!output) {
|
||||
|
@ -287,7 +287,7 @@ NS_IMPL_CI_INTERFACE_GETTER(nsJSIID, nsIJSID, nsIJSIID)
|
||||
#include "xpc_map_end.h" /* This will #undef the above */
|
||||
|
||||
|
||||
nsJSIID::nsJSIID(nsIInterfaceInfo* aInfo)
|
||||
nsJSIID::nsJSIID(const nsXPTInterfaceInfo* aInfo)
|
||||
: mInfo(aInfo)
|
||||
{
|
||||
}
|
||||
@ -350,15 +350,14 @@ NS_IMETHODIMP nsJSIID::ToString(char** _retval)
|
||||
|
||||
// static
|
||||
already_AddRefed<nsJSIID>
|
||||
nsJSIID::NewID(nsIInterfaceInfo* aInfo)
|
||||
nsJSIID::NewID(const nsXPTInterfaceInfo* aInfo)
|
||||
{
|
||||
if (!aInfo) {
|
||||
NS_ERROR("no info");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool canScript;
|
||||
if (NS_FAILED(aInfo->IsScriptable(&canScript)) || !canScript)
|
||||
if (!aInfo->IsScriptable())
|
||||
return nullptr;
|
||||
|
||||
RefPtr<nsJSIID> idObj = new nsJSIID(aInfo);
|
||||
|
@ -218,28 +218,28 @@ XPCArrayHomogenizer::GetTypeForArray(JSContext* cx, HandleObject array,
|
||||
|
||||
switch (state) {
|
||||
case tInt :
|
||||
*resultType = nsXPTType((uint8_t)TD_INT32);
|
||||
*resultType = TD_INT32;
|
||||
break;
|
||||
case tDbl :
|
||||
*resultType = nsXPTType((uint8_t)TD_DOUBLE);
|
||||
*resultType = TD_DOUBLE;
|
||||
break;
|
||||
case tBool:
|
||||
*resultType = nsXPTType((uint8_t)TD_BOOL);
|
||||
*resultType = TD_BOOL;
|
||||
break;
|
||||
case tStr :
|
||||
*resultType = nsXPTType((uint8_t)TD_PWSTRING);
|
||||
*resultType = TD_PWSTRING;
|
||||
break;
|
||||
case tID :
|
||||
*resultType = nsXPTType((uint8_t)TD_PNSIID);
|
||||
*resultType = TD_PNSIID;
|
||||
break;
|
||||
case tISup:
|
||||
*resultType = nsXPTType((uint8_t)TD_INTERFACE_IS_TYPE);
|
||||
*resultType = TD_INTERFACE_IS_TYPE;
|
||||
*resultID = NS_GET_IID(nsISupports);
|
||||
break;
|
||||
case tNull:
|
||||
// FALL THROUGH
|
||||
case tVar :
|
||||
*resultType = nsXPTType((uint8_t)TD_INTERFACE_IS_TYPE);
|
||||
*resultType = TD_INTERFACE_IS_TYPE;
|
||||
*resultID = NS_GET_IID(nsIVariant);
|
||||
break;
|
||||
case tArr :
|
||||
@ -453,21 +453,21 @@ XPCVariant::VariantDataToJS(nsIVariant* variant,
|
||||
char c;
|
||||
if (NS_FAILED(variant->GetAsChar(&c)))
|
||||
return false;
|
||||
return XPCConvert::NativeData2JS(pJSVal, (const void*)&c, TD_CHAR, &iid, pErr);
|
||||
return XPCConvert::NativeData2JS(pJSVal, (const void*)&c, { TD_CHAR }, &iid, pErr);
|
||||
}
|
||||
case nsIDataType::VTYPE_WCHAR:
|
||||
{
|
||||
char16_t wc;
|
||||
if (NS_FAILED(variant->GetAsWChar(&wc)))
|
||||
return false;
|
||||
return XPCConvert::NativeData2JS(pJSVal, (const void*)&wc, TD_WCHAR, &iid, pErr);
|
||||
return XPCConvert::NativeData2JS(pJSVal, (const void*)&wc, { TD_WCHAR }, &iid, pErr);
|
||||
}
|
||||
case nsIDataType::VTYPE_ID:
|
||||
{
|
||||
if (NS_FAILED(variant->GetAsID(&iid)))
|
||||
return false;
|
||||
nsID* v = &iid;
|
||||
return XPCConvert::NativeData2JS(pJSVal, (const void*)&v, TD_PNSIID, &iid, pErr);
|
||||
return XPCConvert::NativeData2JS(pJSVal, (const void*)&v, { TD_PNSIID }, &iid, pErr);
|
||||
}
|
||||
case nsIDataType::VTYPE_ASTRING:
|
||||
{
|
||||
@ -475,7 +475,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant,
|
||||
if (NS_FAILED(variant->GetAsAString(astring)))
|
||||
return false;
|
||||
nsAutoString* v = &astring;
|
||||
return XPCConvert::NativeData2JS(pJSVal, (const void*)&v, TD_ASTRING, &iid, pErr);
|
||||
return XPCConvert::NativeData2JS(pJSVal, (const void*)&v, { TD_ASTRING }, &iid, pErr);
|
||||
}
|
||||
case nsIDataType::VTYPE_DOMSTRING:
|
||||
{
|
||||
@ -484,7 +484,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant,
|
||||
return false;
|
||||
nsAutoString* v = &astring;
|
||||
return XPCConvert::NativeData2JS(pJSVal, (const void*)&v,
|
||||
TD_DOMSTRING, &iid, pErr);
|
||||
{ TD_DOMSTRING }, &iid, pErr);
|
||||
}
|
||||
case nsIDataType::VTYPE_CSTRING:
|
||||
{
|
||||
@ -493,7 +493,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant,
|
||||
return false;
|
||||
nsAutoCString* v = &cString;
|
||||
return XPCConvert::NativeData2JS(pJSVal, (const void*)&v,
|
||||
TD_CSTRING, &iid, pErr);
|
||||
{ TD_CSTRING }, &iid, pErr);
|
||||
}
|
||||
case nsIDataType::VTYPE_UTF8STRING:
|
||||
{
|
||||
@ -502,7 +502,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant,
|
||||
return false;
|
||||
nsUTF8String* v = &utf8String;
|
||||
return XPCConvert::NativeData2JS(pJSVal, (const void*)&v,
|
||||
TD_UTF8STRING, &iid, pErr);
|
||||
{ TD_UTF8STRING }, &iid, pErr);
|
||||
}
|
||||
case nsIDataType::VTYPE_CHAR_STR:
|
||||
{
|
||||
@ -510,7 +510,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant,
|
||||
if (NS_FAILED(variant->GetAsString(&pc)))
|
||||
return false;
|
||||
bool success = XPCConvert::NativeData2JS(pJSVal, (const void*)&pc,
|
||||
TD_PSTRING, &iid, pErr);
|
||||
{ TD_PSTRING }, &iid, pErr);
|
||||
free(pc);
|
||||
return success;
|
||||
}
|
||||
@ -521,7 +521,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant,
|
||||
if (NS_FAILED(variant->GetAsStringWithSize(&size, &pc)))
|
||||
return false;
|
||||
bool success = XPCConvert::NativeStringWithSize2JS(pJSVal, (const void*)&pc,
|
||||
TD_PSTRING_SIZE_IS, size, pErr);
|
||||
{ TD_PSTRING_SIZE_IS }, size, pErr);
|
||||
free(pc);
|
||||
return success;
|
||||
}
|
||||
@ -531,7 +531,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant,
|
||||
if (NS_FAILED(variant->GetAsWString(&pwc)))
|
||||
return false;
|
||||
bool success = XPCConvert::NativeData2JS(pJSVal, (const void*)&pwc,
|
||||
TD_PSTRING, &iid, pErr);
|
||||
{ TD_PSTRING }, &iid, pErr);
|
||||
free(pwc);
|
||||
return success;
|
||||
}
|
||||
@ -542,7 +542,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant,
|
||||
if (NS_FAILED(variant->GetAsWStringWithSize(&size, &pwc)))
|
||||
return false;
|
||||
bool success = XPCConvert::NativeStringWithSize2JS(pJSVal, (const void*)&pwc,
|
||||
TD_PWSTRING_SIZE_IS, size, pErr);
|
||||
{ TD_PWSTRING_SIZE_IS }, size, pErr);
|
||||
free(pwc);
|
||||
return success;
|
||||
}
|
||||
@ -558,7 +558,7 @@ XPCVariant::VariantDataToJS(nsIVariant* variant,
|
||||
free((char*)piid);
|
||||
|
||||
bool success = XPCConvert::NativeData2JS(pJSVal, (const void*)&pi,
|
||||
TD_INTERFACE_IS_TYPE, &iid, pErr);
|
||||
{ TD_INTERFACE_IS_TYPE }, &iid, pErr);
|
||||
if (pi)
|
||||
pi->Release();
|
||||
return success;
|
||||
@ -596,23 +596,23 @@ XPCVariant::VariantDataToJS(nsIVariant* variant,
|
||||
case nsIDataType::VTYPE_BOOL:
|
||||
case nsIDataType::VTYPE_CHAR:
|
||||
case nsIDataType::VTYPE_WCHAR:
|
||||
conversionType = nsXPTType((uint8_t)elementType);
|
||||
conversionType = (uint8_t)elementType;
|
||||
break;
|
||||
|
||||
case nsIDataType::VTYPE_ID:
|
||||
case nsIDataType::VTYPE_CHAR_STR:
|
||||
case nsIDataType::VTYPE_WCHAR_STR:
|
||||
conversionType = nsXPTType((uint8_t)elementType);
|
||||
conversionType = (uint8_t)elementType;
|
||||
break;
|
||||
|
||||
case nsIDataType::VTYPE_INTERFACE:
|
||||
pid = &NS_GET_IID(nsISupports);
|
||||
conversionType = nsXPTType((uint8_t)elementType);
|
||||
conversionType = (uint8_t)elementType;
|
||||
break;
|
||||
|
||||
case nsIDataType::VTYPE_INTERFACE_IS:
|
||||
pid = &du.u.array.mArrayInterfaceID;
|
||||
conversionType = nsXPTType((uint8_t)elementType);
|
||||
conversionType = (uint8_t)elementType;
|
||||
break;
|
||||
|
||||
// The rest are illegal.
|
||||
|
@ -585,7 +585,7 @@ nsXPCWrappedJS::FindInherited(REFNSIID aIID)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPCWrappedJS::GetInterfaceInfo(nsIInterfaceInfo** infoResult)
|
||||
nsXPCWrappedJS::GetInterfaceInfo(const nsXPTInterfaceInfo** infoResult)
|
||||
{
|
||||
MOZ_ASSERT(GetClass(), "wrapper without class");
|
||||
MOZ_ASSERT(GetClass()->GetInterfaceInfo(), "wrapper class without interface");
|
||||
@ -593,11 +593,8 @@ nsXPCWrappedJS::GetInterfaceInfo(nsIInterfaceInfo** infoResult)
|
||||
// Since failing to get this info will crash some platforms(!), we keep
|
||||
// mClass valid at shutdown time.
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> info = GetClass()->GetInterfaceInfo();
|
||||
if (!info)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
info.forget(infoResult);
|
||||
return NS_OK;
|
||||
*infoResult = GetClass()->GetInterfaceInfo();
|
||||
return *infoResult ? NS_OK : NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -113,8 +113,7 @@ nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID, bool allowNonScr
|
||||
RefPtr<nsXPCWrappedJSClass> clasp = map->Find(aIID);
|
||||
|
||||
if (!clasp) {
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
nsXPConnect::XPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
||||
const nsXPTInterfaceInfo* info = nsXPTInterfaceInfo::ByIID(aIID);
|
||||
if (info) {
|
||||
bool canScript, isBuiltin;
|
||||
if (NS_SUCCEEDED(info->IsScriptable(&canScript)) && (canScript || allowNonScriptable) &&
|
||||
@ -131,7 +130,7 @@ nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID, bool allowNonScr
|
||||
}
|
||||
|
||||
nsXPCWrappedJSClass::nsXPCWrappedJSClass(JSContext* cx, REFNSIID aIID,
|
||||
nsIInterfaceInfo* aInfo)
|
||||
const nsXPTInterfaceInfo* aInfo)
|
||||
: mRuntime(nsXPConnect::GetRuntimeInstance()),
|
||||
mInfo(aInfo),
|
||||
mName(nullptr),
|
||||
@ -225,14 +224,12 @@ nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx,
|
||||
if (!aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
bool allowNonScriptable = mozilla::jsipc::IsWrappedCPOW(jsobj);
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
nsXPConnect::XPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
||||
if (!info)
|
||||
return nullptr;
|
||||
bool canScript, isBuiltin;
|
||||
if (NS_FAILED(info->IsScriptable(&canScript)) || (!canScript && !allowNonScriptable) ||
|
||||
NS_FAILED(info->IsBuiltinClass(&isBuiltin)) || isBuiltin)
|
||||
const nsXPTInterfaceInfo* info = nsXPTInterfaceInfo::ByIID(aIID);
|
||||
if (!info || info->IsBuiltinClass() ||
|
||||
(!info->IsScriptable() && !allowNonScriptable))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
id = xpc_NewIDObject(cx, jsobj, aIID);
|
||||
@ -295,7 +292,7 @@ GetNamedPropertyAsVariantRaw(XPCCallContext& ccx,
|
||||
nsIVariant** aResult,
|
||||
nsresult* pErr)
|
||||
{
|
||||
nsXPTType type = nsXPTType((uint8_t)TD_INTERFACE_TYPE);
|
||||
nsXPTType type = { TD_INTERFACE_TYPE };
|
||||
RootedValue val(ccx);
|
||||
|
||||
return JS_GetPropertyById(ccx, aJSObj, aName, &val) &&
|
||||
@ -490,7 +487,7 @@ GetFunctionName(JSContext* cx, HandleObject obj)
|
||||
if (funName) {
|
||||
nsCString* displayNamePtr = &displayName;
|
||||
RootedValue funNameVal(cx, StringValue(funName));
|
||||
if (!XPCConvert::JSData2Native(&displayNamePtr, funNameVal, nsXPTType::T_UTF8STRING,
|
||||
if (!XPCConvert::JSData2Native(&displayNamePtr, funNameVal, { nsXPTType::T_UTF8STRING },
|
||||
nullptr, nullptr))
|
||||
{
|
||||
JS_ClearPendingException(cx);
|
||||
@ -587,10 +584,8 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
||||
// Check if the desired interface is a function interface. If so, we don't
|
||||
// want to QI, because the function almost certainly doesn't have a QueryInterface
|
||||
// property, and doesn't need one.
|
||||
bool isFunc = false;
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
nsXPConnect::XPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
||||
if (info && NS_SUCCEEDED(info->IsFunction(&isFunc)) && isFunc) {
|
||||
const nsXPTInterfaceInfo* info = nsXPTInterfaceInfo::ByIID(aIID);
|
||||
if (info && info->IsFunction()) {
|
||||
RefPtr<nsXPCWrappedJS> wrapper;
|
||||
RootedObject obj(RootingCx(), self->GetJSObject());
|
||||
nsresult rv = nsXPCWrappedJS::GetNewOrUsed(obj, aIID, getter_AddRefs(wrapper));
|
||||
@ -1031,7 +1026,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
|
||||
// XXX ASSUMES that retval is last arg. The xpidl compiler ensures this.
|
||||
uint8_t paramCount = info->GetParamCount();
|
||||
uint8_t argc = paramCount;
|
||||
if (paramCount > 0 && info->GetParam(paramCount - 1).IsRetval()) {
|
||||
if (info->HasRetval()) {
|
||||
argc -= 1;
|
||||
}
|
||||
|
||||
@ -1263,7 +1258,7 @@ pre_call_clean_up:
|
||||
else
|
||||
pv = (nsXPTCMiniVariant*) nativeParams[i].val.p;
|
||||
|
||||
if (param.IsRetval())
|
||||
if (¶m == info->GetRetval())
|
||||
val = rval;
|
||||
else if (argv[i].isPrimitive())
|
||||
break;
|
||||
@ -1312,7 +1307,7 @@ pre_call_clean_up:
|
||||
|
||||
pv = (nsXPTCMiniVariant*) nativeParams[i].val.p;
|
||||
|
||||
if (param.IsRetval())
|
||||
if (¶m == info->GetRetval())
|
||||
val = rval;
|
||||
else {
|
||||
RootedObject obj(cx, &argv[i].toObject());
|
||||
@ -1419,14 +1414,14 @@ nsXPCWrappedJSClass::DebugDump(int16_t depth)
|
||||
XPC_LOG_ALWAYS(("IID number is %s", iid ? iid : "invalid"));
|
||||
if (iid)
|
||||
free(iid);
|
||||
XPC_LOG_ALWAYS(("InterfaceInfo @ %p", mInfo.get()));
|
||||
XPC_LOG_ALWAYS(("InterfaceInfo @ %p", mInfo));
|
||||
uint16_t methodCount = 0;
|
||||
if (depth) {
|
||||
uint16_t i;
|
||||
nsCOMPtr<nsIInterfaceInfo> parent;
|
||||
const nsXPTInterfaceInfo* parent;
|
||||
XPC_LOG_INDENT();
|
||||
mInfo->GetParent(getter_AddRefs(parent));
|
||||
XPC_LOG_ALWAYS(("parent @ %p", parent.get()));
|
||||
mInfo->GetParent(&parent);
|
||||
XPC_LOG_ALWAYS(("parent @ %p", parent));
|
||||
mInfo->GetMethodCount(&methodCount);
|
||||
XPC_LOG_ALWAYS(("MethodCount = %d", methodCount));
|
||||
mInfo->GetConstantCount(&i);
|
||||
|
@ -1136,7 +1136,7 @@ class MOZ_STACK_CLASS CallMethodHelper
|
||||
{
|
||||
XPCCallContext& mCallContext;
|
||||
nsresult mInvokeResult;
|
||||
nsIInterfaceInfo* const mIFaceInfo;
|
||||
const nsXPTInterfaceInfo* const mIFaceInfo;
|
||||
const nsXPTMethodInfo* mMethodInfo;
|
||||
nsISupports* const mCallee;
|
||||
const uint16_t mVTableIndex;
|
||||
@ -1399,9 +1399,10 @@ bool
|
||||
CallMethodHelper::GetOutParamSource(uint8_t paramIndex, MutableHandleValue srcp) const
|
||||
{
|
||||
const nsXPTParamInfo& paramInfo = mMethodInfo->GetParam(paramIndex);
|
||||
bool isRetval = ¶mInfo == mMethodInfo->GetRetval();
|
||||
|
||||
MOZ_ASSERT(!paramInfo.IsDipper(), "Dipper params are handled separately");
|
||||
if (paramInfo.IsOut() && !paramInfo.IsRetval()) {
|
||||
if (paramInfo.IsOut() && !isRetval) {
|
||||
MOZ_ASSERT(paramIndex < mArgc || paramInfo.IsOptional(),
|
||||
"Expected either enough arguments or an optional argument");
|
||||
Value arg = paramIndex < mArgc ? mArgv[paramIndex] : JS::NullValue();
|
||||
@ -1488,7 +1489,7 @@ CallMethodHelper::GatherAndConvertResults()
|
||||
}
|
||||
}
|
||||
|
||||
if (paramInfo.IsRetval()) {
|
||||
if (¶mInfo == mMethodInfo->GetRetval()) {
|
||||
mCallContext.SetRetVal(v);
|
||||
} else if (i < mArgc) {
|
||||
// we actually assured this before doing the invoke
|
||||
@ -1541,7 +1542,7 @@ CallMethodHelper::QueryInterfaceFastPath()
|
||||
nsresult err;
|
||||
bool success =
|
||||
XPCConvert::NativeData2JS(&v, &qiresult,
|
||||
nsXPTType::T_INTERFACE_IS,
|
||||
{ nsXPTType::T_INTERFACE_IS },
|
||||
iid, &err);
|
||||
NS_IF_RELEASE(qiresult);
|
||||
|
||||
@ -1564,7 +1565,7 @@ CallMethodHelper::InitializeDispatchParams()
|
||||
uint8_t hasRetval = 0;
|
||||
|
||||
// XXX ASSUMES that retval is last arg. The xpidl compiler ensures this.
|
||||
if (paramCount && mMethodInfo->GetParam(paramCount-1).IsRetval()) {
|
||||
if (mMethodInfo->HasRetval()) {
|
||||
hasRetval = 1;
|
||||
requiredArgs--;
|
||||
}
|
||||
@ -2072,7 +2073,7 @@ static void DEBUG_CheckClassInfoClaims(XPCWrappedNative* wrapper)
|
||||
for (uint16_t i = 0; i < count; i++) {
|
||||
nsIClassInfo* clsInfo = wrapper->GetClassInfo();
|
||||
XPCNativeInterface* iface = set->GetInterfaceAt(i);
|
||||
nsIInterfaceInfo* info = iface->GetInterfaceInfo();
|
||||
const nsXPTInterfaceInfo* info = iface->GetInterfaceInfo();
|
||||
const nsIID* iid;
|
||||
nsISupports* ptr;
|
||||
|
||||
|
@ -77,8 +77,8 @@ XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface,
|
||||
return false;
|
||||
|
||||
// Note: ASSUMES that retval is last arg.
|
||||
argc = (int) info->GetParamCount();
|
||||
if (argc && info->GetParam((uint8_t)(argc-1)).IsRetval())
|
||||
argc = (int) info->ParamCount();
|
||||
if (info->HasRetval())
|
||||
argc-- ;
|
||||
|
||||
callback = XPC_WN_CallMethod;
|
||||
@ -129,8 +129,7 @@ XPCNativeInterface::GetNewOrUsed(const nsIID* iid)
|
||||
if (iface)
|
||||
return iface.forget();
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
XPTInterfaceInfoManager::GetSingleton()->GetInfoForIID(iid, getter_AddRefs(info));
|
||||
const nsXPTInterfaceInfo* info = nsXPTInterfaceInfo::ByIID(*iid);
|
||||
if (!info)
|
||||
return nullptr;
|
||||
|
||||
@ -151,7 +150,7 @@ XPCNativeInterface::GetNewOrUsed(const nsIID* iid)
|
||||
|
||||
// static
|
||||
already_AddRefed<XPCNativeInterface>
|
||||
XPCNativeInterface::GetNewOrUsed(nsIInterfaceInfo* info)
|
||||
XPCNativeInterface::GetNewOrUsed(const nsXPTInterfaceInfo* info)
|
||||
{
|
||||
RefPtr<XPCNativeInterface> iface;
|
||||
|
||||
@ -189,8 +188,7 @@ XPCNativeInterface::GetNewOrUsed(nsIInterfaceInfo* info)
|
||||
already_AddRefed<XPCNativeInterface>
|
||||
XPCNativeInterface::GetNewOrUsed(const char* name)
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
XPTInterfaceInfoManager::GetSingleton()->GetInfoForName(name, getter_AddRefs(info));
|
||||
const nsXPTInterfaceInfo* info = nsXPTInterfaceInfo::ByName(name);
|
||||
return info ? GetNewOrUsed(info) : nullptr;
|
||||
}
|
||||
|
||||
@ -204,7 +202,7 @@ XPCNativeInterface::GetISupports()
|
||||
|
||||
// static
|
||||
already_AddRefed<XPCNativeInterface>
|
||||
XPCNativeInterface::NewInstance(nsIInterfaceInfo* aInfo)
|
||||
XPCNativeInterface::NewInstance(const nsXPTInterfaceInfo* aInfo)
|
||||
{
|
||||
AutoJSContext cx;
|
||||
static const uint16_t MAX_LOCAL_MEMBER_COUNT = 16;
|
||||
@ -419,7 +417,7 @@ XPCNativeInterface::DebugDump(int16_t depth)
|
||||
XPC_LOG_INDENT();
|
||||
XPC_LOG_ALWAYS(("name is %s", GetNameString()));
|
||||
XPC_LOG_ALWAYS(("mMemberCount is %d", mMemberCount));
|
||||
XPC_LOG_ALWAYS(("mInfo @ %p", mInfo.get()));
|
||||
XPC_LOG_ALWAYS(("mInfo @ %p", mInfo));
|
||||
XPC_LOG_OUTDENT();
|
||||
#endif
|
||||
}
|
||||
|
@ -176,12 +176,9 @@ nsXPConnect::GetRuntimeInstance()
|
||||
|
||||
// static
|
||||
bool
|
||||
nsXPConnect::IsISupportsDescendant(nsIInterfaceInfo* info)
|
||||
nsXPConnect::IsISupportsDescendant(const nsXPTInterfaceInfo* info)
|
||||
{
|
||||
bool found = false;
|
||||
if (info)
|
||||
info->HasAncestor(&NS_GET_IID(nsISupports), &found);
|
||||
return found;
|
||||
return info && info->HasAncestor(NS_GET_IID(nsISupports));
|
||||
}
|
||||
|
||||
void
|
||||
@ -394,12 +391,6 @@ xpc::ErrorReport::ErrorReportToMessageString(JSErrorReport* aReport,
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
nsresult
|
||||
nsXPConnect::GetInfoForIID(const nsIID * aIID, nsIInterfaceInfo** info)
|
||||
{
|
||||
return XPTInterfaceInfoManager::GetSingleton()->GetInfoForIID(aIID, info);
|
||||
}
|
||||
|
||||
void
|
||||
xpc_TryUnmarkWrappedGrayObject(nsISupports* aWrappedJS)
|
||||
{
|
||||
|
@ -243,7 +243,7 @@ public:
|
||||
|
||||
static XPCJSRuntime* GetRuntimeInstance();
|
||||
|
||||
static bool IsISupportsDescendant(nsIInterfaceInfo* info);
|
||||
static bool IsISupportsDescendant(const nsXPTInterfaceInfo* info);
|
||||
|
||||
static nsIScriptSecurityManager* SecurityManager()
|
||||
{
|
||||
@ -268,8 +268,6 @@ public:
|
||||
|
||||
bool IsShuttingDown() const {return mShuttingDown;}
|
||||
|
||||
nsresult GetInfoForIID(const nsIID * aIID, nsIInterfaceInfo** info);
|
||||
|
||||
void RecordTraversal(void* p, nsISupports* s);
|
||||
|
||||
protected:
|
||||
@ -1141,12 +1139,12 @@ class XPCNativeInterface final
|
||||
DestroyInstance(this))
|
||||
|
||||
static already_AddRefed<XPCNativeInterface> GetNewOrUsed(const nsIID* iid);
|
||||
static already_AddRefed<XPCNativeInterface> GetNewOrUsed(nsIInterfaceInfo* info);
|
||||
static already_AddRefed<XPCNativeInterface> GetNewOrUsed(const nsXPTInterfaceInfo* info);
|
||||
static already_AddRefed<XPCNativeInterface> GetNewOrUsed(const char* name);
|
||||
static already_AddRefed<XPCNativeInterface> GetISupports();
|
||||
|
||||
inline nsIInterfaceInfo* GetInterfaceInfo() const {return mInfo.get();}
|
||||
inline jsid GetName() const {return mName;}
|
||||
inline const nsXPTInterfaceInfo* GetInterfaceInfo() const {return mInfo;}
|
||||
inline jsid GetName() const {return mName;}
|
||||
|
||||
inline const nsIID* GetIID() const;
|
||||
inline const char* GetNameString() const;
|
||||
@ -1168,10 +1166,10 @@ class XPCNativeInterface final
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
||||
|
||||
protected:
|
||||
static already_AddRefed<XPCNativeInterface> NewInstance(nsIInterfaceInfo* aInfo);
|
||||
static already_AddRefed<XPCNativeInterface> NewInstance(const nsXPTInterfaceInfo* aInfo);
|
||||
|
||||
XPCNativeInterface() = delete;
|
||||
XPCNativeInterface(nsIInterfaceInfo* aInfo, jsid aName)
|
||||
XPCNativeInterface(const nsXPTInterfaceInfo* aInfo, jsid aName)
|
||||
: mInfo(aInfo), mName(aName), mMemberCount(0)
|
||||
{}
|
||||
~XPCNativeInterface();
|
||||
@ -1184,7 +1182,7 @@ class XPCNativeInterface final
|
||||
static void DestroyInstance(XPCNativeInterface* inst);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
const nsXPTInterfaceInfo* mInfo;
|
||||
jsid mName;
|
||||
uint16_t mMemberCount;
|
||||
XPCNativeMember mMembers[1]; // always last - object sized for array
|
||||
@ -1754,7 +1752,7 @@ public:
|
||||
|
||||
REFNSIID GetIID() const {return mIID;}
|
||||
XPCJSRuntime* GetRuntime() const {return mRuntime;}
|
||||
nsIInterfaceInfo* GetInterfaceInfo() const {return mInfo;}
|
||||
const nsXPTInterfaceInfo* GetInterfaceInfo() const {return mInfo;}
|
||||
const char* GetInterfaceName();
|
||||
|
||||
NS_IMETHOD DelegatedQueryInterface(nsXPCWrappedJS* self, REFNSIID aIID,
|
||||
@ -1791,7 +1789,7 @@ private:
|
||||
|
||||
nsXPCWrappedJSClass() = delete;
|
||||
nsXPCWrappedJSClass(JSContext* cx, REFNSIID aIID,
|
||||
nsIInterfaceInfo* aInfo);
|
||||
const nsXPTInterfaceInfo* aInfo);
|
||||
|
||||
bool IsReflectable(uint16_t i) const
|
||||
{return (bool)(mDescriptors[i/32] & (1 << (i%32)));}
|
||||
@ -1827,7 +1825,7 @@ private:
|
||||
|
||||
private:
|
||||
XPCJSRuntime* mRuntime;
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
const nsXPTInterfaceInfo* mInfo;
|
||||
char* mName;
|
||||
nsIID mIID;
|
||||
uint32_t* mDescriptors;
|
||||
@ -2190,15 +2188,15 @@ public:
|
||||
NS_DECL_NSIJSIID
|
||||
NS_DECL_NSIXPCSCRIPTABLE
|
||||
|
||||
static already_AddRefed<nsJSIID> NewID(nsIInterfaceInfo* aInfo);
|
||||
static already_AddRefed<nsJSIID> NewID(const nsXPTInterfaceInfo* aInfo);
|
||||
|
||||
explicit nsJSIID(nsIInterfaceInfo* aInfo);
|
||||
explicit nsJSIID(const nsXPTInterfaceInfo* aInfo);
|
||||
nsJSIID() = delete;
|
||||
|
||||
private:
|
||||
virtual ~nsJSIID();
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
const nsXPTInterfaceInfo* mInfo;
|
||||
};
|
||||
|
||||
// nsJSCID
|
||||
|
@ -242,24 +242,6 @@ nsThreadManagerGetSingleton(nsISupports* aOuter,
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThreadPool)
|
||||
|
||||
static nsresult
|
||||
nsXPTIInterfaceInfoManagerGetSingleton(nsISupports* aOuter,
|
||||
const nsIID& aIID,
|
||||
void** aInstancePtr)
|
||||
{
|
||||
NS_ASSERTION(aInstancePtr, "null outptr");
|
||||
if (NS_WARN_IF(aOuter)) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim(XPTInterfaceInfoManager::GetSingleton());
|
||||
if (!iim) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return iim->QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = nullptr;
|
||||
bool gXPCOMShuttingDown = false;
|
||||
bool gXPCOMThreadsShutDown = false;
|
||||
@ -668,10 +650,6 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
|
||||
NS_ADDREF(*aResult = nsComponentManagerImpl::gComponentManager);
|
||||
}
|
||||
|
||||
// The iimanager constructor searches and registers XPT files.
|
||||
// (We trigger the singleton's lazy construction here to make that happen.)
|
||||
(void)XPTInterfaceInfoManager::GetSingleton();
|
||||
|
||||
// After autoreg, but before we actually instantiate any components,
|
||||
// add any services listed in the "xpcom-directory-providers" category
|
||||
// to the directory service.
|
||||
@ -1008,12 +986,6 @@ ShutdownXPCOM(nsIServiceManager* aServMgr)
|
||||
}
|
||||
}
|
||||
|
||||
// Release our own singletons
|
||||
// Do this _after_ shutting down the component manager, because the
|
||||
// JS component loader will use XPConnect to call nsIModule::canUnload,
|
||||
// and that will spin up the InterfaceInfoManager again -- bad mojo
|
||||
XPTInterfaceInfoManager::FreeInterfaceInfoManager();
|
||||
|
||||
// Finally, release the component manager last because it unloads the
|
||||
// libraries:
|
||||
if (nsComponentManagerImpl::gComponentManager) {
|
||||
|
@ -11,9 +11,9 @@
|
||||
[scriptable,uuid(4d12e540-83d7-11d5-90ed-0010a4e73d9a)]
|
||||
interface nsIDataType : nsISupports
|
||||
{
|
||||
// These MUST match the declarations in xpt_struct.h.
|
||||
// Otherwise the world is likely to explode.
|
||||
// From xpt_struct.h ...
|
||||
// These MUST match the declarations in xptinfo.h.
|
||||
// Otherwise the world is likely to explode.
|
||||
// From xptinfo.h ...
|
||||
const uint16_t VTYPE_INT8 = 0; // TD_INT8 = 0,
|
||||
const uint16_t VTYPE_INT16 = 1; // TD_INT16 = 1,
|
||||
const uint16_t VTYPE_INT32 = 2; // TD_INT32 = 2,
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "prdtoa.h"
|
||||
#include <math.h>
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "xpt_struct.h"
|
||||
#include "xptinfo.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsString.h"
|
||||
@ -1645,7 +1645,7 @@ nsVariantBase::nsVariantBase()
|
||||
#ifdef DEBUG
|
||||
{
|
||||
// Assert that the nsIDataType consts match the values #defined in
|
||||
// xpt_struct.h. Bad things happen somewhere if they don't.
|
||||
// xptinfo.h. Bad things happen somewhere if they don't.
|
||||
struct THE_TYPES
|
||||
{
|
||||
uint16_t a;
|
||||
|
@ -16,9 +16,8 @@
|
||||
# as a result of the limitations of immediate values in ARM assembly.
|
||||
#
|
||||
# This number is verified by the IDL parser in xpcom/idl-parser/xpidl.py, as
|
||||
# well as in xpcom/reflect/xptinfo/xptiInterfaceInfoManager.cpp, to
|
||||
# prevent generating interfaces or loading xpt files that would cause the
|
||||
# stubs to run off the entries.
|
||||
# well as in xpcom/reflect/xptinfo/xptinfo.cpp, to prevent generating interfaces
|
||||
# or loading xpt files that would cause the stubs to run off the entries.
|
||||
# If you change this number, please update that location.
|
||||
|
||||
# 3 entries are already 'used' by the 3 methods of nsISupports.
|
||||
|
@ -14,7 +14,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
|
||||
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCMiniVariant* dispatchParams = nullptr;
|
||||
nsIInterfaceInfo* iface_info = nullptr;
|
||||
const nsXPTInterfaceInfo* iface_info = nullptr;
|
||||
const nsXPTMethodInfo* info;
|
||||
uint8_t paramCount;
|
||||
uint8_t i;
|
||||
@ -73,8 +73,6 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
|
||||
|
||||
result = self->CallMethod((uint16_t)methodIndex, info, dispatchParams);
|
||||
|
||||
NS_RELEASE(iface_info);
|
||||
|
||||
if(dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
||||
|
@ -19,7 +19,7 @@ extern "C" {
|
||||
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCMiniVariant* dispatchParams = nullptr;
|
||||
nsIInterfaceInfo* iface_info = nullptr;
|
||||
const nsXPTInterfaceInfo* iface_info = nullptr;
|
||||
const nsXPTMethodInfo* info;
|
||||
uint8_t paramCount;
|
||||
uint8_t i;
|
||||
@ -82,8 +82,6 @@ extern "C" {
|
||||
|
||||
result = self->CallMethod((uint16_t)methodIndex, info, dispatchParams);
|
||||
|
||||
NS_RELEASE(iface_info);
|
||||
|
||||
if(dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
||||
|
@ -36,7 +36,7 @@ PrepareAndDispatch(nsXPTCStubBase* self,
|
||||
{
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCMiniVariant* dispatchParams = nullptr;
|
||||
nsIInterfaceInfo* iface_info = nullptr;
|
||||
const nsXPTInterfaceInfo* iface_info = nullptr;
|
||||
const nsXPTMethodInfo* info;
|
||||
uint32_t paramCount;
|
||||
uint32_t i;
|
||||
@ -149,8 +149,6 @@ PrepareAndDispatch(nsXPTCStubBase* self,
|
||||
|
||||
result = self->CallMethod((uint16_t) methodIndex, info, dispatchParams);
|
||||
|
||||
NS_RELEASE(iface_info);
|
||||
|
||||
if (dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
||||
|
@ -23,7 +23,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
|
||||
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCMiniVariant* dispatchParams = nullptr;
|
||||
nsIInterfaceInfo* iface_info = nullptr;
|
||||
const nsXPTInterfaceInfo* iface_info = nullptr;
|
||||
const nsXPTMethodInfo* info;
|
||||
uint8_t paramCount;
|
||||
uint8_t i;
|
||||
@ -88,8 +88,6 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
|
||||
|
||||
result = self->CallMethod((uint16_t)methodIndex, info, dispatchParams);
|
||||
|
||||
NS_RELEASE(iface_info);
|
||||
|
||||
if(dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
||||
|
@ -23,7 +23,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
|
||||
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCMiniVariant* dispatchParams = nullptr;
|
||||
nsIInterfaceInfo* iface_info = nullptr;
|
||||
const nsXPTInterfaceInfo* iface_info = nullptr;
|
||||
const nsXPTMethodInfo* info;
|
||||
uint8_t paramCount;
|
||||
uint8_t i;
|
||||
@ -91,8 +91,6 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
|
||||
|
||||
result = self->CallMethod((uint16_t)methodIndex, info, dispatchParams);
|
||||
|
||||
NS_RELEASE(iface_info);
|
||||
|
||||
if(dispatchParams != paramBuffer)
|
||||
delete [] dispatchParams;
|
||||
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
|
||||
// return a refcounted pointer to the InterfaceInfo for this object
|
||||
// NOTE: on some platforms this MUST not fail or we crash!
|
||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info) = 0;
|
||||
NS_IMETHOD GetInterfaceInfo(const nsXPTInterfaceInfo** info) = 0;
|
||||
|
||||
// call this method and return result
|
||||
NS_IMETHOD CallMethod(uint16_t methodIndex,
|
||||
|
@ -42,23 +42,10 @@ NS_GetXPTCallStub(REFNSIID aIID, nsIXPTCProxy* aOuter,
|
||||
if (NS_WARN_IF(!aOuter) || NS_WARN_IF(!aResult))
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
XPTInterfaceInfoManager *iim =
|
||||
XPTInterfaceInfoManager::GetSingleton();
|
||||
if (NS_WARN_IF(!iim))
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
xptiInterfaceEntry *iie = iim->GetInterfaceEntryForIID(&aIID);
|
||||
if (!iie || !iie->EnsureResolved() || iie->GetBuiltinClassFlag())
|
||||
const nsXPTInterfaceInfo* iie = nsXPTInterfaceInfo::ByIID(aIID);
|
||||
if (!iie || !iie->EnsureResolved() || iie->IsBuiltinClass())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (iie->GetHasNotXPCOMFlag()) {
|
||||
#ifdef DEBUG
|
||||
nsPrintfCString msg("XPTCall will not implement interface %s because of [notxpcom] members.", iie->GetTheName());
|
||||
NS_WARNING(msg.get());
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aResult = new nsXPTCStubBase(aOuter, iie);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -44,11 +44,11 @@ public:
|
||||
|
||||
#include "xptcstubsdef.inc"
|
||||
|
||||
nsXPTCStubBase(nsIXPTCProxy* aOuter, xptiInterfaceEntry *aEntry)
|
||||
nsXPTCStubBase(nsIXPTCProxy* aOuter, const nsXPTInterfaceInfo *aEntry)
|
||||
: mOuter(aOuter), mEntry(aEntry) {}
|
||||
|
||||
nsIXPTCProxy* mOuter;
|
||||
xptiInterfaceEntry* mEntry;
|
||||
nsIXPTCProxy* mOuter;
|
||||
const nsXPTInterfaceInfo* mEntry;
|
||||
|
||||
~nsXPTCStubBase() {}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user