You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(60) |
Jul
(35) |
Aug
(32) |
Sep
(5) |
Oct
(5) |
Nov
(58) |
Dec
(34) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(114) |
Feb
(184) |
Mar
(153) |
Apr
(90) |
May
(153) |
Jun
(59) |
Jul
(24) |
Aug
(43) |
Sep
(17) |
Oct
(34) |
Nov
(11) |
Dec
(204) |
2007 |
Jan
(84) |
Feb
(119) |
Mar
(38) |
Apr
(28) |
May
(52) |
Jun
(105) |
Jul
(64) |
Aug
(67) |
Sep
(14) |
Oct
(3) |
Nov
(28) |
Dec
(55) |
2008 |
Jan
(228) |
Feb
(55) |
Mar
(30) |
Apr
(30) |
May
(15) |
Jun
(20) |
Jul
(12) |
Aug
(3) |
Sep
(13) |
Oct
(54) |
Nov
(35) |
Dec
(35) |
2009 |
Jan
(19) |
Feb
(20) |
Mar
(34) |
Apr
(4) |
May
(60) |
Jun
(25) |
Jul
(16) |
Aug
(51) |
Sep
(19) |
Oct
(62) |
Nov
(21) |
Dec
(12) |
2010 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
(12) |
May
(23) |
Jun
(13) |
Jul
(1) |
Aug
(40) |
Sep
(18) |
Oct
(21) |
Nov
(26) |
Dec
(34) |
2011 |
Jan
(17) |
Feb
(23) |
Mar
(1) |
Apr
(10) |
May
(1) |
Jun
(5) |
Jul
(1) |
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(43) |
2012 |
Jan
(5) |
Feb
(19) |
Mar
(6) |
Apr
(24) |
May
(39) |
Jun
(83) |
Jul
(29) |
Aug
(36) |
Sep
(64) |
Oct
(55) |
Nov
(12) |
Dec
(7) |
2013 |
Jan
(17) |
Feb
(10) |
Mar
(37) |
Apr
(27) |
May
(13) |
Jun
(9) |
Jul
(7) |
Aug
(61) |
Sep
(23) |
Oct
(23) |
Nov
(30) |
Dec
(16) |
2014 |
Jan
(23) |
Feb
(13) |
Mar
(9) |
Apr
(17) |
May
(2) |
Jun
(11) |
Jul
(2) |
Aug
|
Sep
(9) |
Oct
(24) |
Nov
(2) |
Dec
(14) |
2015 |
Jan
(6) |
Feb
(4) |
Mar
(17) |
Apr
|
May
(7) |
Jun
(3) |
Jul
|
Aug
|
Sep
(2) |
Oct
(21) |
Nov
(6) |
Dec
(2) |
2016 |
Jan
(4) |
Feb
(2) |
Mar
(7) |
Apr
(3) |
May
(11) |
Jun
(6) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
|
Mar
(6) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(4) |
Dec
|
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(8) |
Nov
|
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
1
|
2
|
3
|
4
|
5
|
6
|
7
(4) |
8
|
9
|
10
(4) |
11
|
12
|
13
|
14
|
15
|
16
|
17
|
18
(3) |
19
|
20
(3) |
21
(4) |
22
(9) |
23
|
24
(6) |
25
(4) |
26
(1) |
27
(7) |
28
(1) |
29
(4) |
30
(3) |
31
(1) |
|
From: John L. <jla...@gm...> - 2008-10-31 05:23:38
|
On Thu, Oct 30, 2008 at 3:09 PM, klaas.holwerda <ng...@kl...> wrote: > John Labenski wrote: >>> obj = iter3:op_mul() >> >> This should error out since op_mul() expects an argument. > > No it really works. And operator*() generates things different compared too > operator*( const a2dAffineMatrix& m ) > I guess this was just a lucky, genwxbind.lua doesn't check everything since we assume that the compiler will get the rest. >>> If possible adding an extra op_deref or something like that would be >>> nice. Added as op_deref(). >> Can you explain why you need to dereference an object pushed into Lua? >> wxLua uses pointers to all class objects, gets them as pointers in the >> bindings and simply puts a * in front if necessary. Unless I'm >> misunderstanding, the operator will convert the pointer to the object, >> but then immediately convert it back to a pointer to push it into Lua. > > First of all a2dCanvasObjectListIter is internal in my code a: > > typedef a2dCanvasObjectList::iterator a2dCanvasObjectListIter; > > and > > a2dCanvasObjectList is derived from a template instantiation of a smart > pointer list called a2dSmrtPtrList<a2dCanvasObject>, which contain > a2dCanvasObjectPtr, this last is a > > typedef a2dSmrtPtr<a2dCanvasObject> a2dCanvasObjectPtr; > > a2dSmrtPtrList is on it turn a normal STL list containing Smart Pointers. > > Now STL lists only work properly/best with complete objects in the list, > so not pointers. STL makes copies of the objects you put in the list, > and deletes them itself. > And that is why the STL list works very well with Smart Pointer, since ... Ok, I figured there was probably a good reason, but I just wanted to be sure that there wasn't some simple work-around that would be more Lua like. You may want to consider writing an %override function just to give the function a better name, like GetItem(), instead of the more cryptic op_deref(). Actually, the %rename tag should work if you decide to go this route. -John |
From: klaas.holwerda <ng...@kl...> - 2008-10-30 19:27:37
|
John Labenski wrote: >> obj = iter3:op_mul() > > This should error out since op_mul() expects an argument. No it really works. And operator*() generates things different compared too operator*( const a2dAffineMatrix& m ) Which is what i need, only the naming i don't like. > >> If possible adding an extra op_deref or something like that would be >> nice. > > Can you explain why you need to dereference an object pushed into Lua? > wxLua uses pointers to all class objects, gets them as pointers in the > bindings and simply puts a * in front if necessary. Unless I'm > misunderstanding, the operator will convert the pointer to the object, > but then immediately convert it back to a pointer to push it into Lua. First of all a2dCanvasObjectListIter is internal in my code a: typedef a2dCanvasObjectList::iterator a2dCanvasObjectListIter; and a2dCanvasObjectList is derived from a template instantiation of a smart pointer list called a2dSmrtPtrList<a2dCanvasObject>, which contain a2dCanvasObjectPtr, this last is a typedef a2dSmrtPtr<a2dCanvasObject> a2dCanvasObjectPtr; a2dSmrtPtrList is on it turn a normal STL list containing Smart Pointers. Now STL lists only work properly/best with complete objects in the list, so not pointers. STL makes copies of the objects you put in the list, and deletes them itself. And that is why the STL list works very well with Smart Pointer, since they are objects, which internal uses a pointer to the actual object, which has a refcounter. Here that is a a2dCanvasObject. So copies are cheap, just increment the refcounter. (Very similar to the typical wxWidgest refcounting, but not copy on write here). And deletion by STL, is calling a delete on the SmartPointer, which means only decrementing the refcount of the a2dCanvasObject, unless 0. Anyway, the STL list has an internal nested iterator class. So my a2dCanvasObjectList above, has a a2dCanvasObjectList::iterator, which i need to use to iterate the list. I can't derive that iterator, and nor redefine its methods. So in order to use it in wxLua, i need to use its methods as is. And to bad that is mostly operatorXXX. The iterator in STL always delivers references to the object it points too. And it does that with operator*(). I need to write: a2dCanvasObjectList::value_type obj = *iter; So in my case i get a a2dCanvasObjectPtr from it. And to get to the real object, i need to use the Get() method of my Smart Pointer a2dCanvasObjectPtr, which delivers me a a2dCanvasObject*. Here is what i have in the binding file. %class %delete %encapsulate %noclassinfo a2dCanvasObjectPtr a2dCanvasObject* Get() const %endclass %class %encapsulate %noclassinfo a2dCanvasObjectListIter a2dCanvasObjectListIter() %operator a2dCanvasObjectPtr operator*() const ....rest... %endclass %class %noclassinfo a2dCanvasObjectList, a2dSmrtPtrList a2dCanvasObjectList() a2dCanvasObjectListIter lbegin() a2dCanvasObjectListIter lend() ....rest... %endclass And here is how it is use it inside a lua script. iter3 = childs:lbegin() for i=1,childs:size() do obj = iter3:op_mul() nameOfobj = obj:Get():GetName() iter3:op_inc() end As you can see, op_mul() gives me a a2dCanvasObjectPtr, and i can even call the Get() method on it. Now if you say that is in fact not a a2dCanvasObjectPtr, but a a2dCanvasObjectPtr*, i believe you, and i see it in the C++ binding code :-) But that does not change the fact that in C++ the operator*() is really use to get to the STL iterator. Which is the only way possible. So some way or the other, currently op_mul() is correctly resulting in the operator*(), which i need to get to the STL iterator its objects. The a2dCanvasObjectPtr* returns = new a2dCanvasObjectPtr(*(*self)) is also interesting. First the iterator (*self) delivers a "a2dCanvasObjectPtr&" using *(*self). I can write it like this also: a2dCanvasObjectPtr* returns = new a2dCanvasObjectPtr(self->operator *()); That lua wants a a2dCanvasObjectPtr* is fine with me, it deletes it himself, and its just an extra refcount behind the scenes inside the a2dCanvasObject. Therefore it makes no differnce who deletes it first (Lua or the list). Down here the code that is generated for operator*(), which is different compared to what is generated for // %operator a2dAffineMatrix operator*( const a2dAffineMatrix& m ) const There is contains: a2dAffineMatrix* returns = new a2dAffineMatrix((*self)*(*m)); // %operator a2dCanvasObjectPtr operator*() const static int LUACALL wxLua_a2dCanvasObjectListIter_op_mul(lua_State *L) { // get this a2dCanvasObjectListIter * self = (a2dCanvasObjectListIter *)wxluaT_getuserdatatype(L, 1, wxluatype_a2dCanvasObjectListIter); // call op_mul // allocate a new object using the copy constructor a2dCanvasObjectPtr* returns = new a2dCanvasObjectPtr(*(*self)); // add the new object to the tracked memory list wxluaO_addgcobject(L, (void*)returns, new wxLua_wxObject_a2dCanvasObjectPtr((a2dCanvasObjectPtr*)returns)); // push the result datatype wxluaT_pushuserdatatype(L, returns, wxluatype_a2dCanvasObjectPtr); return 1; } So after all it looks this is really implemented, still i would like it to be called not op_mul but op_deref :-) Hope this helps to understand what is happening here, Regards, Klaas > |
From: John L. <jla...@gm...> - 2008-10-30 04:17:44
|
On Wed, Oct 29, 2008 at 5:49 PM, klaas.holwerda <ng...@kl...> wrote: > John Labenski wrote: >> I will look into the adding both pre and post increment/decrement >> operators however. >> > All the better. Should work now. op_inc/dec are for post inc/decrementing and op_preinc/dec are for preinc/decrementing. > And if its not asking to much, i would be great if you could distinguish > between *() and *( arg). > As i said, to dereference, i now need to use op_mul, which looks a bit > weird. > > obj = iter3:op_mul() This should error out since op_mul() expects an argument. > If possible adding an extra op_deref or something like that would be nice. Can you explain why you need to dereference an object pushed into Lua? wxLua uses pointers to all class objects, gets them as pointers in the bindings and simply puts a * in front if necessary. Unless I'm misunderstanding, the operator will convert the pointer to the object, but then immediately convert it back to a pointer to push it into Lua. > For the rest i think wxLua is just great. I wrapped most parts of > wxArt2D in a week are so. > Still lost of things to do, but what is already possible from the wxLua > scripts is cool! > When all is in place, i write a topic or two, to show what it is. Great. Regards, John |
From: John L. <jla...@gm...> - 2008-10-30 02:24:18
|
On Wed, Oct 29, 2008 at 6:49 PM, klaas.holwerda <ng...@kl...> wrote: > Hi John, > > It worked, but something went wrong, but it looks the solution is simple. > Operator+ and operator<< > > Need ".operator" like this: > > a2dBoundingBox* returns = &(*self).operator+(*arg1); > a2dIOHandlerXMLWrite* returns = &(*self).operator<<(wc); > This should work too, hopefully, I think and it doesn't require any exceptions. I've changed CVS to do this. a2dBoundingBox* returns = &((*self)+(*arg1)); a2dIOHandlerXMLWrite* returns = &((*self)<<(wc)); Regards, John |
From: klaas.holwerda <ng...@kl...> - 2008-10-29 22:49:46
|
Hi John, It worked, but something went wrong, but it looks the solution is simple. Operator+ and operator<< Need ".operator" like this: a2dBoundingBox* returns = &(*self).operator+(*arg1); a2dIOHandlerXMLWrite* returns = &(*self).operator<<(wc); After that is compiles again, Klaas Here two of the problems (others equal): // %operator a2dBoundingBox& operator+( a2dBoundingBox& ) static int LUACALL wxLua_a2dBoundingBox_op_add(lua_State *L) { // a2dBoundingBox arg1 a2dBoundingBox * arg1 = (a2dBoundingBox *)wxluaT_getuserdatatype(L, 2, wxluatype_a2dBoundingBox); // get this a2dBoundingBox * self = (a2dBoundingBox *)wxluaT_getuserdatatype(L, 1, wxluatype_a2dBoundingBox); // call op_add a2dBoundingBox* returns = &(*self).operator+(*arg1); // push the result datatype wxluaT_pushuserdatatype(L, returns, wxluatype_a2dBoundingBox); return 1; } // %operator a2dIOHandlerXMLWrite& operator<<(wchar_t wc) static int LUACALL wxLua_a2dIOHandlerXMLWrite_op_lshift11(lua_State *L) { // wchar_t wc wchar_t wc = (wchar_t)wxlua_getnumbertype(L, 2); // get this a2dIOHandlerXMLWrite * self = (a2dIOHandlerXMLWrite *)wxluaT_getuserdatatype(L, 1, wxluatype_a2dIOHandlerXMLWrite); // call op_lshift a2dIOHandlerXMLWrite* returns = &(*self).operator<<(wc); // push the result datatype wxluaT_pushuserdatatype(L, returns, wxluatype_a2dIOHandlerXMLWrite); return 1; } |
From: klaas.holwerda <ng...@kl...> - 2008-10-29 21:49:21
|
John Labenski wrote: > I will look into the adding both pre and post increment/decrement > operators however. > > All the better. And if its not asking to much, i would be great if you could distinguish between *() and *( arg). As i said, to dereference, i now need to use op_mul, which looks a bit weird. obj = iter3:op_mul() If possible adding an extra op_deref or something like that would be nice. For the rest i think wxLua is just great. I wrapped most parts of wxArt2D in a week are so. Still lost of things to do, but what is already possible from the wxLua scripts is cool! When all is in place, i write a topic or two, to show what it is. Thanks, Klaas |
From: John L. <jla...@gm...> - 2008-10-29 04:18:44
|
On Tue, Oct 28, 2008 at 4:45 PM, klaas.holwerda <ng...@kl...> wrote: > klaas.holwerda wrote: >> > It looks like this post inc solved itself, i out commented it in my > binding files, and things still work. > So it seems STL does not really need this operator after all. > I think i am getting a bit mixed up with all operator problems. > That's probably best. As I said, I don't think it's best to try to wrap absolutely everything since the generated binding code might end up being larger than the C++ classes themselves. I will look into the adding both pre and post increment/decrement operators however. -John |
From: John L. <jla...@gm...> - 2008-10-29 03:47:40
|
On Mon, Oct 27, 2008 at 3:57 PM, klaas.holwerda <ng...@kl...> wrote: > 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) Should be fixed now. I added this test to wxcore_gdi.cpp %operator wxVideoMode& operator[](size_t nIndex) -John |
From: klaas.holwerda <ng...@kl...> - 2008-10-28 20:45:34
|
klaas.holwerda wrote: > John Labenski wrote: > >> On Sat, Oct 25, 2008 at 1:05 PM, klaas.holwerda <ng...@kl...> >> wrote: >> >>> Hi John, >>> >>> %operator a2dCanvasObjectListIter& operator--(int) >>> >>> If you change it to generate this, down here, it will work: >>> >>> *returns = ((*self).operator++(arg1)); >>> >> I don't think that post-incrementing makes much sense for Lua. >> > > I would be very happy if you could still change it to become like the > above, since else i can't get it compiled for STL lists. Its iterator > does not accept the pre-incr only, or the other way around. > > It looks like this post inc solved itself, i out commented it in my binding files, and things still work. So it seems STL does not really need this operator after all. I think i am getting a bit mixed up with all operator problems. Klaas |
From: klaas.holwerda <ng...@kl...> - 2008-10-27 20:49:53
|
> By the way, have you found a link that exhaustively goes through the > C++ code for each operator? I can only find lists of the operators or > discussions about particular cases, but there's always some nuances > that aren't discussed. > Via: http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B I arrive in MSDN, with samples per operator, e.g. http://msdn.microsoft.com/en-us/library/fw63e3c3(VS.80).aspx I find it oke. Klaas |
From: klaas.holwerda <ng...@kl...> - 2008-10-27 19:57:59
|
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 |
From: klaas.holwerda <ng...@kl...> - 2008-10-27 19:25:52
|
John Labenski wrote: > On Sat, Oct 25, 2008 at 1:05 PM, klaas.holwerda <ng...@kl...> > wrote: >> Hi John, >> >> %operator a2dCanvasObjectListIter& operator--(int) >> >> If you change it to generate this, down here, it will work: >> >> *returns = ((*self).operator++(arg1)); > > I don't think that post-incrementing makes much sense for Lua. I would be very happy if you could still change it to become like the above, since else i can't get it compiled for STL lists. Its iterator does not accept the pre-incr only, or the other way around. I try to explain how i do it now, and it works, if i do the needed modification to the generated C++ wrapping, in order to fit the STL operators, which i can not change. First i already have a subclassed list based on STL and smart pointers. The members lbegin and lend i had to add to satisfy lua, it does not like function called end(). All the rest of the STL list functions and iterator functions, i do add in lua. class A2DCANVASDLLEXP a2dCanvasObjectList: public a2dSmrtPtrList<a2dCanvasObject> { public: a2dCanvasObjectList(); ~a2dCanvasObjectList(); iterator lbegin(); iterator lend(); .... all other members ... } Next i make a typedef for this list its iterator in order to have a non template iterator for wxLua. Understand that i do not subclass the iterator, and that this would make the trick impossible. The iterator above is a fixed subclass of the STL template list class, and i can not modify it or use another subclass of this iterator. That is why i need to use the operators of the base STL iterator, and i need to use them from wxLua directly also, or at least the code generated in C++ by the wrapper, must fit the STL iterator class directly. typedef a2dCanvasObjectList::iterator a2dCanvasObjectListIter; Now this is how the list is wrapped, notice the extra functions, which are not part of a2dCanvasObjectList directly, only of the lowest STL list base class. %include "canvas/include/objlist.h" %class %noclassinfo a2dCanvasObjectList, a2dSmrtPtrList a2dCanvasObjectList() a2dCanvasObjectListIter lbegin() a2dCanvasObjectListIter lend() bool empty() size_t size() a2dCanvasObject* front() a2dCanvasObject* back() void push_front( a2dCanvasObject* obj ) void pop_front() void push_back( a2dCanvasObject* obj ) void pop_back() %operator a2dCanvasObjectList& operator=( const a2dCanvasObjectList& other ) // REST here %endclass And now the wrapping code for the iterator. In principle i just add all function of STL list it's iterator. But first only the operator ones, because the are the key factor to succeed. %class %encapsulate %noclassinfo a2dCanvasObjectListIter a2dCanvasObjectListIter() %operator a2dCanvasObjectPtr operator*() const %operator a2dCanvasObjectListIter& operator=(const a2dCanvasObjectListIter& other) %operator bool operator ==( const a2dCanvasObjectListIter& iter ) const %operator bool operator !=( const a2dCanvasObjectListIter& iter ) const %operator a2dCanvasObjectListIter& operator++() %operator a2dCanvasObjectListIter& operator++( int ) %operator a2dCanvasObjectListIter& operator--() %operator a2dCanvasObjectListIter& operator--(int) %endclass And at last a working wxLua script with the above. iter3 = childs:lbegin() iter4 = childs:lend() if iter3:op_eq(iter4) then cmdh:Message("list is empty"..tostring(iter3)..tostring(iter4) ) else cmdh:Message("list has "..childs:size().." elements" ) end nameOfobj = "" iter3 = childs:lbegin() for i=1,childs:size() do obj = iter3:op_mul() nameOfobj = nameOfobj.."\n"..obj:Get():GetName() iter3:op_inc() end cmdh:Message("names are:\n"..nameOfobj) The only thing i do not like in this script is the name op_mul() to get a reference to the object in the list. A name like op_deref() would be much better. If we can get the operators to work (generate working code) for STL, in think that it is a nice way to use STL lists in lua. And the effort is very reasonable. But i need you to make it happen, because i can't make bananas of genwxbind.lua :-) Thanks, Klaas |
From: Klaas H. <db...@nl...> - 2008-10-27 09:49:11
|
John Labenski wrote: > On Sat, Oct 25, 2008 at 1:05 PM, klaas.holwerda <ng...@kl...> wrote: >> Hi John, >> >> %operator a2dCanvasObjectListIter& operator--(int) >> >> If you change it to generate this, down here, it will work: >> >> *returns = ((*self).operator++(arg1)); > > I don't think that post-incrementing makes much sense for Lua. I would be very happy if you could still change it to become like the above, since else i can't get it compiled for STL lists. Its iterator does not accept the pre-incr only, or the other way around. I try to explain how i do it now, and it works, if i do the needed modification to the generated C++ wrapping, in order to fit the STL operators, which i can not change. First i already have a subclassed list based on STL and smart pointers. The members lbegin and lend i had to add to satisfy lua, it does not like function called end(). All the rest of the STL list functions and iterator functions, i do add in lua. class A2DCANVASDLLEXP a2dCanvasObjectList: public a2dSmrtPtrList<a2dCanvasObject> { public: a2dCanvasObjectList(); ~a2dCanvasObjectList(); iterator lbegin(); iterator lend(); .... all other members ... } Next i make a typedef for this list its iterator in order to have a non template iterator for wxLua. Understand that i do not subclass the iterator, and that this would make the trick impossible. The iterator above is a fixed subclass of the STL template list class, and i can not modify it or use another subclass of this iterator. That is why i need to use the operators of the base STL iterator, and i need to use them from wxLua directly also, or at least the code generated in C++ by the wrapper, must fit the STL iterator class directly. typedef a2dCanvasObjectList::iterator a2dCanvasObjectListIter; Now this is how the list is wrapped, notice the extra functions, which are not part of a2dCanvasObjectList directly, only of the lowest STL list base class. %include "canvas/include/objlist.h" %class %noclassinfo a2dCanvasObjectList, a2dSmrtPtrList a2dCanvasObjectList() a2dCanvasObjectListIter lbegin() a2dCanvasObjectListIter lend() bool empty() size_t size() a2dCanvasObject* front() a2dCanvasObject* back() void push_front( a2dCanvasObject* obj ) void pop_front() void push_back( a2dCanvasObject* obj ) void pop_back() %operator a2dCanvasObjectList& operator=( const a2dCanvasObjectList& other ) // REST here %endclass And now the wrapping code for the iterator. In principle i just add all function of STL list it's iterator. But first only the operator ones, because the are the key factor to succeed. %class %encapsulate %noclassinfo a2dCanvasObjectListIter a2dCanvasObjectListIter() %operator a2dCanvasObjectPtr operator*() const %operator a2dCanvasObjectListIter& operator=(const a2dCanvasObjectListIter& other) %operator bool operator ==( const a2dCanvasObjectListIter& iter ) const %operator bool operator !=( const a2dCanvasObjectListIter& iter ) const %operator a2dCanvasObjectListIter& operator++() %operator a2dCanvasObjectListIter& operator++( int ) %operator a2dCanvasObjectListIter& operator--() %operator a2dCanvasObjectListIter& operator--(int) %endclass And at last a working wxLua script with the above. iter3 = childs:lbegin() iter4 = childs:lend() if iter3:op_eq(iter4) then cmdh:Message("list is empty"..tostring(iter3)..tostring(iter4) ) else cmdh:Message("list has "..childs:size().." elements" ) end nameOfobj = "" iter3 = childs:lbegin() for i=1,childs:size() do obj = iter3:op_mul() nameOfobj = nameOfobj.."\n"..obj:Get():GetName() iter3:op_inc() end cmdh:Message("names are:\n"..nameOfobj) The only thing i do not like in this script is the name op_mul() to get a reference to the object in the list. A name like op_deref() would be much better. If we can get the operators to work (generate working code) for STL, in think that it is a nice way to use STL lists in lua. And the effort is very reasonable. But i need you to make it happen, because i can't make bananas of genwxbind.lua :-) Thanks, Klaas -- Unclassified ------------------------------------------------------------------------------------------------------------ Disclaimer: If you are not the intended recipient of this email, please notify the sender and delete it. Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden. Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s). Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578. ------------------------------------------------------------------------------------------------------------ |
From: John L. <jla...@gm...> - 2008-10-27 04:49:22
|
On Sat, Oct 25, 2008 at 1:05 PM, klaas.holwerda <ng...@kl...> wrote: > Hi John, > > %operator a2dCanvasObjectListIter& operator--(int) > > If you change it to generate this, down here, it will work: > > *returns = ((*self).operator++(arg1)); I don't think that post-incrementing makes much sense for Lua. I see that you can overload it to mean something different than pre-incrementing, but since it will have to be converted to a function it can never be make to actually increment after the expression is evaluated without resorting to using a debug hook to check to see if we're on the next line. This would lead to an unacceptable performance penalty for such a small thing. By the way, have you found a link that exhaustively goes through the C++ code for each operator? I can only find lists of the operators or discussions about particular cases, but there's always some nuances that aren't discussed. -John ps. I've updated Lua to 5.1.4, but the changes are very small. |
From: John L. <jla...@gm...> - 2008-10-27 01:11:22
|
On Sat, Oct 25, 2008 at 7:49 AM, klaas.holwerda <ng...@kl...> wrote: > John Labenski wrote: >> I think the latter makes more sense since you're writing that the == >> operator should be applied between the class object instance and "b". >> I've never understood why operators are often written outside the >> class. >> > It is for cases like this, where the first argument is not a matrix. > > friend bool operator== ( double a, const a2dAffineMatrix& b ); > > But i think i don't use that type, so i switch to the short notation. That is probably best since, we can't add functions to the number so we'd have to invent a whole new set of operators for the left hand side operators. -John |
From: John L. <jla...@gm...> - 2008-10-27 00:51:51
|
On Sun, Oct 26, 2008 at 10:52 AM, klaas.holwerda <ng...@kl...> wrote: > Hi John, > > The index operator almost works. > The line: > a2dLayerInfo* returns = new a2dLayerInfo((*self)[(indx)]); > should become this: > a2dLayerInfo* returns = new a2dLayerInfo(*(*self)[(indx)]); > > The copy constructor needs a reference, while my inde operator return a > pointer. > If it would return a reference it would be oke. So maybe in other cases > it might be oke. > > Here the binding code: > > %include "canvas/include/layerinf.h" > %class %noclassinfo a2dLayers, a2dCanvasObject > a2dLayers() > a2dLayers( const a2dLayers& other, a2dObject::CloneOptions options = > a2dObject::clone_deep ) > %operator a2dLayerInfo* operator[] (int indx) > %operator const a2dLayerInfo* operator[] (int indx) const > 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. -John |
From: klaas.holwerda <ng...@kl...> - 2008-10-26 14:52:50
|
Hi John, The index operator almost works. The line: a2dLayerInfo* returns = new a2dLayerInfo((*self)[(indx)]); should become this: a2dLayerInfo* returns = new a2dLayerInfo(*(*self)[(indx)]); The copy constructor needs a reference, while my inde operator return a pointer. If it would return a reference it would be oke. So maybe in other cases it might be oke. Here the binding code: %include "canvas/include/layerinf.h" %class %noclassinfo a2dLayers, a2dCanvasObject a2dLayers() a2dLayers( const a2dLayers& other, a2dObject::CloneOptions options = a2dObject::clone_deep ) %operator a2dLayerInfo* operator[] (int indx) %operator const a2dLayerInfo* operator[] (int indx) const Here the (already corrected by me) result: static int LUACALL wxLua_a2dLayers_op_index(lua_State *L) { // int indx int indx = (int)wxlua_getnumbertype(L, 2); // get this a2dLayers * self = (a2dLayers *)wxluaT_getuserdatatype(L, 1, wxluatype_a2dLayers); // call op_index // allocate a new object using the copy constructor a2dLayerInfo* returns = new a2dLayerInfo(*(*self)[(indx)]); // add the new object to the tracked memory list wxluaO_addgcobject(L, (a2dLayerInfo*)returns); // push the result datatype wxluaT_pushuserdatatype(L, returns, wxluatype_a2dLayerInfo); return 1; } |
From: klaas.holwerda <ng...@kl...> - 2008-10-25 17:06:04
|
Hi John, %operator a2dCanvasObjectListIter& operator--(int) If you change it to generate this, down here, it will work: *returns = ((*self).operator++(arg1)); Found in your interesting link http://www.acm.org/crossroads/xrds2-1/ovp.html static wxLuaArgType s_wxluatypeArray_wxLua_a2dCanvasObjectListIter_op_inc1[] = { &wxluatype_a2dCanvasObjectListIter, &wxluatype_TNUMBER, NULL }; static int LUACALL wxLua_a2dCanvasObjectListIter_op_inc1(lua_State *L); // static wxLuaBindCFunc s_wxluafunc_wxLua_a2dCanvasObjectListIter_op_inc1[1] = {{ wxLua_a2dCanvasObjectListIter_op_inc1, WXLUAMETHOD_METHOD, 2, 2, s_wxluatypeArray_wxLua_a2dCanvasObjectListIter_op_inc1 }}; // %operator a2dCanvasObjectListIter& operator++( int ) static int LUACALL wxLua_a2dCanvasObjectListIter_op_inc1(lua_State *L) { // int arg1 int arg1 = (int)wxlua_getnumbertype(L, 2); // get this a2dCanvasObjectListIter * self = (a2dCanvasObjectListIter *)wxluaT_getuserdatatype(L, 1, wxluatype_a2dCanvasObjectListIter); // call op_inc a2dCanvasObjectListIter* returns = self; *returns = ((*self).operator++(arg1)); // push the result datatype wxluaT_pushuserdatatype(L, returns, wxluatype_a2dCanvasObjectListIter); return 1; } |
From: klaas.holwerda <ng...@kl...> - 2008-10-25 11:54:52
|
John Labenski wrote: > I think the latter makes more sense since you're writing that the == > operator should be applied between the class object instance and "b". > I've never understood why operators are often written outside the > class. > It is for cases like this, where the first argument is not a matrix. friend bool operator== ( double a, const a2dAffineMatrix& b ); But i think i don't use that type, so i switch to the short notation. Still what you made for the two argument case, was really close to a solution. Just changing it too this in the line giving the error in C++ bool returns = *a == *b; made it work, rest could stay the same. > ----------------- > > -John > > ps. I am adding the [] operator as op_index() if you need to use that. > Oke thanks, Klaas |
From: John L. <jla...@gm...> - 2008-10-25 04:49:10
|
On Fri, Oct 24, 2008 at 1:29 PM, klaas.holwerda <ng...@kl...> wrote: > John Labenski wrote: >> By the way, I'm a little hesitant to do too much work on the bindings >> since wxWidgets 3.0 uses doxygen and some sort of stripped down >> headers for their docs. In order to keep the bindings updated I'll >> probably want to switch to that format and have to completely rewrite >> the binder. >> > Yes i have bin thinking about that for some days now :-) > It looks to me that the headers are still valid headers and they are > parsed by doxygen. > So the tags can still be found. > But doxygen can generate XML, and that might be a much better way to > automatically generate *.i files. > From what i understand you are now parsing the headers yourself with > parse_ctags.lua. > With XML from doxygen and a pullparser (mine for instance) in lua, i > think it is easier to parse than header files directly. > So produce the *.i files from the XML. > > I assume you want to preserve the *.i files as is?? No, I'd probably go directly from C/C++ headers through doxygen to XML to the Lua binding files. BUT, this is all speculation as I haven't tried it yet. It may also be enough to simply use the stripped down wxWidgets C++ doc headers since they have the full class declarations that should work on all platforms as opposed to the real headers can be quite different between platforms for some classes. In any case, I don't think I'll have too much time in the near future to do too much. -John |
From: John L. <jla...@gm...> - 2008-10-25 04:10:31
|
On Fri, Oct 24, 2008 at 12:54 PM, klaas.holwerda <ng...@kl...> wrote: > John Labenski wrote: >> I don't know why, didn't it generate something like this? >> >> %operator double operator-( int col, int row ) >> >> double returns = ((*self)-(col, row)); >> >> Anyway, it should be fixed in CVS. >> > I updated, and now get errors. > > http://www.velocityreviews.com/forums/t291623-why-overload-operator-as-friend-.html > > So the friend keyword is needed in C++. And there or two ways to > write/reach the same thing with operator==. > Operators with 2 args, need the friend word to reach the private members. > In principle it is a function which is not part of the class, but > declared inside it. > In any case if you generate the next (after the word WRONG), all is fine. > > %class %noclassinfo %encapsulate a2dAffineMatrix > > %operator bool operator== ( const a2dAffineMatrix& a, const > a2dAffineMatrix& b ) > > Should become: > > static int LUACALL wxLua_a2dAffineMatrix_op_eq(lua_State *L) > { > // const a2dAffineMatrix b > const a2dAffineMatrix * b = (const a2dAffineMatrix > *)wxluaT_getuserdatatype(L, 3, wxluatype_a2dAffineMatrix); > // const a2dAffineMatrix a > const a2dAffineMatrix * a = (const a2dAffineMatrix > *)wxluaT_getuserdatatype(L, 2, wxluatype_a2dAffineMatrix); > // get this > a2dAffineMatrix * self = (a2dAffineMatrix > *)wxluaT_getuserdatatype(L, 1, wxluatype_a2dAffineMatrix); > // call op_eq > // WRONG bool returns = ((*self)(*a, *b)); > bool returns = *a == *b; > // push the result flag > lua_pushboolean(L, returns); > > return 1; > } > >From the www.velocityreviews.com link you have above, I think the friend is "needed" since you are writing a member operator function with the syntax meant for being outside the class declaration. The compiler you have treats it correctly, but I'm afraid that this exception would be too much to try to handle in genwxbind.lua and it would be better to use the standard syntax. If you look at the generated C++ binding code above, you'll see that three a2dAffineMatrix are retrieved from Lua, but only 2 are needed for the == operator. This is because class member functions expect that the self, the class itself, is always acted on. You have this in your class http://www.wxart2d.org/wxart2dDoxygen/html/afmatrix_8h-source.html friend bool operator== ( const a2dAffineMatrix& a, const a2dAffineMatrix& b ); However if you have the operator function as a member function to the class you only need to write this which is what you did for the *= operator and others: class a2dAffineMatrix { ... bool operator== ( const a2dAffineMatrix& b ); } I think the latter makes more sense since you're writing that the == operator should be applied between the class object instance and "b". I've never understood why operators are often written outside the class. ------------------ There is a short discussion halfway down this page; search for: Complex operator+ (const Complex& a, Complex& b); http://www.acm.org/crossroads/xrds2-1/ovp.html ------------------ -John ps. I am adding the [] operator as op_index() if you need to use that. |
From: klaas.holwerda <ng...@kl...> - 2008-10-24 17:29:39
|
John Labenski wrote: > By the way, I'm a little hesitant to do too much work on the bindings > since wxWidgets 3.0 uses doxygen and some sort of stripped down > headers for their docs. In order to keep the bindings updated I'll > probably want to switch to that format and have to completely rewrite > the binder. > Yes i have bin thinking about that for some days now :-) It looks to me that the headers are still valid headers and they are parsed by doxygen. So the tags can still be found. But doxygen can generate XML, and that might be a much better way to automatically generate *.i files. From what i understand you are now parsing the headers yourself with parse_ctags.lua. With XML from doxygen and a pullparser (mine for instance) in lua, i think it is easier to parse than header files directly. So produce the *.i files from the XML. I assume you want to preserve the *.i files as is?? Klaas |
From: klaas.holwerda <ng...@kl...> - 2008-10-24 16:54:39
|
John Labenski wrote: > I don't know why, didn't it generate something like this? > > %operator double operator-( int col, int row ) > > double returns = ((*self)-(col, row)); > > Anyway, it should be fixed in CVS. > I updated, and now get errors. http://www.velocityreviews.com/forums/t291623-why-overload-operator-as-friend-.html So the friend keyword is needed in C++. And there or two ways to write/reach the same thing with operator==. Operators with 2 args, need the friend word to reach the private members. In principle it is a function which is not part of the class, but declared inside it. In any case if you generate the next (after the word WRONG), all is fine. %class %noclassinfo %encapsulate a2dAffineMatrix %operator bool operator== ( const a2dAffineMatrix& a, const a2dAffineMatrix& b ) Should become: static int LUACALL wxLua_a2dAffineMatrix_op_eq(lua_State *L) { // const a2dAffineMatrix b const a2dAffineMatrix * b = (const a2dAffineMatrix *)wxluaT_getuserdatatype(L, 3, wxluatype_a2dAffineMatrix); // const a2dAffineMatrix a const a2dAffineMatrix * a = (const a2dAffineMatrix *)wxluaT_getuserdatatype(L, 2, wxluatype_a2dAffineMatrix); // get this a2dAffineMatrix * self = (a2dAffineMatrix *)wxluaT_getuserdatatype(L, 1, wxluatype_a2dAffineMatrix); // call op_eq // WRONG bool returns = ((*self)(*a, *b)); bool returns = *a == *b; // push the result flag lua_pushboolean(L, returns); return 1; } |
From: John L. <jla...@gm...> - 2008-10-24 05:04:13
|
On Wed, Oct 22, 2008 at 3:33 PM, klaas.holwerda <ng...@kl...> wrote: > John, > > You told that templates are not possible, and i understand that. > But i still need to find a solutions, since all my lists are STL/STD > template based. > Like my main a2dList class is a pure std::list, with some extra members > that return an iterator. > All the other list are derived from that or they are template > instantiations of it. > > template<class T> > class a2dlist: public std::list< T, std::allocator<T> > > > Has a member like: > > typename a2dlist<T>::iterator item(size_t index) {.....} I would make separate bindings for each type T that you expect to have. First, give them a normal name that the binder can handle. typedef a2dlist<int> a2dlist_int; typedef a2dlist<double> a2dlist_double; Then add all the functions that might be useful in Lua, you might not have to add all of them to simplify your life and also make the generated code smaller. For example, maybe only have == and not !=, etc. Finally add the a2dlist_int::iterator class. There's an example of a member class: wxFileType::MessageParameters. > The smart pointer list is also a2dlist / std::list based. > > template<class T> > class a2dSmrtPtrList: public a2dlist< a2dSmrtPtr< T > > > > And of those i have many instantiations like this: > > class a2dVertexList : public a2dSmrtPtrList< a2dLineSegment > > > class a2dCanvasObjectList: public a2dSmrtPtrList<a2dCanvasObject> Again, you just have to define all of these. > So do you have any idea how i best approach this? > Should i for instance best write lua code to generate the template > instantiation in *.i lines code?? Probably just copy and paste. Once you get one working, you just have to change the parameters, boring, but it shouldn't take too long. > Its the iterators that worry me the most :-( What i saw in wxLua looks > like its based on wxList "old fashion" use, where wxNode is not typed. > But my iterator are typed i am afraid. > Is there a sample demo-ing wxList usage?? I think it is weird to use > lists in lua, should be a table. But my data in the document/C++, is all > stored in the type of lists is showed above, and i like to iterate > through them. Maybe i should just make a GetFirst() GetNext() kind of > iteration inside list classes ?? I left the wxList in wxLua since I didn't want to create a table duplicating what may be a very large list. > I am very bad in writing lua code, but this will change :-). But for the > moment this makes it a bit difficult to see through all this :-(. I tried to keep all the C++ side very much like C++ to reuse the wxWidgets docs and I think this makes sense for your stuff too. -John |
From: John L. <jla...@gm...> - 2008-10-24 04:39:28
|
On Wed, Oct 22, 2008 at 3:06 PM, klaas.holwerda <ng...@kl...> wrote: > John, > > I hope you don't mind i keep reporting issues, it just to improve wxLua. > Most of them i can just change to make them work, but maybe you can > improve the binding generator. > If you prefer i report them in separate threads, let me know. > No this is fine, but remind me if I accidentally skip over one. By the way, I'm a little hesitant to do too much work on the bindings since wxWidgets 3.0 uses doxygen and some sort of stripped down headers for their docs. In order to keep the bindings updated I'll probably want to switch to that format and have to completely rewrite the binder. > ===================================== > The default values like this are refused. > > virtual void BlitBuffer( wxDC* dc, wxRect rect, const wxPoint& bufferpos > = wxPoint( 0, 0 ) ) The parser probably gags on the extra (). I think a reasonable hack would be to have something like this as a replacement. #define wxZeroPoint wxPoint(0,0) > ===================================== > > I have no idea, why this member of a class is a problem. > > void SetAlpha( unsigned char* alphadata ) > > 1>..\..\..\..\wxArt2D\modules\luawraps\src\artbase.cpp(7533) : error > C2664: 'void a2dImageRGBA::SetAlpha(unsigned char)' : cannot convert > parameter 1 from 'wxCharBuffer' to 'unsigned char' Hopefully fixed, I added code to cast the wxCharBuffer (unsigned char*). However, it does have to be "const unsigned char*" since you cannot take ownership of the string from Lua. I think wxImage wrappers have an override that shows how to set the image data from a Lua string. > ======================================== > > These are memebers of a class, i just removed friend, and it is > compiling, did not actually use it in lua code. > > %operator friend bool operator==(const a2dFont& a, const > a2dFont& b) > %operator friend bool operator!=(const a2dFont& a, const > a2dFont& b) > > I made it: > > %operator bool operator==(const a2dFont& a, const a2dFont& b) > %operator bool operator!=(const a2dFont& a, const a2dFont& b) Probably ok to just remove the friend word as you did. What does it mean to have a friend function like this in C++? > ======================================= > > It seems that a default value like &something is not accepted. > > a2dComEvent( a2dPropObject* sender, const a2dPropertyId& id, const > wxEventType* eventid = &a2dComEvent::sm_changedProperty ) > a2dComEvent( wxObject* sender, a2dNamedProperty* property, const > wxEventType* id = &sm_changedProperty, bool ownProp = false ) > > > ERROR: Expected Parameter Default Value, got Tag='&'. File: > 'C:/data/art2d/wxArt2D/modules/luawraps/src/general.i':(line 435) > ' a2dComEvent( a2dPropObject* sender, const a2dPropertyId& id, > const wxEventType* eventid = &a2dComEvent::sm_changedProperty )' > ERROR: Expected Parameter Default Value, got Tag='&'. File: > 'C:/data/art2d/wxArt2D/modules/luawraps/src/general.i':(line 436) > ' a2dComEvent( wxObject* sender, a2dNamedProperty* property, > const wxEventType* id = &sm_changedProperty, bool ownProp = false )' > I'll look into this. > ======================================= > > I don't know why, but a reference to wxUint32 are any other type does > give a problem in C++. > > %class %noclassinfo a2dUint32Property, a2dNamedProperty > a2dUint32Property() > wxUint32& GetValueRef() > > > 1> There is no context in which this conversion is possible > 1>..\..\..\..\wxArt2D\modules\luawraps\src\general.cpp(5161) : error > C2440: 'initializing' : cannot convert from 'wxUint32 *' to 'wxUint32' > > > static int LUACALL wxLua_a2dUint32Property_GetValueRef(lua_State *L) > { > // get this > a2dUint32Property * self = (a2dUint32Property > *)wxluaT_getuserdatatype(L, 1, wxluatype_a2dUint32Property); > // call GetValueRef > wxUint32 returns = &self->GetValueRef(); > // push the result number > lua_pushnumber(L, returns); > > return 1; > } You can't get & references like this in Lua since it only has double valued numbers. But, I've fixed the bindings to not put the extra & before self->GetValueRef(). -John |