Hello. I read Alexander Kolbasov's excellent blog on the pitfalls
of Perl XS with enums. I used the following xs_test.h and got
Alexander's h2xs fixes to work the way the blog described.

// xs_test.h
typedef enum mdNameNameHints {
NameFull=1,
NameInverse=2,
NameGovernmentInverse=4,
NameMixedFirst=8,
NameMixedLast=16} xst_NameHints_t;

  I am now trying to call a C function by passing in one of these enum
values in perl 5.8.8. This is the perl script:

use mdNamePerl;
my $g;
#Create
mdName Object$g=&mdNamePerl::mdNameCreate();
&mdNamePerl::mdNameSetPrimaryNameHint($g,NameFull);

mdNamePerl is a Perl XS application which glues a C/C++ application
together with Perl.

The C prototype I am trying to access is :
MDAPI int __stdcall mdNameSetPrimaryNameHint(mdName, enum
mdNameNameHints);

In the typemap, I have mapped enum mdNameNameHints to a T_IV(integer)
but when I run this perl program I get the error : Argument "NameFull"
isn't numeric in entersub at test.pl line 66, <CONFIG> chunk 39.

Does  anyone  have any ideas how I can pass the enumeration NameFull
to the perl subroutine call correctly given that I have
implemented(hopefully correctly) the h2xs fixes in Alexander's
blog ,"Pitfals of the Perl XS or what to do when things do not work as
advertised"? Thank you very much.

Reply via email to