Plugin Reference

There are some general macros essential to interfacing with Gwion in general.

The return codes of functions are of type m_bool and consist of the following values:

NameValueDescription
GW_OK1Success
GW_PASS0Ignore the result and continue
GW_ERROR-1An error occured

The following macros are sugar for handling error codes. They can exit the scope of the function. It is recommended to use these rather than writing:

if (!a) return NULL;

and co.

NameValueDescription
CHECK_BBif (f < 0) return GW_ERROR;Takes an expression that evaluates to m_bool. Potentially exits function returning GW_ERROR.
CHECK_BOif (f < 0) return NULL;Takes an expression that evaluates to m_bool. Potentially exits function returning NULL.
CHECK_OBif (!f) return GW_ERROR;Takes an expression that evaluates to a pointer. Potentially exits function returning GW_ERROR.
CHECK_OOif (!f) return NULL;Takes an expression that evaluates to a pointer. Potentially exits function returning NULL.

Likewise there are the DECL_XX macros which specialize to failing if a declaration fails. Their general syntax is as follows:

DECL_XX(type, var_name, = value);

These macros are specific to creating plugins.

MFUN(name) signature for a member function SFUN(name) signature for a static function CTOR(name) signature for a constructor DTOR(name) signature for a destructor GACK(name) signature for a pretty print function TICK(name) signature for a UGen tick function GWION_IMPORT(name) main function of a plugin/library

in said main function, one should use GWI_XX instead of CHECK_XX since it takes care of position and might optimize some checks away (in gwion's internals)

OP_CHECK(name) define a type checking function. should return correct type in success error type on failure NULL to continue type checking

OP_EMIT(name) define an emitter function. returns an m_bool

built with mdBook
You'll find the source here, Luke!