By providing default implementations, servers can provide partial implementations of protocols without having to stub out functions.
* server.c (WriteDefaultRoutine): New function. (WriteRoutine): Call WriteDefaultRoutine. --- server.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/server.c b/server.c index ae5977f..bcdeb0b 100644 --- a/server.c +++ b/server.c @@ -1279,6 +1279,28 @@ WriteFieldDecl(FILE *file, const argument_t *arg) } static void +WriteDefaultRoutine(FILE *file, const routine_t *rt) +{ + fprintf(file, "\n/* Default implementation of %s */\n", + rt->rtServerName); + + fprintf(file, "#ifdef\tMIG_EOPNOTSUPP\n"); + + fprintf(file, "%s __attribute__ ((weak))\n%s\n", + ReturnTypeStr(rt), rt->rtServerName); + fprintf(file, "(\n"); + WriteList(file, rt->rtArgs, WriteServerVarDecl, + akbServerArg, ",\n", "\n"); + + if (rt->rtReturn == argNULL) + fprintf(file, ") {}\n"); + else + fprintf(file, ") { return MIG_EOPNOTSUPP; }\n"); + + fprintf(file, "#endif\t/* MIG_EOPNOTSUPP */\n"); +} + +static void WriteRoutine(FILE *file, const routine_t *rt) { fprintf(file, "\n"); @@ -1346,6 +1368,8 @@ WriteRoutine(FILE *file, const routine_t *rt) } fprintf(file, "}\n"); + + WriteDefaultRoutine(file, rt); } void -- 2.1.1