Pink 0.9
|
This file defines the macros, which facilitate the export of functions in Python. The emphasis is given to multiple inclusion of template functions with all different types. As python cannot 'compile' in runtime, you must compile the template functions with all the possible image types. The macros and templates in this file ease you do that. More...
Defines | |
#define | UI_EXPORT_FUNCTION(FNAME, FN, ARGS, DOC) |
Generates a Python wrapper function for a C++ function using all image types. | |
#define | UI_DEFINE_FUNCTION(FNAME, FN, ARGS, DOC) |
Generates a Python wrapper function for a C++ function using all image types. | |
#define | UI_WRAP_CPP(FNAME, FN, ARGS, DOC) |
Generates a Python wrapper function for a C++ function using all image types. | |
#define | UI_EXPORT_ONE_FUNCTION(FNAME, FN, ARGS, DOC) |
Generates a Python wrapper function for a C++ function using all image types. | |
#define | EXPORT_FUNCTION(z, n, text) export_function##n(); |
Generates and 'void export_function15();' declaration. It is used by the UI_WRAP_FUNCTION in 'pypink.cpp' Generates and 'export_function15();' declaration. It is used by the UI_WRAP_FUNCTION in 'pypink.cpp'. | |
#define | CALL_EXPORTED_FUNCTIONS(n) BOOST_PP_REPEAT(n, EXPORT_FUNCTION, ~) |
Call the exported functions. |
This file defines the macros, which facilitate the export of functions in Python. The emphasis is given to multiple inclusion of template functions with all different types. As python cannot 'compile' in runtime, you must compile the template functions with all the possible image types. The macros and templates in this file ease you do that.
Example:
void py_maxflow_export(){ boost::python::def( "cpp_maxflow_float", &maxflow_float, args("source and sink", "boundaries", "iteration", "tau", "the number of threads"), "maximal flows, returns the image (potential field) \n" " \n" // end of the documenation ); boost::python::def( "cpp_maxflow_cami_float", &maxflow_cami, args("source and sink", "boundaries", "iteration", "tau", "the number of threads"), "maximal flows, returns the flow (float array of size pixels * dimension ) \n" " \n" // end of the documenation );
#define CALL_EXPORTED_FUNCTIONS | ( | n | ) | BOOST_PP_REPEAT(n, EXPORT_FUNCTION, ~) |
Call the exported functions.
export_function0(); export_function1(); export_function2(); export_function3(); export_function4(); ... export_function##n();
The exported functions are generated by the WRAP macros.
#define UI_DEFINE_FUNCTION | ( | FNAME, | |
FN, | |||
ARGS, | |||
DOC | |||
) |
Generates a Python wrapper function for a C++ function using all image types.
This macro generates a block with function calls for all image functions. You can call it from BOOST_PYTHON_MODULE.
FNAME | The function name in Python (a string) |
FN | The C++ template function to wrap |
ARGS | The description of the arguments (see Exporting functions to Python) |
DOC | The documentation string. This string appears in Python if the help function is called. |
#define UI_EXPORT_FUNCTION | ( | FNAME, | |
FN, | |||
ARGS, | |||
DOC | |||
) |
Generates a Python wrapper function for a C++ function using all image types.
This macro generates a function named "FNAME_export()" which you can call from 'pypink.cpp'. You can use this function to export a template function. It takes an image type as template parameter and it substitutes all the image types in it.
FNAME | The function name in Python (a string) |
FN | The C++ template function to wrap |
ARGS | The description of the arguments (see Exporting functions to Python) |
DOC | The documentation string. This string appears in Python if the help function is called. |
#define UI_EXPORT_ONE_FUNCTION | ( | FNAME, | |
FN, | |||
ARGS, | |||
DOC | |||
) |
\
void FNAME##_export() \
{ \
boost::python::def( BOOST_PP_STRINGIZE(FNAME), &BOOST_PP_EXPAND(FN), \
ARGS, \
DOC \
); \
}
Generates a Python wrapper function for a C++ function using all image types.
This macro generates a function named "FNAME_export()" which you can call from 'pypink.cpp'. You can use this function to export a template function. It takes an image type as template parameter and it substitutes all the image types in it.
FNAME | The function name in Python (a string) |
FN | The C++ template function to wrap |
ARGS | The description of the arguments (see Exporting functions to Python) |
DOC | The documentation string. This string appears in Python if the help function is called. |
#define UI_WRAP_CPP | ( | FNAME, | |
FN, | |||
ARGS, | |||
DOC | |||
) |
void BOOST_PP_CAT(export_function, BOOST_PP_COUNTER)() \ { \ boost::python::def( FNAME, BOOST_PP_EXPAND(FN)<pink::char_image>, \ ARGS, \ DOC \ ); \ \ boost::python::def( FNAME, BOOST_PP_EXPAND(FN)<pink::short_image>, \ ARGS, \ DOC \ ); \ \ boost::python::def( FNAME, BOOST_PP_EXPAND(FN)<pink::int_image>, \ ARGS, \ DOC \ ); \ \ boost::python::def( FNAME, BOOST_PP_EXPAND(FN)<pink::float_image>, \ ARGS, \ DOC \ ); \ \ boost::python::def( FNAME, BOOST_PP_EXPAND(FN)<pink::double_image>, \ ARGS, \ DOC \ ); \ \ \ }
Generates a Python wrapper function for a C++ function using all image types.
You can use this function to export a template function from within 'pypink.cpp'. It takes an image type as template parameter and it substitutes all the image types in it.
FNAME | The function name in Python (a string) |
FN | The C++ template function to wrap |
ARGS | The description of the arguments (see Exporting functions to Python) |
DOC | The documentation string. This string appears in Python if the help function is called. |