Bug 1444129, part 3 - Rename XPTInterfaceDescriptor fields. r=njn
MozReview-Commit-ID: C5jenxkkDgl
--- a/xpcom/reflect/xptinfo/xptiInterfaceInfo.cpp
+++ b/xpcom/reflect/xptinfo/xptiInterfaceInfo.cpp
@@ -62,51 +62,51 @@ xptiInterfaceEntry::ResolveLocked()
if(resolvedState == RESOLVE_FAILED)
return false;
NS_ASSERTION(GetResolveState() == PARTIALLY_RESOLVED, "bad state!");
// 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)
{
xptiInterfaceEntry* parent =
mTypelib->GetEntryAt(parent_index - 1);
if(!parent || !parent->EnsureResolvedLocked())
{
SetResolvedState(RESOLVE_FAILED);
return false;
}
mParent = parent;
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;
}
}
}
mMethodBaseIndex =
parent->mMethodBaseIndex +
- parent->mDescriptor->num_methods;
+ parent->mDescriptor->mNumMethods;
mConstantBaseIndex =
parent->mConstantBaseIndex +
- parent->mDescriptor->num_constants;
+ parent->mDescriptor->mNumConstants;
}
SetResolvedState(FULLY_RESOLVED);
return true;
}
/**************************************************/
@@ -148,70 +148,69 @@ xptiInterfaceEntry::IsFunction(bool* res
nsresult
xptiInterfaceEntry::GetMethodCount(uint16_t* count)
{
if(!EnsureResolved())
return NS_ERROR_UNEXPECTED;
*count = mMethodBaseIndex +
- mDescriptor->num_methods;
+ mDescriptor->mNumMethods;
return NS_OK;
}
nsresult
xptiInterfaceEntry::GetConstantCount(uint16_t* count)
{
if(!EnsureResolved())
return NS_ERROR_UNEXPECTED;
if(!count)
return NS_ERROR_UNEXPECTED;
*count = mConstantBaseIndex +
- mDescriptor->num_constants;
+ mDescriptor->mNumConstants;
return NS_OK;
}
nsresult
xptiInterfaceEntry::GetMethodInfo(uint16_t index, const nsXPTMethodInfo** info)
{
if(!EnsureResolved())
return NS_ERROR_UNEXPECTED;
if(index < mMethodBaseIndex)
return mParent->GetMethodInfo(index, info);
if(index >= mMethodBaseIndex +
- mDescriptor->num_methods)
+ mDescriptor->mNumMethods)
{
NS_ERROR("bad param");
*info = nullptr;
return NS_ERROR_INVALID_ARG;
}
// else...
*info = static_cast<const nsXPTMethodInfo*>
- (&mDescriptor->method_descriptors[index - mMethodBaseIndex]);
+ (&mDescriptor->mMethodDescriptors[index - mMethodBaseIndex]);
return NS_OK;
}
nsresult
xptiInterfaceEntry::GetMethodInfoForName(const char* methodName, uint16_t *index,
const nsXPTMethodInfo** result)
{
if(!EnsureResolved())
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;
return NS_OK;
}
}
if(mParent)
@@ -230,23 +229,23 @@ xptiInterfaceEntry::GetConstant(uint16_t
{
if(!EnsureResolved())
return NS_ERROR_UNEXPECTED;
if(index < mConstantBaseIndex)
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();
switch (c.type.prefix.flags) {
case nsXPTType::T_I16:
{
v.setInt32(c.value.i16);
@@ -289,26 +288,26 @@ xptiInterfaceEntry::GetInterfaceIndexFor
if(!EnsureResolved())
return NS_ERROR_UNEXPECTED;
if(methodIndex < mMethodBaseIndex)
return mParent->GetInterfaceIndexForParam(methodIndex, param,
interfaceIndex);
if(methodIndex >= mMethodBaseIndex +
- mDescriptor->num_methods)
+ mDescriptor->mNumMethods)
{
NS_ERROR("bad param");
return NS_ERROR_INVALID_ARG;
}
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) {
NS_ERROR("not an interface");
return NS_ERROR_INVALID_ARG;
}
*interfaceIndex = (td->u.iface.iface_hi8 << 8) | td->u.iface.iface_lo8;
@@ -434,17 +433,17 @@ nsresult
xptiInterfaceEntry::GetTypeInArray(const nsXPTParamInfo* param,
uint16_t dimension,
const XPTTypeDescriptor** type)
{
NS_ASSERTION(IsFullyResolved(), "bad state");
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) {
NS_ERROR("bad dimension");
return NS_ERROR_INVALID_ARG;
}
td = &additional_types[td->u.array.additional_type];
}
@@ -462,17 +461,17 @@ xptiInterfaceEntry::GetTypeForParam(uint
if(!EnsureResolved())
return NS_ERROR_UNEXPECTED;
if(methodIndex < mMethodBaseIndex)
return mParent->
GetTypeForParam(methodIndex, param, dimension, type);
if(methodIndex >= mMethodBaseIndex +
- mDescriptor->num_methods)
+ mDescriptor->mNumMethods)
{
NS_ERROR("bad index");
return NS_ERROR_INVALID_ARG;
}
const XPTTypeDescriptor *td;
if(dimension) {
@@ -496,17 +495,17 @@ xptiInterfaceEntry::GetSizeIsArgNumberFo
if(!EnsureResolved())
return NS_ERROR_UNEXPECTED;
if(methodIndex < mMethodBaseIndex)
return mParent->
GetSizeIsArgNumberForParam(methodIndex, param, dimension, argnum);
if(methodIndex >= mMethodBaseIndex +
- mDescriptor->num_methods)
+ mDescriptor->mNumMethods)
{
NS_ERROR("bad index");
return NS_ERROR_INVALID_ARG;
}
const XPTTypeDescriptor *td;
if(dimension) {
@@ -542,26 +541,26 @@ xptiInterfaceEntry::GetInterfaceIsArgNum
if(!EnsureResolved())
return NS_ERROR_UNEXPECTED;
if(methodIndex < mMethodBaseIndex)
return mParent->
GetInterfaceIsArgNumberForParam(methodIndex, param, argnum);
if(methodIndex >= mMethodBaseIndex +
- mDescriptor->num_methods)
+ mDescriptor->mNumMethods)
{
NS_ERROR("bad index");
return NS_ERROR_INVALID_ARG;
}
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) {
NS_ERROR("not an iid_is");
return NS_ERROR_INVALID_ARG;
}
*argnum = td->u.interface_is.argnum;
--- a/xpcom/reflect/xptinfo/xptiInterfaceInfoManager.cpp
+++ b/xpcom/reflect/xptinfo/xptiInterfaceInfoManager.cpp
@@ -135,17 +135,17 @@ XPTInterfaceInfoManager::VerifyAndAddEnt
xptiTypelibGuts* typelib)
{
if (!iface->mInterfaceDescriptor)
return;
// 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);
return;
}
mWorkingSet.mTableReentrantMonitor.AssertCurrentThreadIn();
xptiInterfaceEntry* entry = mWorkingSet.mIIDTable.Get(iface->mIID);
--- a/xpcom/typelib/xpt/xpt_struct.cpp
+++ b/xpcom/typelib/xpt/xpt_struct.cpp
@@ -207,36 +207,36 @@ DoInterfaceDirectoryEntry(XPTArena *aren
return true;
}
static bool
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 */
new_ = static_cast<XPTTypeDescriptor*>(XPT_CALLOC8(arena, new_size));
if (!new_)
return false;
if (old) {
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;
}
bool
DoInterfaceDescriptor(XPTArena *arena, NotNull<XPTCursor*> outer,
const XPTInterfaceDescriptor **idp)
{
XPTInterfaceDescriptor *id;
@@ -253,61 +253,61 @@ DoInterfaceDescriptor(XPTArena *arena, N
return false;
if (!XPT_Do32(outer, &cursor->offset))
return false;
if (!cursor->offset) {
*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;
}
return true;
}
bool
DoConstDescriptor(XPTArena *arena, NotNull<XPTCursor*> cursor,
@@ -425,17 +425,17 @@ DoTypeDescriptor(XPTArena *arena, NotNul
!XPT_Do8(cursor, &argnum2))
return false;
XPTTypeDescriptor elementTypeDescriptor;
if (!DoTypeDescriptor(arena, cursor, &elementTypeDescriptor, id))
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;
}
case TD_PSTRING_SIZE_IS:
case TD_PWSTRING_SIZE_IS: {
// argnum2 appears in the on-disk format but it isn't used.
uint8_t argnum2 = 0;
if (!XPT_Do8(cursor, &td->u.pstring_is.argnum) ||
--- a/xpcom/typelib/xpt/xpt_struct.h
+++ b/xpcom/typelib/xpt/xpt_struct.h
@@ -86,51 +86,51 @@ struct XPTInterfaceDirectoryEntry {
* its methods.
*/
struct XPTInterfaceDescriptor {
static const uint8_t kScriptableMask = 0x80;
static const uint8_t kFunctionMask = 0x40;
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;
};
/*
* A TypeDescriptor is a variable-size record used to identify the type of a
* method argument or return value.
*
* There are three types of TypeDescriptors:
*