jfroebe has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I need a verification that either there is a typo or I've gone whacko in the head.... ;-)

In Win32 Perl Programming: The Standard Extensions by Dave Roth (ISBN 1-57870-067-1), on pages 401-404 the author names the functions as ExtensionFunctionName. However, in the calling script, the calls are simply FunctionName. I've looked through a few Win32::* modules and it appears that the Extension part of the function name is simply an over sight by the author.

Calling perl code:

if( $Count = Win32::Test::GetFileSizes( 'c:\temp\*.*', $Data ) ) { .... }

Author's C code:

XS( ExtensionGetFileSizes ) { .... }

Shouldn't the C code be:

XS( GetFileSizes ) { .... }

Am I correct in this?

Jason L. Froebe

Team Sybase member

No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Replies are listed 'Best First'.
Re: Extension Functions on Win32
by BrowserUk (Patriarch) on Mar 23, 2006 at 03:51 UTC

    Could it be that the author uses the XS PREFIX keyword in his code? From perlxs

    The PREFIX Keyword

    The PREFIX keyword designates prefixes which should be removed from the Perl function names. If the C function is rpcb_gettime() and the PREFIX value is rpcb_ then Perl will see this function as gettime().

    This keyword should follow the PACKAGE keyword when used. If PACKAGE is not used then PREFIX should follow the MODULE keyword.

    MODULE = RPC PREFIX = rpc_ MODULE = RPC PACKAGE = RPCB PREFIX = rpcb_

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Thanks!

      After my brain had been rebooted (sleep), I was able to find the mapping the author does:

      newXS( "Win32::Test::GetFileSizes", ExtensionGetFileSizes, pszFile);

      I would have wished the author explained that little detail but oh well.. thanks for the info on PREFIX! :)

      Jason L. Froebe

      Team Sybase member

      No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1