msl.equipment.resources.utils module
Utility functions/classes to help create modules in the msl.equipment.resources package.
- msl.equipment.resources.utils.camelcase_to_underscore(text)[source]
Converts
CamelCaseText
tocamel_case_text
.
- msl.equipment.resources.utils.get_lines(path, remove_comments=True)[source]
Returns the lines in a C/C++ header file that are not empty.
Also strips the whitespace from each line and can optionally remove the comments.
- class msl.equipment.resources.utils.CHeader(path, remove_comments=True)[source]
Bases:
object
Parses a C/C++ header file to determine the constants, enums, structs, callbacks and the function signatures.
- Parameters:
- constants(ignore_ifdef=True)[source]
Finds the
#define
statements that are in the C/C++ header file.
- enums()[source]
- Returns:
dict
– Theenums
that are defined in the C/C++ header file. The value for each dictionary key is a tuple of(the enum name, the enum data type, a dict of name-value pairs)
.
- functions(regex)[source]
Returns the function signatures.
- Parameters:
regex (
str
) –The regex must contain 2 groups,
(return type)(function name)
, and it must match the function declaration up until, but excluding, the(
which begins the argument declarations.For example,
If the function declarations are similar to
FILTERFLIPPERDLL_API unsigned int __cdecl FF_GetTransitTime(const char * serialNo);
then the value of regex could ber'_API\s+([\w\s]+?)__cdecl\s+(\w+)'
If the function declarations are similar to
PREF0 PREF1 PICO_STATUS PREF2 PREF3 (ps6000OpenUnit)(int16_t *handle, int8_t *serial);
then the value of regex could ber'PREF0\s+PREF1\s+(\w+)\s+PREF2\s+PREF3\s+\((\w+)\)'
- Returns:
dict
– The function signature. The key is the function name and the value is a list of[return type, [(argument data type, argument name), ... ] ]
.
- get_struct_imports()[source]
-
Note
Must call
functions()
first.