Index: mozilla/xpcom/typelib/xpidl/xpidl_util.c =================================================================== RCS file: /cvsroot/mozilla/xpcom/typelib/xpidl/xpidl_util.c,v retrieving revision 1.21 diff -u -r1.21 mozilla/xpcom/typelib/xpidl/xpidl_util.c --- mozilla/xpcom/typelib/xpidl/xpidl_util.c +++ mozilla/xpcom/typelib/xpidl/xpidl_util.c @@ -251,6 +251,42 @@ } gboolean +matches_IFoo(const char* substring) +{ + char letter = *substring; + if (letter != 'I') + return FALSE; + substring++; + letter = *substring; + if (letter < 'A' || + letter > 'Z') + return FALSE; + substring++; + letter = *substring; + if (letter < 'a' || + letter > 'z') + return FALSE; + return TRUE; +} + +gboolean +matches_nsIFoo(const char* attribute_name) +{ + if (attribute_name[0] < 'a' || + attribute_name[0] > 'z') + return FALSE; + if (attribute_name[1] < 'a' || + attribute_name[1] > 'z') + return FALSE; + if (matches_IFoo(attribute_name+2)) + return TRUE; + if (attribute_name[1] < 'a' || + attribute_name[1] > 'z') + return FALSE; + return matches_IFoo(attribute_name+3); +} + +gboolean verify_attribute_declaration(IDL_tree attr_tree) { IDL_tree iface; @@ -344,6 +380,18 @@ 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.