Bug 1474369 - Part 7: Rename [array] to LegacyArray within xpt and xpidl, r=mccr8

Summary:
This is done so we can use Array as the name for the new nsTArray-based
type, rather than having to come up with a new name.

LegacyArray was chosen as the [array] attribute is now effectively deprecated,
and we'd like to remove it ASAP.

Depends On D2334

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2335
This commit is contained in:
Nika Layzell 2018-07-24 15:16:13 -04:00
parent 758bebfa14
commit 2e51038216
11 changed files with 28 additions and 28 deletions

View File

@ -385,7 +385,7 @@ XPCConvert::NativeData2JS(MutableHandleValue d, const void* s,
return true;
}
case nsXPTType::T_ARRAY:
case nsXPTType::T_LEGACY_ARRAY:
return NativeArray2JS(d, *static_cast<const void* const*>(s),
type.ArrayElementType(), iid, arrlen, pErr);
@ -841,7 +841,7 @@ XPCConvert::JSData2Native(void* d, HandleValue s,
return ok;
}
case nsXPTType::T_ARRAY:
case nsXPTType::T_LEGACY_ARRAY:
{
void** dest = (void**)d;
const nsXPTType& elty = type.ArrayElementType();
@ -1561,7 +1561,7 @@ xpc::InnerCleanupValue(const nsXPTType& aType, void* aValue, uint32_t aArrayLen)
MOZ_ASSERT(aArrayLen == 0 ||
aType.Tag() == nsXPTType::T_PSTRING_SIZE_IS ||
aType.Tag() == nsXPTType::T_PWSTRING_SIZE_IS ||
aType.Tag() == nsXPTType::T_ARRAY,
aType.Tag() == nsXPTType::T_LEGACY_ARRAY,
"Array lengths may only appear for certain types!");
switch (aType.Tag()) {
@ -1599,7 +1599,7 @@ xpc::InnerCleanupValue(const nsXPTType& aType, void* aValue, uint32_t aArrayLen)
break;
// Array Types
case nsXPTType::T_ARRAY:
case nsXPTType::T_LEGACY_ARRAY:
{
const nsXPTType& elty = aType.ArrayElementType();
void* elements = *(void**)aValue;

View File

@ -668,7 +668,7 @@ nsXPCWrappedJSClass::GetArraySizeFromParam(const nsXPTMethodInfo* method,
nsXPTCMiniVariant* nativeParams,
uint32_t* result) const
{
if (type.Tag() != nsXPTType::T_ARRAY &&
if (type.Tag() != nsXPTType::T_LEGACY_ARRAY &&
type.Tag() != nsXPTType::T_PSTRING_SIZE_IS &&
type.Tag() != nsXPTType::T_PWSTRING_SIZE_IS) {
*result = 0;

View File

@ -1258,7 +1258,7 @@ CallMethodHelper::GetArraySizeFromParam(const nsXPTType& type,
HandleValue maybeArray,
uint32_t* result)
{
if (type.Tag() != nsXPTType::T_ARRAY &&
if (type.Tag() != nsXPTType::T_LEGACY_ARRAY &&
type.Tag() != nsXPTType::T_PSTRING_SIZE_IS &&
type.Tag() != nsXPTType::T_PWSTRING_SIZE_IS) {
*result = 0;
@ -1687,7 +1687,7 @@ TraceParam(JSTracer* aTrc, void* aVal, const nsXPTType& aType,
for (uint32_t i = 0; i < sequence->Length(); ++i) {
TraceParam(aTrc, elty.ElementPtr(sequence->Elements(), i), elty);
}
} else if (aType.Tag() == nsXPTType::T_ARRAY && *(void**)aVal) {
} else if (aType.Tag() == nsXPTType::T_LEGACY_ARRAY && *(void**)aVal) {
const nsXPTType& elty = aType.ArrayElementType();
for (uint32_t i = 0; i < aArrayLen; ++i) {

View File

@ -3050,7 +3050,7 @@ nsIPrincipal* GetObjectPrincipal(JSObject* obj);
// value : char[16_t]** (free)
// TD_INTERFACE_TYPE, TD_INTERFACE_IS_TYPE
// value : nsISupports** (release)
// TD_ARRAY (NOTE: aArrayLen should be passed)
// TD_LEGACY_ARRAY (NOTE: aArrayLen should be passed)
// value : void** (cleanup elements & free)
// TD_DOMOBJECT
// value : T** (cleanup)

View File

@ -34,7 +34,7 @@ interface nsIDataType : nsISupports
const uint16_t VTYPE_WCHAR_STR = 17; // TD_PWSTRING = 17,
const uint16_t VTYPE_INTERFACE = 18; // TD_INTERFACE_TYPE = 18,
const uint16_t VTYPE_INTERFACE_IS = 19; // TD_INTERFACE_IS_TYPE = 19,
const uint16_t VTYPE_ARRAY = 20; // TD_ARRAY = 20,
const uint16_t VTYPE_ARRAY = 20; // TD_LEGACY_ARRAY = 20,
const uint16_t VTYPE_STRING_SIZE_IS = 21; // TD_PSTRING_SIZE_IS = 21,
const uint16_t VTYPE_WSTRING_SIZE_IS = 22; // TD_PWSTRING_SIZE_IS = 22,
const uint16_t VTYPE_UTF8STRING = 23; // TD_UTF8STRING = 23,

View File

@ -1672,7 +1672,7 @@ nsVariantBase::nsVariantBase()
{nsIDataType::VTYPE_WCHAR_STR , TD_PWSTRING },
{nsIDataType::VTYPE_INTERFACE , TD_INTERFACE_TYPE },
{nsIDataType::VTYPE_INTERFACE_IS , TD_INTERFACE_IS_TYPE},
{nsIDataType::VTYPE_ARRAY , TD_ARRAY },
{nsIDataType::VTYPE_ARRAY , TD_LEGACY_ARRAY },
{nsIDataType::VTYPE_STRING_SIZE_IS , TD_PSTRING_SIZE_IS },
{nsIDataType::VTYPE_WSTRING_SIZE_IS , TD_PWSTRING_SIZE_IS },
{nsIDataType::VTYPE_UTF8STRING , TD_UTF8STRING },

View File

@ -70,11 +70,11 @@ def get_type(type, calltype, iid_is=None, size_is=None):
'element': get_type(type.type, calltype, iid_is),
}
if isinstance(type, xpidl.Array):
# NB: For an Array<T> we pass down the iid_is to get the type of T.
# This allows Arrays of InterfaceIs types to work.
if isinstance(type, xpidl.LegacyArray):
# NB: For a Legacy [array] T we pass down iid_is to get the type of T.
# This allows [array] of InterfaceIs types to work.
return {
'tag': 'TD_ARRAY',
'tag': 'TD_LEGACY_ARRAY',
'size_is': size_is,
'element': get_type(type.type, calltype, iid_is),
}

View File

@ -81,7 +81,7 @@ long bar(in long a, in float b, [array] in long c);
self.assertEqual("in", m.params[1].paramtype)
self.assertEqual("long", m.params[2].type)
self.assertEqual("in", m.params[2].paramtype)
self.assertTrue(isinstance(m.params[2].realtype, xpidl.Array))
self.assertTrue(isinstance(m.params[2].realtype, xpidl.LegacyArray))
self.assertEqual("long", m.params[2].realtype.type.name)
def testAttribute(self):

View File

@ -1206,7 +1206,7 @@ class Param(object):
def resolve(self, method):
self.realtype = method.iface.idl.getName(self.type, self.location)
if self.array:
self.realtype = Array(self.realtype)
self.realtype = LegacyArray(self.realtype)
if (self.null is not None and
getBuiltinOrNativeTypeName(self.realtype) != '[domstring]'):
raise IDLError("'Null' attribute can only be used on DOMString",
@ -1251,7 +1251,7 @@ class Param(object):
self.name)
class Array(object):
class LegacyArray(object):
def __init__(self, basetype):
self.type = basetype
self.location = self.type.location

View File

@ -280,13 +280,13 @@ def link_to_cpp(interfaces, fd):
tag = type['tag']
d1 = d2 = 0
if tag == 'TD_ARRAY':
if tag == 'TD_LEGACY_ARRAY':
d1 = type['size_is']
d2 = lower_extra_type(type['element'])
elif tag == 'TD_SEQUENCE':
# NOTE: TD_SEQUENCE can hold 16 bits of type index, while TD_ARRAY
# can only hold 8.
# NOTE: TD_SEQUENCE can hold 16 bits of type index, while
# TD_LEGACY_ARRAY can only hold 8.
d1, d2 = splitint(lower_extra_type(type['element']))
elif tag == 'TD_INTERFACE_TYPE':

View File

@ -187,7 +187,7 @@ enum nsXPTTypeTag : uint8_t
TD_PWSTRING = 16,
TD_INTERFACE_TYPE = 17,
TD_INTERFACE_IS_TYPE = 18,
TD_ARRAY = 19,
TD_LEGACY_ARRAY = 19,
TD_PSTRING_SIZE_IS = 20,
TD_PWSTRING_SIZE_IS = 21,
TD_DOMOBJECT = 22,
@ -228,7 +228,7 @@ struct nsXPTType
MOZ_ASSERT(Tag() == TD_INTERFACE_IS_TYPE ||
Tag() == TD_PSTRING_SIZE_IS ||
Tag() == TD_PWSTRING_SIZE_IS ||
Tag() == TD_ARRAY);
Tag() == TD_LEGACY_ARRAY);
return mData1;
}
@ -241,7 +241,7 @@ public:
// fit 8 bits of type data, while sequences support up to 16 bits of type data
// due to not needing to store an ArgNum.
const nsXPTType& ArrayElementType() const {
if (Tag() == TD_ARRAY) {
if (Tag() == TD_LEGACY_ARRAY) {
return xpt::detail::GetType(mData2);
}
MOZ_ASSERT(Tag() == TD_SEQUENCE);
@ -273,13 +273,13 @@ public:
bool IsDependent() const {
return (Tag() == TD_SEQUENCE && InnermostType().IsDependent()) ||
Tag() == TD_INTERFACE_IS_TYPE || Tag() == TD_ARRAY ||
Tag() == TD_INTERFACE_IS_TYPE || Tag() == TD_LEGACY_ARRAY ||
Tag() == TD_PSTRING_SIZE_IS || Tag() == TD_PWSTRING_SIZE_IS;
}
// Unwrap a nested type to its innermost value (e.g. through arrays).
const nsXPTType& InnermostType() const {
if (Tag() == TD_ARRAY || Tag() == TD_SEQUENCE) {
if (Tag() == TD_LEGACY_ARRAY || Tag() == TD_SEQUENCE) {
return ArrayElementType().InnermostType();
}
return *this;
@ -324,7 +324,7 @@ public:
// Helper methods for fabricating nsXPTType values used by xpconnect.
static nsXPTType MkArrayType(Idx aInner) {
MOZ_ASSERT(aInner <= Idx::INTERFACE_IS_TYPE);
return { TD_ARRAY, false, false, false, 0, (uint8_t)aInner };
return { TD_LEGACY_ARRAY, false, false, false, 0, (uint8_t)aInner };
}
static const nsXPTType& Get(Idx aInner) {
MOZ_ASSERT(aInner <= Idx::INTERFACE_IS_TYPE);
@ -359,7 +359,7 @@ public:
TD_ALIAS_(T_WCHAR_STR , TD_PWSTRING );
TD_ALIAS_(T_INTERFACE , TD_INTERFACE_TYPE );
TD_ALIAS_(T_INTERFACE_IS , TD_INTERFACE_IS_TYPE);
TD_ALIAS_(T_ARRAY , TD_ARRAY );
TD_ALIAS_(T_LEGACY_ARRAY , TD_LEGACY_ARRAY );
TD_ALIAS_(T_PSTRING_SIZE_IS , TD_PSTRING_SIZE_IS );
TD_ALIAS_(T_PWSTRING_SIZE_IS , TD_PWSTRING_SIZE_IS );
TD_ALIAS_(T_UTF8STRING , TD_UTF8STRING );
@ -676,7 +676,7 @@ nsXPTType::Stride() const
case TD_PWSTRING: return sizeof(char16_t*);
case TD_INTERFACE_TYPE: return sizeof(nsISupports*);
case TD_INTERFACE_IS_TYPE: return sizeof(nsISupports*);
case TD_ARRAY: return sizeof(void*);
case TD_LEGACY_ARRAY: return sizeof(void*);
case TD_PSTRING_SIZE_IS: return sizeof(char*);
case TD_PWSTRING_SIZE_IS: return sizeof(char16_t*);
case TD_DOMOBJECT: return sizeof(void*);