@@ -328,7 +328,7 @@ def getStructTypes(self):
328328 return self .getTypes (StructureType )
329329
330330 def getMacroTypes (self ):
331- return self .getTypes ( MacroType )
331+ return self .consts
332332
333333
334334class Parser (object ):
@@ -367,14 +367,13 @@ def clearVersionDetails(self):
367367 self .structVersionDetails = {"name" :"" , "valB" :2 ** 16 - 1 , "valL" :0 }
368368
369369 def parse (self , data ):
370- self ._macros (data )
371370 self ._constants (data )
372371 self ._enums (data )
373372 self ._structs (data )
374373 self ._lookups (data )
375374
376375 def _constants (self , data ):
377- r = re .finditer (r'#define\s+(?P<name>[^\s]+)\s+(?P<value>[^\r\n]+)\s*\n' , data )
376+ r = re .finditer (COMMENT_REGEX_START + r'#define\s+(?P<name>[^\s\r\n ]+)\s+(?P<value>[^\s\ r\n]+)\s*\n' + COMMENT_REGEX_END , data )
378377 for t in r :
379378 d = t .groupdict ()
380379 v = d ['value' ].rsplit ('//' )[0 ]
@@ -497,10 +496,11 @@ def getNumber(sign:str, number:int):
497496 s , re .MULTILINE
498497 )
499498 r :list [StructureFieldType ] = []
499+ # print(regex)
500+ # print(s)
500501
501502 for f in fields :
502503 d = f .groupdict ()
503- # print(regex)
504504 # print(d)
505505 if d .get ("if" ,None ) != None :
506506 macroNameA = d .get ('macroNameA' ,None )
@@ -529,10 +529,8 @@ def getNumber(sign:str, number:int):
529529 self .structVersionDetails ["valB" ] = numB
530530 elif dirB == ">" :
531531 self .structVersionDetails ["valL" ] = numB
532- continue
533532 if d .get ("endif" ,None ) != None :
534533 self .clearVersionDetails ()
535- continue
536534 if d ['type' ].startswith ('//' ):
537535 continue
538536
@@ -586,19 +584,6 @@ def parse_comment_block(self,s):
586584
587585 return commentAttributes
588586
589- def _macros (self , s ):
590- r = re .finditer (
591- COMMENT_REGEX_START + r'#define\s*(?P<name>[A-Za-z0-9_]+)\s+(?P<value>[A-Za-z0-9_"()])' + COMMENT_REGEX_END ,
592- s , re .MULTILINE
593- )
594-
595- for t in r :
596- d = t .groupdict ()
597-
598- mt = MacroType (self .cstruct , d ["name" ], d ["value" ])
599-
600- self .cstruct .addtype (d ['name' ], mt , True )
601-
602587 def _lookups (self , data ):
603588 r = re .finditer (r'\$(?P<name>[^\s]+) = ({[^}]+})\w*\n' , data )
604589
@@ -1539,13 +1524,6 @@ def __repr__(self):
15391524 return '<EnumType {}>' .format (self .name )
15401525
15411526
1542- class MacroType (RawType ):
1543- def __init__ (self , cstruct , name :str , value :typing .Any ):
1544- self .name = name
1545- self .value = value
1546- super (MacroType , self ).__init__ (cstruct , name , 0 )
1547-
1548-
15491527class EnumInstance (object ):
15501528 """Implements a value instance of an EnumType"""
15511529
0 commit comments