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;
my $matchcode;
my $record;
my $vfirst;
my $vlast;
my $vaddress1;
my $vaddress2;
my $vcity;
my $vstate;
my $vzip;
my $vapartment;
my $vSSN1;
my $vSSN2;
my $vSSN3;
my $result;
my $vkey;
my $vdupegroup;
my $vcount; 
my $ventry;
$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");

mdMatchupTestc::mdMUReadWrite_InitializeDataFiles($readwrite); 
print( "BuildNumber:   " .mdMatchupTestc::mdMUReadWrite_GetBuildNumber($readwrite). "\n");
   
mdMatchupTestc::mdMUReadWrite_SetKeyFile($readwrite,"C:\\MatchupAPI\\Distribution\\Keys.Dbf");
$matchcode = mdMatchupTestc::new_mdMUMatchcode();
mdMatchupTestc::mdMUMatchcode_SetPathToMatchUpFiles($matchcode,"C:\\MatchupAPI\\Distribution");
mdMatchupTestc::mdMUMatchcode_InitializeDataFiles($matchcode);
if (mdMatchupTestc::mdMUMatchcode_FindMatchcode($matchcode,"Address, Last Name and First Name and SSN Fuzzy") != 0){ 
    mdMatchupTestc::mdMUReadWrite_SetMatchcodeObject($readwrite,$matchcode);
   print( "matchcode found\n" );
}
mdMatchupTestc::mdMUReadWrite_Initialize($readwrite);
mdMatchupTestc::mdMUReadWrite_ClearMappings($readwrite);
mdMatchupTestc::mdMUReadWrite_AddMapping($readwrite,18);
mdMatchupTestc::mdMUReadWrite_AddMapping($readwrite,6);
mdMatchupTestc::mdMUReadWrite_AddMapping($readwrite,3);
mdMatchupTestc::mdMUReadWrite_AddMapping($readwrite,30);
mdMatchupTestc::mdMUReadWrite_AddMapping($readwrite,30);
mdMatchupTestc::mdMUReadWrite_AddMapping($readwrite,30);
mdMatchupTestc::mdMUReadWrite_AddMapping($readwrite,14);
mdMatchupTestc::mdMUReadWrite_AddMapping($readwrite,14);
mdMatchupTestc::mdMUReadWrite_AddMapping($readwrite,14);
  
mdMatchupTestc::mdMUReadWrite_SetGroupSorting($readwrite,1);
open (TESTSDF, "C:\\MatchupAPI\\Distribution\\DemoDatabases\\Demo74.Sdf");
while ($record = <TESTSDF>) {
       $vfirst = substr($record, 0,15);
       $vfirst =~ s/\s+$//;  
       $vlast = substr($record,15,15);
       $vlast =~ s/\s+$//;  
       $vaddress1 = substr($record,30,25);
       $vaddress1 =~ s/\s+$//;  
       $vaddress2 = substr($record,55,25);
       $vaddress2 =~ s/\s+$//;  
       $vcity = substr($record,80,15);
       $vcity =~ s/\s+$//;  
       $vstate = substr($record,95,15);
       $vstate =~ s/\s+$//;  
       $vzip = substr($record,110,10);
       $vzip =~ s/\s+$//;  
       $vapartment = substr($record,120,10);
       $vapartment =~ s/\s+$//;  
       $vSSN1 =~ s/\s+$//;  
       $vSSN2 = substr($record,142,12);
       $vSSN2 =~ s/\s+$//;  
       $vSSN3 = substr($record,154,12);
       $vSSN3 =~ s/\s+$//;  
       mdMatchupTestc::mdMUReadWrite_ClearFields($readwrite);
       mdMatchupTestc::mdMUReadWrite_AddField($readwrite,$vzip);
       mdMatchupTestc::mdMUReadWrite_AddField($readwrite,$vlast);
       mdMatchupTestc::mdMUReadWrite_AddField($readwrite,$vfirst);
       mdMatchupTestc::mdMUReadWrite_AddField($readwrite,$vSSN1);
       mdMatchupTestc::mdMUReadWrite_AddField($readwrite,$vSSN2);
       mdMatchupTestc::mdMUReadWrite_AddField($readwrite,$vSSN3);
       mdMatchupTestc::mdMUReadWrite_AddField($readwrite,$vaddress1);
       mdMatchupTestc::mdMUReadWrite_AddField($readwrite,$vaddress2);
       mdMatchupTestc::mdMUReadWrite_AddField($readwrite,$vapartment);
       mdMatchupTestc::mdMUReadWrite_BuildKey($readwrite);
       mdMatchupTestc::mdMUReadWrite_WriteRecord($readwrite);
}
mdMatchupTestc::mdMUReadWrite_Process($readwrite);
while (mdMatchupTestc::mdMUReadWrite_ReadRecord($readwrite)!=0){
    $result = mdMatchupTestc::mdMUReadWrite_GetError($readwrite);
    $vkey = mdMatchupTestc::mdMUReadWrite_GetKey($readwrite);
    $vdupegroup = mdMatchupTestc::mdMUReadWrite_GetDupeGroup($readwrite);
    $vcount = mdMatchupTestc::mdMUReadWrite_GetCount($readwrite); 
    $ventry = mdMatchupTestc::mdMUReadWrite_GetEntry($readwrite); 
    if (($result & 16) != 0){
       printf("* %s %4d %2d %8x\n",$vkey,$vdupegroup,$vcount,$result);
    }
    elsif (($result & 32) != 0){
      printf("  # %d %s %4d %4d %8x\n",$ventry,$vkey,$vdupegroup,$vcount,$result);
    }
    else{
      printf("  1 %s %4d %2d %8x\n",$vkey,$vdupegroup,$vcount,$result);
    }
}

