widl: Do the consistency checks on interfaces after parsing is complete.
authorRob Shearman <robertshearman@gmail.com>
Mon, 5 Jan 2009 23:33:19 +0000 (23:33 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 6 Jan 2009 11:53:49 +0000 (12:53 +0100)
tools/widl/parser.h
tools/widl/parser.y
tools/widl/typetree.c

index 85171f74b9f9bdbabf6b467239000eaf86dc0c1b..5822984f8e926011a4126d55b1dfeca210d23be6 100644 (file)
@@ -45,7 +45,6 @@ void pop_import(void);
 
 int is_type(const char *name);
 
-void check_functions(const type_t *iface);
 func_list_t *gen_function_list(const statement_list_t *stmts);
 
 #endif
index d9b5c3cbfdf25fec96bc1074097795a4719eac98..0f15f85c282aba40f3f81f11d530effb2e9c8770 100644 (file)
@@ -70,8 +70,6 @@
 
 unsigned char pointer_default = RPC_FC_UP;
 static int is_object_interface = FALSE;
-/* are we inside a library block? */
-static int is_inside_library = FALSE;
 
 typedef struct list typelist_t;
 struct typenode {
@@ -140,6 +138,7 @@ static var_t *reg_const(var_t *var);
 
 static char *gen_name(void);
 static void check_arg(var_t *arg);
+static void check_statements(const statement_list_t *stmts, int is_inside_library);
 static void check_all_user_types(const statement_list_t *stmts);
 static attr_list_t *check_iface_attrs(const char *name, attr_list_t *attrs);
 static attr_list_t *check_function_attrs(const char *name, attr_list_t *attrs);
@@ -346,6 +345,7 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s
 %%
 
 input:   gbl_statements                                { fix_incomplete();
+                                                 check_statements($1, FALSE);
                                                  check_all_user_types($1);
                                                  write_header($1);
                                                  write_id_data($1);
@@ -433,14 +433,12 @@ libraryhdr: tLIBRARY aIDENTIFIER          { $$ = $2; }
        ;
 library_start: attributes libraryhdr '{'       { $$ = make_library($2, check_library_attrs($2, $1));
                                                  if (!parse_only) start_typelib($$);
-                                                 is_inside_library = TRUE;
                                                }
        ;
 librarydef: library_start imp_statements '}'
            semicolon_opt                       { $$ = $1;
                                                  $$->stmts = $2;
                                                  if (!parse_only) end_typelib();
-                                                 is_inside_library = FALSE;
                                                }
        ;
 
@@ -2540,7 +2538,7 @@ static void add_explicit_handle_if_necessary(func_t *func)
     }
 }
 
-void check_functions(const type_t *iface)
+static void check_functions(const type_t *iface, int is_inside_library)
 {
     if (is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE) && iface->funcs)
     {
@@ -2559,6 +2557,19 @@ void check_functions(const type_t *iface)
     }
 }
 
+static void check_statements(const statement_list_t *stmts, int is_inside_library)
+{
+    const statement_t *stmt;
+
+    if (stmts) LIST_FOR_EACH_ENTRY(stmt, stmts, const statement_t, entry)
+    {
+      if (stmt->type == STMT_LIBRARY)
+          check_statements(stmt->u.lib->stmts, TRUE);
+      else if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP)
+          check_functions(stmt->u.type, is_inside_library);
+    }
+}
+
 static void check_all_user_types(const statement_list_t *stmts)
 {
   const statement_t *stmt;
index 2b56bb8e6ffb1b1ab2d79ee1729a675e2e2af4c7..f13ec5354d3707a9a73b852c86dabbc8f50a2d26 100644 (file)
@@ -73,7 +73,6 @@ void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stm
     iface->details.iface->disp_methods = NULL;
     iface->stmts = stmts;
     iface->defined = TRUE;
-    check_functions(iface);
     compute_method_indexes(iface);
 }
 
@@ -87,7 +86,6 @@ void type_dispinterface_define(type_t *iface, var_list_t *props, func_list_t *me
     iface->details.iface->disp_methods = methods;
     iface->stmts = NULL;
     iface->defined = TRUE;
-    check_functions(iface);
     compute_method_indexes(iface);
 }