[gst-devel] desired behaviour of "(int) ...." and deserialization functions
Thomas Vander Stichele
thomas at apestaart.org
Thu Jun 23 04:05:34 CEST 2005
Hi everyone,
after losing some time on trying to track down some gstvalue bugs, I
couldn't decide for myself what the (int) syntax and the deserialization
functions should be trying to achieve in corner cases.
>From 0.8, I was assuming that the "(int) 0xFF000000" syntax aims at
producing a number that would follow C's casting rules; ie, it would
return a negative int that happens to be machine-written as the given
bitmask, even though the bitmask is written, strictly speaking, as a
positive number that overflows an int, and hence gets interpreted as
negative.
(I'm conveniently ignoring the fact here that int isn't even required to
be 32 bits wide; it can be less; so on those arch's (int) 0xFF000000
would not work as a C statement the way you intend it to.)
The parsing of structure field values uses a deserialize to G_TYPE_INT
to implement interpreting strings specified as "(int) ...". This
function in GStreamer was also checking if the resulting 64-bit value
fits between MIN and MAX for the end type, which, if you stick to the
previous interpretation, is bogus - the 64 bit value might end up
getting interpreted as an overflowed value.
So, the questions:
a) is this interpretation of compiler-like casting what we want to
achieve ?
b) or should we say instead that the value you specify should fit
naturally into the data type ? In that case, rgb masks would need to be
specified as (uint), since (int) 0xFF000000 is outside the range of
G_TYPE_INT; or it could be specified as int64.
c) what do people feel should happen when you try to deserialize the
string "-1" as a G_TYPE_UINT ? Should it fail because it's out of range,
or should it be deserialized to the value you get when you do (guint)
-1 ?
Thanks
Thomas
Dave/Dina : future TV today ! - http://www.davedina.org/
<-*- thomas (dot) apestaart (dot) org -*->
"First lesson : you have to treat your kite like a woman."
"You mean, take her home and meet your mom, sir ?"
"No, get inside her five times a day and
take her to heaven and down again !"
<-*- thomas (at) apestaart (dot) org -*->
URGent, best radio on the net - 24/7 ! - http://urgent.fm/
More information about the gstreamer-devel
mailing list