https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bd27b050fcd44d38cfbbe4...
commit bd27b050fcd44d38cfbbe4d054dffecfc46c2432 Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Sun Aug 30 02:02:26 2020 +0200 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Sun Aug 30 02:16:15 2020 +0200
[SPEC2DEF] Improve the 'int128' arguments display. Addendum to commit a28fa3fd.
'int128' arguments are NOT almost always GUID, as was claimed, and the usage of the wine_dbgstr_guid() function to display them would require the presence of yet another wine-specific header.
Instead, define a "MyInt128" typedef, local to the stub file being generated, as the structure of two __int64's (lower and upper), and print this "MyInt128" as the couple of these two __int64's.
Besides, display the __int64 numbers prefixed with "0x" (together with the PRIx64 formatter).
Finally, when generating the debug-print function calls, it is useless to explicitly cast the 'aX' variables with their types, because their types are already known from the prototype of the stub-function!! Therefore we can use the same `fprintf(file, "a%d", i);` for all the ARG_LONG, ARG_PTR, ARG_STR, ARG_WSTR, ARG_DBL, ARG_INT64 and ARG_FLOAT. Only in the case of ARG_INT128 we output "a%d.lower, a%d.upper" . --- sdk/tools/spec2def/spec2def.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/sdk/tools/spec2def/spec2def.c b/sdk/tools/spec2def/spec2def.c index e4c9441c7e6..a7b67b8d239 100644 --- a/sdk/tools/spec2def/spec2def.c +++ b/sdk/tools/spec2def/spec2def.c @@ -227,6 +227,13 @@ OutputHeader_stub(FILE *file) fprintf(file, "WINE_DECLARE_DEBUG_CHANNEL(relay);\n"); }
+ /* __int128 is not supported on x86, so use a custom type */ + fprintf(file, "\n" + "typedef struct {\n" + " __int64 lower;\n" + " __int64 upper;\n" + "} MyInt128;\n"); + fprintf(file, "\n"); }
@@ -303,8 +310,8 @@ OutputLine_stub(FILE *file, EXPORT *pexp) case ARG_WSTR: fprintf(file, "wchar_t*"); break; case ARG_DBL: fprintf(file, "double"); break; case ARG_INT64: fprintf(file, "__int64"); break; - /* __int128 is not supported on x86, and int128 in spec files most often represents a GUID */ - case ARG_INT128: fprintf(file, "GUID"); break; + /* __int128 is not supported on x86, so use a custom type */ + case ARG_INT128: fprintf(file, "MyInt128"); break; case ARG_FLOAT: fprintf(file, "float"); break; } fprintf(file, " a%d", i); @@ -350,8 +357,8 @@ OutputLine_stub(FILE *file, EXPORT *pexp) case ARG_STR: fprintf(file, "'%%s'"); break; case ARG_WSTR: fprintf(file, "'%%ws'"); break; case ARG_DBL: fprintf(file, "%%f"); break; - case ARG_INT64: fprintf(file, "%%"PRIx64""); break; - case ARG_INT128: fprintf(file, "'%%s'"); break; + case ARG_INT64: fprintf(file, "0x%%"PRIx64""); break; + case ARG_INT128: fprintf(file, "0x%%"PRIx64"-0x%%"PRIx64""); break; case ARG_FLOAT: fprintf(file, "%%f"); break; } } @@ -362,14 +369,13 @@ OutputLine_stub(FILE *file, EXPORT *pexp) fprintf(file, ", "); switch (pexp->anArgs[i]) { - case ARG_LONG: fprintf(file, "(long)a%d", i); break; - case ARG_PTR: fprintf(file, "(void*)a%d", i); break; - case ARG_STR: fprintf(file, "(char*)a%d", i); break; - case ARG_WSTR: fprintf(file, "(wchar_t*)a%d", i); break; - case ARG_DBL: fprintf(file, "(double)a%d", i); break; - case ARG_INT64: fprintf(file, "(__int64)a%d", i); break; - case ARG_INT128: fprintf(file, "wine_dbgstr_guid(&a%d)", i); break; - case ARG_FLOAT: fprintf(file, "(float)a%d", i); break; + case ARG_LONG: case ARG_PTR: case ARG_STR: + case ARG_WSTR: case ARG_DBL: case ARG_INT64: + fprintf(file, "a%d", i); break; + case ARG_INT128: + fprintf(file, "a%d.lower, a%d.upper", i, i); break; + case ARG_FLOAT: + fprintf(file, "a%d", i); break; } } fprintf(file, ");\n"); @@ -404,7 +410,7 @@ OutputLine_stub(FILE *file, EXPORT *pexp) { if (pexp->uFlags & FL_RET64) { - fprintf(file, "\tif (TRACE_ON(relay))\n\t\tDPRINTF("%s: %.*s: retval = %%"PRIx64"\n", retval);\n", + fprintf(file, "\tif (TRACE_ON(relay))\n\t\tDPRINTF("%s: %.*s: retval = 0x%%"PRIx64"\n", retval);\n", pszDllName, pexp->strName.len, pexp->strName.buf); } else