macrogen
FreeBodyEngine.cli.cpp.macrogen
#
Param = Tuple[str, str]
module-attribute
#
CppBindingGenerator(source, module_name='my_module')
#
Parses one C++ file's //@bind-marked functions/classes and can emit
a pybind11 registration function for them - register(m), which the
caller wires into whatever module/submodule it wants, rather than a
self-contained PYBIND11_MODULE block. That split is what lets many
bound files share a single compiled extension (only one PYBIND11_MODULE
entry point may exist per shared library), which in turn is what lets
ordinary multi-file C++ - separate translation units linked together -
work at all.
Stores the raw C++ source and target module_name, plus the
C++ -> Python type map used by _cpp_to_python_type. Call
parse() before using any of the generation methods.
classes = []
instance-attribute
#
functions = []
instance-attribute
#
module_name = module_name
instance-attribute
#
source = source
instance-attribute
#
type_map = {'void': 'None', 'bool': 'bool', 'int': 'int', 'long': 'int', 'float': 'float', 'double': 'float', 'std::string': 'str', 'string': 'str', 'const std::string&': 'str', 'const std::string &': 'str', 'std::vector': 'list', 'vector': 'list'}
instance-attribute
#
free_function_declarations()
#
Forward declarations for this file's bound free functions -
enough for a separate translation unit to reference them (and link
against wherever they're actually defined) without needing to
#include the file itself, which would double-define them if that
file is also compiled on its own.
generate_bindings_function(function_name)
#
Emits void <function_name>(pybind11::module_& m) { ... },
registering every //@bind class/function this file declared into
whatever module or submodule m the caller passes in.
generate_pyi()
#
Generate Python stub file (.pyi) for type checking
has_bindings()
#
True if this file declared any //@bind classes or free
functions.
parse()
#
Scans source line by line for //@bind markers, dispatching
each one into class/struct parsing or free-function parsing, and
populates self.classes/self.functions.
CppClass(name)
#
A parsed C++ class/struct: its public constructors, methods and
attributes, as discovered by CppBindingGenerator.
Stores the class name and starts with empty constructor/method/ attribute lists, filled in as parsing proceeds.
attributes = []
instance-attribute
#
constructors = []
instance-attribute
#
methods = []
instance-attribute
#
name = name
instance-attribute
#
add_attribute(name)
#
Records a public attribute name.
add_constructor(params_raw, parse_params)
#
Parses params_raw with parse_params (passed in by the caller
to avoid a circular reference back to the generator) and records the
resulting constructor.
add_method(name, params_raw, return_type, parse_params)
#
Parses params_raw with parse_params and records the
resulting method, unless name matches the class name (a
constructor mis-parsed as a method).