|
于 2013-12-21 17:24, Ulrich Schmidt 写道:
I wrote a tiny module to print some values to console for debugging purposes. (see attaches file) after reading your code and some debugging work, I think I have found the reason. in the function "pairsByKeys", you first get all keys of a table and store them sorted. then you return an iterator which walk throgh the sorted keys. this is all fine, as long the table is a _normal_ table. the potential problem might occur in such case that the table has the __index meta method which would have some side effects when you index into that table. in this special case where ZBS give the error message: >wxLua: Attempt to call a static class method using 'nil' on a 'wxANIHandler' type. > [C]: in function '__index' which I guess the table is just a proxy for a object of the class wxANIHandler. so you actually got no keys at all in that proxy table, thus the sorted keys are empty. the the code on line 60 > return a[i], t[a[i]] actually translated as > return nil, t[nil] thus the __index meta method of the proxy is called with a nil value, thus the error. A simple work aroud won't give errors as I tested. Just change that line as follows: > return a[i], a[i] and t[a[i]] which would index the table only if the key _does exists_. Good luck. |