On 2/7/07, Ryan Pusztai <[EMAIL PROTECTED]> wrote:
> I am having problems in Visual C++ 8.0 (2005) when I create an enum
> and then a class has a member variable of that type. Under MinGW it
> compiles fine.
>
> I use the %member syntax and it when it generates the Get/Set's for
> the variable it gives this error.
>
> 1>.\ctb.cpp(62) : error C2440: 'type cast' : cannot convert from
> 'double' to 'wxBaud'
> 1> Conversions between enumeration and floating point values
> are no longer allowed
>
> Here is the function:
> // %rename Baud %member wxBaud baud
> static int LUACALL wxLua_wxSerialPort_DCS_SetBaud(lua_State *L)
> {
> wxLuaState wxlState(L);
> // get the number value
> wxBaud val = (wxBaud)wxlState.GetNumberType(2); // <- This line fails.
> // get this
> wxSerialPort_DCS *self = (wxSerialPort_DCS
> *)wxlState.GetUserDataType(1, s_wxluatag_wxSerialPort_DCS);
> self->baud = val;
> // return the number of parameters
> return 0;
> }
>
> To make it compile I do something that looks terrible and probably is
> in bad form, I cast it to an 'int' before the cast to a wxBaud. I am
> sure this is not right, but any ideas how to get the generator to
> output the correct code?
>
> Here is the line when I make the changes:
> wxBaud val = (wxBaud)(int)wxlState.GetNumberType(2);
This is ok, numbers are double in lua so you always have to do
multiple casts. I wonder why wxBAUD is not treated as an enumeration
though? The function call should be
wxBaud val = (wxBaud)wxlState.GetEnumerationType(2);
Ahh... I have updated the file "genwxbind.lua" to handle this (line
2820) where we check to see if the value is a enumeration type
IsDataTypeEnum(...). Please try this new version to see if it works
since none of the bindings we currently have require this.
> Here is the interface file section:
> %enum wxBaud
> wxBAUD_150
> wxBAUD_300
> wxBAUD_600
> wxBAUD_1200
> wxBAUD_2400
> wxBAUD_4800
> wxBAUD_9600
> wxBAUD_19200
> wxBAUD_38400
> wxBAUD_57600
> wxBAUD_115200
> wxBAUD_230400
> wxBAUD_460800
> wxBAUD_921600
> %endenum
>
> %class %delete %noclassinfo %encapsulate wxSerialPort_DCS
> wxSerialPort_DCS()
> %rename Baud %member wxBaud baud
> %rename Parity %member wxParity parity
> %rename WordLen %member unsigned char wordlen
> %rename StopBits %member unsigned char stopbits
> %rename RtsCts %member bool rtscts
> %rename XonXoff %member bool xonxoff
>
> char* GetSettings(char* buf,size_t bufsize)
> %endclass
>
> The wxParity gives me the same problem as well.
This all looks good.
Let me know if the new genwxbind.lua works for you,
John Labenski
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
wxlua-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxlua-users