OS_FUNCTION macro

Started by nanomad, January 20, 2013, 11:38:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nanomad

Ok, I'll admit that this has been bothering me for a while (mainly because I'm a bit OCD).

Snippet taken from:
Code (src/plugin.h) Select

// standard functions
#ifdef PLUGIN_CLIENT
#define OS_FUNCTION( fid, fret, fname, ... ) enum { os_##fname = fid }; fret (*fname) (__VA_ARGS__);
#define IMPORT_FUNC( v ) v = get_function( os_##v )
#else
#define REGISTER_PLUGIN_COMMAND( fid, ffunc ) \
__attribute__((section(".plugin_commands"))) \
__attribute__((used)) \
static struct os_command _os_command_##fid##_block = { \
        .id             = fid, \
        .func           = (void*)ffunc, \
}
#ifdef PLUGIN_C_FILE // only include this from the plugin.c file
#define OS_FUNCTION( fid, fret, fname, ... ) extern fret fname (__VA_ARGS__); REGISTER_PLUGIN_COMMAND( fid, fname );
#else
#define OS_FUNCTION( fid, fret, fname, ... ) extern fret fname (__VA_ARGS__);
#endif // PLUGIN_C_FILE
#endif // PLUGIN_CLIENT


As far as I could understand the OS_FUNCTION macro is used for two things:

1) Static type-checking for some DryOS functions
2) Exporting them to the plugin interface (ruby) using an unique function_id

If this information is correct, why do we have OS_FUNCTION macros all over the place instaad of inside the "dryos.h" header ?
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5