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 @@
C++ API
=========
The C++ API of ``xbob.machine`` allows users to leverage from automatic
converters for classes in :py:class:`xbob.machine`. To use the C API, clients
should first, include the header file ``<xbob.machine/api.h>`` on their
compilation units and then, make sure to call once ``import_xbob_machine()`` at
their module instantiation, as explained at the `Python manual
The C++ API of ``xbob.learn.activation`` allows users to leverage from
automatic converters for classes in :py:class:`xbob.learn.activation`. To use
the C API, clients should first, include the header file
``<xbob.learn.activation/api.h>`` on their compilation units and then, make
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>`_.
Here is a dummy C example showing how to include the header and where to call
......@@ -18,7 +19,7 @@ the import function:
.. code-block:: c++
#include <xbob.machine/api.h>
#include <xbob.learn.activation/api.h>
PyMODINIT_FUNC initclient(void) {
......@@ -35,20 +36,20 @@ the import function:
// imports xbob.io C-API
import_xbob_io();
// imports xbob.machine C-API
import_xbob_machine();
// imports xbob.learn.activation C-API
import_xbob_learn_activation();
}
.. note::
The include directory can be discovered using
:py:func:`xbob.machine.get_include`.
:py:func:`xbob.learn.activation.get_include`.
Activation Functors
-------------------
.. cpp:type:: PyBobMachineActivationObject
.. cpp:type:: PyBobLearnActivationObject
The pythonic object representation for a ``bob::machine::Activation``
object. It is the base class of all activation functors available in
......@@ -60,16 +61,16 @@ Activation Functors
typedef struct {
PyObject_HEAD
bob::machine::Activation* base;
} PyBobMachineActivationObject;
} PyBobLearnActivationObject;
.. cpp:member:: bob::machine::Activation* base
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.
......@@ -84,9 +85,9 @@ Activation Functors
.. code-block:: c++
typedef struct {
PyBobMachineActivationObject parent;
PyBobLearnActivationObject parent;
bob::machine::<Subtype>Activation* base;
} PyBobMachine<Subtype>ActivationObject;
} PyBobLearn<Subtype>ActivationObject;
Presently, ``<Subtype>`` can be one of:
......@@ -97,6 +98,6 @@ Activation Functors
* MultipliedHyperbolicTangent
Type objects are also named consistently like
``PyBobMachine<Subtype>_Type``.
``PyBobLearn<Subtype>Activation_Type``.
.. include:: links.rst
......@@ -230,7 +230,7 @@ typedef struct {
* Returns -1 on error, 0 on success. PyCapsule_Import will set an exception
* if there's an error.
*/
static int import_xbob_io(void) {
static int import_xbob_learn_activation(void) {
PyObject *c_api_object;
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