[SPEC2DEF]
[reactos.git] / reactos / tools / spec2def / spec2def.c
index 1090a6b..bbf2880 100644 (file)
@@ -182,7 +182,7 @@ OutputLine_stub(FILE *file, EXPORT *pexp)
 {
     int i;
     int bRelay = 0;
-    int bInPrototype;
+    int bInPrototype = 0;
 
     if (pexp->nCallingConvention != CC_STUB &&
         (pexp->uFlags & FL_STUB) == 0)
@@ -250,7 +250,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;
-                case ARG_INT128 :  fprintf(file, "__int128"); break;
+                /* __int128 is not supported on x86, and int128 in spec files most often represents a GUID */
+                case ARG_INT128 :  fprintf(file, "GUID"); break;
                 case ARG_FLOAT: fprintf(file, "float"); break;
             }
             fprintf(file, " a%d", i);
@@ -296,8 +297,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, "%%\"PRix128\""); break;
+            case ARG_INT64: fprintf(file, "%%\"PRIx64\""); break;
+            case ARG_INT128: fprintf(file, "'%%s'"); break;
             case ARG_FLOAT: fprintf(file, "%%f"); break;
         }
     }
@@ -314,7 +315,7 @@ OutputLine_stub(FILE *file, EXPORT *pexp)
             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, "(__int128)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;
         }
     }
@@ -385,7 +386,7 @@ OutputHeader_asmstub(FILE *file, char *libname)
 }
 
 void
-Output_symbol(FILE *fileDest, char* pszSymbolName)
+Output_stublabel(FILE *fileDest, char* pszSymbolName)
 {
     if (giArch == ARCH_ARM)
     {
@@ -429,19 +430,21 @@ OutputLine_asmstub(FILE *fileDest, EXPORT *pexp)
         sprintf(szNameBuffer, "@_stub_%.*s@%d",
                 pexp->strName.len, pexp->strName.buf, pexp->nStackBytes);
     }
-    else if (pexp->nCallingConvention == CC_CDECL ||
-             pexp->nCallingConvention == CC_STUB)
+    else if ((pexp->nCallingConvention == CC_CDECL) ||
+             (pexp->nCallingConvention == CC_THISCALL) ||
+             (pexp->nCallingConvention == CC_EXTERN) ||
+             (pexp->nCallingConvention == CC_STUB))
     {
         sprintf(szNameBuffer, "__stub_%.*s",
                 pexp->strName.len, pexp->strName.buf);
     }
-    else if (pexp->nCallingConvention == CC_EXTERN)
+    else
     {
-        sprintf(szNameBuffer, "__stub_%.*s",
-                pexp->strName.len, pexp->strName.buf);
+        fprintf(stderr, "Invalid calling convention");
+        return 0;
     }
 
-    Output_symbol(fileDest, szNameBuffer);
+    Output_stublabel(fileDest, szNameBuffer);
 
     return 1;
 }
@@ -602,7 +605,8 @@ OutputLine_def_GCC(FILE *fileDest, EXPORT *pexp)
         /* C++ stubs are forwarded to C stubs */
         fprintf(fileDest, "=stub_function%d", pexp->nNumber);
     }
-    else if (gbTracing && ((pexp->uFlags & FL_NORELAY) == 0) && (pexp->nCallingConvention == CC_STDCALL) &&
+    else if (gbTracing && ((pexp->uFlags & FL_NORELAY) == 0) &&
+             (pexp->nCallingConvention == CC_STDCALL) &&
             (pexp->strName.buf[0] != '?'))
     {
         /* Redirect it to the relay-tracing trampoline */