Allswellthatendswell
2008-09-30 22:58:35 UTC
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 try to use the C++ enumerations in our test.pl program we get run
time errors. We were wondering whether we should write our own perl xs
module or whether we should use swig -c++ perl. Here is the perl test
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 or should we hand code a Perl XS script to accomplish
this task? 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------------------------------------
/*
* 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();
};
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 try to use the C++ enumerations in our test.pl program we get run
time errors. We were wondering whether we should write our own perl xs
module or whether we should use swig -c++ perl. Here is the perl test
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 or should we hand code a Perl XS script to accomplish
this task? 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------------------------------------
/*
* 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();
};