John Labenski wrote:
> I changed it so that it does not create a "new" instance of the
> returned pointer and try to run the copy constructor on it, but rather
> it just pushes the pointer to the object into Lua. This means that the
> object must exist for the life of any Lua calls to it.
>
> Hope it works now.
>   
This looks to work now, at least it compiles, will test it in lua soon.
But it only works when a pointer is returned, not for a reference.
The next is still wrong (actually looking at the generated code, i think 
you made a mistake somehow).
Here what is generated, when returning a reference, and after a 
corrected version.

//     %operator a2dVpathSegment& operator[](size_t index) const
static int LUACALL wxLua_a2dVectorPath_op_index(lua_State *L)
{
    // size_t index
    size_t index = (size_t)wxlua_getnumbertype(L, 2);
    // get this
    a2dVectorPath * self = (a2dVectorPath *)wxluaT_getuserdatatype(L, 1, 
wxluatype_a2dVectorPath);
    // call op_index
    a2dVpathSegment* returns = self;
    *returns = ((*self)[(index)]);
    // push the result datatype
    wxluaT_pushuserdatatype(L, returns, wxluatype_a2dVpathSegment);

    return 1;
}

static int LUACALL wxLua_a2dVectorPath_op_index(lua_State *L)
{
    // size_t index
    size_t index = (size_t)wxlua_getnumbertype(L, 2);
    // get this
    a2dVectorPath * self = (a2dVectorPath *)wxluaT_getuserdatatype(L, 1, 
wxluatype_a2dVectorPath);
    // call op_index
    a2dVpathSegment* returns = &((*self)[(index)]);
    // push the result datatype
    wxluaT_pushuserdatatype(L, returns, wxluatype_a2dVpathSegment);

    return 1;
}

Thanks,

Klaas


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to