diff options
author | Mike Pall <mike> | 2011-01-16 18:32:33 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2011-01-16 18:32:33 +0100 |
commit | 6f746577d087e39d72d9ce2bc61df27828c6422e (patch) | |
tree | 4575fd34dbd66f7cce2dd7ab6bf085432d1e0251 /src/lj_cdata.c | |
parent | 0fa32e5d3128bbbfc2419a2bd158d5a72f2cd15b (diff) | |
download | luajit-6f746577d087e39d72d9ce2bc61df27828c6422e.tar.gz luajit-6f746577d087e39d72d9ce2bc61df27828c6422e.tar.bz2 luajit-6f746577d087e39d72d9ce2bc61df27828c6422e.zip |
FFI: Allow indexing a struct constructor to get constants.
Specialize to the CTypeID held by a constructor in all cases.
Diffstat (limited to 'src/lj_cdata.c')
-rw-r--r-- | src/lj_cdata.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lj_cdata.c b/src/lj_cdata.c index 5bd55237..1d0aea85 100644 --- a/src/lj_cdata.c +++ b/src/lj_cdata.c | |||
@@ -127,6 +127,17 @@ collect_attrib: | |||
127 | return ct; | 127 | return ct; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | } else if (cd->typeid == CTID_CTYPEID) { | ||
131 | /* Allow indexing a (pointer to) struct constructor to get constants. */ | ||
132 | CType *sct = ct = ctype_raw(cts, *(CTypeID *)p); | ||
133 | if (ctype_isptr(sct->info)) | ||
134 | sct = ctype_rawchild(cts, sct); | ||
135 | if (ctype_isstruct(sct->info)) { | ||
136 | CTSize ofs; | ||
137 | CType *fct = lj_ctype_getfield(cts, sct, name, &ofs); | ||
138 | if (fct && ctype_isconstval(fct->info)) | ||
139 | return fct; | ||
140 | } | ||
130 | } | 141 | } |
131 | { | 142 | { |
132 | GCstr *s = lj_ctype_repr(cts->L, ctype_typeid(cts, ct), NULL); | 143 | GCstr *s = lj_ctype_repr(cts->L, ctype_typeid(cts, ct), NULL); |