This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: LibXSLT #2
Feed Title: Michael Lucas-Smith
Feed URL: http://www.michaellucassmith.com/site.atom
Feed Description: Smalltalk and my misinterpretations of life
To continue on from where I left off. I've published a new version of LibXSLT to the public store, this is version 1.1, which includes proper error reporting and real character encoding handling based on the output from the stylesheet object itself.
All of this work was harder than it should have been, for a couple of reasons. The main one is that C really stinks. Yes, you heard me - in Smalltalk I never have to care about the encoding of strings. They are encoded in an encoding, end of story. Objects are objects. In C, I have to care about the encoding - which means when I'm interfacing to C I have to care about the encodings.
*shrug* That aside, the real pain was in DLLCC - typecasting of all things!
Since it refused to let me use a struct* as a return type of a procedure, nor would it let me make a typedef for the struct*, I had to resort to using typecasting. To type cast in DLLCC, one has to perform the following sort of dance:
That's a mouthful consider C's answer to this is newVariable = (myStructureType*) currentVariable.
To make a long story short - all is possible, but it's not as straight forward as it should be. This is Smalltalk after all, the language of flexibility and descriptiveness, yet I'm bending over backwards to achieve a relatively simple job.
Perhaps the reason there are so few C library wrappers in VW is not because those libraries "would have to be xplatform" (which many Linux ones are these days!) but because using DLLCC is a complete pain in the ...
Now, back to complaining about C. Because of C the LibXSLT package has memory leaks. Enough said - if you can fix it for me, then thanks go to you!