Commit 896b4f05 authored by Alexandre Julliard's avatar Alexandre Julliard

widl: Always use new-style format strings in interpreted mode.

parent 7cd0f395
......@@ -285,7 +285,6 @@ static void write_function_stub( const type_t *iface, const var_t *func,
static void write_serialize_function(FILE *file, const type_t *type, const type_t *iface,
const char *func_name, const char *ret_type)
{
enum stub_mode mode = get_stub_mode();
static int emitted_pickling_info;
if (iface && !type->typestring_offset)
......@@ -296,7 +295,7 @@ static void write_serialize_function(FILE *file, const type_t *type, const type_
return;
}
if (!emitted_pickling_info && iface && mode != MODE_Os)
if (!emitted_pickling_info && iface && interpreted_mode)
{
fprintf(file, "static const MIDL_TYPE_PICKLING_INFO __MIDL_TypePicklingInfo =\n");
fprintf(file, "{\n");
......@@ -318,9 +317,9 @@ static void write_serialize_function(FILE *file, const type_t *type, const type_
fprintf(file, "{\n");
fprintf(file, " %sNdrMesType%s%s(\n", ret_type ? "return " : "", func_name,
mode != MODE_Os ? "2" : "");
interpreted_mode ? "2" : "");
fprintf(file, " IDL_handle,\n");
if (mode != MODE_Os)
if (interpreted_mode)
fprintf(file, " (MIDL_TYPE_PICKLING_INFO*)&__MIDL_TypePicklingInfo,\n");
fprintf(file, " &%s_StubDesc,\n", iface->name);
fprintf(file, " (PFORMAT_STRING)&__MIDL_TypeFormatString.Format[%u],\n",
......@@ -418,7 +417,7 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
print_client("0,\n");
print_client("__MIDL_TypeFormatString.Format,\n");
print_client("1, /* -error bounds_check flag */\n");
print_client("0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001);
print_client("0x%x, /* Ndr library version */\n", interpreted_mode ? 0x50002 : 0x10001);
print_client("0,\n");
print_client("0x50200ca, /* MIDL Version 5.2.202 */\n");
print_client("0,\n");
......
......@@ -61,7 +61,7 @@ static void write_stubdesc(int expr_eval_routines)
print_proxy( "{0}, 0, 0, %s, 0,\n", expr_eval_routines ? "ExprEvalRoutines" : "0");
print_proxy( "__MIDL_TypeFormatString.Format,\n");
print_proxy( "1, /* -error bounds_check flag */\n");
print_proxy( "0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001);
print_proxy( "0x%x, /* Ndr library version */\n", interpreted_mode ? 0x50002 : 0x10001);
print_proxy( "0,\n");
print_proxy( "0x50200ca, /* MIDL Version 5.2.202 */\n");
print_proxy( "0,\n");
......@@ -193,7 +193,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
indent = 0;
if (is_interpreted_func( iface, func ))
{
if (get_stub_mode() == MODE_Oif && !is_callas( func->attrs )) return;
if (!is_callas( func->attrs )) return;
write_type_decl_left(proxy, &retval->declspec);
print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
write_args(proxy, args, iface->name, 1, TRUE, NAME_DEFAULT);
......@@ -519,7 +519,6 @@ static int write_proxy_methods(type_t *iface, int skip)
if (skip || (is_local(func->attrs) && !get_callas_source(iface, func)))
print_proxy( "0, /* %s::%s */\n", iface->name, get_name(func));
else if (is_interpreted_func( iface, func ) &&
get_stub_mode() == MODE_Oif &&
!is_local( func->attrs ) &&
type_iface_get_inherit(iface))
print_proxy( "(void *)-1, /* %s::%s */\n", iface->name, get_name(func));
......@@ -556,7 +555,7 @@ static int write_stub_methods(type_t *iface, int skip)
if (i) fprintf(proxy,",\n");
if (skip || missing) print_proxy("STUB_FORWARDING_FUNCTION");
else if (is_interpreted_func( iface, func ))
print_proxy( "(PRPC_STUB_FUNCTION)%s", get_stub_mode() == MODE_Oif ? "NdrStubCall2" : "NdrStubCall" );
print_proxy( "(PRPC_STUB_FUNCTION)%s", interpreted_mode ? "NdrStubCall2" : "NdrStubCall" );
else print_proxy( "%s_%s_Stub", iface->name, fname);
i++;
}
......@@ -641,7 +640,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
print_proxy( "};\n\n" );
/* proxy info */
if (get_stub_mode() == MODE_Oif)
if (interpreted_mode)
{
print_proxy( "static const MIDL_STUBLESS_PROXY_INFO %s_ProxyInfo =\n", iface->name );
print_proxy( "{\n" );
......@@ -658,13 +657,13 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
/* proxy vtable */
print_proxy( "static %sCINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n",
(get_stub_mode() != MODE_Os || need_delegation_indirect(iface)) ? "" : "const ",
(interpreted_mode || need_delegation_indirect(iface)) ? "" : "const ",
count, iface->name);
print_proxy( "{\n");
indent++;
print_proxy( "{\n");
indent++;
if (get_stub_mode() == MODE_Oif) print_proxy( "&%s_ProxyInfo,\n", iface->name );
if (interpreted_mode) print_proxy( "&%s_ProxyInfo,\n", iface->name );
print_proxy( "&IID_%s,\n", iface->name);
indent--;
print_proxy( "},\n");
......@@ -785,7 +784,7 @@ int need_inline_stubs(const type_t *iface)
{
const statement_t *stmt;
if (get_stub_mode() == MODE_Os) return 1;
if (!interpreted_mode) return 1;
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
{
......@@ -801,7 +800,7 @@ static int need_proxy_and_inline_stubs(const type_t *iface)
const statement_t *stmt;
if (!need_proxy( iface )) return 0;
if (get_stub_mode() == MODE_Os) return 1;
if (!interpreted_mode) return 1;
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
{
......@@ -895,10 +894,10 @@ static void write_proxy_routines(const statement_list_t *stmts)
const type_t * delegate_to;
print_proxy( "#ifndef __REDQ_RPCPROXY_H_VERSION__\n");
print_proxy( "#define __REQUIRED_RPCPROXY_H_VERSION__ %u\n", get_stub_mode() == MODE_Oif ? 475 : 440);
print_proxy( "#define __REQUIRED_RPCPROXY_H_VERSION__ %u\n", interpreted_mode ? 475 : 440);
print_proxy( "#endif\n");
print_proxy( "\n");
if (get_stub_mode() == MODE_Oif) print_proxy( "#define USE_STUBLESS_PROXY\n");
if (interpreted_mode) print_proxy( "#define USE_STUBLESS_PROXY\n");
print_proxy( "#include \"rpcproxy.h\"\n");
print_proxy( "#ifndef __RPCPROXY_H_VERSION__\n");
print_proxy( "#error This code needs a newer version of rpcproxy.h\n");
......@@ -1002,7 +1001,7 @@ static void write_proxy_routines(const statement_list_t *stmts)
fprintf(proxy, "}\n");
fprintf(proxy, "\n");
table_version = get_stub_mode() == MODE_Oif ? 2 : 1;
table_version = interpreted_mode ? 2 : 1;
for (i = 0; i < count; i++)
{
if (type_iface_get_async_iface(interfaces[i]) != interfaces[i]) continue;
......
......@@ -273,7 +273,7 @@ static void write_dispatchtable(type_t *iface)
{
var_t *func = stmt->u.var;
if (is_interpreted_func( iface, func ))
print_server("%s,\n", get_stub_mode() == MODE_Oif ? "NdrServerCall2" : "NdrServerCall");
print_server("NdrServerCall2,\n");
else
print_server("%s_%s,\n", iface->name, get_name(func));
method_count++;
......@@ -380,7 +380,7 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
print_server("0,\n");
print_server("__MIDL_TypeFormatString.Format,\n");
print_server("1, /* -error bounds_check flag */\n");
print_server("0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001);
print_server("0x%x, /* Ndr library version */\n", interpreted_mode ? 0x50002 : 0x10001);
print_server("0,\n");
print_server("0x50200ca, /* MIDL Version 5.2.202 */\n");
print_server("0,\n");
......
......@@ -1242,7 +1242,7 @@ static unsigned int write_new_procformatstring_type(FILE *file, int indent, cons
}
static unsigned int write_old_procformatstring_type(FILE *file, int indent, const var_t *var,
int is_return, int is_interpreted)
int is_return)
{
unsigned int size;
......@@ -1281,7 +1281,7 @@ static unsigned int write_old_procformatstring_type(FILE *file, int indent, cons
{
unsigned short offset = var->typestring_offset;
if (!is_interpreted && is_array(var->declspec.type)
if (is_array(var->declspec.type)
&& type_array_is_decl_as_ptr(var->declspec.type)
&& type_array_get_ptr_tfsoff(var->declspec.type))
offset = var->declspec.type->typestring_offset;
......@@ -1306,8 +1306,6 @@ static unsigned int write_old_procformatstring_type(FILE *file, int indent, cons
int is_interpreted_func( const type_t *iface, const var_t *func )
{
const char *str;
const var_t *var;
const var_list_t *args = type_function_get_args( func->declspec.type );
const type_t *ret_type = type_function_get_rettype( func->declspec.type );
if (type_get_type( ret_type ) == TYPE_BASIC)
......@@ -1327,30 +1325,9 @@ int is_interpreted_func( const type_t *iface, const var_t *func )
break;
}
}
if (get_stub_mode() != MODE_Oif && args)
{
LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
switch (type_get_type( var->declspec.type ))
{
case TYPE_BASIC:
switch (type_basic_get_type( var->declspec.type ))
{
/* floating point arguments are not supported in Oi mode */
case TYPE_BASIC_FLOAT: return 0;
case TYPE_BASIC_DOUBLE: return 0;
default: break;
}
break;
/* unions passed by value are not supported in Oi mode */
case TYPE_UNION: return 0;
case TYPE_ENCAPSULATED_UNION: return 0;
default: break;
}
}
if ((str = get_attrp( func->attrs, ATTR_OPTIMIZE ))) return !strcmp( str, "i" );
if ((str = get_attrp( iface->attrs, ATTR_OPTIMIZE ))) return !strcmp( str, "i" );
return (get_stub_mode() != MODE_Os);
return interpreted_mode;
}
static void write_proc_func_interp( FILE *file, int indent, const type_t *iface,
......@@ -1364,18 +1341,22 @@ static void write_proc_func_interp( FILE *file, int indent, const type_t *iface,
var_t *retval = type_function_get_retval( func->declspec.type );
const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc );
unsigned char oi_flags = Oi_HAS_RPCFLAGS | Oi_USE_NEW_INIT_ROUTINES;
unsigned char oi2_flags = get_func_oi2_flags( func );
unsigned char ext_flags = 0;
unsigned int rpc_flags = get_rpc_flags( func->attrs );
unsigned int nb_args = 0;
unsigned int stack_size = 0;
unsigned int stack_offset = 0;
unsigned short param_num = 0;
unsigned short handle_stack_offset = 0;
unsigned short handle_param_num = 0;
unsigned int size;
if (is_full_pointer_function( func )) oi_flags |= Oi_FULL_PTR_USED;
if (is_object( iface ))
{
oi_flags |= Oi_OBJECT_PROC;
if (get_stub_mode() == MODE_Oif) oi_flags |= Oi_OBJ_USE_V2_INTERPRETER;
oi_flags |= Oi_OBJECT_PROC | Oi_OBJ_USE_V2_INTERPRETER;
stack_offset = pointer_size;
stack_size += pointer_size;
}
......@@ -1441,13 +1422,6 @@ static void write_proc_func_interp( FILE *file, int indent, const type_t *iface,
}
}
if (get_stub_mode() == MODE_Oif)
{
unsigned int stack_offset = is_object(iface) ? pointer_size : 0;
unsigned char oi2_flags = get_func_oi2_flags( func );
unsigned char ext_flags = 0;
unsigned int size;
if (is_attr( func->attrs, ATTR_NOTIFY )) ext_flags |= 0x08; /* HasNotify */
if (is_attr( func->attrs, ATTR_NOTIFYFLAG )) ext_flags |= 0x10; /* HasNotify2 */
if (iface == type_iface_get_async_iface(iface)) oi2_flags |= 0x20;
......@@ -1505,30 +1479,6 @@ static void write_proc_func_interp( FILE *file, int indent, const type_t *iface,
print_file( file, 0, "/* %u (return value) */\n", *offset );
*offset += write_new_procformatstring_type(file, indent, retval, TRUE, &stack_offset);
}
}
else /* old style */
{
/* emit argument data */
if (args) LIST_FOR_EACH_ENTRY( var, args, var_t, entry )
{
print_file( file, 0, "/* %u (parameter %s) */\n", *offset, var->name );
*offset += write_old_procformatstring_type(file, indent, var, FALSE, TRUE);
}
/* emit return value data */
if (is_void(retval->declspec.type))
{
print_file(file, 0, "/* %u (void) */\n", *offset);
print_file(file, indent, "0x5b,\t/* FC_END */\n");
print_file(file, indent, "0x5c,\t/* FC_PAD */\n");
*offset += 2;
}
else
{
print_file( file, 0, "/* %u (return value) */\n", *offset );
*offset += write_old_procformatstring_type(file, indent, retval, TRUE, TRUE);
}
}
}
static void write_procformatstring_func( FILE *file, int indent, const type_t *iface,
......@@ -1550,7 +1500,7 @@ static void write_procformatstring_func( FILE *file, int indent, const type_t *i
LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), const var_t, entry )
{
print_file( file, 0, "/* %u (parameter %s) */\n", *offset, var->name );
*offset += write_old_procformatstring_type(file, indent, var, FALSE, FALSE);
*offset += write_old_procformatstring_type(file, indent, var, FALSE);
}
}
......@@ -1566,7 +1516,7 @@ static void write_procformatstring_func( FILE *file, int indent, const type_t *i
else
{
print_file( file, 0, "/* %u (return value) */\n", *offset );
*offset += write_old_procformatstring_type(file, indent, retval, TRUE, FALSE);
*offset += write_old_procformatstring_type(file, indent, retval, TRUE);
}
}
......@@ -2228,7 +2178,7 @@ static unsigned int write_nonsimple_pointer(FILE *file, const attr_list_t *attrs
if (out_attr && !in_attr && pointer_type == FC_RP)
flags |= FC_ALLOCED_ON_STACK;
}
else if (get_stub_mode() == MODE_Oif)
else
{
if (context == TYPE_CONTEXT_TOPLEVELPARAM && is_ptr(type) && pointer_type == FC_RP)
{
......@@ -2312,7 +2262,7 @@ static unsigned int write_simple_pointer(FILE *file, const attr_list_t *attrs,
if (out_attr && !in_attr && pointer_fc == FC_RP)
flags |= FC_ALLOCED_ON_STACK;
}
else if (get_stub_mode() == MODE_Oif)
else
{
if (context == TYPE_CONTEXT_TOPLEVELPARAM && fc == FC_ENUM16 && pointer_fc == FC_RP)
flags |= FC_ALLOCED_ON_STACK;
......@@ -5091,7 +5041,7 @@ void write_client_call_routine( FILE *file, const type_t *iface, const var_t *fu
len = fprintf( file, " %s%s( ",
has_ret ? "_RetVal = " : "",
get_stub_mode() == MODE_Oif ? "NdrClientCall2" : "NdrClientCall" );
interpreted_mode ? "NdrClientCall2" : "NdrClientCall" );
fprintf( file, "&%s_StubDesc,", prefix );
fprintf( file, "\n%*s&__MIDL_ProcFormatString.Format[%u]", len, "", proc_offset );
if (needs_params)
......
......@@ -109,9 +109,9 @@ int do_dlldata = 0;
static int no_preprocess = 0;
int old_names = 0;
int winrt_mode = 0;
int interpreted_mode = 0;
int use_abi_namespace = 0;
static int stdinc = 1;
static enum stub_mode stub_mode = MODE_Os;
char *input_name;
char *idl_name;
......@@ -199,13 +199,6 @@ static const struct long_option long_options[] = {
static void rm_tempfile(void);
enum stub_mode get_stub_mode(void)
{
/* old-style interpreted stubs are not supported on 64-bit */
if (stub_mode == MODE_Oi && pointer_size == 8) return MODE_Oif;
return stub_mode;
}
static char *make_token(const char *name)
{
char *token;
......@@ -595,11 +588,11 @@ static void option_callback( int optc, char *optarg )
output_name = xstrdup(optarg);
break;
case 'O':
if (!strcmp( optarg, "s" )) stub_mode = MODE_Os;
else if (!strcmp( optarg, "i" )) stub_mode = MODE_Oi;
else if (!strcmp( optarg, "ic" )) stub_mode = MODE_Oif;
else if (!strcmp( optarg, "if" )) stub_mode = MODE_Oif;
else if (!strcmp( optarg, "icf" )) stub_mode = MODE_Oif;
if (!strcmp( optarg, "s" )) interpreted_mode = 0;
else if (!strcmp( optarg, "i" )) interpreted_mode = 1;
else if (!strcmp( optarg, "ic" )) interpreted_mode = 1;
else if (!strcmp( optarg, "if" )) interpreted_mode = 1;
else if (!strcmp( optarg, "icf" )) interpreted_mode = 1;
else error( "Invalid argument '-O%s'\n", optarg );
break;
case 'p':
......
......@@ -48,6 +48,7 @@ extern int do_idfile;
extern int do_dlldata;
extern int old_names;
extern int winrt_mode;
extern int interpreted_mode;
extern int use_abi_namespace;
extern char *input_name;
......@@ -72,13 +73,6 @@ extern unsigned int packing;
extern unsigned int pointer_size;
extern time_t now;
enum stub_mode
{
MODE_Os, /* inline stubs */
MODE_Oi, /* old-style interpreted stubs */
MODE_Oif /* new-style fully interpreted stubs */
};
extern enum stub_mode get_stub_mode(void);
extern int open_typelib( const char *name );
extern void write_header(const statement_list_t *stmts);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment