Monks;
I have just started dabbling with XS, and I've run into a
snag. I want to change the way I'm calling the XS routine
to use named parameters instead of positional parameters.
So instead of this:
calculate('V_MIN',4.5);
I can do this:
calculate(NAME => 'V_MIN',
THETA => 4.5);
I've looked at perlxs, but haven't found a way to do this.
I want to be anle to get the values from the passed-in hash
for keys "NAME" and "THETA". Here's my best quess thus far:
int
calculate(hash)
HV * hash;
CODE:
char * name;
float theta;
name = (char *)hv_fetch(hash,"NAME",4,0);
theta = hv_fetch(hash,"THETA",5,0);
printf("%s,%.1f\n",name,theta);
.
.
.
RETVAL = 1;
OUTPUT:
RETVAL
...but it won't even compile. I get errors:
ChemC.xs: In function `XS_ChemC_calculate':
ChemC.xs:122: parse error before `char'
ChemC.xs:125: `name' undeclared (first use in this function)
ChemC.xs:125: (Each undeclared identifier is reported only once
ChemC.xs:125: for each function it appears in.)
ChemC.xs:126: `theta' undeclared (first use in this function)
make: *** [ChemC.o] Error 1
Can anyone help?
Nelson