From: John L. <jla...@gm...> - 2006-04-19 03:28:21
|
I've added the %operator tag to the bindings, just for wxPoint for now. Since lua has only a limited subset of operators (no +=3D, ++, etc) I've just made them into functions, which even if we wanted to override the lua operators in the metatable we'd still use the functions. They take the same semantics as C++ class operator functions, just prepend %operator to it. operators["=3D"] =3D "op_assign" operators["=3D=3D"] =3D "op_eq" operators["!=3D"] =3D "op_ne" operators["<"] =3D "op_lt" operators[">"] =3D "op_gt" operators["<=3D"] =3D "op_le" operators[">=3D"] =3D "op_ge" operators["|"] =3D "op_or" operators["&"] =3D "op_and" operators["||"] =3D "op_lor" operators["&&"] =3D "op_land" operators["!"] =3D "op_not" operators["++"] =3D "op_inc" operators["--"] =3D "op_dec" operators["+"] =3D "op_add" operators["-"] =3D "op_sub" operators["*"] =3D "op_mul" operators["/"] =3D "op_div" operators["+=3D"] =3D "op_add_eq" operators["-=3D"] =3D "op_sub_eq" operators["*=3D"] =3D "op_mul_eq" operators["/=3D"] =3D "op_div_sub" operators["%=3D"] =3D "op_mod_sub" operators["&=3D"] =3D "op_and_eq" operators["|=3D"] =3D "op_or_eq" operators["^=3D"] =3D "op_xor_eq" For example: a =3D wx.wxPoint(1,2) b =3D wx.wxPoint(1,2) print(a:op_eq(b)) b =3D wx.wxPoint(1,3) print(a:op_eq(b)) c =3D wx.wxSize(3,3) d =3D b:op_add_eq(c) print(d:GetX(), d:GetY()) true false 4, 6 Regards, John Labenski |