@@ -324,7 +324,7 @@ def parse(self, data):
324324 self ._constants (data )
325325 self ._enums (data )
326326 self ._structs (data )
327- self ._lookups (data , self . cstruct . consts )
327+ self ._lookups (data )
328328
329329 def _constants (self , data ):
330330 r = re .finditer (r'#define\s+(?P<name>[^\s]+)\s+(?P<value>[^\r\n]+)\s*\n' , data )
@@ -375,7 +375,7 @@ def _parse_fields_enums(self, s):
375375 commentAttributes = self .parse_comment_block (d ['commentBlock' ])
376376
377377 field = re .finditer (
378- r'(?P<key>[a-zA-z][^ =]*)[ ]*=?[ ]*(?P<value>[^ ]+)?' ,
378+ r'(?P<key>[a-zA-z][^ =]*)[ ]*=?[ ]*(?P<value>[^,/ ]+)?' ,
379379 d ["value" ],
380380 )
381381
@@ -484,7 +484,7 @@ def parse_comment_block(self,s):
484484
485485 return commentAttributes
486486
487- def _lookups (self , data , consts ):
487+ def _lookups (self , data ):
488488 r = re .finditer (r'\$(?P<name>[^\s]+) = ({[^}]+})\w*\n' , data )
489489
490490 for t in r :
@@ -493,6 +493,15 @@ def _lookups(self, data, consts):
493493 [(self .cstruct .consts [k ], v ) for k , v in d .items ()]
494494 )
495495
496+ #support simple defines
497+ r = re .finditer (r'^[ \t]*#define (?P<name>[^\s]+)[ \t]+(?P<value>\(?-?[0-9]+U?\)?)\n?' , data )
498+
499+ for t in r :
500+ d = ast .literal_eval (t .group (2 ))
501+ self .cstruct .lookups [t .group (1 )] = dict (
502+ [(self .cstruct .consts [k ], v ) for k , v in d .items ()]
503+ )
504+
496505
497506class Instance (object ):
498507 """Holds parsed structure data."""
0 commit comments