CSS and KJS Parser and Qt/e 2: Final summary

Stefan Eilers stefan.eilers at basyskom.de
Thu Feb 2 13:41:47 GMT 2006


Hi!

The endianess problem seems to be fixed. Several patches are uploaded into the 
svn at trunk/kdenox. All these patches are just Qt/e 2 related and will not 
be integrated in the Qt/e 3 release.  Thus, this information may not very 
interesting for most of you.. ;)

Just to remember the problem:
QChar within Qt/e 2 uses to uchars to store a unicode char. Ich you do 
something like 

ushort unicode;
QChar* qchar = (QChar*) &unicode;

you will get a wrong qchar if you use Qt 2 on a little endian machine.  It 
works well (but still is incorrect code) with Qt 3 as it stores the unicode 
value internally as ushort, too.

This problem caused to confuse the CSS-Parser as it gets the CSS-Strings as 
big-endian values instead little endian. Thus, it parses nothing at all.
Event the KJS parser is affected, as it uses the class UString which is 
working with ushort and uses QChar internally.

The solution was to reimplement the central string class DOMStringImpl and 
cover the big endian/little endian conversion. Internally it stores a QChar* 
and a ushort* representation of the string and returns the version which is 
requested. All operations (like split etc.) are applied on both 
representations, thus they stay consistent. By using this class and removing 
of all direct casts, the problem was solved. 
The KJS-Parser provides a very good encapsulation of the string 
implementation, thus it was very simple to fix this problem by changing the 
UString class in the file "khtml/ecma/kjs_binding.cpp". In this case, I just 
had to use the DOMString intenally as it already provides the infrastructure 
to convert the endianess stuff.

As a final summary, there is one thing left to say:

Never expose the internal implementation to the public. Neither use public 
member variables, nor this QConstString class or do casts like the one above. 
All of them make it impossible to change the internal implementation without 
real pain.

Thanks to Luciano for his assistance. :)

Bye, Stefan
-- 
Stefan Eilers
Software Engineer

basysKom GmbH
Robert-Bosch-Str. 7 | 64293 Darmstadt | Germany
Tel: +49 6151 3969-962 | Fax: -736 | Mobile: +49 170 4213459 |
Jabber: eilers at jabber.org
stefan.eilers at basyskom.de | www.basyskom.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20060202/3d79a23d/attachment.sig>
-------------- next part --------------
_______________________________________________
konq-e mailing list
konq-e at kde.org
https://mail.kde.org/mailman/listinfo/konq-e


More information about the kfm-devel mailing list