зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1444129, part 3 - Rename XPTInterfaceDescriptor fields. r=njn
MozReview-Commit-ID: C5jenxkkDgl --HG-- extra : rebase_source : 98c588e8433009c00acf014eb58be10b73fdb8cf
This commit is contained in:
Родитель
324e8c87a2
Коммит
f7a3e0281d
|
@ -67,7 +67,7 @@ xptiInterfaceEntry::ResolveLocked()
|
|||
// Finish out resolution by finding parent and Resolving it so
|
||||
// we can set the info we get from it.
|
||||
|
||||
uint16_t parent_index = mDescriptor->parent_interface;
|
||||
uint16_t parent_index = mDescriptor->mParentInterface;
|
||||
|
||||
if(parent_index)
|
||||
{
|
||||
|
@ -84,9 +84,9 @@ xptiInterfaceEntry::ResolveLocked()
|
|||
if (parent->GetHasNotXPCOMFlag()) {
|
||||
SetHasNotXPCOMFlag();
|
||||
} else {
|
||||
for (uint16_t idx = 0; idx < mDescriptor->num_methods; ++idx) {
|
||||
for (uint16_t idx = 0; idx < mDescriptor->mNumMethods; ++idx) {
|
||||
const nsXPTMethodInfo* method = static_cast<const nsXPTMethodInfo*>(
|
||||
mDescriptor->method_descriptors + idx);
|
||||
mDescriptor->mMethodDescriptors + idx);
|
||||
if (method->IsNotXPCOM()) {
|
||||
SetHasNotXPCOMFlag();
|
||||
break;
|
||||
|
@ -97,11 +97,11 @@ xptiInterfaceEntry::ResolveLocked()
|
|||
|
||||
mMethodBaseIndex =
|
||||
parent->mMethodBaseIndex +
|
||||
parent->mDescriptor->num_methods;
|
||||
parent->mDescriptor->mNumMethods;
|
||||
|
||||
mConstantBaseIndex =
|
||||
parent->mConstantBaseIndex +
|
||||
parent->mDescriptor->num_constants;
|
||||
parent->mDescriptor->mNumConstants;
|
||||
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ xptiInterfaceEntry::GetMethodCount(uint16_t* count)
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
*count = mMethodBaseIndex +
|
||||
mDescriptor->num_methods;
|
||||
mDescriptor->mNumMethods;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ xptiInterfaceEntry::GetConstantCount(uint16_t* count)
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
*count = mConstantBaseIndex +
|
||||
mDescriptor->num_constants;
|
||||
mDescriptor->mNumConstants;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ xptiInterfaceEntry::GetMethodInfo(uint16_t index, const nsXPTMethodInfo** info)
|
|||
return mParent->GetMethodInfo(index, info);
|
||||
|
||||
if(index >= mMethodBaseIndex +
|
||||
mDescriptor->num_methods)
|
||||
mDescriptor->mNumMethods)
|
||||
{
|
||||
NS_ERROR("bad param");
|
||||
*info = nullptr;
|
||||
|
@ -190,7 +190,7 @@ xptiInterfaceEntry::GetMethodInfo(uint16_t index, const nsXPTMethodInfo** info)
|
|||
|
||||
// else...
|
||||
*info = static_cast<const nsXPTMethodInfo*>
|
||||
(&mDescriptor->method_descriptors[index - mMethodBaseIndex]);
|
||||
(&mDescriptor->mMethodDescriptors[index - mMethodBaseIndex]);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -202,11 +202,10 @@ xptiInterfaceEntry::GetMethodInfoForName(const char* methodName, uint16_t *index
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// This is a slow algorithm, but this is not expected to be called much.
|
||||
for(uint16_t i = 0; i < mDescriptor->num_methods; ++i)
|
||||
for(uint16_t i = 0; i < mDescriptor->mNumMethods; ++i)
|
||||
{
|
||||
const nsXPTMethodInfo* info;
|
||||
info = static_cast<const nsXPTMethodInfo*>
|
||||
(&mDescriptor->method_descriptors[i]);
|
||||
info = static_cast<const nsXPTMethodInfo*>(&mDescriptor->mMethodDescriptors[i]);
|
||||
if (PL_strcmp(methodName, info->GetName()) == 0) {
|
||||
*index = i + mMethodBaseIndex;
|
||||
*result = info;
|
||||
|
@ -235,13 +234,13 @@ xptiInterfaceEntry::GetConstant(uint16_t index, JS::MutableHandleValue constant,
|
|||
return mParent->GetConstant(index, constant, name);
|
||||
|
||||
if(index >= mConstantBaseIndex +
|
||||
mDescriptor->num_constants)
|
||||
mDescriptor->mNumConstants)
|
||||
{
|
||||
NS_PRECONDITION(0, "bad param");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
const auto& c = mDescriptor->const_descriptors[index - mConstantBaseIndex];
|
||||
const auto& c = mDescriptor->mConstDescriptors[index - mConstantBaseIndex];
|
||||
AutoJSContext cx;
|
||||
JS::Rooted<JS::Value> v(cx);
|
||||
v.setUndefined();
|
||||
|
@ -294,7 +293,7 @@ xptiInterfaceEntry::GetInterfaceIndexForParam(uint16_t methodIndex,
|
|||
interfaceIndex);
|
||||
|
||||
if(methodIndex >= mMethodBaseIndex +
|
||||
mDescriptor->num_methods)
|
||||
mDescriptor->mNumMethods)
|
||||
{
|
||||
NS_ERROR("bad param");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
@ -303,7 +302,7 @@ xptiInterfaceEntry::GetInterfaceIndexForParam(uint16_t methodIndex,
|
|||
const XPTTypeDescriptor *td = ¶m->type;
|
||||
|
||||
while (td->Tag() == TD_ARRAY) {
|
||||
td = &mDescriptor->additional_types[td->u.array.additional_type];
|
||||
td = &mDescriptor->mAdditionalTypes[td->u.array.additional_type];
|
||||
}
|
||||
|
||||
if (td->Tag() != TD_INTERFACE_TYPE) {
|
||||
|
@ -439,7 +438,7 @@ xptiInterfaceEntry::GetTypeInArray(const nsXPTParamInfo* param,
|
|||
|
||||
const XPTTypeDescriptor *td = ¶m->type;
|
||||
const XPTTypeDescriptor *additional_types =
|
||||
mDescriptor->additional_types;
|
||||
mDescriptor->mAdditionalTypes;
|
||||
|
||||
for (uint16_t i = 0; i < dimension; i++) {
|
||||
if (td->Tag() != TD_ARRAY) {
|
||||
|
@ -467,7 +466,7 @@ xptiInterfaceEntry::GetTypeForParam(uint16_t methodIndex,
|
|||
GetTypeForParam(methodIndex, param, dimension, type);
|
||||
|
||||
if(methodIndex >= mMethodBaseIndex +
|
||||
mDescriptor->num_methods)
|
||||
mDescriptor->mNumMethods)
|
||||
{
|
||||
NS_ERROR("bad index");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
@ -501,7 +500,7 @@ xptiInterfaceEntry::GetSizeIsArgNumberForParam(uint16_t methodIndex,
|
|||
GetSizeIsArgNumberForParam(methodIndex, param, dimension, argnum);
|
||||
|
||||
if(methodIndex >= mMethodBaseIndex +
|
||||
mDescriptor->num_methods)
|
||||
mDescriptor->mNumMethods)
|
||||
{
|
||||
NS_ERROR("bad index");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
@ -547,7 +546,7 @@ xptiInterfaceEntry::GetInterfaceIsArgNumberForParam(uint16_t methodIndex,
|
|||
GetInterfaceIsArgNumberForParam(methodIndex, param, argnum);
|
||||
|
||||
if(methodIndex >= mMethodBaseIndex +
|
||||
mDescriptor->num_methods)
|
||||
mDescriptor->mNumMethods)
|
||||
{
|
||||
NS_ERROR("bad index");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
@ -556,7 +555,7 @@ xptiInterfaceEntry::GetInterfaceIsArgNumberForParam(uint16_t methodIndex,
|
|||
const XPTTypeDescriptor *td = ¶m->type;
|
||||
|
||||
while (td->Tag() == TD_ARRAY) {
|
||||
td = &mDescriptor->additional_types[td->u.array.additional_type];
|
||||
td = &mDescriptor->mAdditionalTypes[td->u.array.additional_type];
|
||||
}
|
||||
|
||||
if (td->Tag() != TD_INTERFACE_IS_TYPE) {
|
||||
|
|
|
@ -140,7 +140,7 @@ XPTInterfaceInfoManager::VerifyAndAddEntryIfNew(const XPTInterfaceDirectoryEntry
|
|||
// The number of maximum methods is not arbitrary. It is the same value as
|
||||
// in xpcom/reflect/xptcall/genstubs.pl; do not change this value
|
||||
// without changing that one or you WILL see problems.
|
||||
if (iface->mInterfaceDescriptor->num_methods > 250 &&
|
||||
if (iface->mInterfaceDescriptor->mNumMethods > 250 &&
|
||||
!iface->mInterfaceDescriptor->IsBuiltinClass()) {
|
||||
NS_ASSERTION(0, "Too many methods to handle for the stub, cannot load");
|
||||
fprintf(stderr, "ignoring too large interface: %s\n", iface->mName);
|
||||
|
|
|
@ -212,9 +212,9 @@ InterfaceDescriptorAddType(XPTArena *arena,
|
|||
XPTInterfaceDescriptor *id,
|
||||
XPTTypeDescriptor *td)
|
||||
{
|
||||
const XPTTypeDescriptor *old = id->additional_types;
|
||||
const XPTTypeDescriptor *old = id->mAdditionalTypes;
|
||||
XPTTypeDescriptor *new_;
|
||||
size_t old_size = id->num_additional_types * sizeof(XPTTypeDescriptor);
|
||||
size_t old_size = id->mNumAdditionalTypes * sizeof(XPTTypeDescriptor);
|
||||
size_t new_size = old_size + sizeof(XPTTypeDescriptor);
|
||||
|
||||
/* XXX should grow in chunks to minimize alloc overhead */
|
||||
|
@ -225,13 +225,13 @@ InterfaceDescriptorAddType(XPTArena *arena,
|
|||
memcpy(new_, old, old_size);
|
||||
}
|
||||
|
||||
new_[id->num_additional_types] = *td;
|
||||
id->additional_types = new_;
|
||||
new_[id->mNumAdditionalTypes] = *td;
|
||||
id->mAdditionalTypes = new_;
|
||||
|
||||
if (id->num_additional_types == UINT8_MAX)
|
||||
if (id->mNumAdditionalTypes == UINT8_MAX)
|
||||
return false;
|
||||
|
||||
id->num_additional_types += 1;
|
||||
id->mNumAdditionalTypes += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -258,51 +258,51 @@ DoInterfaceDescriptor(XPTArena *arena, NotNull<XPTCursor*> outer,
|
|||
*idp = NULL;
|
||||
return true;
|
||||
}
|
||||
if(!XPT_Do16(cursor, &id->parent_interface) ||
|
||||
!XPT_Do16(cursor, &id->num_methods)) {
|
||||
if(!XPT_Do16(cursor, &id->mParentInterface) ||
|
||||
!XPT_Do16(cursor, &id->mNumMethods)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XPTMethodDescriptor* method_descriptors = nullptr;
|
||||
|
||||
if (id->num_methods) {
|
||||
size_t n = id->num_methods * sizeof(XPTMethodDescriptor);
|
||||
if (id->mNumMethods) {
|
||||
size_t n = id->mNumMethods * sizeof(XPTMethodDescriptor);
|
||||
method_descriptors =
|
||||
static_cast<XPTMethodDescriptor*>(XPT_CALLOC8(arena, n));
|
||||
if (!method_descriptors)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < id->num_methods; i++) {
|
||||
for (i = 0; i < id->mNumMethods; i++) {
|
||||
if (!DoMethodDescriptor(arena, cursor, &method_descriptors[i], id))
|
||||
return false;
|
||||
}
|
||||
|
||||
id->method_descriptors = method_descriptors;
|
||||
id->mMethodDescriptors = method_descriptors;
|
||||
|
||||
if (!XPT_Do16(cursor, &id->num_constants)) {
|
||||
if (!XPT_Do16(cursor, &id->mNumConstants)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XPTConstDescriptor* const_descriptors = nullptr;
|
||||
|
||||
if (id->num_constants) {
|
||||
size_t n = id->num_constants * sizeof(XPTConstDescriptor);
|
||||
if (id->mNumConstants) {
|
||||
size_t n = id->mNumConstants * sizeof(XPTConstDescriptor);
|
||||
const_descriptors =
|
||||
static_cast<XPTConstDescriptor*>(XPT_CALLOC8(arena, n));
|
||||
if (!const_descriptors)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < id->num_constants; i++) {
|
||||
for (i = 0; i < id->mNumConstants; i++) {
|
||||
if (!DoConstDescriptor(arena, cursor, &const_descriptors[i], id)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
id->const_descriptors = const_descriptors;
|
||||
id->mConstDescriptors = const_descriptors;
|
||||
|
||||
if (!XPT_Do8(cursor, &id->flags)) {
|
||||
if (!XPT_Do8(cursor, &id->mFlags)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -430,7 +430,7 @@ DoTypeDescriptor(XPTArena *arena, NotNull<XPTCursor*> cursor,
|
|||
return false;
|
||||
if (!InterfaceDescriptorAddType(arena, id, &elementTypeDescriptor))
|
||||
return false;
|
||||
td->u.array.additional_type = id->num_additional_types - 1;
|
||||
td->u.array.additional_type = id->mNumAdditionalTypes - 1;
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -91,41 +91,41 @@ struct XPTInterfaceDescriptor {
|
|||
static const uint8_t kBuiltinClassMask = 0x20;
|
||||
static const uint8_t kMainProcessScriptableOnlyMask = 0x10;
|
||||
|
||||
bool IsScriptable() const { return !!(flags & kScriptableMask); }
|
||||
bool IsFunction() const { return !!(flags & kFunctionMask); }
|
||||
bool IsBuiltinClass() const { return !!(flags & kBuiltinClassMask); }
|
||||
bool IsMainProcessScriptableOnly() const { return !!(flags & kMainProcessScriptableOnlyMask); }
|
||||
bool IsScriptable() const { return !!(mFlags & kScriptableMask); }
|
||||
bool IsFunction() const { return !!(mFlags & kFunctionMask); }
|
||||
bool IsBuiltinClass() const { return !!(mFlags & kBuiltinClassMask); }
|
||||
bool IsMainProcessScriptableOnly() const { return !!(mFlags & kMainProcessScriptableOnlyMask); }
|
||||
|
||||
/*
|
||||
* This field ordering minimizes the size of this struct.
|
||||
* The fields are serialized on disk in a different order.
|
||||
* See DoInterfaceDescriptor().
|
||||
*/
|
||||
const XPTMethodDescriptor* method_descriptors;
|
||||
const XPTConstDescriptor* const_descriptors;
|
||||
const XPTTypeDescriptor* additional_types;
|
||||
uint16_t parent_interface;
|
||||
uint16_t num_methods;
|
||||
uint16_t num_constants;
|
||||
uint8_t flags;
|
||||
const XPTMethodDescriptor* mMethodDescriptors;
|
||||
const XPTConstDescriptor* mConstDescriptors;
|
||||
const XPTTypeDescriptor* mAdditionalTypes;
|
||||
uint16_t mParentInterface;
|
||||
uint16_t mNumMethods;
|
||||
uint16_t mNumConstants;
|
||||
uint8_t mFlags;
|
||||
|
||||
/*
|
||||
* additional_types are used for arrays where we may need multiple
|
||||
* mAdditionalTypes are used for arrays where we may need multiple
|
||||
* XPTTypeDescriptors for a single XPTMethodDescriptor. Since we still
|
||||
* want to have a simple array of XPTMethodDescriptor (each with a single
|
||||
* embedded XPTTypeDescriptor), a XPTTypeDescriptor can have a reference
|
||||
* to an 'additional_type'. That reference is an index in this
|
||||
* "additional_types" array. So a given XPTMethodDescriptor might have
|
||||
* "mAdditionalTypes" array. So a given XPTMethodDescriptor might have
|
||||
* a whole chain of these XPTTypeDescriptors to represent, say, a multi
|
||||
* dimensional array.
|
||||
*
|
||||
* Note that in the typelib file these additional types are stored 'inline'
|
||||
* in the MethodDescriptor. But, in the typelib MethodDescriptors can be
|
||||
* of varying sizes, where in XPT's in memory mapping of the data we want
|
||||
* them to be of fixed size. This additional_types scheme is here to allow
|
||||
* them to be of fixed size. This mAdditionalTypes scheme is here to allow
|
||||
* for that.
|
||||
*/
|
||||
uint8_t num_additional_types;
|
||||
uint8_t mNumAdditionalTypes;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче