Commit 9b139018 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

widl: Add new function, type_iface_get_stmts.

Use it to retrieve statements contained in interface types.
parent 8fc59d0e
...@@ -81,7 +81,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) ...@@ -81,7 +81,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
if (!implicit_handle) if (!implicit_handle)
print_client("static RPC_BINDING_HANDLE %s__MIDL_AutoBindHandle;\n\n", iface->name); print_client("static RPC_BINDING_HANDLE %s__MIDL_AutoBindHandle;\n\n", iface->name);
STATEMENTS_FOR_EACH_FUNC( stmt, iface->details.iface->stmts ) STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
{ {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
const var_t* explicit_handle_var; const var_t* explicit_handle_var;
...@@ -478,7 +478,7 @@ static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_rou ...@@ -478,7 +478,7 @@ static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_rou
fprintf(client, " */\n"); fprintf(client, " */\n");
fprintf(client, "\n"); fprintf(client, "\n");
STATEMENTS_FOR_EACH_FUNC(stmt2, iface->details.iface->stmts) STATEMENTS_FOR_EACH_FUNC(stmt2, type_iface_get_stmts(iface))
{ {
has_func = 1; has_func = 1;
break; break;
......
...@@ -631,7 +631,7 @@ static void write_method_macro(FILE *header, const type_t *iface, const char *na ...@@ -631,7 +631,7 @@ static void write_method_macro(FILE *header, const type_t *iface, const char *na
if (type_iface_get_inherit(iface)) if (type_iface_get_inherit(iface))
write_method_macro(header, type_iface_get_inherit(iface), name); write_method_macro(header, type_iface_get_inherit(iface), name);
STATEMENTS_FOR_EACH_FUNC(stmt, iface->details.iface->stmts) STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface))
{ {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
...@@ -692,7 +692,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface) ...@@ -692,7 +692,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
{ {
const statement_t *stmt; const statement_t *stmt;
STATEMENTS_FOR_EACH_FUNC(stmt, iface->details.iface->stmts) STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface))
{ {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
if (!is_callas(func->attrs)) { if (!is_callas(func->attrs)) {
...@@ -717,7 +717,7 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char ...@@ -717,7 +717,7 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char
if (type_iface_get_inherit(iface)) if (type_iface_get_inherit(iface))
do_write_c_method_def(header, type_iface_get_inherit(iface), name); do_write_c_method_def(header, type_iface_get_inherit(iface), name);
STATEMENTS_FOR_EACH_FUNC(stmt, iface->details.iface->stmts) STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface))
{ {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
if (first_iface) { if (first_iface) {
...@@ -752,7 +752,7 @@ static void write_method_proto(FILE *header, const type_t *iface) ...@@ -752,7 +752,7 @@ static void write_method_proto(FILE *header, const type_t *iface)
{ {
const statement_t *stmt; const statement_t *stmt;
STATEMENTS_FOR_EACH_FUNC(stmt, iface->details.iface->stmts) STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface))
{ {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
...@@ -783,16 +783,16 @@ static void write_locals(FILE *fp, const type_t *iface, int body) ...@@ -783,16 +783,16 @@ static void write_locals(FILE *fp, const type_t *iface, int body)
if (!is_object(iface->attrs)) if (!is_object(iface->attrs))
return; return;
STATEMENTS_FOR_EACH_FUNC(stmt, iface->details.iface->stmts) { STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
const var_t *cas = is_callas(func->attrs); const var_t *cas = is_callas(func->attrs);
if (cas) { if (cas) {
const statement_t *stmt2 = NULL; const statement_t *stmt2 = NULL;
STATEMENTS_FOR_EACH_FUNC(stmt2, iface->details.iface->stmts) STATEMENTS_FOR_EACH_FUNC(stmt2, type_iface_get_stmts(iface))
if (!strcmp(stmt2->u.var->name, cas->name)) if (!strcmp(stmt2->u.var->name, cas->name))
break; break;
if (&stmt2->entry != iface->details.iface->stmts) { if (&stmt2->entry != type_iface_get_stmts(iface)) {
const var_t *m = stmt2->u.var; const var_t *m = stmt2->u.var;
/* 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));
...@@ -1062,7 +1062,7 @@ static void write_imports(FILE *header, const statement_list_t *stmts) ...@@ -1062,7 +1062,7 @@ static void write_imports(FILE *header, const statement_list_t *stmts)
{ {
case STMT_TYPE: case STMT_TYPE:
if (stmt->u.type->type == RPC_FC_IP) if (stmt->u.type->type == RPC_FC_IP)
write_imports(header, stmt->u.type->details.iface->stmts); write_imports(header, type_iface_get_stmts(stmt->u.type));
break; break;
case STMT_TYPEREF: case STMT_TYPEREF:
case STMT_IMPORTLIB: case STMT_IMPORTLIB:
...@@ -1132,13 +1132,13 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons ...@@ -1132,13 +1132,13 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons
if (is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE) || is_object(stmt->u.type->attrs)) if (is_attr(stmt->u.type->attrs, ATTR_DISPINTERFACE) || is_object(stmt->u.type->attrs))
{ {
write_com_interface_start(header, iface); write_com_interface_start(header, iface);
write_header_stmts(header, iface->details.iface->stmts, stmt->u.type, TRUE); write_header_stmts(header, type_iface_get_stmts(iface), stmt->u.type, TRUE);
write_com_interface_end(header, iface); write_com_interface_end(header, iface);
} }
else else
{ {
write_rpc_interface_start(header, iface); write_rpc_interface_start(header, iface);
write_header_stmts(header, iface->details.iface->stmts, iface, FALSE); write_header_stmts(header, type_iface_get_stmts(iface), iface, FALSE);
write_rpc_interface_end(header, iface); write_rpc_interface_end(header, iface);
} }
} }
......
...@@ -2501,7 +2501,7 @@ static void check_functions(const type_t *iface, int is_inside_library) ...@@ -2501,7 +2501,7 @@ static void check_functions(const type_t *iface, int is_inside_library)
const statement_t *stmt; const statement_t *stmt;
if (is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE)) if (is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE))
{ {
STATEMENTS_FOR_EACH_FUNC( stmt, iface->details.iface->stmts ) STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
{ {
var_t *func = stmt->u.var; var_t *func = stmt->u.var;
add_explicit_handle_if_necessary(func); add_explicit_handle_if_necessary(func);
...@@ -2509,7 +2509,7 @@ static void check_functions(const type_t *iface, int is_inside_library) ...@@ -2509,7 +2509,7 @@ static void check_functions(const type_t *iface, int is_inside_library)
} }
if (!is_inside_library && !is_attr(iface->attrs, ATTR_LOCAL)) if (!is_inside_library && !is_attr(iface->attrs, ATTR_LOCAL))
{ {
STATEMENTS_FOR_EACH_FUNC( stmt, iface->details.iface->stmts ) STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
{ {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
if (!is_attr(func->attrs, ATTR_LOCAL)) if (!is_attr(func->attrs, ATTR_LOCAL))
...@@ -2543,7 +2543,7 @@ static void check_all_user_types(const statement_list_t *stmts) ...@@ -2543,7 +2543,7 @@ static void check_all_user_types(const statement_list_t *stmts)
!is_local(stmt->u.type->attrs)) !is_local(stmt->u.type->attrs))
{ {
const statement_t *stmt_func; const statement_t *stmt_func;
STATEMENTS_FOR_EACH_FUNC(stmt_func, stmt->u.type->details.iface->stmts) { STATEMENTS_FOR_EACH_FUNC(stmt_func, type_iface_get_stmts(stmt->u.type)) {
const var_t *func = stmt_func->u.var; const var_t *func = stmt_func->u.var;
check_for_additional_prototype_types(func->type->details.function->args); check_for_additional_prototype_types(func->type->details.function->args);
} }
......
...@@ -535,7 +535,7 @@ static int count_methods(type_t *iface) ...@@ -535,7 +535,7 @@ static int count_methods(type_t *iface)
if (type_iface_get_inherit(iface)) if (type_iface_get_inherit(iface))
count = count_methods(type_iface_get_inherit(iface)); count = count_methods(type_iface_get_inherit(iface));
STATEMENTS_FOR_EACH_FUNC(stmt, iface->details.iface->stmts) { STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
if (!is_callas(func->attrs)) count++; if (!is_callas(func->attrs)) count++;
} }
...@@ -550,7 +550,7 @@ static int write_proxy_methods(type_t *iface, int skip) ...@@ -550,7 +550,7 @@ static int write_proxy_methods(type_t *iface, int skip)
if (type_iface_get_inherit(iface)) if (type_iface_get_inherit(iface))
i = write_proxy_methods(type_iface_get_inherit(iface), i = write_proxy_methods(type_iface_get_inherit(iface),
need_delegation(iface)); need_delegation(iface));
STATEMENTS_FOR_EACH_FUNC(stmt, iface->details.iface->stmts) { STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
if (!is_callas(func->attrs)) { if (!is_callas(func->attrs)) {
if (i) fprintf(proxy, ",\n"); if (i) fprintf(proxy, ",\n");
...@@ -572,7 +572,7 @@ static int write_stub_methods(type_t *iface, int skip) ...@@ -572,7 +572,7 @@ static int write_stub_methods(type_t *iface, int skip)
else else
return i; /* skip IUnknown */ return i; /* skip IUnknown */
STATEMENTS_FOR_EACH_FUNC(stmt, iface->details.iface->stmts) { STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
if (!is_local(func->attrs)) { if (!is_local(func->attrs)) {
if (i) fprintf(proxy,",\n"); if (i) fprintf(proxy,",\n");
...@@ -592,7 +592,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) ...@@ -592,7 +592,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
/* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */ /* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */
STATEMENTS_FOR_EACH_FUNC(stmt, iface->details.iface->stmts) { STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
if (first_func) { if (first_func) {
fprintf(proxy, "/*****************************************************************************\n"); fprintf(proxy, "/*****************************************************************************\n");
...@@ -606,7 +606,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) ...@@ -606,7 +606,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
int idx = func->type->details.function->idx; int idx = func->type->details.function->idx;
if (cname) { if (cname) {
const statement_t *stmt2; const statement_t *stmt2;
STATEMENTS_FOR_EACH_FUNC(stmt2, iface->details.iface->stmts) { STATEMENTS_FOR_EACH_FUNC(stmt2, type_iface_get_stmts(iface)) {
const var_t *m = stmt2->u.var; const var_t *m = stmt2->u.var;
if (!strcmp(m->name, cname)) if (!strcmp(m->name, cname))
{ {
...@@ -630,7 +630,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) ...@@ -630,7 +630,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
for (inherit_iface = type_iface_get_inherit(iface); for (inherit_iface = type_iface_get_inherit(iface);
inherit_iface; inherit_iface;
inherit_iface = type_iface_get_inherit(inherit_iface)) { inherit_iface = type_iface_get_inherit(inherit_iface)) {
STATEMENTS_FOR_EACH_FUNC(stmt, inherit_iface->details.iface->stmts) { STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(inherit_iface)) {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
int idx = func->type->details.function->idx; int idx = func->type->details.function->idx;
if (idx + 1 > midx) midx = idx + 1; if (idx + 1 > midx) midx = idx + 1;
......
...@@ -54,7 +54,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) ...@@ -54,7 +54,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
const var_t *var; const var_t *var;
const var_t* explicit_handle_var; const var_t* explicit_handle_var;
STATEMENTS_FOR_EACH_FUNC( stmt, iface->details.iface->stmts ) STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
{ {
const var_t *func = stmt->u.var; const var_t *func = stmt->u.var;
int has_full_pointer = is_full_pointer_function(func); int has_full_pointer = is_full_pointer_function(func);
...@@ -256,7 +256,7 @@ static void write_dispatchtable(type_t *iface) ...@@ -256,7 +256,7 @@ static void write_dispatchtable(type_t *iface)
print_server("{\n"); print_server("{\n");
indent++; indent++;
STATEMENTS_FOR_EACH_FUNC( stmt, iface->details.iface->stmts ) STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
{ {
var_t *func = stmt->u.var; var_t *func = stmt->u.var;
print_server("%s_%s,\n", iface->name, get_name(func)); print_server("%s_%s,\n", iface->name, get_name(func));
...@@ -416,7 +416,7 @@ static void write_server_stmts(const statement_list_t *stmts, int expr_eval_rout ...@@ -416,7 +416,7 @@ static void write_server_stmts(const statement_list_t *stmts, int expr_eval_rout
fprintf(server, " */\n"); fprintf(server, " */\n");
fprintf(server, "\n"); fprintf(server, "\n");
if (statements_has_func(iface->details.iface->stmts)) if (statements_has_func(type_iface_get_stmts(iface)))
{ {
write_serverinterfacedecl(iface); write_serverinterfacedecl(iface);
write_stubdescdecl(iface); write_stubdescdecl(iface);
......
...@@ -682,7 +682,7 @@ static void write_procformatstring_stmts(FILE *file, int indent, const statement ...@@ -682,7 +682,7 @@ static void write_procformatstring_stmts(FILE *file, int indent, const statement
const statement_t *stmt_func; const statement_t *stmt_func;
if (!pred(stmt->u.type)) if (!pred(stmt->u.type))
continue; continue;
STATEMENTS_FOR_EACH_FUNC(stmt_func, stmt->u.type->details.iface->stmts) STATEMENTS_FOR_EACH_FUNC(stmt_func, type_iface_get_stmts(stmt->u.type))
{ {
const var_t *func = stmt_func->u.var; const var_t *func = stmt_func->u.var;
if (is_local(func->attrs)) continue; if (is_local(func->attrs)) continue;
...@@ -2599,7 +2599,7 @@ static size_t process_tfs_stmts(FILE *file, const statement_list_t *stmts, ...@@ -2599,7 +2599,7 @@ static size_t process_tfs_stmts(FILE *file, const statement_list_t *stmts,
continue; continue;
current_iface = iface; current_iface = iface;
STATEMENTS_FOR_EACH_FUNC( stmt_func, iface->details.iface->stmts ) STATEMENTS_FOR_EACH_FUNC( stmt_func, type_iface_get_stmts(iface) )
{ {
const var_t *func = stmt_func->u.var; const var_t *func = stmt_func->u.var;
if (is_local(func->attrs)) continue; if (is_local(func->attrs)) continue;
...@@ -3271,7 +3271,7 @@ size_t get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred ...@@ -3271,7 +3271,7 @@ size_t get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred
if (!pred(iface)) if (!pred(iface))
continue; continue;
STATEMENTS_FOR_EACH_FUNC( stmt_func, iface->details.iface->stmts ) STATEMENTS_FOR_EACH_FUNC( stmt_func, type_iface_get_stmts(iface) )
{ {
const var_t *func = stmt_func->u.var; const var_t *func = stmt_func->u.var;
if (!is_local(func->attrs)) if (!is_local(func->attrs))
......
...@@ -91,7 +91,7 @@ static int compute_method_indexes(type_t *iface) ...@@ -91,7 +91,7 @@ static int compute_method_indexes(type_t *iface)
else else
idx = 0; idx = 0;
STATEMENTS_FOR_EACH_FUNC( stmt, iface->details.iface->stmts ) STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
{ {
var_t *func = stmt->u.var; var_t *func = stmt->u.var;
if (!is_callas(func->attrs)) if (!is_callas(func->attrs))
......
...@@ -80,6 +80,12 @@ static inline var_list_t *type_union_get_cases(const type_t *type) ...@@ -80,6 +80,12 @@ static inline var_list_t *type_union_get_cases(const type_t *type)
return type->details.structure->fields; return type->details.structure->fields;
} }
static inline statement_list_t *type_iface_get_stmts(const type_t *type)
{
assert(type->type == RPC_FC_IP);
return type->details.iface->stmts;
}
static inline type_t *type_iface_get_inherit(const type_t *type) static inline type_t *type_iface_get_inherit(const type_t *type)
{ {
assert(type->type == RPC_FC_IP); assert(type->type == RPC_FC_IP);
......
...@@ -2037,7 +2037,7 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface) ...@@ -2037,7 +2037,7 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface)
/* count the number of inherited interfaces and non-local functions */ /* count the number of inherited interfaces and non-local functions */
for(ref = inherit; ref; ref = type_iface_get_inherit(ref)) { for(ref = inherit; ref; ref = type_iface_get_inherit(ref)) {
num_parents++; num_parents++;
STATEMENTS_FOR_EACH_FUNC( stmt_func, ref->details.iface->stmts ) { STATEMENTS_FOR_EACH_FUNC( stmt_func, type_iface_get_stmts(ref) ) {
var_t *func = stmt_func->u.var; var_t *func = stmt_func->u.var;
if (!is_local(func->attrs)) num_funcs++; if (!is_local(func->attrs)) num_funcs++;
} }
...@@ -2045,7 +2045,7 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface) ...@@ -2045,7 +2045,7 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface)
msft_typeinfo->typeinfo->datatype2 = num_funcs << 16 | num_parents; msft_typeinfo->typeinfo->datatype2 = num_funcs << 16 | num_parents;
msft_typeinfo->typeinfo->cbSizeVft = num_funcs * 4; msft_typeinfo->typeinfo->cbSizeVft = num_funcs * 4;
STATEMENTS_FOR_EACH_FUNC( stmt_func, interface->details.iface->stmts ) { STATEMENTS_FOR_EACH_FUNC( stmt_func, type_iface_get_stmts(interface) ) {
var_t *func = stmt_func->u.var; var_t *func = stmt_func->u.var;
if(add_func_desc(msft_typeinfo, func, idx) == S_OK) if(add_func_desc(msft_typeinfo, func, idx) == S_OK)
idx++; idx++;
......
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