Alexandre Julliard : widl: Move the pointer check functionality to typegen. c.

Alexandre Julliard julliard at winehq.org
Tue Jun 14 11:57:46 CDT 2011


Module: wine
Branch: master
Commit: c173399d62e6a65872bee60bd4e3d95d0e06431e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c173399d62e6a65872bee60bd4e3d95d0e06431e

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Jun 14 12:55:39 2011 +0200

widl: Move the pointer check functionality to typegen.c.

---

 tools/widl/client.c    |   15 +--------------
 tools/widl/proxy.c     |   29 +----------------------------
 tools/widl/typegen.c   |   29 +++++++++++++++++++++++++++++
 tools/widl/typegen.h   |    1 +
 tools/widl/widltypes.h |    1 -
 5 files changed, 32 insertions(+), 43 deletions(-)

diff --git a/tools/widl/client.c b/tools/widl/client.c
index 84f480b..be42b1b 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -50,19 +50,6 @@ static void print_client( const char *format, ... )
     va_end(va);
 }
 
-
-static void check_pointers(const var_t *func)
-{
-    const var_t *var;
-
-    if (!type_get_function_args(func->type))
-        return;
-
-    LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
-        if (cant_be_null(var))
-            print_client("if (!%s) RpcRaiseException(RPC_X_NULL_REF_POINTER);\n", var->name);
-}
-
 static void write_client_func_decl( const type_t *iface, const var_t *func )
 {
     const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
@@ -173,7 +160,7 @@ static void write_function_stub( const type_t *iface, const var_t *func,
         write_full_pointer_init(client, indent, func, FALSE);
 
     /* check pointers */
-    check_pointers(func);
+    write_pointer_checks( client, indent, func );
 
     print_client("RpcTryFinally\n");
     print_client("{\n");
diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c
index 2ff8ea1..8e2db07 100644
--- a/tools/widl/proxy.c
+++ b/tools/widl/proxy.c
@@ -120,23 +120,6 @@ static void clear_output_vars( const var_list_t *args )
   }
 }
 
-int cant_be_null(const var_t *v)
-{
-    switch (typegen_detect_type(v->type, v->attrs, TDT_IGNORE_STRINGS))
-    {
-    case TGT_ARRAY:
-        if (!type_array_is_decl_as_ptr( v->type )) return 0;
-        /* fall through */
-    case TGT_POINTER:
-        return (get_pointer_fc(v->type, v->attrs, TRUE) == RPC_FC_RP);
-    case TGT_CTXT_HANDLE_POINTER:
-        return TRUE;
-    default:
-        return 0;
-    }
-
-}
-
 static int need_delegation(const type_t *iface)
 {
     const type_t *parent = type_iface_get_inherit( iface );
@@ -161,16 +144,6 @@ static int need_delegation_indirect(const type_t *iface)
   return get_delegation_indirect(iface, NULL);
 }
 
-static void proxy_check_pointers( const var_list_t *args )
-{
-  const var_t *arg;
-
-  if (!args) return;
-  LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
-      if (cant_be_null(arg))
-          print_proxy( "if (!%s) RpcRaiseException(RPC_X_NULL_REF_POINTER);\n", arg->name );
-}
-
 static void free_variable( const var_t *arg, const char *local_var_prefix )
 {
   unsigned int type_offset = arg->type->typestring_offset;
@@ -303,7 +276,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
   print_proxy( "{\n" );
   indent++;
   print_proxy( "NdrProxyInitialize(This, &_RpcMessage, &__frame->_StubMsg, &Object_StubDesc, %d);\n", idx);
-  proxy_check_pointers( type_get_function_args(func->type) );
+  write_pointer_checks( proxy, indent, func );
 
   print_proxy( "RpcTryFinally\n" );
   print_proxy( "{\n" );
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index 1a2329d..0096c32 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -373,6 +373,23 @@ enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *att
     return TGT_INVALID;
 }
 
+static int cant_be_null(const var_t *v)
+{
+    switch (typegen_detect_type(v->type, v->attrs, TDT_IGNORE_STRINGS))
+    {
+    case TGT_ARRAY:
+        if (!type_array_is_decl_as_ptr( v->type )) return 0;
+        /* fall through */
+    case TGT_POINTER:
+        return (get_pointer_fc(v->type, v->attrs, TRUE) == RPC_FC_RP);
+    case TGT_CTXT_HANDLE_POINTER:
+        return TRUE;
+    default:
+        return 0;
+    }
+
+}
+
 static int get_padding(const var_list_t *fields)
 {
     unsigned short offset = 0;
@@ -4720,6 +4737,18 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun
     print_file( file, 0, "\n" );
 }
 
+void write_pointer_checks( FILE *file, int indent, const var_t *func )
+{
+    const var_list_t *args = type_get_function_args( func->type );
+    const var_t *var;
+
+    if (!args) return;
+
+    LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
+        if (cant_be_null( var ))
+            print_file( file, indent, "if (!%s) RpcRaiseException(RPC_X_NULL_REF_POINTER);\n", var->name );
+}
+
 int write_expr_eval_routines(FILE *file, const char *iface)
 {
     static const char *var_name = "pS";
diff --git a/tools/widl/typegen.h b/tools/widl/typegen.h
index 3efd421..c98aff8 100644
--- a/tools/widl/typegen.h
+++ b/tools/widl/typegen.h
@@ -77,6 +77,7 @@ void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char
 void declare_stub_args( FILE *file, int indent, const var_t *func );
 void write_func_param_struct( FILE *file, const type_t *iface, const type_t *func,
                               const char *var_decl, int add_retval );
+void write_pointer_checks( FILE *file, int indent, const var_t *func );
 int write_expr_eval_routines(FILE *file, const char *iface);
 void write_expr_eval_routine_list(FILE *file, const char *iface);
 void write_user_quad_list(FILE *file);
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index 9e9bec6..64c94e5 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -544,7 +544,6 @@ void clear_all_offsets(void);
 
 int is_ptr(const type_t *t);
 int is_array(const type_t *t);
-int cant_be_null(const var_t *v);
 
 #define tsENUM   1
 #define tsSTRUCT 2




More information about the wine-cvs mailing list