Utilities
Module for extracting cython headers from the Spinnaker headers. For example:
header = r'E:\FLIR\Spinnaker\include\spinc\FSpinnakerC'
content = parse_header('{}.h'.format(header))
dump_cython(content, '{}.h'.format(header), '{}.pxi'.format(header))
Or to get the class nodes:
content = parse_class_vars(f)
dump_genapi_var_type_prop_cython(content, f'{name}.px')
Classes:
Represents a variable declaration in e.g. |
|
Represents a c function prototype. |
|
Represents a c struct definition. |
|
Represents a c enum definition. |
|
Represents a c enum member. |
|
Represents a c typedef. |
|
Represnts a Node that is a class variable in the header. |
Functions:
Returns the headers with comments removed. |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a list of |
|
Generates a cython typedef from a |
|
Returns a cython enum from a |
|
Returns a cython variable from a |
|
Returns a cython function from a |
|
Returns a cython struct from a |
|
Generates a cython pxi file from the output of |
|
Parses the variable nodes from a header. |
|
Dumps all the nodes as |
|
Dumps all the C++ class nodes in the format to be included in a pxi file representing the header import. |
|
Dumps all the names of the nodes of a cython class and groups them into the type of node, e.g. |
- class VariableSpec(type, pointer, name, count)
Bases:
tuple
Represents a variable declaration in e.g. the definition of a function or its return value.
Attributes:
Alias for field number 3
Alias for field number 2
Alias for field number 1
Alias for field number 0
- count
Alias for field number 3
- name
Alias for field number 2
- pointer
Alias for field number 1
- type
Alias for field number 0
- class FunctionSpec(dec, type, pointer, name, args)
Bases:
tuple
Represents a c function prototype.
Attributes:
Alias for field number 4
Alias for field number 0
Alias for field number 3
Alias for field number 2
Alias for field number 1
- args
Alias for field number 4
- dec
Alias for field number 0
- name
Alias for field number 3
- pointer
Alias for field number 2
- type
Alias for field number 1
- class StructSpec(tp_name, names, members)
Bases:
tuple
Represents a c struct definition.
Attributes:
Alias for field number 2
Alias for field number 1
Alias for field number 0
- members
Alias for field number 2
- names
Alias for field number 1
- tp_name
Alias for field number 0
- class EnumSpec(tp_name, names, values)
Bases:
tuple
Represents a c enum definition.
Attributes:
Alias for field number 1
Alias for field number 0
Alias for field number 2
- names
Alias for field number 1
- tp_name
Alias for field number 0
- values
Alias for field number 2
- class EnumMemberSpec(name, value)
Bases:
tuple
Represents a c enum member.
Attributes:
Alias for field number 0
Alias for field number 1
- name
Alias for field number 0
- value
Alias for field number 1
- class TypeDef(body)
Bases:
tuple
Represents a c typedef.
Attributes:
Alias for field number 0
- body
Alias for field number 0
- class GenAPIVarSpec(visibility, type_name, type_template, name, description)
Bases:
tuple
Represnts a Node that is a class variable in the header.
Attributes:
Alias for field number 4
Alias for field number 3
Alias for field number 1
Alias for field number 2
Alias for field number 0
- description
Alias for field number 4
- name
Alias for field number 3
- type_name
Alias for field number 1
- type_template
Alias for field number 2
- visibility
Alias for field number 0
- parse_prototype(prototype)[source]
Returns a
FunctionSpec
instance from the input.
- parse_struct(type_name, body, name)[source]
Returns a
StructSpec
instance from the input.
- parse_header(filename)[source]
Returns a list of
VariableSpec
,FunctionSpec
,StructSpec
,EnumSpec
,EnumMemberSpec
, andTypeDef
instances representing the c header file.
- format_variable(variable)[source]
Returns a cython variable from a
VariableSpec
instance.
- format_function(function)[source]
Returns a cython function from a
FunctionSpec
instance.
- format_struct(struct_def)[source]
Returns a cython struct from a
StructSpec
instance.
- dump_cython(content, name, ofile)[source]
Generates a cython pxi file from the output of
parse_header()
.
- dump_genapi_prop_cython(items: List[GenAPIVarSpec], ofile, prop_storage_name='_nodes', cam_name='_camera', handle_name='_camera', prop_prefix='', name_mod='.camera', enum_suffix='Enum')[source]
Dumps all the nodes as
@property
methods of a cython class.
- dump_genapi_import_prop_cython(items: List[GenAPIVarSpec], ofile)[source]
Dumps all the C++ class nodes in the format to be included in a pxi file representing the header import.
- dump_genapi_var_type_prop_cython(items: List[GenAPIVarSpec], ofile)[source]
Dumps all the names of the nodes of a cython class and groups them into the type of node, e.g. string, float, enum etc.