PythonOverloads¶
Note
Generated from the C++ headers by apiary --emit-cpp-docs-json.
-
class ExpandedParam¶
One C++ parameter after a template parameter pack has been expanded.
-
std::string type¶
Concrete parameter type, with the pack’s template parameter substituted.
-
std::string name¶
Parameter name; an expanded pack element gets its index appended.
-
std::string type¶
-
void compute_python_overloads(BoundFunction &f)¶
Compute and assign
f.python_overloads.Note
Idempotent — calling twice on the same function clears the previous result first.
Warning
Calls to this must happen after the Visitor has finished populating instantiations.
- Parameters:
f – The bound function whose
python_overloadsare computed and assigned.
-
void compute_python_overloads(Module &module_)¶
Walk every function in
module_and run compute_python_overloads on it.- Parameters:
module – The module whose functions are processed.
-
void drop_unbindable_names(Module &module_)¶
Drop every entity whose Python name is not a Python identifier.
A C++ name is not always a Python one. A free
operator*exposed without a rename reached both emitters verbatim: the binding registered it under a name no Python caller can type, and the stub emitteddef operator*(...), which is a syntax error - so the whole.pyifailed to parse and the type checker got nothing from the file, not just nothing for that function.apiary cannot represent this, so it says so and binds nothing rather than emitting something unusable. The report is an error, not a warning: the author wrote APIARY_EXPOSE, the fix is one annotation away (
APIARY_RENAME, orAPIARY_OPERATORon a class member), and a build that quietly lacks a function the source asked for is worse than one that stops.Filtering the module once, before either emitter runs, rather than checking at each of the fifteen places a name is chosen: one policy, one diagnostic, and no way for the two emitters to disagree about what got bound.
- Parameters:
module – The module to filter in place.
-
std::vector<std::string> dtype_aliases_for(const std::string &cpp_type)¶
Map a C++ scalar type to its accepted dtype-string aliases.
Note
The dispatcher path only triggers for known dtypes.
- Parameters:
cpp_type – The C++ scalar type to map.
- Returns:
The accepted dtype-string aliases, or empty when the type isn’t a recognized dtype.
-
std::vector<ExpandedParam> expand_parameter_pack(const std::vector<ExpandedParam> ¶ms, const std::vector<std::string> &template_param_names, const std::vector<std::string> &type_args)¶
Expand a trailing parameter pack against an instantiation’s arguments.
A pack has no arity until it is instantiated, and
Ts... valuesreaches both emitters as the single parameterTs.... Re-emitted verbatim that is a disaster in either target:double...in a C++ cast is VARARGS, so the cast names nothing and the TU will not compile, and in a.pyiit is not even valid syntax, which costs the type checker the whole file.The instantiation supplies the arity. Template parameters before the pack consume one argument each; the pack takes the rest - which is the only arrangement a function template’s pack can have, since it must be last to be deducible.
- Parameters:
params – Declared parameters, as (type, name) pairs.
template_param_names – The function template’s parameter names, in order.
type_args – The instantiation’s type arguments, already split.
- Returns:
The parameter list with any pack expanded; unchanged when there is none.
-
std::string pick_default_dtype(const std::vector<std::string> &dtype_values_in_order)¶
Pick the default dtype string for a dispatcher group.
Note
Numpy convention favors
float64(double) when present; otherwise the first instance’s first alias.- Parameters:
dtype_values_in_order – The dtype values in instantiation order.
- Returns:
The default dtype string.
-
std::vector<std::string> split_instantiation_args(const std::string &combo)¶
Split a per-instantiation comma-joined string into individual values, respecting
<>nesting.- Parameters:
combo – The comma-joined instantiation string, e.g.
"float, 2".- Returns:
The individual values, e.g.
{"float", "2"}.