Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

ethan (3163)

ethan
  reversethis-{ed. ... rap.nov.olissat}

Being a 25-year old chap living in the western-most town of Germany. Stuying communication and information science and being a huge fan of XS-related things.

Journal of ethan (3163)

Monday December 02, 2002
07:35 AM

MP3::Mplib 0.01

[ #9230 ]

        The uploaded file

                MP3-Mplib-0.01.tar.gz

        has entered CPAN as

            file: $CPAN/authors/id/V/VP/VPARSEVAL/MP3-Mplib-0.01.tar.gz
            size: 80543 bytes
              md5: 7acf4fa07a13648ecbc9e0509a27b6da

        No action is required on your part
        Request entered by: VPARSEVAL (Tassilo von Parseval)
        Request entered on: Mon, 02 Dec 2002 12:15:17 GMT
        Request completed: Mon, 02 Dec 2002 12:15:57 GMT

                Virtually Yours,
                Id: paused,v 1.81 2002/08/02 11:34:24 k Exp k

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:

        static double
        constant_UTF1(char *name, int len, int arg)
        {
                if (4 + 1 >= len ) {
                errno = EINVAL;
                return 0;
                }
                switch (name[4 + 1]) {
                case '\0':
                if (strEQ(name + 4, "6")) { /* UTF1 removed */
        #ifdef UTF16
                        return UTF16;
        #else
                        goto not_there;
        #endif
                }
                case 'B':
                if (strEQ(name + 4, "6BE")) { /* UTF1 removed */
        #ifdef UTF16BE
                        return UTF16BE;
        #else
                        goto not_there;
        #endif

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.

</rant>

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • 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