Bug 362843 xpidl should warn about attribute anytype aaaIAa ([a-z]{2,3}I[A-Z][a-z])

r=bsmedberg
This commit is contained in:
timeless%mozdev.org 2006-12-07 20:10:34 +00:00
Родитель bd52908b8a
Коммит 4bfc04e48c
1 изменённых файлов: 50 добавлений и 0 удалений

Просмотреть файл

@ -250,6 +250,44 @@ verify_type_fits_version(IDL_tree in_tree, IDL_tree error_tree)
return TRUE;
}
static gboolean
IsNot_AlphaUpper(char letter)
{
return letter < 'A' || letter > 'Z';
}
static gboolean
IsNot_AlphaLower(char letter)
{
return letter < 'a' || letter > 'z';
}
static gboolean
matches_IFoo(const char* substring)
{
if (substring[0] != 'I')
return FALSE;
if (IsNot_AlphaUpper(substring[1]))
return FALSE;
if (IsNot_AlphaLower(substring[2]))
return FALSE;
return TRUE;
}
static gboolean
matches_nsIFoo(const char* attribute_name)
{
if (IsNot_AlphaLower(attribute_name[0]))
return FALSE;
if (IsNot_AlphaLower(attribute_name[1]))
return FALSE;
if (matches_IFoo(attribute_name + 2))
return TRUE;
if (IsNot_AlphaLower(attribute_name[2]))
return FALSE;
return matches_IFoo(attribute_name + 3);
}
gboolean
verify_attribute_declaration(IDL_tree attr_tree)
{
@ -344,6 +382,18 @@ verify_attribute_declaration(IDL_tree attr_tree)
return FALSE;
}
/*
* canIGoHomeNow is a bad name for an attribute.
* /^[a-z]{2,3}I[A-Z][a-z]/ => bad, reserved for
* interface flattening.
*/
if (matches_nsIFoo(IDL_IDENT(IDL_LIST(IDL_ATTR_DCL(attr_tree).
simple_declarations).data).str)) {
XPIDL_WARNING((attr_tree, IDL_WARNING1,
"Naming an attribute nsIFoo causes "
"problems for interface flattening"));
}
/*
* Run additional error checks on the attribute type if targetting an
* older version of XPConnect.