Another tough session today made the above possible. Perl5.8.0 complained about some readonly values that I tried set somewhere within my XS code. It took a while to find the delinquent. 5.005_03 and 5.6.1 did not have these objections.

In the last moment I decided to use Test::More instead of Test. That made a few rewrites necessary, too.

Also, h2xs obviously screwed up when I created the extension skeleton some months ago. This part was funny actually: When I tested all the constants from mplib.h, Perl failed to export UTF16...but only on this one. UTF16BE and all the other encodings worked ok. I located the error somewhere here:

It turned out that the first if-condition was messed up. It should have been:

if (3 + 1 >= len ) {

I have no explanation for this failure but I find it somehow amusing that even a machine can come up with an incorrect calculation of a string length. This puts my sometimes scaringly silly errors into the right perspective, I think.;-)

<rant>

Who actually came up with this insane constant handling in XS code? A constant name is cut into strings of variable length and then control is delegated to another suitable constant-function that exclusively deals with constants of a particular prefix. If that is a performance tweak then it is silly since any constant is only retrieved once and after that compiled into a subroutine by AUTOLOAD.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Without JavaScript enabled, you might want to
use the classic discussion system instead. If you login, you can remember this preference.

Please Log In to Continue

Who actually came up with this insane constant handling in XS code? A constant name is cut into strings of variable length and then control is delegated to another suitable constant-function that exclusively deals with constants of a particular prefix. If that is a performance tweak then it is silly since any constant is only retrieved once and after that compiled into a subroutine by AUTOLOAD.

Fair comment.

What you saw with the miscalculated if condition looks like the bug I found in the constant genera

Quite relieved to see that I am not the only one with these woes so I don't have to feel stupid.:-)

This makes it very hard to add new constants later on, if later versions of the module you're wrapping add new constants. It also means that you're stuck with whatever lousy autogenerated switch code was the style at the time of the h2xs you ran.

That was exactly my second thought after fixing constant_U(): What happens if the next release of mplib has additional constants? I don't want to re-run h2xs (and