From 80c76492b3118a983bd5d109a79d5336d694f514 Mon Sep 17 00:00:00 2001 From: Joshua Cranmer Date: Thu, 25 Aug 2011 10:24:58 -0700 Subject: [PATCH] Bug 681740 - xpidl.py does not resolve references to consts in superinterfaces. r=bsmedberg --HG-- extra : rebase_source : 8b860e76fa0634b408dc15c6e1a3c587ae080cd7 --- xpcom/idl-parser/xpidl.py | 8 ++- xpcom/idl-parser/xpidlyacc.py | 112 +++++++++++++++++----------------- 2 files changed, 63 insertions(+), 57 deletions(-) diff --git a/xpcom/idl-parser/xpidl.py b/xpcom/idl-parser/xpidl.py index 9bb4c6c56b22..ca31b959a4c8 100644 --- a/xpcom/idl-parser/xpidl.py +++ b/xpcom/idl-parser/xpidl.py @@ -565,7 +565,13 @@ class Interface(object): return "".join(l) def getConst(self, name, location): - c = self.namemap.get(name, location) + # The constant may be in a base class + iface = self + while name not in iface.namemap and iface is not None: + iface = self.idl.getName(self.base, self.location) + if iface is None: + raise IDLError("cannot find symbol '%s'" % name, c.location) + c = iface.namemap.get(name, location) if c.kind != 'const': raise IDLError("symbol '%s' is not a constant", c.location) diff --git a/xpcom/idl-parser/xpidlyacc.py b/xpcom/idl-parser/xpidlyacc.py index 4cf721f5f593..679402ee34bb 100644 --- a/xpcom/idl-parser/xpidlyacc.py +++ b/xpcom/idl-parser/xpidlyacc.py @@ -26,60 +26,60 @@ for _k, _v in _lr_goto_items.items(): del _lr_goto_items _lr_productions = [ ("S' -> idlfile","S'",1,None,None,None), - ('idlfile -> productions','idlfile',1,'p_idlfile','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1055), - ('productions -> ','productions',0,'p_productions_start','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1059), - ('productions -> CDATA productions','productions',2,'p_productions_cdata','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1063), - ('productions -> INCLUDE productions','productions',2,'p_productions_include','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1068), - ('productions -> interface productions','productions',2,'p_productions_interface','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1073), - ('productions -> typedef productions','productions',2,'p_productions_interface','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1074), - ('productions -> native productions','productions',2,'p_productions_interface','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1075), - ('typedef -> TYPEDEF IDENTIFIER IDENTIFIER ;','typedef',4,'p_typedef','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1080), - ('native -> attributes NATIVE IDENTIFIER afternativeid ( NATIVEID ) ;','native',8,'p_native','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1087), - ('afternativeid -> ','afternativeid',0,'p_afternativeid','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1094), - ('anyident -> IDENTIFIER','anyident',1,'p_anyident','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1100), - ('anyident -> CONST','anyident',1,'p_anyident','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1101), - ('attributes -> [ attlist ]','attributes',3,'p_attributes','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1106), - ('attributes -> ','attributes',0,'p_attributes','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1107), - ('attlist -> attribute','attlist',1,'p_attlist_start','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1115), - ('attlist -> attribute , attlist','attlist',3,'p_attlist_continue','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1119), - ('attribute -> anyident attributeval','attribute',2,'p_attribute','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1124), - ('attributeval -> ( IDENTIFIER )','attributeval',3,'p_attributeval','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1128), - ('attributeval -> ( IID )','attributeval',3,'p_attributeval','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1129), - ('attributeval -> ','attributeval',0,'p_attributeval','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1130), - ('interface -> attributes INTERFACE IDENTIFIER ifacebase ifacebody ;','interface',6,'p_interface','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1135), - ('ifacebody -> { members }','ifacebody',3,'p_ifacebody','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1164), - ('ifacebody -> ','ifacebody',0,'p_ifacebody','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1165), - ('ifacebase -> : IDENTIFIER','ifacebase',2,'p_ifacebase','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1170), - ('ifacebase -> ','ifacebase',0,'p_ifacebase','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1171), - ('members -> ','members',0,'p_members_start','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1176), - ('members -> member members','members',2,'p_members_continue','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1180), - ('member -> CDATA','member',1,'p_member_cdata','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1185), - ('member -> CONST IDENTIFIER IDENTIFIER = number ;','member',6,'p_member_const','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1189), - ('number -> NUMBER','number',1,'p_number_decimal','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1197), - ('number -> HEXNUM','number',1,'p_number_hex','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1202), - ('number -> IDENTIFIER','number',1,'p_number_identifier','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1207), - ('number -> ( number )','number',3,'p_number_paren','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1213), - ('number -> - number','number',2,'p_number_neg','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1217), - ('number -> number + number','number',3,'p_number_add','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1222), - ('number -> number - number','number',3,'p_number_add','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1223), - ('number -> number * number','number',3,'p_number_add','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1224), - ('number -> number LSHIFT number','number',3,'p_number_shift','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1235), - ('number -> number RSHIFT number','number',3,'p_number_shift','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1236), - ('number -> number | number','number',3,'p_number_bitor','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1245), - ('member -> attributes optreadonly ATTRIBUTE IDENTIFIER IDENTIFIER ;','member',6,'p_member_att','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1251), - ('member -> attributes IDENTIFIER IDENTIFIER ( paramlist ) raises ;','member',8,'p_member_method','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1267), - ('paramlist -> param moreparams','paramlist',2,'p_paramlist','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1282), - ('paramlist -> ','paramlist',0,'p_paramlist','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1283), - ('moreparams -> ','moreparams',0,'p_moreparams_start','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1291), - ('moreparams -> , param moreparams','moreparams',3,'p_moreparams_continue','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1295), - ('param -> attributes paramtype IDENTIFIER IDENTIFIER','param',4,'p_param','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1300), - ('paramtype -> IN','paramtype',1,'p_paramtype','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1308), - ('paramtype -> INOUT','paramtype',1,'p_paramtype','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1309), - ('paramtype -> OUT','paramtype',1,'p_paramtype','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1310), - ('optreadonly -> READONLY','optreadonly',1,'p_optreadonly','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1314), - ('optreadonly -> ','optreadonly',0,'p_optreadonly','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1315), - ('raises -> RAISES ( idlist )','raises',4,'p_raises','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1322), - ('raises -> ','raises',0,'p_raises','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1323), - ('idlist -> IDENTIFIER','idlist',1,'p_idlist','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1330), - ('idlist -> IDENTIFIER , idlist','idlist',3,'p_idlist_continue','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1334), + ('idlfile -> productions','idlfile',1,'p_idlfile','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1088), + ('productions -> ','productions',0,'p_productions_start','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1092), + ('productions -> CDATA productions','productions',2,'p_productions_cdata','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1096), + ('productions -> INCLUDE productions','productions',2,'p_productions_include','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1101), + ('productions -> interface productions','productions',2,'p_productions_interface','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1106), + ('productions -> typedef productions','productions',2,'p_productions_interface','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1107), + ('productions -> native productions','productions',2,'p_productions_interface','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1108), + ('typedef -> TYPEDEF IDENTIFIER IDENTIFIER ;','typedef',4,'p_typedef','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1113), + ('native -> attributes NATIVE IDENTIFIER afternativeid ( NATIVEID ) ;','native',8,'p_native','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1120), + ('afternativeid -> ','afternativeid',0,'p_afternativeid','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1127), + ('anyident -> IDENTIFIER','anyident',1,'p_anyident','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1133), + ('anyident -> CONST','anyident',1,'p_anyident','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1134), + ('attributes -> [ attlist ]','attributes',3,'p_attributes','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1139), + ('attributes -> ','attributes',0,'p_attributes','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1140), + ('attlist -> attribute','attlist',1,'p_attlist_start','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1148), + ('attlist -> attribute , attlist','attlist',3,'p_attlist_continue','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1152), + ('attribute -> anyident attributeval','attribute',2,'p_attribute','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1157), + ('attributeval -> ( IDENTIFIER )','attributeval',3,'p_attributeval','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1161), + ('attributeval -> ( IID )','attributeval',3,'p_attributeval','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1162), + ('attributeval -> ','attributeval',0,'p_attributeval','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1163), + ('interface -> attributes INTERFACE IDENTIFIER ifacebase ifacebody ;','interface',6,'p_interface','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1168), + ('ifacebody -> { members }','ifacebody',3,'p_ifacebody','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1197), + ('ifacebody -> ','ifacebody',0,'p_ifacebody','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1198), + ('ifacebase -> : IDENTIFIER','ifacebase',2,'p_ifacebase','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1203), + ('ifacebase -> ','ifacebase',0,'p_ifacebase','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1204), + ('members -> ','members',0,'p_members_start','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1209), + ('members -> member members','members',2,'p_members_continue','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1213), + ('member -> CDATA','member',1,'p_member_cdata','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1218), + ('member -> CONST IDENTIFIER IDENTIFIER = number ;','member',6,'p_member_const','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1222), + ('number -> NUMBER','number',1,'p_number_decimal','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1230), + ('number -> HEXNUM','number',1,'p_number_hex','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1235), + ('number -> IDENTIFIER','number',1,'p_number_identifier','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1240), + ('number -> ( number )','number',3,'p_number_paren','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1246), + ('number -> - number','number',2,'p_number_neg','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1250), + ('number -> number + number','number',3,'p_number_add','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1255), + ('number -> number - number','number',3,'p_number_add','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1256), + ('number -> number * number','number',3,'p_number_add','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1257), + ('number -> number LSHIFT number','number',3,'p_number_shift','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1268), + ('number -> number RSHIFT number','number',3,'p_number_shift','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1269), + ('number -> number | number','number',3,'p_number_bitor','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1278), + ('member -> attributes optreadonly ATTRIBUTE IDENTIFIER IDENTIFIER ;','member',6,'p_member_att','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1284), + ('member -> attributes IDENTIFIER IDENTIFIER ( paramlist ) raises ;','member',8,'p_member_method','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1300), + ('paramlist -> param moreparams','paramlist',2,'p_paramlist','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1315), + ('paramlist -> ','paramlist',0,'p_paramlist','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1316), + ('moreparams -> ','moreparams',0,'p_moreparams_start','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1324), + ('moreparams -> , param moreparams','moreparams',3,'p_moreparams_continue','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1328), + ('param -> attributes paramtype IDENTIFIER IDENTIFIER','param',4,'p_param','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1333), + ('paramtype -> IN','paramtype',1,'p_paramtype','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1341), + ('paramtype -> INOUT','paramtype',1,'p_paramtype','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1342), + ('paramtype -> OUT','paramtype',1,'p_paramtype','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1343), + ('optreadonly -> READONLY','optreadonly',1,'p_optreadonly','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1347), + ('optreadonly -> ','optreadonly',0,'p_optreadonly','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1348), + ('raises -> RAISES ( idlist )','raises',4,'p_raises','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1355), + ('raises -> ','raises',0,'p_raises','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1356), + ('idlist -> IDENTIFIER','idlist',1,'p_idlist','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1363), + ('idlist -> IDENTIFIER , idlist','idlist',3,'p_idlist_continue','/src/trunk/mozilla/xpcom/idl-parser/xpidl.py',1367), ]