--- rpl/src/rplexternals.h 2013/04/02 11:56:33 1.50 +++ rpl/src/rplexternals.h 2013/04/03 09:40:31 1.51 @@ -228,16 +228,34 @@ -------------------------------------------------------------------------------- */ -#define declareInternalFunction(type, name, ...) \ - type __internal_##name(struct_rpl_arguments *rpl_arguments, __VA_ARGS__) { \ +#define CONCAT(a, b) __CONCAT(a, b) +#define __CONCAT(a, b) a##b +#define FIRST(...) FIRST_HELPER(__VA_ARGS__, throwaway) +#define FIRST_HELPER(first, ...) first +#define REST(...) REST_HELPER(NUM(__VA_ARGS__), __VA_ARGS__) +#define REST_HELPER(qty, ...) REST_HELPER2(qty, __VA_ARGS__) +#define REST_HELPER2(qty, ...) REST_HELPER_##qty(__VA_ARGS__) +#define REST_HELPER_ONE(first) +#define REST_HELPER_TWOORMORE(first, ...) , __VA_ARGS__ +#define NUM(...) \ + SELECT_10TH(__VA_ARGS__, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE,\ + TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, ONE, throwaway) +#define SELECT_10TH(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, ...) a10 + +#define declareInternalFunction(type, ...) \ + type CONCAT(__internal_, FIRST(__VA_ARGS__)) \ + (struct_rpl_arguments *rpl_arguments REST(__VA_ARGS__)) { \ + type __internal_return; __internal_return = 0; int __type; \ + DISABLE_SET_BUT_NOT_USED_WARNING(__type); + +#define endInternalFunction return(__internal_return); } + +#define useInternalFunction(type, ...) \ + type CONCAT(__internal_, FIRST(__VA_ARGS__)) \ + (struct_rpl_arguments *rpl_arguments REST(__VA_ARGS__)) -#define endInternalFunction leave; } - -#define useInternalFunction(type, name, ...) \ - type __internal_##name(struct_rpl_arguments *rpl_arguments, __VA_ARGS__) - -#define callInternalFunction(name, ...) \ - __internal_##name(rpl_arguments, __VA_ARGS__) +#define callInternalFunction(...) \ + CONCAT(__internal_, FIRST(__VA_ARGS__))(rpl_arguments REST(__VA_ARGS__)) /* -------------------------------------------------------------------------------- @@ -246,8 +264,8 @@ */ #define declareCFunction(type, name, ...) \ - type name(__VA_ARGS__) { __RPL__ -#define endCFunction leave; } + type name(__VA_ARGS__) { __RPL__ type __c_return; +#define endCFunction return(__c_return); } /* --------------------------------------------------------------------------------