Sync to Wine-0.9.55:
authorAleksey Bragin <aleksey@reactos.org>
Sun, 10 Feb 2008 10:10:44 +0000 (10:10 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Sun, 10 Feb 2008 10:10:44 +0000 (10:10 +0000)
- Rob Shearman <rob@codeweavers.com> Sun, 20 Jan 2008
widl: Write out code for initialising out-only client context handles.

- Francois Gouget <fgouget@free.fr> Wed, 23 Jan 2008
Assorted spelling fixes.

- Jacek Caban <jacek@codeweavers.com> Tue, 29 Jan 2008
widl: Ignore ATTR_LOCAL in create_msft_typeinfo.

- Rob Shearman <rob@codeweavers.com> Wed, 30 Jan 2008
widl: Don't search for a import file name with a path in the include directories for compatibility with MIDL.

- Rob Shearman <rob@codeweavers.com> Wed, 30 Jan 2008
widl: Output code for initialising and freeing full pointer translation tables.

- Colin Finck <mail@colinfinck.de> Thu, 7 Feb 2008
widl: Support Windows paths in dup_basename and make_token.

- Colin Finck <mail@colinfinck.de> Thu, 7 Feb 2008
widl: Write the TLB file in binary mode, so the line endings won't be changed.

svn path=/trunk/; revision=32252

reactos/tools/widl/client.c
reactos/tools/widl/header.c
reactos/tools/widl/parser.l
reactos/tools/widl/parser.yy.c
reactos/tools/widl/proxy.c
reactos/tools/widl/server.c
reactos/tools/widl/typegen.c
reactos/tools/widl/typegen.h
reactos/tools/widl/typelib_struct.h
reactos/tools/widl/widl_ros.diff
reactos/tools/widl/write_msft.c

index 5cd2a81..2eaa43c 100644 (file)
@@ -85,6 +85,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
     {
         const var_t *def = func->def;
         const var_t* explicit_handle_var;
+        int has_full_pointer = is_full_pointer_function(func);
 
         /* check for a defined binding handle */
         explicit_handle_var = get_explicit_handle_var(func);
@@ -142,6 +143,9 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
         }
         fprintf(client, "\n");
 
+        if (has_full_pointer)
+            write_full_pointer_init(client, indent, func, FALSE);
+
         /* check pointers */
         check_pointers(func);
 
@@ -245,6 +249,9 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
 
         /* FIXME: emit client finally code */
 
+        if (has_full_pointer)
+            write_full_pointer_free(client, indent, func);
+
         print_client("NdrFreeBuffer((PMIDL_STUB_MESSAGE)&_StubMsg);\n");
 
         indent--;
index fd89534..0f697b8 100644 (file)
@@ -578,23 +578,21 @@ static void write_method_macro(const type_t *iface, const char *name)
     var_t *def = cur->def;
     if (!is_callas(def->attrs)) {
       const var_t *arg;
-      int argc = 0;
-      int c;
-
-      if (cur->args) LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry ) argc++;
 
       fprintf(header, "#define %s_", name);
       write_name(header,def);
-      fprintf(header, "(p");
-      for (c=0; c<argc; c++)
-       fprintf(header, ",%c", c+'a');
+      fprintf(header, "(This");
+      if (cur->args)
+          LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
+              fprintf(header, ",%s", arg->name);
       fprintf(header, ") ");
 
-      fprintf(header, "(p)->lpVtbl->");
+      fprintf(header, "(This)->lpVtbl->");
       write_name(header, def);
-      fprintf(header, "(p");
-      for (c=0; c<argc; c++)
-       fprintf(header, ",%c", c+'a');
+      fprintf(header, "(This");
+      if (cur->args)
+          LIST_FOR_EACH_ENTRY( arg, cur->args, const var_t, entry )
+              fprintf(header, ",%s", arg->name);
       fprintf(header, ")\n");
     }
   }
index 98f17af..2497a5e 100644 (file)
@@ -414,7 +414,11 @@ int do_import(char *fname)
        import->next = first_import;
        first_import = import;
 
-        if (!(path = wpp_find_include( fname, input_name )))
+        /* don't search for a file name with a path in the include directories,
+         * for compatibility with MIDL */
+        if (strchr( fname, '/' ) || strchr( fname, '\\' ))
+            path = strdup( fname );
+        else if (!(path = wpp_find_include( fname, input_name )))
             error_loc("Unable to open include file %s\n", fname);
 
        import_stack[ptr].temp_name = temp_name;
