Fix up autoproto with class-accessors and named enums.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5959 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
246cd8147c
commit
d3b1350ca5
3 changed files with 93 additions and 25 deletions
|
@ -46,9 +46,11 @@ char *r_defaultimageextensions =
|
|||
#endif
|
||||
#ifdef IMAGEFMT_KTX
|
||||
"ktx " //compressed or something. not to be confused with the qw mod by the same name. GL requires that etc2 compression is supported by modern drivers, but not necessarily the hardware. as such, dds with its s3tc bias should always come first (as the patents mean that drivers are much less likely to advertise it when they don't support it properly).
|
||||
//"ktx2 "
|
||||
#endif
|
||||
#ifdef IMAGEFMT_TGA
|
||||
"tga" //fairly fast to load
|
||||
//" htga"
|
||||
#endif
|
||||
#if defined(IMAGEFMT_PNG) || defined(FTE_TARGET_WEB)
|
||||
" png" //pngs, fairly common, but slow
|
||||
|
@ -3602,7 +3604,7 @@ static void *ReadRadianceFile(qbyte *buf, size_t len, const char *fname, int *wi
|
|||
*o++ = 1;
|
||||
}
|
||||
}
|
||||
else if (rgbe[0] == 1 && rgbe[1] == 1 && rgbe[2] == 1)
|
||||
else if (buf[0] == 1 && buf[1] == 1 && buf[2] == 1)
|
||||
{ //old rle logic
|
||||
Con_Printf("%s uses unsupported (old) RLE compression\n", fname);
|
||||
goto fail;
|
||||
|
|
|
@ -17477,7 +17477,7 @@ QCC_type_t *QCC_PR_ParseEnum(pbool flags)
|
|||
|
||||
strictenum = QCC_PR_CheckName("class"); //c++11 style
|
||||
|
||||
type = QCC_PR_ParseType(false, true); //legacy behaviour
|
||||
type = autoprototyped?NULL:QCC_PR_ParseType(false, true); //legacy behaviour
|
||||
if (type)
|
||||
{
|
||||
QCC_PR_ParseWarning(WARN_DEPRECACTEDSYNTAX, "legacy enum base type. Use \"enum [class] [name_e]:type\" instead");
|
||||
|
@ -17501,7 +17501,7 @@ QCC_type_t *QCC_PR_ParseEnum(pbool flags)
|
|||
QCC_PR_Expect("{");
|
||||
}
|
||||
|
||||
if (name)
|
||||
if (name && !enumtype)
|
||||
{
|
||||
enumtype = QCC_TypeForName(name);
|
||||
if (!enumtype)
|
||||
|
@ -17642,6 +17642,8 @@ QCC_type_t *QCC_PR_ParseEnum(pbool flags)
|
|||
}
|
||||
}
|
||||
|
||||
sref.sym->referenced = true;
|
||||
|
||||
//value gets added to global pool too (but referable whenever not strict)
|
||||
//we just generate an entirely new def (within the parent's pr_globals allocation). this also gives 'symbol was defined HERE' info.
|
||||
sref.sym = QCC_PR_DummyDef(sref.cast, name, pr_scope, 0, sref.sym, sref.ofs, !strictenum, GDF_CONST|GDF_STRIP);
|
||||
|
@ -17653,17 +17655,25 @@ QCC_type_t *QCC_PR_ParseEnum(pbool flags)
|
|||
for (acc = enumtype->accessors; acc; acc = acc->next)
|
||||
if (!strcmp(acc->fieldname, name))
|
||||
{
|
||||
QCC_Error(ERR_TOOMANYINITIALISERS, "%s::%s already declared", enumtype->name, name);
|
||||
const QCC_eval_t *old, *new;
|
||||
old = QCC_SRef_EvalConst(acc->staticval);
|
||||
new = QCC_SRef_EvalConst(sref);
|
||||
if (old && old == new && !typecmp(acc->staticval.cast, sref.cast))
|
||||
break;
|
||||
QCC_PR_ParseError(ERR_TOOMANYINITIALISERS, "%s::%s already declared", enumtype->name, name);
|
||||
break;
|
||||
}
|
||||
acc = qccHunkAlloc(sizeof(*acc));
|
||||
acc->fieldname = (char*)name;
|
||||
acc->next = enumtype->accessors;
|
||||
acc->type = enumtype;//sref.cast;
|
||||
acc->indexertype = NULL;
|
||||
enumtype->accessors = acc;
|
||||
acc->staticval = sref;
|
||||
acc->staticval.cast = enumtype;
|
||||
if (!acc)
|
||||
{
|
||||
acc = qccHunkAlloc(sizeof(*acc));
|
||||
acc->fieldname = (char*)name;
|
||||
acc->next = enumtype->accessors;
|
||||
acc->type = enumtype;//sref.cast;
|
||||
acc->indexertype = NULL;
|
||||
enumtype->accessors = acc;
|
||||
acc->staticval = sref;
|
||||
acc->staticval.cast = enumtype;
|
||||
}
|
||||
}
|
||||
QCC_FreeTemp(sref);
|
||||
|
||||
|
|
|
@ -3954,6 +3954,7 @@ void QCC_PR_ParsePrintDef (int type, QCC_def_t *def)
|
|||
{
|
||||
char tybuffer[512];
|
||||
char tmbuffer[512];
|
||||
char vlbuffer[512];
|
||||
char *modifiers;
|
||||
if (QCC_Temp_Describe(def, tmbuffer, sizeof(tmbuffer)))
|
||||
{
|
||||
|
@ -3966,10 +3967,28 @@ void QCC_PR_ParsePrintDef (int type, QCC_def_t *def)
|
|||
modifiers = "const ";
|
||||
else if (def->isstatic)
|
||||
modifiers = "static ";
|
||||
if (flag_msvcstyle)
|
||||
externs->Printf ("%s%s(%i) : %s%s%s %s%s%s is defined here\n", col_location, def->filen, def->s_line, col_type, modifiers, TypeName(def->type, tybuffer, sizeof(tybuffer)), col_symbol, def->name, col_none);
|
||||
|
||||
|
||||
if (def && def->initialized && def->constant && !def->arraysize)
|
||||
{
|
||||
const QCC_eval_t *ev = (const QCC_eval_t*)&def->symboldata[0];
|
||||
switch(def->type->type)
|
||||
{
|
||||
case ev_float: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %g", ev->_float); break;
|
||||
case ev_double: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %g", ev->_double); break;
|
||||
case ev_integer:QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %i", ev->_int); break;
|
||||
case ev_uint: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %u", ev->_uint); break;
|
||||
case ev_int64: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %i", (int)ev->_int64); break;
|
||||
case ev_uint64: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %u", (unsigned)ev->_uint64); break;
|
||||
default: *vlbuffer = 0; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
externs->Printf ("%s%s:%i: %s%s%s %s%s%s is defined here\n", col_location, def->filen, def->s_line, col_type, modifiers, TypeName(def->type, tybuffer, sizeof(tybuffer)), col_symbol, def->name, col_none);
|
||||
*vlbuffer = 0;
|
||||
if (flag_msvcstyle)
|
||||
externs->Printf ("%s%s(%i) : %s%s%s %s%s%s%s%s is defined here\n", col_location, def->filen, def->s_line, col_type, modifiers, TypeName(def->type, tybuffer, sizeof(tybuffer)), col_symbol, def->name, col_type, vlbuffer, col_none);
|
||||
else
|
||||
externs->Printf ("%s%s:%i: %s%s%s %s%s%s%s%s is defined here\n", col_location, def->filen, def->s_line, col_type, modifiers, TypeName(def->type, tybuffer, sizeof(tybuffer)), col_symbol, def->name, col_type, vlbuffer, col_none);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4559,7 +4578,8 @@ int typecmp(QCC_type_t *a, QCC_type_t *b)
|
|||
return 1;
|
||||
if (typecmp(a->params[i].type, b->params[i].type))
|
||||
return 1;
|
||||
if (a->params[i].defltvalue.cast || b->params[i].defltvalue.cast)
|
||||
if ((a->type != ev_function && (a->params[i].defltvalue.cast || b->params[i].defltvalue.cast)) ||
|
||||
(a->type == ev_function && (a->params[i].defltvalue.cast && b->params[i].defltvalue.cast)))
|
||||
{
|
||||
if (typecmp(a->params[i].defltvalue.cast, b->params[i].defltvalue.cast) ||
|
||||
a->params[i].defltvalue.sym != b->params[i].defltvalue.sym ||
|
||||
|
@ -4635,7 +4655,8 @@ int typecmp_lax(QCC_type_t *a, QCC_type_t *b)
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (a->params[t].defltvalue.cast || b->params[t].defltvalue.cast)
|
||||
if ((a->type != ev_function && (a->params[t].defltvalue.cast || b->params[t].defltvalue.cast)) ||
|
||||
(a->type == ev_function && (a->params[t].defltvalue.cast && b->params[t].defltvalue.cast)))
|
||||
{
|
||||
if (typecmp(a->params[t].defltvalue.cast, b->params[t].defltvalue.cast) ||
|
||||
a->params[t].defltvalue.sym != b->params[t].defltvalue.sym ||
|
||||
|
@ -5333,13 +5354,45 @@ struct accessor_s *QCC_PR_ParseAccessorMember(QCC_type_t *classtype, pbool isinl
|
|||
|
||||
def = QCC_PR_GetSRef(functype, funcname, NULL, true, 0, GDF_CONST | (isinline?GDF_INLINE:0));
|
||||
|
||||
pr_classtype = ((classtype->type==ev_entity)?classtype:NULL);
|
||||
f = QCC_PR_ParseImmediateStatements (def.sym, functype, false);
|
||||
pr_classtype = NULL;
|
||||
pr_scope = NULL;
|
||||
def.sym->symboldata[def.ofs].function = f - functions;
|
||||
f->def = def.sym;
|
||||
def.sym->initialized = 1;
|
||||
if (autoprototype)
|
||||
{
|
||||
if (QCC_PR_CheckToken("["))
|
||||
{
|
||||
while (!QCC_PR_CheckToken("]"))
|
||||
{
|
||||
if (pr_token_type == tt_eof)
|
||||
break;
|
||||
QCC_PR_Lex();
|
||||
}
|
||||
}
|
||||
QCC_PR_Expect("{");
|
||||
|
||||
{
|
||||
int blev = 1;
|
||||
//balance out the { and }
|
||||
while(blev)
|
||||
{
|
||||
if (pr_token_type == tt_eof)
|
||||
break;
|
||||
if (QCC_PR_CheckToken("{"))
|
||||
blev++;
|
||||
else if (QCC_PR_CheckToken("}"))
|
||||
blev--;
|
||||
else
|
||||
QCC_PR_Lex(); //ignore it.
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pr_classtype = ((classtype->type==ev_entity)?classtype:NULL);
|
||||
f = QCC_PR_ParseImmediateStatements (def.sym, functype, false);
|
||||
pr_classtype = NULL;
|
||||
pr_scope = NULL;
|
||||
def.sym->symboldata[def.ofs].function = f - functions;
|
||||
f->def = def.sym;
|
||||
def.sym->initialized = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5364,7 +5417,10 @@ struct accessor_s *QCC_PR_ParseAccessorMember(QCC_type_t *classtype, pbool isinl
|
|||
classtype->accessors = acc;
|
||||
}
|
||||
|
||||
if (acc->getset_func[setnotget].cast)
|
||||
if (acc->getset_func[setnotget].cast && (
|
||||
acc->getset_func[setnotget].sym != def.sym ||
|
||||
acc->getset_func[setnotget].cast != def.cast ||
|
||||
acc->getset_func[setnotget].ofs != def.ofs))
|
||||
QCC_Error(ERR_TOOMANYINITIALISERS, "%s::%s_%s already declared", classtype->name, setnotget?"set":"get", accessorname);
|
||||
acc->getset_func[setnotget] = def;
|
||||
acc->getset_isref[setnotget] = isref;
|
||||
|
|
Loading…
Reference in a new issue