Hello Carsten,

"Carsten Neumann" <carsten_neum...@gmx.net> schrieb im 
Newsbeitrag news:4c52f58b.4090...@gmx.net...

> Johannes Brunen wrote:
>> inline
>> void ExceptionBinaryDataHandler::getValues(Real32 *value,
>>                                            UInt32  size ) throw 
>> (ReadError)
>> {
>> ...
>> }
>
> hm, these are for the reading direction, so the expectation is that
> values read by get(value, size * sizeof(Real32)) (which itself only
> deals with raw bytes) are in network byte order. Applying osgSwapMemory
> converts the values into proper floats for the host so the caller should
> be safe to treat them as such.
>
Yes, I see. Might it be worth to change the interface a little bit? 
Something like

inline
Real32* ExceptionBinaryDataHandler::getValues(UInt32 *value,
                                            UInt32  size ) throw (ReadError)
{
    get(value, size * sizeof(UInt32));

#if BYTE_ORDER == LITTLE_ENDIAN
    if(_networkOrder == true)
    {
        osgSwapMemy<sizeof(Real32)>(value, size);
    }
#endif
    return reintepret_cast<Real32*>(value);
}

but that is also ugly. Maybe its best just to document the difficulty of 
this issue, so that a potential user is aware of it.

>> inline
>> OSG::Real32 osghtonf(OSG::Real32 src)
>
> yes, those are still unsafe, but they only exist for backwards
> compatibility and I don't see a way to make them safe without breaking
> compatibility - just changing the return value to UInt32 does not help,
> because callers will assign that UInt32 to a Real32 and simply round all
> their floats to integers...
>
Understood...

> We can either remove these functions entirely (there should be no uses
> inside the OpenSG codebase) or make them only visible when
> OSGCOMPAT_ENABLE_DEPRECATED is defined.
>
1+
for the latter.

Best,
Johannes




------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to