we get the Perl interprepter message : Bareword "mdMatchupc::mdMUReadWrite_NoError" not allowed while "strict subs" in use at test.pl line 31. Is there a correct way to use packages with C++ enumerations in our perl program? Thank you.
 
 
    P.S. When we look at the mdMatchup.pm, we see the following code :
 
############# 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;
*LicenseExpired = *mdMatchupTestc::mdMUReadWrite_LicenseExpired;
*DatabaseExpired = *mdMatchupTestc::mdMUReadWrite_DatabaseExpired;
*MatchcodeNotSpecified = *mdMatchupTestc::mdMUReadWrite_MatchcodeNotSpecified;
*MatchcodeNotFound = *mdMatchupTestc::mdMUReadWrite_MatchcodeNotFound;
*InvalidMatchcode = *mdMatchupTestc::mdMUReadWrite_InvalidMatchcode;
sub new {
    my $pkg = shift;
    my $self = mdMatchupTestc::new_mdMUReadWrite(@_);
    bless $self, $pkg if defined($self);
}
sub DESTROY {
    return unless $_[0]->isa('HASH');
    my $self = tied(%{$_[0]});
    return unless defined $self;
    delete $ITERATORS{$self};
    if (exists $OWNER{$self}) {
        mdMatchupTestc::delete_mdMUReadWrite($self);
        delete $OWNER{$self};
    }
}
*SetPathToMatchUpFiles = *mdMatchupTestc::mdMUReadWrite_SetPathToMatchUpFiles;
*SetMatchcodeName = *mdMatchupTestc::mdMUReadWrite_SetMatchcodeName;
*SetMatchcodeObject = *mdMatchupTestc::mdMUReadWrite_SetMatchcodeObject;

 
 
