From a2fedc376964e0eec04386f7556198c853052e85 Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Thu, 27 Sep 2007 17:38:13 -0700 Subject: [PATCH] widl: Write prototypes for context handle rundown rountines into generated header files. --- tools/widl/header.c | 37 +++++++++++++++++++++++++++++++++---- tools/widl/header.h | 1 + tools/widl/parser.y | 2 +- tools/widl/widl.c | 1 + tools/widl/widltypes.h | 4 +++- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/tools/widl/header.c b/tools/widl/header.c index 971b30fc543..ded4c1888ac 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -38,6 +38,8 @@ #include "header.h" static int indentation = 0; +user_type_list_t user_type_list = LIST_INIT(user_type_list); +static context_handle_list_t context_handle_list = LIST_INIT(context_handle_list); static void indent(FILE *h, int delta) { @@ -286,8 +288,6 @@ void write_type(FILE *h, type_t *t, int is_field, const char *fmt, ...) write_type_right(h, t, is_field); } -user_type_list_t user_type_list = LIST_INIT(user_type_list); - static int user_type_registered(const char *name) { user_type_t *ut; @@ -297,7 +297,16 @@ static int user_type_registered(const char *name) return 0; } -void check_for_user_types(const var_list_t *list) +static int context_handle_registered(const char *name) +{ + context_handle_t *ch; + LIST_FOR_EACH_ENTRY(ch, &context_handle_list, context_handle_t, entry) + if (!strcmp(name, ch->name)) + return 1; + return 0; +} + +void check_for_user_types_and_context_handles(const var_list_t *list) { const var_t *v; @@ -309,6 +318,16 @@ void check_for_user_types(const var_list_t *list) const char *name = type->name; if (type->user_types_registered) continue; type->user_types_registered = 1; + if (is_attr(type->attrs, ATTR_CONTEXTHANDLE)) { + if (!context_handle_registered(name)) + { + context_handle_t *ch = xmalloc(sizeof(*ch)); + ch->name = xstrdup(name); + list_add_tail(&context_handle_list, &ch->entry); + } + /* don't carry on parsing fields within this type */ + break; + } if (is_attr(type->attrs, ATTR_WIREMARSHAL)) { if (!user_type_registered(name)) { @@ -322,7 +341,7 @@ void check_for_user_types(const var_list_t *list) } else { - check_for_user_types(type->fields); + check_for_user_types_and_context_handles(type->fields); } } } @@ -341,6 +360,16 @@ void write_user_types(void) } } +void write_context_handle_rundowns(void) +{ + context_handle_t *ch; + LIST_FOR_EACH_ENTRY(ch, &context_handle_list, context_handle_t, entry) + { + const char *name = ch->name; + fprintf(header, "void __RPC_USER %s_rundown(%s);\n", name, name); + } +} + void write_typedef(type_t *type) { fprintf(header, "typedef "); diff --git a/tools/widl/header.h b/tools/widl/header.h index 54655a29b59..19a90a38347 100644 --- a/tools/widl/header.h +++ b/tools/widl/header.h @@ -52,6 +52,7 @@ extern void write_constdef(const var_t *v); extern void write_externdef(const var_t *v); extern void write_library(const char *name, const attr_list_t *attr); extern void write_user_types(void); +extern void write_context_handle_rundowns(void); extern const var_t* get_explicit_handle_var(const func_t* func); extern int has_out_arg_or_return(const func_t *func); extern void write_guid(FILE *f, const char *guid_prefix, const char *name, diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 17dd700c5b4..c4fc2c9f4f8 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -2021,6 +2021,6 @@ static void check_all_user_types(ifref_list_t *ifrefs) { const func_list_t *fs = ifref->iface->funcs; if (fs) LIST_FOR_EACH_ENTRY(f, fs, const func_t, entry) - check_for_user_types(f->args); + check_for_user_types_and_context_handles(f->args); } } diff --git a/tools/widl/widl.c b/tools/widl/widl.c index ca88958708e..c5e9d4090ce 100644 --- a/tools/widl/widl.c +++ b/tools/widl/widl.c @@ -409,6 +409,7 @@ int main(int argc,char *argv[]) fprintf(header, "/* Begin additional prototypes for all interfaces */\n"); fprintf(header, "\n"); write_user_types(); + write_context_handle_rundowns(); fprintf(header, "\n"); fprintf(header, "/* End additional prototypes */\n"); fprintf(header, "\n"); diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 2b1aaa90182..5dc634c8b0d 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -47,6 +47,7 @@ typedef struct _importlib_t importlib_t; typedef struct _importinfo_t importinfo_t; typedef struct _typelib_t typelib_t; typedef struct _user_type_t user_type_t; +typedef struct _user_type_t context_handle_t; typedef struct list attr_list_t; typedef struct list str_list_t; @@ -57,6 +58,7 @@ typedef struct list pident_list_t; typedef struct list ifref_list_t; typedef struct list array_dims_t; typedef struct list user_type_list_t; +typedef struct list context_handle_list_t; enum attr_type { @@ -306,7 +308,7 @@ struct _user_type_t { }; extern user_type_list_t user_type_list; -void check_for_user_types(const var_list_t *list); +void check_for_user_types_and_context_handles(const var_list_t *list); void init_types(void);