A couple of winapi_test fixes

Francois Gouget fgouget at free.fr
Fri Aug 13 21:23:53 CDT 2004


This patch adds to MACRO definitions to help winapi_test determine the
size of structures. It also fixes a bug that prevented it from
recognizing 'unsigned' as a type when on its own.

But there is a lot of work left on winapi_test:

 * the most serious issue is that it does not support nested structures,
i.e. it is unable to compute the size and alignment of things like:

   typedef struct _NT_TIB
   {
       int a;
       union {
           int b;
           int c;
       } nested;
   } mystruct;

   The problem is that the union is treated as a field with an empty
name (''), and a type of 'union { }' and no further information seems to
be available to _find_align_kind_size (the only info kept on fields
comes from c_type::c_type_field). Obviously this is woefully
insufficient.


 * it does not support enums either. In this case,
_find_align_kind_size() is not even invoked. enums are shunted by
c_parse::parse_c_typedef() so winapi_test does not have a chance to
keep track of them and their size/alignment. So we we then encounter one
of them in a field (e.g. TOKEN_STATISTICS.ImpersonationLevel in winnt.h)
we are unable to compute the alignment/size of the whole structure.


 * the other issue is that it is not able to handle #include statements.
The main reason for that is that the C parser is not reentrant due to
the use of 'local $_;'. I'm not sure why this construct is used at all.
Is it just to save some typing???
   Supporting #include statements would help reduce the need for
hardcoding some type's size and reduce (or eliminate) the "type needn't
be kludged" warnings.


Unfortunately I have not had much luck with these issues so far. So if
any perl guru wants to look into one of these issues that would be
really cool.


Changelog:

 * tools/winapi/winapi_test

   Add the CCHILDREN_TITLEBAR+1 and NUM_POINTS macros.
   Add a couple base types that winapi_test does not know how to parse.
   Fix a bug so that 'signed' and 'unsigned' are recognised as valid
types.


