Custom block initializers

Issue #69 resolved
Poindexter Frink created an issue

It would be useful if the block XML file had a second function block where the user could declare initialization code. For example (simplified):

<block>
...

    <function type="init" name="f_someblock_init"><![CDATA[
        data->somearray = malloc(data->sa_len);
        for(i = sa_len; i--;)
            // stuff
    ]]></function>

Which could render a function that would be called from init_dsp_objects() with the same data struct pointer as the sample function.

Comments (3)

  1. snoozee

    Very nice Proposal ! Added ! Additionally user can create custom function with parameters and return type in order to make use of it inside the main callback function.

    <function type="custom" name="doubleme" parameter="(int32_t a)" return="int32_t">
    <![CDATA[
        return a + a;
    ]]>
    </function> 
    
  2. Prostetnic Jeltz

    I tried to add a "custom" function, but only get static declaration follows non-static declaration errors. The function itself is listed in the dynamically generated section of emul.c. The same function (copied from dynamic genaration) works as expected when it is included in the template file.

    Should the dynamic generation already work or is this a bug (software version 0.5.3; OSX)?

  3. Log in to comment