index 6bc079a..f8c9b2c 100644 (file)
@@ -2117,7 +2117,11 @@ int do_import(char *fname)
        import->next = first_import;
        first_import = import;
 
-        if (!(path = wpp_find_include( fname, input_name )))
+        /* don't search for a file name with a path in the include directories,
+         * for compatibility with MIDL */
+        if (strchr( fname, '/' ) || strchr( fname, '\\' ))
+            path = strdup( fname );
+        else if (!(path = wpp_find_include( fname, input_name )))
             error_loc("Unable to open include file %s\n", fname);
 
        import_stack[ptr].temp_name = temp_name;
index 731629f..217c64b 100644 (file)
@@ -254,6 +254,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx,
 {
   var_t *def = cur->def;
   int has_ret = !is_void(def->type);
+  int has_full_pointer = is_full_pointer_function(cur);
 
   indent = 0;
   write_type_decl_left(proxy, def->type);
@@ -279,6 +280,9 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx,
   }
   print_proxy( "\n");
 
+  if (has_full_pointer)
+    write_full_pointer_init(proxy, indent, cur, FALSE);
+
   /* FIXME: trace */
   clear_output_vars( cur->args );
 
@@ -325,6 +329,8 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx,
   print_proxy( "RpcFinally\n" );
   print_proxy( "{\n" );
   indent++;
+  if (has_full_pointer)
+    write_full_pointer_free(proxy, indent, cur);
   print_proxy( "NdrProxyFreeBuffer(This, &_StubMsg);\n" );
   indent--;
   print_proxy( "}\n");
@@ -356,6 +362,7 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
   var_t *def = cur->def;
   const var_t *arg;
   int has_ret = !is_void(def->type);
+  int has_full_pointer = is_full_pointer_function(cur);
 
   indent = 0;
   print_proxy( "void __RPC_STUB %s_", iface->name);
@@ -384,6 +391,8 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
   print_proxy("RpcTryFinally\n");
   print_proxy("{\n");
   indent++;
+  if (has_full_pointer)
+    write_full_pointer_init(proxy, indent, cur, TRUE);
   print_proxy("if ((_pRpcMessage->DataRepresentation & 0xffff) != NDR_LOCAL_DATA_REPRESENTATION)\n");
   indent++;
   print_proxy("NdrConvert( &_StubMsg, &__MIDL_ProcFormatString.Format[%u]);\n", proc_offset );
