/* generated by {{ TOOL_WRAPPER }} */

#include <stdlib.h>
{% for OPT in OPERATORS_DATA %}    
#include "{{ OPT["opt_name"] }}.h"
{% endfor %}

{% if SENSORS and SENSORS['elements']-%}
#include "{{ SENSORS['include'] }}"

{% for sns in SENSORS['elements'] %}
/* {{ sns['path'] }} */
{{ sns['type'] }} {{ sns['name'] }};

{% endfor %}
{% endif %}

{% for OPT in OPERATORS_DATA %}    
/* {{ OPT["opt_path"] }} */
__declspec(dllexport) void* py_alloc_{{ OPT["opt_name"] }}()
{
    {% if not OPT["context_type"] -%}
    {% filter indent(width=4) %}
    return 0;
    {% endfilter %}
    {# #}
    {% else %}
        {% if not OPT["reset_parameters"] -%}
            {% if OPT["init_method"] -%}
            {{ OPT["init_c_name"] }}();
            {% endif %}
            {% filter indent(width=4) %}
            return 0;
            {% endfilter %}
            {# #}
        {% else %}
    outC_{{ OPT["opt_name"] }} *ctx = (outC_{{ OPT["opt_name"] }}*)malloc(sizeof(outC_{{ OPT["opt_name"] }}));
            {% if OPT["init_method"] -%}
        {% filter indent(width=4) %}
    {{ OPT["init_c_name"] }}(ctx);
        {% endfilter %}
            {% endif %}
        {% endif %}
    return (void*)ctx;
        {# #}
    {% endif %}
}

__declspec(dllexport) void py_free_{{ OPT["opt_name"] }}(void *ctx)
{
    if (ctx != 0)
        free(ctx);
}

{% if OPT["ios_declared"] -%}
__declspec(dllexport) size_t py_offsets_{{ OPT["opt_name"] }}[] = {
    {% for line in OPT["ios_declared"] %}
    offsetof(outC_{{ OPT["opt_name"] }}, {{line}}),
    {% endfor %}
};

{% endif %}
{% endfor %}
/* end of file */