widl: Add a helper function for generating a stub that uses NdrClientCall.

oldstable
Alexandre Julliard 2011-06-09 10:12:48 +02:00
parent d9fb7b9b92
commit 9f99d74a20
4 changed files with 46 additions and 56 deletions

View File

@ -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;
}

View File

@ -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",

View File

@ -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");

View File

@ -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);