cslug.c_parse
The cslug.c_parse submodule provides some very bare-bones C parsing
tools.
This module's sole purpose is to extract function and struct declarations to
generate prototypes in automatically generated header files, and to parse
type information from the declarations to be passed to cslug.Types.
For a proper C parser, use pycparser.
- class cslug.c_parse.TokenType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntFlag- CODE = 4
- COMMENT = 1
- LITERAL = 2
- cslug.c_parse.parse_function(string, typedefs=None)[source]
Parse a function declaration into its name, its return type and its arguments.
- cslug.c_parse.parse_parameter(string, typedefs=None)[source]
Parse a variable or parameter declaration such as
int * foo.- Parameters:
string (str) – Declaration to parse.
typedefs
- Returns:
(ctypes_type_name, pointers, name)- Return type:
The pointers output is a count of how many layers of pointer referencing cover the raw value. i.e. How many
*s or[]s.