Index: tools/winapi/winapi_test
===================================================================
RCS file: /var/cvs/wine/tools/winapi/winapi_test,v
retrieving revision 1.15
diff -u -r1.15 winapi_test
--- tools/winapi/winapi_test	4 May 2004 00:38:27 -0000	1.15
+++ tools/winapi/winapi_test	13 Aug 2004 18:59:00 -0000
@@ -149,6 +154,7 @@
 my %defines = (
     "ANYSIZE_ARRAY" => 1,
     "CCHDEVICENAME" => 32,
+    "CCHILDREN_TITLEBAR+1" => 6,
     "ELF_VENDOR_SIZE" => 4,
     "EXCEPTION_MAXIMUM_PARAMETERS" => 15,
     "HW_PROFILE_GUIDLEN" => 39,
@@ -160,7 +166,8 @@
     "MAX_GOPHER_DISPLAY_TEXT + 1" => 129,
     "MAX_GOPHER_LOCATOR_LENGTH + 1" => 654,
     "MAX_PATH" => 260,
-    "MAX_PROFILE_LEN" => 80,
+    "MAX_PROFILE_LEN" => 80,
+    "NUM_POINTS" => 3,
     "OFS_MAXPATHNAME" => 128,
     "SIZE_OF_80387_REGISTERS" => 80,
     "TOKEN_SOURCE_LENGTH" => 8,
@@ -203,7 +209,11 @@
 	$align = 2;
 	$kind = "signed";
 	$size = 2;
-    } elsif (!/^$/ && /^(?:(signed|unsigned)\s+)?(?:__int32|int|long(?:\s+int)?)?$/) {
+    } elsif (/^(signed|unsigned)$/) {
+	$align = 4;
+	$kind = defined($1) ? $1 : "signed";
+	$size = 4;
+    } elsif (/^(?:(signed|unsigned)\s+)?(?:__int32|int|long(?:\s+int)?)$/) {
 	$align = 4;
 	$kind = defined($1) ? $1 : "signed";
 	$size = 4;
@@ -215,7 +221,7 @@
 	$align = 8;
 	$kind = defined($1) ? $1 : "signed";
 	$size = 8;
-    } elsif (/^(?:double)$/) {
+    } elsif (/^(?:double|DOUBLE|DATE)$/) {
 	$align = 8;
 	$kind = "float";
 	$size = 8;
@@ -236,9 +242,9 @@
 	$kind = "struct";
 	$size = 8;
     } elsif (/^(?:VOID)$/) {
-    $align = 4;
-    $kind = "signed";
-    $size = 4;
+ 	$align = 4;
+ 	$kind = "signed";
+ 	$size = 4;
     } elsif (/^(?:SHORT)$/) {
 	$align = 2;
 	$kind = "unsigned";
@@ -255,6 +261,14 @@
 	$align = 2;
 	$kind = "unsigned";
 	$size = 2;
+    } elsif (/^(?:INT64|LONG64|LONGLONG)$/) {
+	$align = 8;
+ 	$kind = "signed";
+ 	$size = 8;
+    } elsif (/^(?:UINT64|ULONG64|DWORD64|ULONGLONG|DWORDLONG)$/) {
+	$align = 8;
+ 	$kind = "unsigned";
+ 	$size = 8;
     } elsif (/^(?:LARGE_INTEGER)$/) {
 	$align = 8;
 	$kind = "union";
Index: dlls/shell32/tests/generated.c
===================================================================
RCS file: /var/cvs/wine/dlls/shell32/tests/generated.c,v
retrieving revision 1.5
diff -u -r1.5 generated.c
--- dlls/shell32/tests/generated.c	11 Aug 2004 20:52:37 -0000	1.5
+++ dlls/shell32/tests/generated.c	14 Aug 2004 02:01:32 -0000
@@ -774,9 +759,12 @@
 static void test_pack_AUTO_SCROLL_DATA(void)
 {
     /* AUTO_SCROLL_DATA (pack 4) */
+    TEST_TYPE(AUTO_SCROLL_DATA, 48, 4);
     TEST_FIELD(AUTO_SCROLL_DATA, int, iNextSample, 0, 4, 4);
     TEST_FIELD(AUTO_SCROLL_DATA, DWORD, dwLastScroll, 4, 4, 4);
     TEST_FIELD(AUTO_SCROLL_DATA, BOOL, bFull, 8, 4, 4);
+    TEST_FIELD(AUTO_SCROLL_DATA, POINT[NUM_POINTS], pts, 12, 24, 4);
+    TEST_FIELD(AUTO_SCROLL_DATA, DWORD[NUM_POINTS], dwTimes, 36, 12, 4);
 }

 static void test_pack_BFFCALLBACK(void)
Index: dlls/user/tests/generated.c
===================================================================
RCS file: /var/cvs/wine/dlls/user/tests/generated.c,v
retrieving revision 1.11
diff -u -r1.11 generated.c
--- dlls/user/tests/generated.c	4 May 2004 00:41:11 -0000	1.11
+++ dlls/user/tests/generated.c	14 Aug 2004 02:01:32 -0000
@@ -1112,6 +1112,7 @@
 {
     /* LPTITLEBARINFO */
     TEST_TYPE(LPTITLEBARINFO, 4, 4);
+    TEST_TYPE_POINTER(LPTITLEBARINFO, 44, 4);
 }

 static void test_pack_LPTOGGLEKEYS(void)
@@ -1873,6 +1874,7 @@
 {
     /* PTITLEBARINFO */
     TEST_TYPE(PTITLEBARINFO, 4, 4);
+    TEST_TYPE_POINTER(PTITLEBARINFO, 44, 4);
 }

 static void test_pack_PUSEROBJECTFLAGS(void)
@@ -2037,8 +2039,10 @@
 static void test_pack_TITLEBARINFO(void)
 {
     /* TITLEBARINFO (pack 4) */
+    TEST_TYPE(TITLEBARINFO, 44, 4);
     TEST_FIELD(TITLEBARINFO, DWORD, cbSize, 0, 4, 4);
     TEST_FIELD(TITLEBARINFO, RECT, rcTitleBar, 4, 16, 4);
+    TEST_FIELD(TITLEBARINFO, DWORD[CCHILDREN_TITLEBAR+1], rgstate, 20, 24, 4);
 }

 static void test_pack_TOGGLEKEYS(void)


-- 
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
 "Only wimps use tape backup: _real_ men just upload their important stuff on
       ftp, and let the rest of the world mirror it ;)" -- Linus Torvalds



More information about the wine-patches mailing list