Module: wine Branch: master Commit: 9f99d74a2037524ae8502de071564da3396eb3ab URL: http://source.winehq.org/git/wine.git/?a=commit;h=9f99d74a2037524ae8502de071...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Jun 9 10:12:48 2011 +0200
widl: Add a helper function for generating a stub that uses NdrClientCall.
---
tools/widl/client.c | 32 +------------------------------- tools/widl/proxy.c | 26 +------------------------- tools/widl/typegen.c | 42 ++++++++++++++++++++++++++++++++++++++++++ tools/widl/typegen.h | 2 ++ 4 files changed, 46 insertions(+), 56 deletions(-)
diff --git a/tools/widl/client.c b/tools/widl/client.c index 0ea8cbc..30f24b3 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -97,43 +97,13 @@ static void write_function_stub( const type_t *iface, const var_t *func, unsigned char explicit_fc, implicit_fc; int has_full_pointer = is_full_pointer_function(func); type_t *rettype = type_function_get_rettype(func->type); - const var_list_t *args = type_get_function_args(func->type); const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc ); int has_ret = !is_void(rettype);
if (is_interpreted_func( iface, func )) { write_client_func_decl( iface, func ); - fprintf(client, "{\n"); - indent++; - if (has_ret) print_client( "%s", "CLIENT_CALL_RETURN _RetVal;\n\n" ); - print_client( "%s%s( &%s_StubDesc, &__MIDL_ProcFormatString.Format[%u]", - has_ret ? "_RetVal = " : "", - get_stub_mode() == MODE_Oif ? "NdrClientCall2" : "NdrClientCall", - iface->name, proc_offset ); - if (args) - { - const var_t *arg; - if (pointer_size == 8) - { - LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry ) - fprintf( client, ",\n%*s%s", 4 * indent + 16, "", arg->name ); - } - else - { - arg = LIST_ENTRY( list_head(args), const var_t, entry ); - fprintf( client, ", &%s", arg->name ); - } - } - fprintf( client, " );\n" ); - if (has_ret) - { - print_client( "return (" ); - write_type_decl_left(client, rettype); - fprintf( client, ")*(LONG_PTR *)&_RetVal;\n" ); - } - indent--; - print_client( "}\n\n"); + write_client_call_routine( client, iface, func, iface->name, proc_offset ); return; }
diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c index 549bfaa..0043e6a 100644 --- a/tools/widl/proxy.c +++ b/tools/widl/proxy.c @@ -266,31 +266,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx, print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func)); write_args(proxy, args, iface->name, 1, TRUE); print_proxy( ")\n"); - print_proxy( "{\n"); - indent++; - if (has_ret) print_proxy( "%s", "CLIENT_CALL_RETURN _RetVal;\n\n" ); - print_proxy( "%s%s( &Object_StubDesc, &__MIDL_ProcFormatString.Format[%u],", - has_ret ? "_RetVal = " : "", - get_stub_mode() == MODE_Oif ? "NdrClientCall2" : "NdrClientCall", - proc_offset ); - if (pointer_size == 8) - { - const var_t *arg; - fprintf( proxy, "\n%*sThis", 4 * indent + 16, "" ); - if (args) - LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry ) - fprintf( proxy, ",\n%*s%s", 4 * indent + 16, "", arg->name ); - } - else fprintf( proxy, " &This" ); - fprintf( proxy, " );\n" ); - if (has_ret) - { - print_proxy( "return (" ); - write_type_decl_left(proxy, rettype); - fprintf( proxy, ")*(LONG_PTR *)&_RetVal;\n" ); - } - indent--; - print_proxy( "}\n\n"); + write_client_call_routine( proxy, iface, func, "Object", proc_offset ); return; } print_proxy( "static void __finally_%s_%s_Proxy( struct __proxy_frame *__frame )\n", diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 59de872..abe84d9 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -4806,6 +4806,48 @@ error: error("Invalid endpoint syntax '%s'\n", endpoint->str); }
+void write_client_call_routine( FILE *file, const type_t *iface, const var_t *func, + const char *prefix, unsigned int proc_offset ) +{ + type_t *rettype = type_function_get_rettype( func->type ); + int has_ret = !is_void( rettype ); + const var_list_t *args = type_get_function_args( func->type ); + const var_t *arg; + int len; + + print_file( file, 0, "{\n"); + if (has_ret) print_file( file, 1, "%s", "CLIENT_CALL_RETURN _RetVal;\n\n" ); + len = fprintf( file, " %s%s( ", + has_ret ? "_RetVal = " : "", + get_stub_mode() == MODE_Oif ? "NdrClientCall2" : "NdrClientCall" ); + fprintf( file, "&%s_StubDesc,", prefix ); + fprintf( file, "\n%*s&__MIDL_ProcFormatString.Format[%u]", len, "", proc_offset ); + if (pointer_size == 8) + { + if (is_object( iface )) fprintf( file, ",\n%*sThis", len, "" ); + if (args) + LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry ) + fprintf( file, ",\n%*s%s", len, "", arg->name ); + } + else + { + if (is_object( iface )) fprintf( file, ",\n%*s&This", len, "" ); + else if (args) + { + arg = LIST_ENTRY( list_head(args), const var_t, entry ); + fprintf( file, ",\n%*s&%s", len, "", arg->name ); + } + } + fprintf( file, " );\n" ); + if (has_ret) + { + print_file( file, 1, "return (" ); + write_type_decl_left(file, rettype); + fprintf( file, ")%s;\n", pointer_size == 8 ? "_RetVal.Simple" : "*(LONG_PTR *)&_RetVal" ); + } + print_file( file, 0, "}\n\n"); +} + void write_exceptions( FILE *file ) { fprintf( file, "#ifndef USE_COMPILER_EXCEPTIONS\n"); diff --git a/tools/widl/typegen.h b/tools/widl/typegen.h index 7f3aed1..6c7242e 100644 --- a/tools/widl/typegen.h +++ b/tools/widl/typegen.h @@ -80,6 +80,8 @@ int write_expr_eval_routines(FILE *file, const char *iface); void write_expr_eval_routine_list(FILE *file, const char *iface); void write_user_quad_list(FILE *file); void write_endpoints( FILE *f, const char *prefix, const str_list_t *list ); +void write_client_call_routine( FILE *file, const type_t *iface, const var_t *func, + const char *prefix, unsigned int proc_offset ); void write_exceptions( FILE *file ); unsigned int type_memsize(const type_t *t); int decl_indirect(const type_t *t);