On 17 September 2012 18:29, Michael Kirsch <
mkirs...@gmail.com> wrote:
> On Monday, September 17, 2012 11:25:04 AM UTC-4, Michal Kottman wrote:
>>
>> This is, in essence, what the current lqt does :) Although it is in
>> dire need of re-write. There is a lot of know-how in the current
>> codebase (how to handle virtual methods, how to handle custom Qt
>> signals/slots, enums, custom getters and setters for public members,
>> ...). Should you want to continue with your project and need to ask
>> anything, I will try to answer how it is implemented currently in lqt.
>
>
> Currently it doesn't handle reimplementing virtual methods from Lua at all
> (that's something I only plan in doing if it gets working), same with
> fields/properties. I also haven't thought about signals/slots because I
> think that can be done later, and I don't know of a place to learn how they
> work. But I do have two big problems right now:
>
> First, how to know if a class is copyable?
In Qt, this is relatively simple - everything is copyable, EXCEPT
those classes that have *Private members.... Or at least this is what
I remember. I did quite a lot of bashing on C++ to get the behavior I
wanted of lqt. The relevant code is around
https://github.com/mkottman/lqt/blob/master/generator/classes.lua#L327
- simply stated, for those situations that do not have a copy
constructor explicitly stated, and are eligible for copy construction,
I will generate a copy constructor so that relevant code can be
generated.
> Second, many functions in Qt have different overloads for different number
> types in C++. Lua has only one number type. So whatever overload is checked
> first will be used, which can cause loss of precision. What would be a good
> way to fix that?
This was handled by Mauro Iazzi before me - the relevant code is here
-
https://github.com/mkottman/lqt/blob/master/generator/classes.lua#L648
. Essentially the typesystem is a map of types C++ -> Lua, where the
basic numeric types are mapped in
https://github.com/mkottman/lqt/blob/master/generator/types.lua#L84 .
Each type has associated "defect", where defect(char) > defect(short)
> defect(int) > defect(long). When multiple overloaded methods have
the same Lua signature, the defects are counted, and the one with
smallest defect is chosen. For example, method(char), method(int) and
method(double) all have Lua signature method(number), so only
method(double) is chosen because of smallest defect (0).