Turi Create
4.0
|
Namespaces | |
docstring_macro_impl | |
Macros | |
#define | BEGIN_CLASS_MEMBER_REGISTRATION(python_facing_classname) |
#define | REGISTER_CLASS_MEMBER_FUNCTION(function, ...) |
#define | REGISTER_NAMED_CLASS_MEMBER_FUNCTION(name, function, ...) |
#define | BEGIN_BASE_CLASS_MEMBER_REGISTRATION() |
#define | IMPORT_BASE_CLASS_REGISTRATION(base_class) |
#define | REGISTER_CLASS_MEMBER_DOCSTRING(name, docstring) this->register_docstring(docstring_macro_impl::get_docstring(&name, #name, docstring)); |
#define | REGISTER_CLASS_DOCSTRING(docstring) this->register_docstring({"__doc__", docstring}); |
#define | REGISTER_GETTER(propname, function) |
#define | REGISTER_SETTER(propname, function) |
#define | REGISTER_PROPERTY(propname) |
#define | BEGIN_CLASS_REGISTRATION |
#define | END_CLASS_MEMBER_REGISTRATION set_registered(); } |
#define | REGISTER_CLASS(class_name) |
#define | END_CLASS_REGISTRATION |
The class Extension Interface provides a collection of macros that automate the process of exporting a class to Python. The macros are located in sdk/toolkit_class_macros.hpp.
For detailed usage descriptions, see page_turicreate_extension_interface .
Example:
#define BEGIN_BASE_CLASS_MEMBER_REGISTRATION | ( | ) |
Begins a class member registration block for base classes. These
BEGIN_BASE_CLASS_MEMBER_REGISTRATION()
The basic usage is to put this inside a class to be published, and go:
In the parent class, you would register
Definition at line 154 of file toolkit_class_macros.hpp.
#define BEGIN_CLASS_MEMBER_REGISTRATION | ( | python_facing_classname | ) |
Begins a class member registration block.
BEGIN_CLASS_MEMBER_REGISTRATION(python_facing_classname)
The basic usage is to put this inside a class to be published, and go:
Definition at line 68 of file toolkit_class_macros.hpp.
#define BEGIN_CLASS_REGISTRATION |
Begins a class registration block. Basic usage:
Definition at line 417 of file toolkit_class_macros.hpp.
#define END_CLASS_MEMBER_REGISTRATION set_registered(); } |
Ends a class member registration block. See BEGIN_CLASS_MEMBER_REGISTRATION
Definition at line 427 of file toolkit_class_macros.hpp.
#define END_CLASS_REGISTRATION |
Ends a class registration block.
Basic usage:
Definition at line 470 of file toolkit_class_macros.hpp.
#define IMPORT_BASE_CLASS_REGISTRATION | ( | base_class | ) |
Begins a class member registration block for a base class.
BEGIN_BASE_CLASS_MEMBER_REGISTRATION()
The basic usage is to put this inside a class that is the base class of an inherited, and go:
Definition at line 171 of file toolkit_class_macros.hpp.
#define REGISTER_CLASS | ( | class_name | ) |
Begins a class registration block.
Basic usage:
Definition at line 442 of file toolkit_class_macros.hpp.
#define REGISTER_CLASS_DOCSTRING | ( | docstring | ) | this->register_docstring({"__doc__", docstring}); |
Registers a docstring of a class
Definition at line 320 of file toolkit_class_macros.hpp.
#define REGISTER_CLASS_MEMBER_DOCSTRING | ( | name, | |
docstring | |||
) | this->register_docstring(docstring_macro_impl::get_docstring(&name, #name, docstring)); |
Registers a docstring of a function or property previously registered with any of the registration functions.
Name can be a function, or a string. (Generally for the name, you put the first argument of any of the REGISTER macros and it should work fine)
Definition at line 301 of file toolkit_class_macros.hpp.
#define REGISTER_CLASS_MEMBER_FUNCTION | ( | function, | |
... | |||
) |
Registers a single class member function.
REGISTER_CLASS_MEMBER_FUNCTION(function, ...var args of input argument names ...)
Registers a function with no arguments. REGISTER_CLASS_MEMBER_FUNCTION(class::function)
Registers a function with 2 input arguments. The first input argument is named "a" and the 2nd input argument is named "b" REGISTER_CLASS_MEMBER_FUNCTION(class::function, "a", "b")
Example:
The return value of the function will be returned to Python. The function can return void. If the function fails, it should throw an exception which will be forward back to Python as RuntimeError.
Definition at line 113 of file toolkit_class_macros.hpp.
#define REGISTER_GETTER | ( | propname, | |
function | |||
) |
Registers a function as a getter for a python property.
REGISTER_GETTER(python_property_name, getter_function)
The getter_function must return a single value and take no arguments.
Definition at line 347 of file toolkit_class_macros.hpp.
#define REGISTER_NAMED_CLASS_MEMBER_FUNCTION | ( | name, | |
function, | |||
... | |||
) |
Like REGISTER_CLASS_MEMBER_FUNCTION but allows the python-facing name of the function to be redefined.
REGISTER_NAMED_CLASS_MEMBER_FUNCTION(python_name, function, ...var args of input argument names ...)
Registers a function with 2 input arguments. The function shall be called "hello" in Python. The first input argument is named "a" and the 2nd input argument is named "b".
REGISTER_NAMED_CLASS_MEMBER_FUNCTION("hello", class::function, "a", "b")
Definition at line 132 of file toolkit_class_macros.hpp.
#define REGISTER_PROPERTY | ( | propname | ) |
Registers a member variable, automatically generating a getter and a setter.
REGISTER_PROPERTY(member_variable)
Definition at line 396 of file toolkit_class_macros.hpp.
#define REGISTER_SETTER | ( | propname, | |
function | |||
) |
Registers a function as a setter for a python property.
REGISTER_SETTER(python_property_name, setter_function)
The setter_function must have a single argument, and return no values.
Definition at line 376 of file toolkit_class_macros.hpp.