On Fri, Feb 20, 2009 at 9:26 AM, Andre Arpin <ar...@kingston.net> wrote:
> John Labenski <jlaben...@...> writes:
>
>> The C++ function has this signature:
>> wxStyledTextCtrl::SetMarginMask(int margin, int mask)
>>
>> Even if wxLua handed it with an unsigned int it would be turned right
>> back into -33554432 inside the wxStyledTextCtrl function. I see that
>> editor.wx.lua makes a call to SetMarginMask(2,
>> wxstc.wxSTC_MASK_FOLDERS) and it works fine since if you type "do \n
>> end" into wxlua.exe, Scintilla draws the code folding icons.
>>
>> So just to be sure, what is the problem? Do you not see the code folding
> icons?
>
> Not it does not, it sets it to 0x80000000 which is the folder icon ONLY.
> It should be set 0xfe000000 so the other icons will also be set.

I compiled wxLua with VisualC 6 in debug mode, (32 bit compiler on
32bit WinXP, but on Intel core 2 duo), put a break in
wxLua_wxStyledTextCtrl_SetMarginMask so I could display "int mask".

The debugger shows mask = -33554432 for this code
int mask = (int)wxlua_getnumbertype(L, 3);

and the debugger shows mask = 4261412864 for this code
unsigned int mask = (unsigned int)wxlua_getnumbertype(L, 3);

TRY THIS! (it, of course, works for me)
unsigned long mask = (unsigned long)wxlua_getnumbertype(L, 3);

I never get mask = 2147483648 (0x80000000).

> The icon folder will display because it is controlled by the top bit the other
> icon will not be displayed.
>
> try
>    editor:MarkerDefine(wxstc.wxSTC_MARKNUM_FOLDEROPENMID,
> wxstc.wxSTC_MARK_CIRCLEMINUSCONNECTED, wx.wxBLUE, wx.wxRED)
>
> This should give you a Blue Circle with a Red + for sub folder but it will not
> display.

I put the above code after "grey:delete()" and the
editor:MarkerDefine(...) code in editor.wx.lua and I get the blue
circle with no changes to wxLua.

This is very strange to me. Lets try to figure this out.

What processor?
What OS?
What compiler are you using?

stick these lines into wxLua_wxStyledTextCtrl_SetMarginMask(). It
might just be that your sizeof(double) is not 8 bytes? My sizes in
VC6, Intel core 2 duo, Win XP, are the comments to the right.

int int_size = sizeof(int); // 4
int long_size = sizeof(long); // 4
int float_size = sizeof(float); // 4
int double_size = sizeof(double); // 8

Hopefully this will clear it up.

> ---------------------------------
> The following code will also work and is somewhat simpler
>
> static int LUACALL wxLua_wxStyledTextCtrl_SetMarginMask(lua_State *L)
> {
>    double doubleMask = wxlua_getnumbertype(L, 3);
>        int mask = (doubleMask > INT_MAX) ? (int)(doubleMask + INT_MIN)|
> INT_MIN : (int)doubleMask;
>
> ---------------
>
> I expected that (int)((unsigned int)doubleMask) would work but it does not
> ((unsigned int)doubleMask) is 0x8000000 I whould have expected 0xfe000000
> since
> unsigned int xxx = 0xfe000000; sets xxx to 0xfe000000
> all rather mysterious.

This code is fishy, you subtract off INT_MIN, the topmost bit, from
the double and then OR it back on.

This page below talks about double <--> int conversion. The executive
summary is that doubles can hold 2^52 bits and ints are only 2^32.
http://lua-users.org/wiki/FloatingPoint

Your compiler is mangling 0xFE000000 into 0x80000000 which means that
it is keeping only the topmost bit of 0xFE to get 0x80.

Lemme know about your processor, compiler, etc above.

-John

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to