--------------------------------------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 mdMUMatchcode {
// friend class cDedupe;
//protected:
public:
struct mdMUMatchcode_ *I;
private:
mdMUMatchcode(mdMUMatchcode &X);
mdMUMatchcode&
operator=(mdMUMatchcode &X);
public:
enum ProgramStatus {
NoError=0,
ConfigFile=1,
UnknownMatchcodeString=2,
Unknown=6
};

enum MatchcodeMappingType {
Prefix = 1,
First = 2,
Middle = 3,
Last = 4,
Suffix = 5,
Gender = 6,
FirstNickname = 7,
MiddleNickname = 8,
Title = 9,
Company = 10,
CompanyAcronym = 11,
Address = 12,
City = 13,
State = 14,
Zip9 = 15,
Zip5 = 16,
Zip4 = 17,
Country = 18,
CanadianPC = 19,
UKCity = 20,
UKCounty = 21,
UKPC = 22,
Phone = 23,
EMail = 24,
CreditCard = 25,
General = 26,
Custom = 27,
Address1 = 28,
Address2 = 29,
Address3 = 30
};
mdMUMatchcode();
~mdMUMatchcode(
void);
/* Setup methods */
void SetPathToMatchUpFiles(const char *Path);
enum ProgramStatus InitializeDataFiles();
const char *GetInitializeErrorString();

/* Matchcode database query functions */
int FindMatchcode(const char *Matchcode);
// int FindMatchcodeNext();
const char *GetMatchcodeName();

/* Matchcode item query functions */
int GetMatchcodeItemCount();
mdMUMatchcodeComponent *GetMatchcodeItem(
int Item);

/* Matchcode mapping query functions */
int GetMappingItemCount();
enum MatchcodeMappingType GetMappingItemType(int Pos);
const char *GetMappingItemLabel(int Pos);
 
/*Matchcode editing functions */
bool DeleteMatchcodeItem(int Pos);

/* Matchcode saving functions */
void Save(void);
void SaveToFile(const char* Path);
};

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,
MatchcodeNotSpecified=4,
MatchcodeNotFound=5,
InvalidMatchcode=6,
KeyFile=7,
Unknown=8
};
enum MatchcodeMapping {
Prefix=1,
//0,
Gender=2, //1,
First=3, //2,
MixedFirst=4, //3,
Middle=5, //4,
Last=6, //5,
MixedLast=7, //6
Suffix=8, //7
FullName=9, //8
InverseName=10, //9
GovernmentInverseName=11, //10
Title=12, //11
Company=13, //12
Address=14, //13
City=15, //14
State=16, //15
Zip9=17, //16
Zip5=18, //17
Zip4=19, //18
CityStZip=20, //19
Country=21, //20
CanadianPostalCode=22, //21
UKCity=23, //22
UKCounty=24, //23
UKPostcode=25, //24
UKCityCountyPC=26, //25
Phone=27, //26
EMail=28, //27
CreditCard=29, //28
General=30 //29
};
enum StatusCode {
HasDupe=0x0010,
IsDupe=0x0020,
Combo1Match=0x80000000,
Combo2Match=0x40000000,
Combo3Match=0x20000000,
Combo4Match=0x10000000,
Combo5Match=0x08000000,
Combo6Match=0x04000000,
Combo7Match=0x02000000,
Combo8Match=0x01000000,
Combo9Match=0x00800000,
Combo10Match=0x00400000,
Combo11Match=0x00200000,
Combo12Match=0x00100000,
Combo13Match=0x00080000,
Combo14Match=0x00040000,
Combo15Match=0x00020000,
Combo16Match=0x00010000,
DemoMode=0x00008000
};

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*);

const char *GetBuildNumber();
const char *GetDatabaseDate();
const char *GetDatabaseExpirationDate();
const char *GetLicenseExpirationDate();
mdMUMatchcode *GetMatchcodeObject();
/* Field mapping functions */
void ClearMappings();
int AddMapping(MatchcodeMapping Mapping);

/* Key building functions */
void ClearFields();
void AddField(const char *Field);
void BuildKey();
/* Record writing functions */
void SetKey(const char *Key);
void SetSizeUserInfo(int szUserInfo);
void SetUserInfo(void* UserInfo_);
void WriteRecord();

/* Processing functions */
void Process();

/* Record reading funtions */
int ReadRecord();
const char *GetKey();
void* GetUserInfo();
long GetDupeGroup();
enum StatusCode GetStatusCode();
int GetCount();
int GetEntry();
long GetError();

/* Processing options */
void SetGroupSorting(bool GroupSorting);
};
}




Stay up to date on your PC, the Web, and your mobile phone with Windows Live. See Now