"ulong" in SC source code: remove?

View: New views
3 Messages — Rating Filter:   Alert me  

"ulong" in SC source code: remove?

by Dan Stowell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi -

SC_Types.h defines (on Mac only) the "ulong" type:

    #ifdef SC_DARWIN
    typedef unsigned int ulong;
    #endif

This seems a bit odd to me, what's the point of defining it, and in
particular what's the point of giving it a confusing name? The type is
only used at *one* point in the code, in PyrMathOps.cpp:

    #ifdef SC_WIN32
              unsigned long ia = a->ui;
    #elif defined(SC_FREEBSD)
              u_long ia = a->ui;
    #else
              ulong ia = a->ui;
    #endif

This is in the doSpecialBinaryArithMsg() function, for applying
"opUnsignedShift". The value is loaded from "a->ui" which is of type
"int", and after the bit-shift is stored back there.

It's not exactly clear whether the programmer's intention here was for
"ulong" to be an unsigned int or an unsigned long. (The
Windows/FreeBSD switches were added much later than anything else so
they aren't a clue.) Looking at the other nearby code, I suspect the
intention is for unsigned long.

Any objections to removing the "ulong" definition from SC_Types.h and
removing the switch macro from inside "opUnsignedShift"? i.e.
simplifying the above to:

     unsigned long ia = a->ui;

This would be a pleasant simplification but would also remove a
conflict with the Qt framework ...which defines a ulong type to be
"unsigned long" :O

Dan

_______________________________________________
sc-dev mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/
search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/

Re: "ulong" in SC source code: remove?

by stefan kersten-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi dan,

On 24.06.2008, at 14:26, Dan Stowell wrote:
> SC_Types.h defines (on Mac only) the "ulong" type:
>
>     #ifdef SC_DARWIN
>     typedef unsigned int ulong;
>     #endif
[...]
> Any objections to removing the "ulong" definition from SC_Types.h and
> removing the switch macro from inside "opUnsignedShift"? i.e.
> simplifying the above to:
>
>      unsigned long ia = a->ui;
>

i think you can safely make that change.

<sk>



_______________________________________________
sc-dev mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/
search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/

Re: "ulong" in SC source code: remove?

by Dan Stowell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2008/6/25 stefan kersten <sk@...>:

> hi dan,
>
> On 24.06.2008, at 14:26, Dan Stowell wrote:
>>
>> SC_Types.h defines (on Mac only) the "ulong" type:
>>
>>    #ifdef SC_DARWIN
>>    typedef unsigned int ulong;
>>    #endif
>
> [...]
>>
>> Any objections to removing the "ulong" definition from SC_Types.h and
>> removing the switch macro from inside "opUnsignedShift"? i.e.
>> simplifying the above to:
>>
>>     unsigned long ia = a->ui;
>>
>
> i think you can safely make that change.

Aha, you've applied it in your recent patch - thanks

Dan

_______________________________________________
sc-dev mailing list


info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/
search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/