@@ -439,6 +448,9 @@ static void gen_stub(type_t *iface, const func_t *cur, const char *cas,
 
   write_remoting_arguments(proxy, indent+1, cur, PASS_OUT, PHASE_FREE);
 
+  if (has_full_pointer)
+    write_full_pointer_free(proxy, indent, cur);
+
   print_proxy("}\n");
   print_proxy("RpcEndFinally\n");
 
index 3fc6dd8..c866550 100644 (file)
@@ -62,6 +62,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
     LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry )
     {
         const var_t *def = func->def;
+        int has_full_pointer = is_full_pointer_function(func);
 
         /* check for a defined binding handle */
         explicit_handle_var = get_explicit_handle_var(func);
@@ -126,6 +127,9 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
         print_server("{\n");
         indent++;
 
+        if (has_full_pointer)
+            write_full_pointer_init(server, indent, func, TRUE);
+
         if (func->args)
         {
             print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
@@ -236,6 +240,9 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
 
         write_remoting_arguments(server, indent, func, PASS_OUT, PHASE_FREE);
 
+        if (has_full_pointer)
+            write_full_pointer_free(server, indent, func);
+
         indent--;
         print_server("}\n");
         print_server("RpcEndFinally\n");
index 041e183..41dd22f 100644 (file)
@@ -193,6 +193,46 @@ static int type_has_pointers(const type_t *type)
     return FALSE;
 }
 
+static int type_has_full_pointer(const type_t *type)
+{
+    if (is_user_type(type))
+        return FALSE;
+    else if (type->type == RPC_FC_FP)
+        return TRUE;
+    else if (is_ptr(type))
+        return FALSE;
+    else if (is_array(type))
+        return type_has_full_pointer(type->ref);
+    else if (is_struct(type->type))
+    {
+        const var_t *field;
+        if (type->fields) LIST_FOR_EACH_ENTRY( field, type->fields, const var_t, entry )
+        {
+            if (type_has_full_pointer(field->type))
+                return TRUE;
+        }
+    }
+    else if (is_union(type->type))
+    {
+        var_list_t *fields;
+        const var_t *field;
+        if (type->type == RPC_FC_ENCAPSULATED_UNION)
+        {
+            const var_t *uv = LIST_ENTRY(list_tail(type->fields), const var_t, entry);
+            fields = uv->type->fields;
+        }
+        else
+            fields = type->fields;
+        if (fields) LIST_FOR_EACH_ENTRY( field, fields, const var_t, entry )
+        {
+            if (field->type && type_has_full_pointer(field->type))
+                return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
 static unsigned short user_type_offset(const char *name)
 {
     user_type_t *ut;
@@ -903,6 +943,32 @@ size_t type_memsize(const type_t *t, unsigned int *align)
     return size;
 }
 
+int is_full_pointer_function(const func_t *func)
+{
+    const var_t *var;
+    if (type_has_full_pointer(func->def->type))
+        return TRUE;
+    if (!func->args)
+        return FALSE;
+    LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry )
+        if (type_has_full_pointer( var->type ))
+            return TRUE;
+    return FALSE;
+}
+
+void write_full_pointer_init(FILE *file, int indent, const func_t *func, int is_server)
+{
+    print_file(file, indent, "_StubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,%s);\n",
+                   is_server ? "XLAT_SERVER" : "XLAT_CLIENT");
+    fprintf(file, "\n");
+}
+
+void write_full_pointer_free(FILE *file, int indent, const func_t *func)
+{
+    print_file(file, indent, "NdrFullPointerXlatFree(_StubMsg.FullPtrXlatTables);\n");
+    fprintf(file, "\n");
+}
+
 static unsigned int write_nonsimple_pointer(FILE *file, const type_t *type, size_t offset)
 {
     short absoff = type->ref->typestring_offset;
@@ -2126,7 +2192,7 @@ static size_t write_typeformatstring_var(FILE *file, int indent, const func_t *f
         off = write_array_tfs(file, var->attrs, type, var->name, typeformat_offset);
         ptr_type = get_attrv(var->attrs, ATTR_POINTERTYPE);
         /* Top level pointers to conformant arrays may be handled specially
-           since we can bypass the pointer, but if the array is burried
+           since we can bypass the pointer, but if the array is buried
            beneath another pointer (e.g., "[size_is(,n)] int **p" then we
            always need to write the pointer.  */
         if (!ptr_type && var->type != type)
@@ -2724,6 +2790,8 @@ static void write_remoting_arg(FILE *file, int indent, const func_t *func,
         {
             if (pass == PASS_OUT)
             {
+                if (!in_attr)
+                    print_file(file, indent, "*%s = 0;\n", var->name);
                 print_file(file, indent, "NdrClientContextUnmarshall(\n");
                 print_file(file, indent + 1, "&_StubMsg,\n");
                 print_file(file, indent + 1, "(NDR_CCONTEXT *)%s,\n", var->name);
index c9a5148..4408ffa 100644 (file)
@@ -60,3 +60,6 @@ void print(FILE *file, int indent, const char *format, va_list ap);
 int get_padding(const var_list_t *fields);
 int is_user_type(const type_t *t);
 expr_t *get_size_is_expr(const type_t *t, const char *name);
+int is_full_pointer_function(const func_t *func);
+void write_full_pointer_init(FILE *file, int indent, const func_t *func, int is_server);
+void write_full_pointer_free(FILE *file, int indent, const func_t *func);
index e16387c..79b86b9 100644 (file)
@@ -92,16 +92,16 @@ typedef struct tagMSFT_pSeg {
 
 /* layout of the main segment directory */
 typedef struct tagMSFT_SegDir {
-/*1*/MSFT_pSeg pTypeInfoTab; /* each type info get an entry of 0x64 bytes */
+/*1*/MSFT_pSeg pTypeInfoTab; /* each typeinfo gets an entry of 0x64 bytes */
                              /* (25 ints) */
 /*2*/MSFT_pSeg pImpInfo;     /* table with info for imported types */
-/*3*/MSFT_pSeg pImpFiles;    /* import libaries */
+/*3*/MSFT_pSeg pImpFiles;    /* import libraries */
 /*4*/MSFT_pSeg pRefTab;      /* References table */
-/*5*/MSFT_pSeg pLibtab;      /* always exists, alway same size (0x80) */
+/*5*/MSFT_pSeg pLibtab;      /* always exists, always same size (0x80) */
                              /* hash table w offsets to guid????? */
 /*6*/MSFT_pSeg pGuidTab;     /* all guids are stored here together with  */
                              /* offset in some table???? */
-/*7*/MSFT_pSeg res07;        /* always created, alway same size (0x200) */
+/*7*/MSFT_pSeg res07;        /* always created, always same size (0x200) */
                              /* purpose largely unknown */
 /*8*/MSFT_pSeg pNametab;     /* name tables */
 /*9*/MSFT_pSeg pStringtab;   /* string table */
@@ -119,10 +119,10 @@ typedef struct tagMSFT_SegDir {
 /* base type info data */
 typedef struct tagMSFT_TypeInfoBase {
 /*000*/ INT   typekind;             /*  it is the TKIND_xxx */
-                                    /* some byte alignment stuf */
+                                    /* some byte alignment stuff */
         INT     memoffset;          /* points past the file, if no elements */
         INT     res2;               /* zero if no element, N*0x40 */
-        INT     res3;               /* -1 if no lement, (N-1)*0x38 */
+        INT     res3;               /* -1 if no element, (N-1)*0x38 */
 /*010*/ INT     res4;               /* always? 3 */
         INT     res5;               /* always? zero */
         INT     cElement;           /* counts elements, HI=cVars, LO=cFuncs */
@@ -171,7 +171,7 @@ typedef struct tagMSFT_ImpInfo {
 
 /* function description data */
 typedef struct {
-/*  INT   recsize;       record size including some xtra stuff */
+/*  INT   recsize;       record size including some extra stuff */
     INT   DataType;     /* data type of the member, eg return of function */
     INT   Flags;        /* something to do with attribute flags (LOWORD) */
 #ifdef WORDS_BIGENDIAN
@@ -227,7 +227,7 @@ typedef struct {
 
 /* Variable description data */
 typedef struct {
-/*  INT   recsize;      // record size including some xtra stuff */
+/*  INT   recsize;      // record size including some extra stuff */
     INT   DataType;     /* data type of the variable */
     INT   Flags;        /* VarFlags (LOWORD) */
 #ifdef WORDS_BIGENDIAN
index 166d609..1a92d7f 100644 (file)
@@ -60,34 +60,6 @@ Index: typelib.c
  
  #include "widl.h"
  #include "utils.h"
-Index: utils.c
-===================================================================
---- utils.c    (revision 32187)
-+++ utils.c    (working copy)
-@@ -136,6 +136,9 @@
-               name = "widl.tab";
-       slash = strrchr(name, '/');
-+      if (!slash)
-+              slash = strrchr(name, '\\');
-+
-       if (slash)
-               name = slash + 1;
-Index: widl.c
-===================================================================
---- widl.c     (revision 32187)
-+++ widl.c     (working copy)
-@@ -166,6 +166,9 @@
-   int i;
-   slash = strrchr(name, '/');
-+  if(!slash)
-+    slash = strrchr(name, '\\');
-+
-   if (slash) name = slash + 1;
-   token = xstrdup(name);
 Index: widltypes.h
 ===================================================================
 --- widltypes.h        (revision 32187)
@@ -123,12 +95,3 @@ Index: write_msft.c
  
  #include "widltypes.h"
  #include "typelib.h"
-@@ -2415,7 +2413,7 @@
-     retval = TYPE_E_IOERROR;
--    fd = creat(typelib->typelib->filename, 0666);
-+    fd = open(typelib->typelib->filename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0666);
-     if (fd == -1) return retval;
-     filepos = sizeof(MSFT_Header) + sizeof(MSFT_SegDir);
index 346bf0e..f9bea1f 100644 (file)
@@ -1839,6 +1839,9 @@ static msft_typeinfo_t *create_msft_typeinfo(msft_typelib_t *typelib, enum type_
             typeinfo->flags |= 0x10; /* TYPEFLAG_FHIDDEN */
             break;
 
+        case ATTR_LOCAL:
+            break;
+
         case ATTR_NONCREATABLE:
             typeinfo->flags &= ~0x2; /* TYPEFLAG_FCANCREATE */
             break;