Package mrv :: Package maya :: Module mdb :: Class CppHeaderParser
[hide private]
[frames] | no frames]

Class CppHeaderParser

source code

object --+
         |
        CppHeaderParser

Simplistic regex based parser which will extract information from the file it was initialized with.

For now its so simple that there is no more than one method

Instance Methods [hide private]

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
parseAndExtract(cls, header_filepath, parse_enums=True)
Parse the given header file and return the parsed information
source code
Class Variables [hide private]
  reEnums = re.compile(r"""^\s+ enum \s+ (?P<name>\w+) \s* \{ ...
  reEnumMembers = re.compile(...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

parseAndExtract(cls, header_filepath, parse_enums=True)
Class Method

source code 
Parse the given header file and return the parsed information
Parameters:
  • header_filepath - Path pointing to the given header file. Its currently assumed to be 7 bit ascii
  • parse_enums - If True, enumerations will be parsed from the file. If False, the enumeration tuple in the return value will be empty.
Returns:
tuple(tuple(MEnumDescriptor, ...), )

Note: Currently we can only parse non-anonymous enumerations !


Class Variable Details [hide private]

reEnums

Value:
re.compile(r"""^\s+ enum \s+ (?P<name>\w+) \s* \{                 # en\
um EnumName
                               (?P<members>[\(\)/\w\s,\-+="'\.\#!<\*\\\
]+)     # match whitespace or newlines
                               \}[ \t]*;[ \t]*$                       \
          # closing brace""", re.MULTILINE | re.VERBOSE)

reEnumMembers

Value:
re.compile("""
	                           [\t ]{2,}                                 \
       # assure we don't get something within the comment
								(k\w+)[ ]*                                       # find kSomet\
hing
								(?:=[ ]*[\w]+[ ]*)?                              # optionally \
find initializer = int|other_enum_member
								""", re.VERBOSE)