diff options
Diffstat (limited to 'src/lj_cdata.c')
-rw-r--r-- | src/lj_cdata.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/lj_cdata.c b/src/lj_cdata.c index 11c84d8e..53605e7e 100644 --- a/src/lj_cdata.c +++ b/src/lj_cdata.c | |||
@@ -129,13 +129,7 @@ collect_attrib: | |||
129 | } | 129 | } |
130 | } else if (tvisstr(key)) { /* String key. */ | 130 | } else if (tvisstr(key)) { /* String key. */ |
131 | GCstr *name = strV(key); | 131 | GCstr *name = strV(key); |
132 | if (ctype_isptr(ct->info)) { /* Automatically perform '->'. */ | 132 | if (ctype_isstruct(ct->info)) { |
133 | if (ctype_isstruct(ctype_rawchild(cts, ct)->info)) { | ||
134 | p = (uint8_t *)cdata_getptr(p, ct->size); | ||
135 | ct = ctype_child(cts, ct); | ||
136 | goto collect_attrib; | ||
137 | } | ||
138 | } if (ctype_isstruct(ct->info)) { | ||
139 | CTSize ofs; | 133 | CTSize ofs; |
140 | CType *fct = lj_ctype_getfield(cts, ct, name, &ofs); | 134 | CType *fct = lj_ctype_getfield(cts, ct, name, &ofs); |
141 | if (fct) { | 135 | if (fct) { |
@@ -155,7 +149,7 @@ collect_attrib: | |||
155 | } | 149 | } |
156 | } else if (cd->typeid == CTID_CTYPEID) { | 150 | } else if (cd->typeid == CTID_CTYPEID) { |
157 | /* Allow indexing a (pointer to) struct constructor to get constants. */ | 151 | /* Allow indexing a (pointer to) struct constructor to get constants. */ |
158 | CType *sct = ct = ctype_raw(cts, *(CTypeID *)p); | 152 | CType *sct = ctype_raw(cts, *(CTypeID *)p); |
159 | if (ctype_isptr(sct->info)) | 153 | if (ctype_isptr(sct->info)) |
160 | sct = ctype_rawchild(cts, sct); | 154 | sct = ctype_rawchild(cts, sct); |
161 | if (ctype_isstruct(sct->info)) { | 155 | if (ctype_isstruct(sct->info)) { |
@@ -165,16 +159,16 @@ collect_attrib: | |||
165 | return fct; | 159 | return fct; |
166 | } | 160 | } |
167 | } | 161 | } |
168 | { | ||
169 | GCstr *s = lj_ctype_repr(cts->L, ctype_typeid(cts, ct), NULL); | ||
170 | lj_err_callerv(cts->L, LJ_ERR_FFI_BADMEMBER, strdata(s), strdata(name)); | ||
171 | } | ||
172 | } | 162 | } |
173 | { | 163 | if (ctype_isptr(ct->info)) { /* Automatically perform '->'. */ |
174 | GCstr *s = lj_ctype_repr(cts->L, ctype_typeid(cts, ct), NULL); | 164 | if (ctype_isstruct(ctype_rawchild(cts, ct)->info)) { |
175 | lj_err_callerv(cts->L, LJ_ERR_FFI_BADIDX, strdata(s)); | 165 | p = (uint8_t *)cdata_getptr(p, ct->size); |
166 | ct = ctype_child(cts, ct); | ||
167 | goto collect_attrib; | ||
168 | } | ||
176 | } | 169 | } |
177 | return NULL; /* unreachable */ | 170 | *qual |= 1; /* Lookup failed. */ |
171 | return ct; /* But return the resolved raw type. */ | ||
178 | } | 172 | } |
179 | 173 | ||
180 | /* -- C data getters ------------------------------------------------------ */ | 174 | /* -- C data getters ------------------------------------------------------ */ |