Skip to content
Snippets Groups Projects
Commit 4aacfe1f authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Fix C-API

parent 1a120afd
No related branches found
No related tags found
No related merge requests found
...@@ -6,11 +6,12 @@ ...@@ -6,11 +6,12 @@
C++ API C++ API
========= =========
The C++ API of ``xbob.machine`` allows users to leverage from automatic The C++ API of ``xbob.learn.activation`` allows users to leverage from
converters for classes in :py:class:`xbob.machine`. To use the C API, clients automatic converters for classes in :py:class:`xbob.learn.activation`. To use
should first, include the header file ``<xbob.machine/api.h>`` on their the C API, clients should first, include the header file
compilation units and then, make sure to call once ``import_xbob_machine()`` at ``<xbob.learn.activation/api.h>`` on their compilation units and then, make
their module instantiation, as explained at the `Python manual sure to call once ``import_xbob_learn_activation()`` at their module
instantiation, as explained at the `Python manual
<http://docs.python.org/2/extending/extending.html#using-capsules>`_. <http://docs.python.org/2/extending/extending.html#using-capsules>`_.
Here is a dummy C example showing how to include the header and where to call Here is a dummy C example showing how to include the header and where to call
...@@ -18,7 +19,7 @@ the import function: ...@@ -18,7 +19,7 @@ the import function:
.. code-block:: c++ .. code-block:: c++
#include <xbob.machine/api.h> #include <xbob.learn.activation/api.h>
PyMODINIT_FUNC initclient(void) { PyMODINIT_FUNC initclient(void) {
...@@ -35,20 +36,20 @@ the import function: ...@@ -35,20 +36,20 @@ the import function:
// imports xbob.io C-API // imports xbob.io C-API
import_xbob_io(); import_xbob_io();
// imports xbob.machine C-API // imports xbob.learn.activation C-API
import_xbob_machine(); import_xbob_learn_activation();
} }
.. note:: .. note::
The include directory can be discovered using The include directory can be discovered using
:py:func:`xbob.machine.get_include`. :py:func:`xbob.learn.activation.get_include`.
Activation Functors Activation Functors
------------------- -------------------
.. cpp:type:: PyBobMachineActivationObject .. cpp:type:: PyBobLearnActivationObject
The pythonic object representation for a ``bob::machine::Activation`` The pythonic object representation for a ``bob::machine::Activation``
object. It is the base class of all activation functors available in object. It is the base class of all activation functors available in
...@@ -60,16 +61,16 @@ Activation Functors ...@@ -60,16 +61,16 @@ Activation Functors
typedef struct { typedef struct {
PyObject_HEAD PyObject_HEAD
bob::machine::Activation* base; bob::machine::Activation* base;
} PyBobMachineActivationObject; } PyBobLearnActivationObject;
.. cpp:member:: bob::machine::Activation* base .. cpp:member:: bob::machine::Activation* base
A pointer to the activation functor virtual implementation. A pointer to the activation functor virtual implementation.
.. cpp:function:: int PyBobMachineActivation_Check(PyObject* o) .. cpp:function:: int PyBobLearnActivation_Check(PyObject* o)
Checks if the input object ``o`` is a ``PyBobMachineActivationObject``. Checks if the input object ``o`` is a ``PyBobLearnActivationObject``.
Returns ``1`` if it is, and ``0`` otherwise. Returns ``1`` if it is, and ``0`` otherwise.
...@@ -84,9 +85,9 @@ Activation Functors ...@@ -84,9 +85,9 @@ Activation Functors
.. code-block:: c++ .. code-block:: c++
typedef struct { typedef struct {
PyBobMachineActivationObject parent; PyBobLearnActivationObject parent;
bob::machine::<Subtype>Activation* base; bob::machine::<Subtype>Activation* base;
} PyBobMachine<Subtype>ActivationObject; } PyBobLearn<Subtype>ActivationObject;
Presently, ``<Subtype>`` can be one of: Presently, ``<Subtype>`` can be one of:
...@@ -97,6 +98,6 @@ Activation Functors ...@@ -97,6 +98,6 @@ Activation Functors
* MultipliedHyperbolicTangent * MultipliedHyperbolicTangent
Type objects are also named consistently like Type objects are also named consistently like
``PyBobMachine<Subtype>_Type``. ``PyBobLearn<Subtype>Activation_Type``.
.. include:: links.rst .. include:: links.rst
...@@ -230,7 +230,7 @@ typedef struct { ...@@ -230,7 +230,7 @@ typedef struct {
* Returns -1 on error, 0 on success. PyCapsule_Import will set an exception * Returns -1 on error, 0 on success. PyCapsule_Import will set an exception
* if there's an error. * if there's an error.
*/ */
static int import_xbob_io(void) { static int import_xbob_learn_activation(void) {
PyObject *c_api_object; PyObject *c_api_object;
PyObject *module; PyObject *module;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment