Commit bf011b0f authored by Alexandre Julliard's avatar Alexandre Julliard

widl: Infrastructure for adding a prefix to local variable references.

parent 3bdaba2a
......@@ -204,7 +204,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
fprintf(client, "\n");
}
write_remoting_arguments(client, indent, func, PASS_IN, PHASE_BUFFERSIZE);
write_remoting_arguments(client, indent, func, "", PASS_IN, PHASE_BUFFERSIZE);
print_client("NdrGetBuffer(\n");
indent++;
......@@ -218,7 +218,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
fprintf(client, "\n");
/* marshal arguments */
write_remoting_arguments(client, indent, func, PASS_IN, PHASE_MARSHAL);
write_remoting_arguments(client, indent, func, "", PASS_IN, PHASE_MARSHAL);
/* send/receive message */
/* print_client("NdrNsSendReceive(\n"); */
......@@ -248,7 +248,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
/* unmarshall arguments */
fprintf(client, "\n");
write_remoting_arguments(client, indent, func, PASS_OUT, PHASE_UNMARSHAL);
write_remoting_arguments(client, indent, func, "", PASS_OUT, PHASE_UNMARSHAL);
/* unmarshal return value */
if (!is_void(get_func_return_type(func)))
......@@ -257,7 +257,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
print_client("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal");
else if (is_ptr(get_func_return_type(func)) || is_array(get_func_return_type(func)))
print_client("%s = 0;\n", "_RetVal");
write_remoting_arguments(client, indent, func, PASS_RETURN, PHASE_UNMARSHAL);
write_remoting_arguments(client, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL);
}
/* update proc_offset */
......
......@@ -576,7 +576,7 @@ const type_t *expr_resolve_type(const struct expr_loc *expr_loc, const type_t *c
void write_expr(FILE *h, const expr_t *e, int brackets,
int toplevel, const char *toplevel_prefix,
const type_t *cont_type)
const type_t *cont_type, const char *local_var_prefix)
{
switch (e->type)
{
......@@ -602,9 +602,13 @@ void write_expr(FILE *h, const expr_t *e, int brackets,
{
int found_in_cont_type;
find_identifier(e->u.sval, cont_type, &found_in_cont_type);
if (found_in_cont_type) fprintf(h, "%s", toplevel_prefix);
if (found_in_cont_type)
{
fprintf(h, "%s%s", toplevel_prefix, e->u.sval);
break;
}
}
fprintf(h, "%s", e->u.sval);
fprintf(h, "%s%s", local_var_prefix, e->u.sval);
break;
case EXPR_STRLIT:
fprintf(h, "\"%s\"", e->u.sval);
......@@ -614,33 +618,33 @@ void write_expr(FILE *h, const expr_t *e, int brackets,
break;
case EXPR_LOGNOT:
fprintf(h, "!");
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
break;
case EXPR_NOT:
fprintf(h, "~");
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
break;
case EXPR_POS:
fprintf(h, "+");
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
break;
case EXPR_NEG:
fprintf(h, "-");
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
break;
case EXPR_ADDRESSOF:
fprintf(h, "&");
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
break;
case EXPR_PPTR:
fprintf(h, "*");
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
break;
case EXPR_CAST:
fprintf(h, "(");
write_type_decl(h, e->u.tref, NULL);
fprintf(h, ")");
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
break;
case EXPR_SIZEOF:
fprintf(h, "sizeof(");
......@@ -666,7 +670,7 @@ void write_expr(FILE *h, const expr_t *e, int brackets,
case EXPR_GTREQL:
case EXPR_LESSEQL:
if (brackets) fprintf(h, "(");
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
switch (e->type)
{
case EXPR_SHL: fprintf(h, " << "); break;
......@@ -689,38 +693,38 @@ void write_expr(FILE *h, const expr_t *e, int brackets,
case EXPR_LESSEQL: fprintf(h, " <= "); break;
default: break;
}
write_expr(h, e->u.ext, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->u.ext, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
if (brackets) fprintf(h, ")");
break;
case EXPR_MEMBER:
if (brackets) fprintf(h, "(");
if (e->ref->type == EXPR_PPTR)
{
write_expr(h, e->ref->ref, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ref->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
fprintf(h, "->");
}
else
{
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
fprintf(h, ".");
}
write_expr(h, e->u.ext, 1, 0, toplevel_prefix, cont_type);
write_expr(h, e->u.ext, 1, 0, toplevel_prefix, cont_type, "");
if (brackets) fprintf(h, ")");
break;
case EXPR_COND:
if (brackets) fprintf(h, "(");
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
fprintf(h, " ? ");
write_expr(h, e->u.ext, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->u.ext, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
fprintf(h, " : ");
write_expr(h, e->ext2, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ext2, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
if (brackets) fprintf(h, ")");
break;
case EXPR_ARRAY:
if (brackets) fprintf(h, "(");
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type);
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix);
fprintf(h, "[");
write_expr(h, e->u.ext, 1, 1, toplevel_prefix, cont_type);
write_expr(h, e->u.ext, 1, 1, toplevel_prefix, cont_type, local_var_prefix);
fprintf(h, "]");
if (brackets) fprintf(h, ")");
break;
......
......@@ -37,4 +37,5 @@ extern expr_t *make_expr3(enum expr_type type, expr_t *expr1, expr_t *expr2, exp
extern const type_t *expr_resolve_type(const struct expr_loc *expr_loc, const type_t *cont_type, const expr_t *expr);
extern int compare_expr(const expr_t *a, const expr_t *b);
extern void write_expr(FILE *h, const expr_t *e, int brackets, int toplevel, const char *toplevel_prefix, const type_t *cont_type);
extern void write_expr(FILE *h, const expr_t *e, int brackets, int toplevel, const char *toplevel_prefix,
const type_t *cont_type, const char *local_var_prefix);
......@@ -194,7 +194,7 @@ static void write_enums(FILE *h, var_list_t *enums)
fprintf(h, "%s", get_name(v));
if (v->eval) {
fprintf(h, " = ");
write_expr(h, v->eval, 0, 1, NULL, NULL);
write_expr(h, v->eval, 0, 1, NULL, NULL, "");
}
}
if (list_next( enums, &v->entry )) fprintf(h, ",\n");
......@@ -499,7 +499,7 @@ void write_declaration(const var_t *v, int is_in_interface)
if (is_const_decl(v) && v->eval)
{
fprintf(header, "#define %s (", v->name);
write_expr(header, v->eval, 0, 1, NULL, NULL);
write_expr(header, v->eval, 0, 1, NULL, NULL, "");
fprintf(header, ")\n\n");
}
else if (v->type->type != RPC_FC_FUNCTION || !is_in_interface)
......
......@@ -213,7 +213,7 @@ static void proxy_check_pointers( const var_list_t *args )
}
}
static void free_variable( const var_t *arg )
static void free_variable( const var_t *arg, const char *local_var_prefix )
{
unsigned int type_offset = arg->type->typestring_offset;
expr_t *iid;
......@@ -223,7 +223,7 @@ static void free_variable( const var_t *arg )
if (size)
{
print_proxy( "__frame->_StubMsg.MaxCount = " );
write_expr(proxy, size, 0, 1, NULL, NULL);
write_expr(proxy, size, 0, 1, NULL, NULL, local_var_prefix);
fprintf(proxy, ";\n\n");
print_proxy( "NdrClearOutParameters( &__frame->_StubMsg, ");
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%u], ", type_offset );
......@@ -251,7 +251,7 @@ static void free_variable( const var_t *arg )
if( iid )
{
print_proxy( "__frame->_StubMsg.MaxCount = (unsigned long) " );
write_expr(proxy, iid, 1, 1, NULL, NULL);
write_expr(proxy, iid, 1, 1, NULL, NULL, local_var_prefix);
print_proxy( ";\n\n" );
}
print_proxy( "NdrClearOutParameters( &__frame->_StubMsg, ");
......@@ -264,7 +264,7 @@ static void free_variable( const var_t *arg )
}
}
static void proxy_free_variables( var_list_t *args )
static void proxy_free_variables( var_list_t *args, const char *local_var_prefix )
{
const var_t *arg;
......@@ -272,7 +272,7 @@ static void proxy_free_variables( var_list_t *args )
LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
if (is_attr(arg->attrs, ATTR_OUT))
{
free_variable( arg );
free_variable( arg, local_var_prefix );
fprintf(proxy, "\n");
}
}
......@@ -337,11 +337,11 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx,
print_proxy( "{\n" );
indent++;
write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_BUFFERSIZE);
write_remoting_arguments(proxy, indent, cur, "", PASS_IN, PHASE_BUFFERSIZE);
print_proxy( "NdrProxyGetBuffer(This, &__frame->_StubMsg);\n" );
write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_MARSHAL);
write_remoting_arguments(proxy, indent, cur, "", PASS_IN, PHASE_MARSHAL);
print_proxy( "NdrProxySendReceive(This, &__frame->_StubMsg);\n" );
fprintf(proxy, "\n");
......@@ -354,7 +354,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx,
indent--;
fprintf(proxy, "\n");
write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_UNMARSHAL);
write_remoting_arguments(proxy, indent, cur, "", PASS_OUT, PHASE_UNMARSHAL);
if (has_ret)
{
......@@ -362,7 +362,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx,
print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal");
else if (is_ptr(get_func_return_type(cur)) || is_array(get_func_return_type(cur)))
print_proxy("%s = 0;\n", "_RetVal");
write_remoting_arguments(proxy, indent, cur, PASS_RETURN, PHASE_UNMARSHAL);
write_remoting_arguments(proxy, indent, cur, "", PASS_RETURN, PHASE_UNMARSHAL);
}
indent--;
......@@ -380,7 +380,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx,
print_proxy( "{\n" );
if (has_ret) {
indent++;
proxy_free_variables( cur->args );
proxy_free_variables( cur->args, "" );
print_proxy( "_RetVal = NdrProxyErrorHandler(RpcExceptionCode());\n" );
indent--;
}
......@@ -424,7 +424,7 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
fprintf(proxy, "\n");
print_proxy( "RpcExceptionInit( 0, __stub_finally );\n" );
write_parameters_init(proxy, indent, cur);
write_parameters_init(proxy, indent, cur, "");
print_proxy("RpcTryFinally\n");
print_proxy("{\n");
......@@ -437,10 +437,10 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
indent--;
fprintf(proxy, "\n");
write_remoting_arguments(proxy, indent, cur, PASS_IN, PHASE_UNMARSHAL);
write_remoting_arguments(proxy, indent, cur, "", PASS_IN, PHASE_UNMARSHAL);
fprintf(proxy, "\n");
assign_stub_out_args( proxy, indent, cur );
assign_stub_out_args( proxy, indent, cur, "" );
print_proxy("*_pdwStubPhase = STUB_CALL_SERVER;\n");
fprintf(proxy, "\n");
......@@ -460,26 +460,26 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
print_proxy("*_pdwStubPhase = STUB_MARSHAL;\n");
fprintf(proxy, "\n");
write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_BUFFERSIZE);
write_remoting_arguments(proxy, indent, cur, "", PASS_OUT, PHASE_BUFFERSIZE);
if (!is_void(get_func_return_type(cur)))
write_remoting_arguments(proxy, indent, cur, PASS_RETURN, PHASE_BUFFERSIZE);
write_remoting_arguments(proxy, indent, cur, "", PASS_RETURN, PHASE_BUFFERSIZE);
print_proxy("NdrStubGetBuffer(This, _pRpcChannelBuffer, &__frame->_StubMsg);\n");
write_remoting_arguments(proxy, indent, cur, PASS_OUT, PHASE_MARSHAL);
write_remoting_arguments(proxy, indent, cur, "", PASS_OUT, PHASE_MARSHAL);
fprintf(proxy, "\n");
/* marshall the return value */
if (!is_void(get_func_return_type(cur)))
write_remoting_arguments(proxy, indent, cur, PASS_RETURN, PHASE_MARSHAL);
write_remoting_arguments(proxy, indent, cur, "", PASS_RETURN, PHASE_MARSHAL);
indent--;
print_proxy("}\n");
print_proxy("RpcFinally\n");
print_proxy("{\n");
write_remoting_arguments(proxy, indent+1, cur, PASS_OUT, PHASE_FREE);
write_remoting_arguments(proxy, indent+1, cur, "", PASS_OUT, PHASE_FREE);
if (has_full_pointer)
write_full_pointer_free(proxy, indent, cur);
......
......@@ -87,7 +87,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
fprintf(server, "\n");
print_server( "RpcExceptionInit( __server_filter, __server_finally );\n" );
write_parameters_init(server, indent, func);
write_parameters_init(server, indent, func, "");
if (explicit_handle_var)
{
......@@ -117,7 +117,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
fprintf(server, "\n");
/* unmarshall arguments */
write_remoting_arguments(server, indent, func, PASS_IN, PHASE_UNMARSHAL);
write_remoting_arguments(server, indent, func, "", PASS_IN, PHASE_UNMARSHAL);
}
print_server("if (__frame->_StubMsg.Buffer > __frame->_StubMsg.BufferEnd)\n");
......@@ -138,7 +138,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
fprintf(server, "\n");
/* Assign 'out' arguments */
assign_stub_out_args(server, indent, func);
assign_stub_out_args(server, indent, func, "");
/* Call the real server function */
if (!is_void(get_func_return_type(func)))
......@@ -184,10 +184,10 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
if (has_out_arg_or_return(func))
{
write_remoting_arguments(server, indent, func, PASS_OUT, PHASE_BUFFERSIZE);
write_remoting_arguments(server, indent, func, "", PASS_OUT, PHASE_BUFFERSIZE);
if (!is_void(get_func_return_type(func)))
write_remoting_arguments(server, indent, func, PASS_RETURN, PHASE_BUFFERSIZE);
write_remoting_arguments(server, indent, func, "", PASS_RETURN, PHASE_BUFFERSIZE);
print_server("_pRpcMessage->BufferLength = __frame->_StubMsg.BufferLength;\n");
fprintf(server, "\n");
......@@ -202,11 +202,11 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
}
/* marshall arguments */
write_remoting_arguments(server, indent, func, PASS_OUT, PHASE_MARSHAL);
write_remoting_arguments(server, indent, func, "", PASS_OUT, PHASE_MARSHAL);
/* marshall the return value */
if (!is_void(get_func_return_type(func)))
write_remoting_arguments(server, indent, func, PASS_RETURN, PHASE_MARSHAL);
write_remoting_arguments(server, indent, func, "", PASS_RETURN, PHASE_MARSHAL);
indent--;
print_server("}\n");
......@@ -214,7 +214,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
print_server("{\n");
indent++;
write_remoting_arguments(server, indent, func, PASS_OUT, PHASE_FREE);
write_remoting_arguments(server, indent, func, "", PASS_OUT, PHASE_FREE);
if (has_full_pointer)
write_full_pointer_free(server, indent, func);
......
......@@ -41,13 +41,15 @@ typedef int (*type_pred_t)(const type_t *);
void write_formatstringsdecl(FILE *f, int indent, const statement_list_t *stmts, type_pred_t pred);
void write_procformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred);
void write_typeformatstring(FILE *file, const statement_list_t *stmts, type_pred_t pred);
void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, enum pass pass, const var_t *var, const char *varname);
void write_remoting_arguments(FILE *file, int indent, const func_t *func, enum pass pass, enum remoting_phase phase);
void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, enum remoting_phase phase,
enum pass pass, const var_t *var, const char *varname);
void write_remoting_arguments(FILE *file, int indent, const func_t *func, const char *local_var_prefix,
enum pass pass, enum remoting_phase phase);
size_t get_size_procformatstring_type(const char *name, const type_t *type, const attr_list_t *attrs);
size_t get_size_procformatstring_func(const func_t *func);
size_t get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred);
size_t get_size_typeformatstring(const statement_list_t *stmts, type_pred_t pred);
void assign_stub_out_args( FILE *file, int indent, const func_t *func );
void assign_stub_out_args( FILE *file, int indent, const func_t *func, const char *local_var_prefix );
void declare_stub_args( FILE *file, int indent, const func_t *func );
int write_expr_eval_routines(FILE *file, const char *iface);
void write_expr_eval_routine_list(FILE *file, const char *iface);
......@@ -56,7 +58,7 @@ void write_endpoints( FILE *f, const char *prefix, const str_list_t *list );
void write_exceptions( FILE *file );
size_t type_memsize(const type_t *t, unsigned int *align);
int decl_indirect(const type_t *t);
void write_parameters_init(FILE *file, int indent, const func_t *func);
void write_parameters_init(FILE *file, int indent, const func_t *func, const char *local_var_prefix);
void print(FILE *file, int indent, const char *format, va_list ap);
int get_padding(const var_list_t *fields);
int is_user_type(const type_t *t);
......
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