MiltonKeynes-pm Digest, Vol 37, Issue 1

Frank Chang frankchang91 at gmail.com
Wed Oct 1 13:06:47 PDT 2008


   Dear Mailing List members, I fixed the SWIG Perl C++ enumeration problem
today. I will now hand code the Perl XS module and compare the CPU times to
see if the hand coded Perl XS module is faster than the SWIG wrapper. Thank
you.

On Wed, Oct 1, 2008 at 5:00 PM, <miltonkeynes-pm-request at pm.org> wrote:

> Send MiltonKeynes-pm mailing list submissions to
>        miltonkeynes-pm at pm.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://mail.pm.org/mailman/listinfo/miltonkeynes-pm
> or, via email, send a message with subject or body 'help' to
>        miltonkeynes-pm-request at pm.org
>
> You can reach the person managing the list at
>        miltonkeynes-pm-owner at pm.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of MiltonKeynes-pm digest..."
>
>
> Today's Topics:
>
>   1. Swig Perl C++ enumeration issue (Frank Chang)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 30 Sep 2008 18:33:04 -0200
> From: "Frank Chang" <frankchang91 at gmail.com>
> Subject: Swig Perl C++ enumeration issue
> To: miltonkeynes-pm at pm.org
> Message-ID:
>        <568ca38c0809301333r29ba713cx9eef103cbb24684f at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
>      Hi, We are trying to use SWIG 1.3.36 with perl  5.8.8 and the Visual
> Studio C++ 2005 compiler. The header file used in our mdMatchup.i file is
> shown below. In our mdMatchup.i , we are using the module mdMatchupTest. We
> ran swig -c++ -perl mdMatchup.i and obtained mdMatchup.pm and
> mdMatchup_wrap.cxx.
>       We read that SWIG Perl can handle C++ enumerations. But, when we use
> the enumerations in our test.pl program:
>
> #!perl.exe -w
> use strict;
> use mdMatchupTest;
>
> my $readwrite;
> $readwrite = mdMatchupTestc::new_mdMUReadWrite();
>
> mdMatchupTestc::mdMUReadWrite_SetLicenseString($readwrite,"LL58JH2Y");
>
> mdMatchupTestc::mdMUReadWrite_SetPathToMatchUpFiles($readwrite,"C:\\MatchupAPI\\Distribution");
> if (mdMatchupTestc::mdMUReadWrite_InitializeDataFiles($readwrite) !=
> $mdMatchupc::mdMUReadWrite_NoError ){
>  print( "Failed to Initialize mdMatchupTestc::mdMUReadWrite ",
>  mdMatchupTestc::mdMUReadWrite_GetInitializeErrorString($readwrite). "\n");
> }
>
> we get the Perl interprepter message : Name
> "mdMatchupc::mdMUReadWrite_NoError" used only once: possible typo at
> test.pl
> line 10
> Use of uninitialized value in numeric ne (!=) at test.pl line 10.
>  When we examine the mdMatchup.pm,  we see that
> mdMatchupc::mdMUReadWrite_NoError looks like a string. An excerpt of
> mdMatchup.pm is shown below.
>  Is there a correct way to use SWIG packages with C++ enumerations in our
> perl program? Thank you.
>
> -------------------------------------mdMatchup.pm---------------------------------
> ############# Class : mdMatchupTest::mdMUReadWrite ##############
> package mdMatchupTest::mdMUReadWrite;
> use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
> @ISA = qw( mdMatchupTest );
> %OWNER = ();
> %ITERATORS = ();
> *NoError = *mdMatchupTestc::mdMUReadWrite_NoError;
> *ConfigFile = *mdMatchupTestc::mdMUReadWrite_ConfigFile;
>
> -------------------------------------mdMatchup.h------------------------------------
> #if !defined(MDMATCHUP_H)
> #define MDMATCHUP_H
> #if !defined(MDAPI)
> #if defined(_WIN32) || defined(_WIN64)
> #define MDAPI __declspec(dllimport)
> #else
> #define MDAPI
> #define __stdcall
> #endif
> #endif
> /*
> * C++ version of interface
> */
>
> class MDAPI mdMUReadWrite
> {
> protected:
> struct mdMUReadWrite_ *I;
> private: /* disable implicit constructor and assignment */
> mdMUReadWrite(mdMUReadWrite &X);
> mdMUReadWrite& operator=(mdMUReadWrite &X);
> public:
> enum ProgramStatus {
> NoError=0,
> ConfigFile=1,
> LicenseExpired=2,
> DatabaseExpired=3
> };
>
> mdMUReadWrite();
> ~mdMUReadWrite();
>
> /* Setup methods */
> void SetPathToMatchUpFiles(const char *Path);
> void SetMatchcodeName(const char *MatchcodeName);
> void SetMatchcodeObject(mdMUMatchcode *Matchcode);
> void SetKeyFile(const char *KeyFile);
> enum ProgramStatus InitializeDataFiles();
> const char *GetInitializeErrorString();
> void Initialize(void);
> int SetLicenseString(const char*);
> }
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.pm.org/pipermail/miltonkeynes-pm/attachments/20080930/293d10a9/attachment-0001.html
> >
>
> ------------------------------
>
> _______________________________________________
> MiltonKeynes-pm mailing list
> MiltonKeynes-pm at pm.org
> http://mail.pm.org/mailman/listinfo/miltonkeynes-pm
>
>
> End of MiltonKeynes-pm Digest, Vol 37, Issue 1
> **********************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/miltonkeynes-pm/attachments/20081001/74bdf13d/attachment.html>


More information about the MiltonKeynes-pm mailing list