[SPEC2DEF] Allow stubs with parameters, and assume stdcall in that case

This commit is contained in:
Jérôme Gardou 2020-09-21 22:39:24 +02:00
parent 86a0852ffb
commit fa56912d42

View file

@ -1148,15 +1148,15 @@ ParseFile(char* pcStart, FILE *fileDest, unsigned *cExports)
/* Handle parameters */ /* Handle parameters */
exp.nStackBytes = 0; exp.nStackBytes = 0;
if (exp.nCallingConvention != CC_EXTERN && pc = NextToken(pc);
exp.nCallingConvention != CC_STUB) /* Extern can't have parameters, and it's optional to provide ones for stubs. All other exports must have them */
{ if (!pc && (exp.nCallingConvention != CC_EXTERN && exp.nCallingConvention != CC_STUB))
/* Go to next token */
if (!(pc = NextToken(pc)))
{ {
Fatal(pszSourceFileName, nLine, pcLine, pc, 1, "Unexpected end of line"); Fatal(pszSourceFileName, nLine, pcLine, pc, 1, "Unexpected end of line");
} }
if (pc && (exp.nCallingConvention != CC_EXTERN))
{
/* Verify syntax */ /* Verify syntax */
if (*pc++ != '(') if (*pc++ != '(')
{ {
@ -1228,13 +1228,23 @@ ParseFile(char* pcStart, FILE *fileDest, unsigned *cExports)
{ {
Fatal(pszSourceFileName, nLine, pcLine, pc - 1, 0, "Expected ')'"); Fatal(pszSourceFileName, nLine, pcLine, pc - 1, 0, "Expected ')'");
} }
/* Go to next token */
pc = NextToken(pc);
} }
/* Handle special stub cases */ /* Handle special stub cases */
if (exp.nCallingConvention == CC_STUB) if (exp.nCallingConvention == CC_STUB)
{ {
/* If we got parameters, assume STDCALL */
if (exp.nArgCount != 0)
{
exp.nCallingConvention = CC_STDCALL;
exp.uFlags |= FL_STUB;
}
/* Check for c++ mangled name */ /* Check for c++ mangled name */
if (pc[0] == '?') if (exp.strName.buf[0] == '?')
{ {
//printf("Found c++ mangled name...\n"); //printf("Found c++ mangled name...\n");
// //
@ -1242,13 +1252,13 @@ ParseFile(char* pcStart, FILE *fileDest, unsigned *cExports)
else else
{ {
/* Check for stdcall name */ /* Check for stdcall name */
const char *p = ScanToken(pc, '@'); const char *p = ScanToken(exp.strName.buf, '@');
if (p && (p - pc < exp.strName.len)) if (p && (p - exp.strName.buf < exp.strName.len))
{ {
int i; int i;
/* Truncate the name to before the @ */ /* Truncate the name to before the @ */
exp.strName.len = (int)(p - pc); exp.strName.len = (int)(p - exp.strName.buf);
if (exp.strName.len < 1) if (exp.strName.len < 1)
{ {
Fatal(pszSourceFileName, nLine, pcLine, p, 1, "Unexpected @"); Fatal(pszSourceFileName, nLine, pcLine, p, 1, "Unexpected @");
@ -1263,8 +1273,7 @@ ParseFile(char* pcStart, FILE *fileDest, unsigned *cExports)
} }
} }
/* Get optional redirection */ /* Check optional redirection */
pc = NextToken(pc);
if (pc) if (pc)
{ {
exp.strTarget.buf = pc; exp.strTarget.buf = pc;