Commit eaeaa33e authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Declare the input parameters for the Guile bindings

The goal is to generate functions of the form:
  /* Bind to TarotMachin *function (TarotChose *input_parameter, size_t size, TarotElement *array_rewritten, TarotBidule *output_parameter); */
  static SCM
  tarot_guile_function (SCM g_input_parameter, SCM g_array_rewritten)
    TarotChose *c_input_parameter;
    size_t c_size;
    TarotElement *c_array_rewritten;
    TarotMachin *c_ret;
    TarotBidule c_output_parameter;
    SCM g_ret = SCM_EOL;
    bind_chose (g_input_parameter, c_input_parameter);
    bind_element_array (g_array_rewritten, &c_size, c_array_rewritten);
    c_ret = function (c_input_parameter, c_size, c_array_rewritten, &c_output_parameter);
    clean_chose (&c_input_parameter);
    g_ret = push_machin (g_ret, c_ret);
    g_ret = push_element_array (g_ret, c_size, c_array_rewritten);
    g_ret = push_bidule (g_ret, c_output_parameter);
    return g_ret;

In this commit, we declare the input types.
parent 697bf715
......@@ -21,5 +21,92 @@ along with this program. If not, see <>.
<xsl:strip-space elements="*" />
<xsl:template match="api">
<xsl:text>#include &lt;tarot.h&gt;&#xA;</xsl:text>
<xsl:text>#include &lt;libguile.h&gt;&#xA;</xsl:text>
<xsl:apply-templates />
<xsl:template match="namespace">
<xsl:apply-templates />
<xsl:template match="method">
<xsl:text>static SCM tarot_guile_</xsl:text><xsl:value-of select="@c-name" /><xsl:text> (</xsl:text>
<xsl:for-each select="instance-parameter|parameter[@direction = 'in' and @size-placeholder = 'false']">
<xsl:text>SCM g_</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>, </xsl:text>
<xsl:text>) {</xsl:text>
<xsl:text>/* Declaration of the types for input parameters */</xsl:text>
<xsl:for-each select="instance-parameter|parameter[@direction = 'in']">
<xsl:apply-templates mode="c-type" select="type" />
<xsl:text> c_</xsl:text>
<xsl:value-of select="@name" />
<xsl:text>; </xsl:text>
<xsl:template match="type[@kind = 'scalar' and @type = 'unsigned-int']" mode="c-type">
<xsl:text>unsigned int</xsl:text>
<xsl:template match="type[@kind = 'scalar' and (@type = 'boolean' or @type = 'integer')]" mode="c-type">
<xsl:template match="type[@kind = 'scalar' and @type = 'real']" mode="c-type">
<xsl:template match="type[@kind = 'scalar' and @type = 'size']" mode="c-type">
<xsl:template match="type[@kind = 'scalar' and @type = 'char']" mode="c-type">
<xsl:template match="type[@kind = 'scalar' and @type = 'address']" mode="c-type">
<xsl:text>void *</xsl:text>
<xsl:template match="type[@kind = 'enum']" mode="c-type">
<xsl:variable name="type-name" select="@type" />
<xsl:value-of select="/api/namespace/enumeration[@name = $type-name]/@c" />
<xsl:template match="type[@kind = 'class']" mode="c-type">
<xsl:variable name="type-name" select="@type" />
<xsl:value-of select="/api/namespace/class[@name = $type-name]/@c-name" />
<xsl:text> *</xsl:text>
<xsl:template match="type[@kind = 'array']" mode="c-type">
<xsl:apply-templates mode="c-type" select="type" />
<xsl:template match="type[@kind = 'typedef']" mode="c-type">
<xsl:variable name="type-name" select="@type" />
<xsl:value-of select="/api/namespace/typedef[@name = $type-name]/@c" />
<xsl:template match="type[@kind = 'struct']" mode="c-type">
<xsl:variable name="type-name" select="@type" />
<xsl:value-of select="/api/namespace/struct[@name = $type-name]/@c-name" />
<xsl:template match="type[@kind = 'string' and @type = 'char']" mode="c-type">
<xsl:text>char *</xsl:text>
<xsl:template match="type" mode="c-type">
<xsl:text>&#xA;#error &quot;No support for type of kind </xsl:text>
<xsl:value-of select="@kind" />
<xsl:text>, </xsl:text>
<xsl:value-of select="@type" />
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment