widl: Replace write_name() by get_name() to make the code more readable.
This commit is contained in:
parent
7c0d28b0da
commit
29e20b869c
|
@ -103,8 +103,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
||||||
if (needs_space_after(get_func_return_type(func)))
|
if (needs_space_after(get_func_return_type(func)))
|
||||||
fprintf(client, " ");
|
fprintf(client, " ");
|
||||||
if (callconv) fprintf(client, "%s ", callconv);
|
if (callconv) fprintf(client, "%s ", callconv);
|
||||||
write_prefix_name(client, prefix_client, def);
|
fprintf(client, "%s%s(\n", prefix_client, get_name(def));
|
||||||
fprintf(client, "(\n");
|
|
||||||
indent++;
|
indent++;
|
||||||
if (func->args)
|
if (func->args)
|
||||||
write_args(client, func->args, iface->name, 0, TRUE);
|
write_args(client, func->args, iface->name, 0, TRUE);
|
||||||
|
|
|
@ -130,21 +130,20 @@ void write_guid(FILE *f, const char *guid_prefix, const char *name, const UUID *
|
||||||
uuid->Data4[6], uuid->Data4[7]);
|
uuid->Data4[6], uuid->Data4[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_name(FILE *h, const var_t *v)
|
const char *get_name(const var_t *v)
|
||||||
{
|
{
|
||||||
if (is_attr( v->attrs, ATTR_PROPGET ))
|
static char buffer[256];
|
||||||
fprintf(h, "get_" );
|
|
||||||
else if (is_attr( v->attrs, ATTR_PROPPUT ))
|
|
||||||
fprintf(h, "put_" );
|
|
||||||
else if (is_attr( v->attrs, ATTR_PROPPUTREF ))
|
|
||||||
fprintf(h, "putref_" );
|
|
||||||
fprintf(h, "%s", v->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_prefix_name(FILE *h, const char *prefix, const var_t *v)
|
if (is_attr( v->attrs, ATTR_PROPGET ))
|
||||||
{
|
strcpy( buffer, "get_" );
|
||||||
fprintf(h, "%s", prefix);
|
else if (is_attr( v->attrs, ATTR_PROPPUT ))
|
||||||
write_name(h, v);
|
strcpy( buffer, "put_" );
|
||||||
|
else if (is_attr( v->attrs, ATTR_PROPPUTREF ))
|
||||||
|
strcpy( buffer, "putref_" );
|
||||||
|
else
|
||||||
|
buffer[0] = 0;
|
||||||
|
strcat( buffer, v->name );
|
||||||
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_field(FILE *h, var_t *v)
|
static void write_field(FILE *h, var_t *v)
|
||||||
|
@ -192,7 +191,7 @@ static void write_enums(FILE *h, var_list_t *enums)
|
||||||
{
|
{
|
||||||
if (v->name) {
|
if (v->name) {
|
||||||
indent(h, 0);
|
indent(h, 0);
|
||||||
write_name(h, v);
|
fprintf(h, "%s", get_name(v));
|
||||||
if (v->eval) {
|
if (v->eval) {
|
||||||
fprintf(h, " = ");
|
fprintf(h, " = ");
|
||||||
write_expr(h, v->eval, 0, 1, NULL, NULL);
|
write_expr(h, v->eval, 0, 1, NULL, NULL);
|
||||||
|
@ -635,17 +634,13 @@ static void write_method_macro(FILE *header, const type_t *iface, const char *na
|
||||||
if (!is_callas(def->attrs)) {
|
if (!is_callas(def->attrs)) {
|
||||||
const var_t *arg;
|
const var_t *arg;
|
||||||
|
|
||||||
fprintf(header, "#define %s_", name);
|
fprintf(header, "#define %s_%s(This", name, get_name(def));
|
||||||
write_name(header,def);
|
|
||||||
fprintf(header, "(This");
|
|
||||||
if (cur->args)
|
if (cur->args)
|
||||||
LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
|
LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
|
||||||
fprintf(header, ",%s", arg->name);
|
fprintf(header, ",%s", arg->name);
|
||||||
fprintf(header, ") ");
|
fprintf(header, ") ");
|
||||||
|
|
||||||
fprintf(header, "(This)->lpVtbl->");
|
fprintf(header, "(This)->lpVtbl->%s(This", get_name(def));
|
||||||
write_name(header, def);
|
|
||||||
fprintf(header, "(This");
|
|
||||||
if (cur->args)
|
if (cur->args)
|
||||||
LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
|
LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
|
||||||
fprintf(header, ",%s", arg->name);
|
fprintf(header, ",%s", arg->name);
|
||||||
|
@ -698,9 +693,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
|
||||||
indent(header, 0);
|
indent(header, 0);
|
||||||
fprintf(header, "virtual ");
|
fprintf(header, "virtual ");
|
||||||
write_type_decl_left(header, get_func_return_type(cur));
|
write_type_decl_left(header, get_func_return_type(cur));
|
||||||
fprintf(header, " %s ", callconv);
|
fprintf(header, " %s %s(\n", callconv, get_name(def));
|
||||||
write_name(header, def);
|
|
||||||
fprintf(header, "(\n");
|
|
||||||
write_args(header, cur->args, iface->name, 2, TRUE);
|
write_args(header, cur->args, iface->name, 2, TRUE);
|
||||||
fprintf(header, ") = 0;\n");
|
fprintf(header, ") = 0;\n");
|
||||||
fprintf(header, "\n");
|
fprintf(header, "\n");
|
||||||
|
@ -725,9 +718,7 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char
|
||||||
if (!callconv) callconv = "";
|
if (!callconv) callconv = "";
|
||||||
indent(header, 0);
|
indent(header, 0);
|
||||||
write_type_decl_left(header, get_func_return_type(cur));
|
write_type_decl_left(header, get_func_return_type(cur));
|
||||||
fprintf(header, " (%s *", callconv);
|
fprintf(header, " (%s *%s)(\n", callconv, get_name(def));
|
||||||
write_name(header, def);
|
|
||||||
fprintf(header, ")(\n");
|
|
||||||
write_args(header, cur->args, name, 1, TRUE);
|
write_args(header, cur->args, name, 1, TRUE);
|
||||||
fprintf(header, ");\n");
|
fprintf(header, ");\n");
|
||||||
fprintf(header, "\n");
|
fprintf(header, "\n");
|
||||||
|
@ -759,15 +750,11 @@ static void write_method_proto(FILE *header, const type_t *iface)
|
||||||
if (!callconv) callconv = "";
|
if (!callconv) callconv = "";
|
||||||
/* proxy prototype */
|
/* proxy prototype */
|
||||||
write_type_decl_left(header, get_func_return_type(cur));
|
write_type_decl_left(header, get_func_return_type(cur));
|
||||||
fprintf(header, " %s %s_", callconv, iface->name);
|
fprintf(header, " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(def));
|
||||||
write_name(header, def);
|
|
||||||
fprintf(header, "_Proxy(\n");
|
|
||||||
write_args(header, cur->args, iface->name, 1, TRUE);
|
write_args(header, cur->args, iface->name, 1, TRUE);
|
||||||
fprintf(header, ");\n");
|
fprintf(header, ");\n");
|
||||||
/* stub prototype */
|
/* stub prototype */
|
||||||
fprintf(header, "void __RPC_STUB %s_", iface->name);
|
fprintf(header, "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(def));
|
||||||
write_name(header,def);
|
|
||||||
fprintf(header, "_Stub(\n");
|
|
||||||
fprintf(header, " IRpcStubBuffer* This,\n");
|
fprintf(header, " IRpcStubBuffer* This,\n");
|
||||||
fprintf(header, " IRpcChannelBuffer* pRpcChannelBuffer,\n");
|
fprintf(header, " IRpcChannelBuffer* pRpcChannelBuffer,\n");
|
||||||
fprintf(header, " PRPC_MESSAGE pRpcMessage,\n");
|
fprintf(header, " PRPC_MESSAGE pRpcMessage,\n");
|
||||||
|
@ -799,9 +786,7 @@ void write_locals(FILE *fp, const type_t *iface, int body)
|
||||||
const var_t *mdef = m->def;
|
const var_t *mdef = m->def;
|
||||||
/* proxy prototype - use local prototype */
|
/* proxy prototype - use local prototype */
|
||||||
write_type_decl_left(fp, get_func_return_type(m));
|
write_type_decl_left(fp, get_func_return_type(m));
|
||||||
fprintf(fp, " CALLBACK %s_", iface->name);
|
fprintf(fp, " CALLBACK %s_%s_Proxy(\n", iface->name, get_name(mdef));
|
||||||
write_name(fp, mdef);
|
|
||||||
fprintf(fp, "_Proxy(\n");
|
|
||||||
write_args(fp, m->args, iface->name, 1, TRUE);
|
write_args(fp, m->args, iface->name, 1, TRUE);
|
||||||
fprintf(fp, ")");
|
fprintf(fp, ")");
|
||||||
if (body) {
|
if (body) {
|
||||||
|
@ -823,9 +808,7 @@ void write_locals(FILE *fp, const type_t *iface, int body)
|
||||||
fprintf(fp, ";\n");
|
fprintf(fp, ";\n");
|
||||||
/* stub prototype - use remotable prototype */
|
/* stub prototype - use remotable prototype */
|
||||||
write_type_decl_left(fp, get_func_return_type(cur));
|
write_type_decl_left(fp, get_func_return_type(cur));
|
||||||
fprintf(fp, " __RPC_STUB %s_", iface->name);
|
fprintf(fp, " __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(mdef));
|
||||||
write_name(fp, mdef);
|
|
||||||
fprintf(fp, "_Stub(\n");
|
|
||||||
write_args(fp, cur->args, iface->name, 1, TRUE);
|
write_args(fp, cur->args, iface->name, 1, TRUE);
|
||||||
fprintf(fp, ")");
|
fprintf(fp, ")");
|
||||||
if (body)
|
if (body)
|
||||||
|
@ -849,8 +832,7 @@ static void write_function_proto(FILE *header, const type_t *iface, const func_t
|
||||||
write_type_decl_left(header, get_func_return_type(fun));
|
write_type_decl_left(header, get_func_return_type(fun));
|
||||||
fprintf(header, " ");
|
fprintf(header, " ");
|
||||||
if (callconv) fprintf(header, "%s ", callconv);
|
if (callconv) fprintf(header, "%s ", callconv);
|
||||||
write_prefix_name(header, prefix, def);
|
fprintf(header, "%s%s(\n", prefix, get_name(def));
|
||||||
fprintf(header, "(\n");
|
|
||||||
if (fun->args)
|
if (fun->args)
|
||||||
write_args(header, fun->args, iface->name, 0, TRUE);
|
write_args(header, fun->args, iface->name, 0, TRUE);
|
||||||
else
|
else
|
||||||
|
|
|
@ -31,8 +31,6 @@ extern unsigned long get_attrv(const attr_list_t *list, enum attr_type t);
|
||||||
extern int is_void(const type_t *t);
|
extern int is_void(const type_t *t);
|
||||||
extern int is_conformant_array(const type_t *t);
|
extern int is_conformant_array(const type_t *t);
|
||||||
extern int is_declptr(const type_t *t);
|
extern int is_declptr(const type_t *t);
|
||||||
extern void write_name(FILE *h, const var_t *v);
|
|
||||||
extern void write_prefix_name(FILE *h, const char *prefix, const var_t *v);
|
|
||||||
extern const char* get_name(const var_t *v);
|
extern const char* get_name(const var_t *v);
|
||||||
extern void write_type_left(FILE *h, type_t *t, int declonly);
|
extern void write_type_left(FILE *h, type_t *t, int declonly);
|
||||||
extern void write_type_right(FILE *h, type_t *t, int is_field);
|
extern void write_type_right(FILE *h, type_t *t, int is_field);
|
||||||
|
|
|
@ -323,9 +323,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx,
|
||||||
|
|
||||||
indent = 0;
|
indent = 0;
|
||||||
write_type_decl_left(proxy, get_func_return_type(cur));
|
write_type_decl_left(proxy, get_func_return_type(cur));
|
||||||
print_proxy( " %s %s_", callconv, iface->name);
|
print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(def));
|
||||||
write_name(proxy, def);
|
|
||||||
print_proxy( "_Proxy(\n");
|
|
||||||
write_args(proxy, cur->args, iface->name, 1, TRUE);
|
write_args(proxy, cur->args, iface->name, 1, TRUE);
|
||||||
print_proxy( ")\n");
|
print_proxy( ")\n");
|
||||||
print_proxy( "{\n");
|
print_proxy( "{\n");
|
||||||
|
@ -430,9 +428,7 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
|
||||||
int has_full_pointer = is_full_pointer_function(cur);
|
int has_full_pointer = is_full_pointer_function(cur);
|
||||||
|
|
||||||
indent = 0;
|
indent = 0;
|
||||||
print_proxy( "void __RPC_STUB %s_", iface->name);
|
print_proxy( "void __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(def));
|
||||||
write_name(proxy, def);
|
|
||||||
print_proxy( "_Stub(\n");
|
|
||||||
indent++;
|
indent++;
|
||||||
print_proxy( "IRpcStubBuffer* This,\n");
|
print_proxy( "IRpcStubBuffer* This,\n");
|
||||||
print_proxy( "IRpcChannelBuffer *_pRpcChannelBuffer,\n");
|
print_proxy( "IRpcChannelBuffer *_pRpcChannelBuffer,\n");
|
||||||
|
@ -474,22 +470,13 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
|
||||||
print_proxy("");
|
print_proxy("");
|
||||||
if (has_ret) fprintf(proxy, "_RetVal = ");
|
if (has_ret) fprintf(proxy, "_RetVal = ");
|
||||||
if (cas) fprintf(proxy, "%s_%s_Stub", iface->name, cas);
|
if (cas) fprintf(proxy, "%s_%s_Stub", iface->name, cas);
|
||||||
else
|
else fprintf(proxy, "_This->lpVtbl->%s", get_name(def));
|
||||||
{
|
|
||||||
fprintf(proxy, "_This->lpVtbl->");
|
|
||||||
write_name(proxy, def);
|
|
||||||
}
|
|
||||||
fprintf(proxy, "(_This");
|
fprintf(proxy, "(_This");
|
||||||
|
|
||||||
if (cur->args)
|
if (cur->args)
|
||||||
{
|
{
|
||||||
LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
|
LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
|
||||||
{
|
fprintf(proxy, ", %s%s", arg->type->declarray ? "*" : "", get_name(arg));
|
||||||
fprintf(proxy, ", ");
|
|
||||||
if (arg->type->declarray)
|
|
||||||
fprintf(proxy, "*");
|
|
||||||
write_name(proxy, arg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fprintf(proxy, ");\n");
|
fprintf(proxy, ");\n");
|
||||||
fprintf(proxy, "\n");
|
fprintf(proxy, "\n");
|
||||||
|
@ -540,9 +527,7 @@ static int write_proxy_methods(type_t *iface)
|
||||||
var_t *def = cur->def;
|
var_t *def = cur->def;
|
||||||
if (!is_callas(def->attrs)) {
|
if (!is_callas(def->attrs)) {
|
||||||
if (i) fprintf(proxy, ",\n");
|
if (i) fprintf(proxy, ",\n");
|
||||||
print_proxy( "%s_", iface->name);
|
print_proxy( "%s_%s_Proxy", iface->name, get_name(def));
|
||||||
write_name(proxy, def);
|
|
||||||
fprintf(proxy, "_Proxy");
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -561,9 +546,7 @@ static int write_stub_methods(type_t *iface)
|
||||||
var_t *def = cur->def;
|
var_t *def = cur->def;
|
||||||
if (!is_local(def->attrs)) {
|
if (!is_local(def->attrs)) {
|
||||||
if (i) fprintf(proxy,",\n");
|
if (i) fprintf(proxy,",\n");
|
||||||
print_proxy( "%s_", iface->name);
|
print_proxy( "%s_%s_Stub", iface->name, get_name(def));
|
||||||
write_name(proxy, def);
|
|
||||||
fprintf(proxy, "_Stub");
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,13 +63,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
||||||
/* check for a defined binding handle */
|
/* check for a defined binding handle */
|
||||||
explicit_handle_var = get_explicit_handle_var(func);
|
explicit_handle_var = get_explicit_handle_var(func);
|
||||||
|
|
||||||
fprintf(server, "void __RPC_STUB\n");
|
print_server("void __RPC_STUB %s_%s( PRPC_MESSAGE _pRpcMessage )\n", iface->name, get_name(def));
|
||||||
fprintf(server, "%s_", iface->name);
|
|
||||||
write_name(server, def);
|
|
||||||
fprintf(server, "(\n");
|
|
||||||
indent++;
|
|
||||||
print_server("PRPC_MESSAGE _pRpcMessage)\n");
|
|
||||||
indent--;
|
|
||||||
|
|
||||||
/* write the functions body */
|
/* write the functions body */
|
||||||
fprintf(server, "{\n");
|
fprintf(server, "{\n");
|
||||||
|
@ -150,7 +144,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
||||||
print_server("_RetVal = ");
|
print_server("_RetVal = ");
|
||||||
else
|
else
|
||||||
print_server("");
|
print_server("");
|
||||||
write_prefix_name(server, prefix_server, def);
|
fprintf(server, "%s%s", prefix_server, get_name(def));
|
||||||
|
|
||||||
if (func->args)
|
if (func->args)
|
||||||
{
|
{
|
||||||
|
@ -176,10 +170,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print_server("");
|
print_server("%s%s", var->type->declarray ? "*" : "", get_name(var));
|
||||||
if (var->type->declarray)
|
|
||||||
fprintf(server, "*");
|
|
||||||
write_name(server, var);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(server, ");\n");
|
fprintf(server, ");\n");
|
||||||
|
@ -260,11 +251,7 @@ static void write_dispatchtable(type_t *iface)
|
||||||
if (iface->funcs) LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry )
|
if (iface->funcs) LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry )
|
||||||
{
|
{
|
||||||
var_t *def = func->def;
|
var_t *def = func->def;
|
||||||
|
print_server("%s_%s,\n", iface->name, get_name(def));
|
||||||
print_server("%s_", iface->name);
|
|
||||||
write_name(server, def);
|
|
||||||
fprintf(server, ",\n");
|
|
||||||
|
|
||||||
method_count++;
|
method_count++;
|
||||||
}
|
}
|
||||||
print_server("0\n");
|
print_server("0\n");
|
||||||
|
|
|
@ -3196,11 +3196,9 @@ void declare_stub_args( FILE *file, int indent, const func_t *func )
|
||||||
write_type_decl_left(file, var->type);
|
write_type_decl_left(file, var->type);
|
||||||
fprintf(file, " ");
|
fprintf(file, " ");
|
||||||
if (var->type->declarray) {
|
if (var->type->declarray) {
|
||||||
fprintf(file, "( *");
|
fprintf(file, "(*%s)", get_name(var));
|
||||||
write_name(file, var);
|
|
||||||
fprintf(file, " )");
|
|
||||||
} else
|
} else
|
||||||
write_name(file, var);
|
fprintf(file, "%s", get_name(var));
|
||||||
write_type_right(file, var->type, FALSE);
|
write_type_right(file, var->type, FALSE);
|
||||||
fprintf(file, ";\n");
|
fprintf(file, ";\n");
|
||||||
|
|
||||||
|
@ -3231,8 +3229,7 @@ void assign_stub_out_args( FILE *file, int indent, const func_t *func )
|
||||||
|
|
||||||
if (!in_attr)
|
if (!in_attr)
|
||||||
{
|
{
|
||||||
print_file(file, indent, "");
|
print_file(file, indent, "%s", get_name(var));
|
||||||
write_name(file, var);
|
|
||||||
|
|
||||||
if (is_context_handle(var->type))
|
if (is_context_handle(var->type))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue