FFI: Allow indexing a struct constructor to get constants.

Specialize to the CTypeID held by a constructor in all cases.
This commit is contained in:
Mike Pall
2011-01-16 18:32:33 +01:00
parent 0fa32e5d31
commit 6f746577d0
2 changed files with 26 additions and 1 deletions

View File

@@ -127,6 +127,17 @@ collect_attrib:
return ct;
}
}
} else if (cd->typeid == CTID_CTYPEID) {
/* Allow indexing a (pointer to) struct constructor to get constants. */
CType *sct = ct = ctype_raw(cts, *(CTypeID *)p);
if (ctype_isptr(sct->info))
sct = ctype_rawchild(cts, sct);
if (ctype_isstruct(sct->info)) {
CTSize ofs;
CType *fct = lj_ctype_getfield(cts, sct, name, &ofs);
if (fct && ctype_isconstval(fct->info))
return fct;
}
}
{
GCstr *s = lj_ctype_repr(cts->L, ctype_typeid(cts, ct), NULL);