From 39857a9745cec89da08a2d1101495a32b3535e38 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Thu, 6 Nov 2014 15:19:49 +0100 Subject: Provide default implementations for server functions 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(+) (limited to 'server.c') diff --git a/server.c b/server.c index ae5977f..bcdeb0b 100644 --- a/server.c +++ b/server.c @@ -1278,6 +1278,28 @@ WriteFieldDecl(FILE *file, const argument_t *arg) WriteFieldDeclPrim(file, arg, FetchServerType); } +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) { @@ -1346,6 +1368,8 @@ WriteRoutine(FILE *file, const routine_t *rt) } fprintf(file, "}\n"); + + WriteDefaultRoutine(file, rt); } void -- cgit v1.2.3