[Kde-java] Another weird cast to uchar: QUuid

Richard Dale kde-java@kde.org
Fri, 28 Feb 2003 10:45:39 +0000


On Friday 28 February 2003 8:05 am, Marco Ladermann wrote:
> as with QSizePolicy I found another cast to (uchar) from (char*). This time
> in class QUuid.
>
> Java:
> private native void newQUuid( int l, short w1, short w2, String b1, String
> b2, String b3, String b4, String b5, String b6, String b7, String b8);
> public QUuid( int l, short w1, short w2, String b1, String b2, String b3,
> String b4, String b5, String b6, String b7, String b8) {
> 		newQUuid( l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8);
> 	}
>
> and in the C++ implementation (QUuid.cpp) of newQUuid are these casts to
> uchar in the constructor call to the bridge:
>
> new QUuidJBridge((uint) l, (ushort) w1, (ushort) w2,
> (uchar) QtSupport::toCharString(env, b1, &_qstring_b1),
> (uchar) QtSupport::toCharString(env, b2, &_qstring_b2),
> (uchar) QtSupport::toCharString(env, b3, &_qstring_b3),
> (uchar) QtSupport::toCharString(env, b4, &_qstring_b4),
> (uchar) QtSupport::toCharString(env, b5, &_qstring_b5),
> (uchar) QtSupport::toCharString(env, b6, &_qstring_b6),
> (uchar) QtSupport::toCharString(env, b7, &_qstring_b7),
> (uchar) QtSupport::toCharString(env, b8, &_qstring_b8))
I've found the bug in the kalyptus code generation that causes this - I'd 
forgotten to escape the '*' in the perl reg exp to match 'unsigned char', so 
it was matching zero or more spaces instead of the '*' and classifying uchars 
as a java String type. But the only headers the uchar occurs in are 
qsizepolicy.h, quuid.h, and qstring.h. QStrings don't get converted to java, 
and I can't find QUuid in the Qt documentation - I don't think it's a public 
class and so it should probably be removed from the bindings.

With other unsigned types, it just knocks the 'unsigned' part off to get the 
java type, rather than promote it to a wider java signed type:
unsigned short -> short
unsigned int -> int
unsigned long -> long

Maybe that should be changed - I don't know if it would cause any problems in 
practice.

-- Richard