Following the "how do I make an object" recipe in the Cookbook, I'm
running into these errors; I wonder if it's because my struct's typedef is
in the included .h file and thus not available for typemapping?
FASTF_cc46.xs: In function `new':
FASTF_cc46.xs:21: invalid type argument of `->'
FASTF_cc46.xs:21: invalid type argument of `->'
FASTF_cc46.xs:21: warning: passing arg 1 of `Perl_sv_2pv_nolen' makes pointer from
integer without a cast
FASTF_cc46.xs:45: warning: passing arg 1 of `strcat' makes pointer from integer
without a cast
FASTF_cc46.xs:45: warning: passing arg 1 of `strncat' makes pointer from integer
without a cast
FASTF_cc46.xs:45: warning: passing arg 1 of `strncat' makes pointer from integer
without a cast
FASTF_cc46.xs:50: warning: passing arg 2 of `Perl_newSVrv' from incompatible pointer
type
FASTF_cc46.xs:50: incompatible types in assignment
FASTF_cc46.xs:51: incompatible type for argument 1 of `Perl_sv_setiv'
FASTF_cc46.xs:52: invalid type argument of `->'
here's my new function (the typedef for Query follows below)
SV* new(char* class, ...) {
Inline_Stack_Vars;
int i;
char* pam;
SV* obj_ref, obj;
Query* query = calloc(1, sizeof(Query));
i = 2; /* default Stack position if we have a matrix to set */
/* set the scoring matrix: */
pam = SvPV_nolen(Inline_Stack_item(1));
if (strcmp(pam, "MD10") == 0) {
query->pam = &(md10[0]);
} else if (strcmp(pam, "MD20") == 0) {
query->pam = &(md20[0]);
} else if (strcmp(pam, "MD40") == 0) {
query->pam = &(md40[0]);
} else if (strcmp(pam, "BL50") == 0) {
query->pam = &(bl50[0]);
} else if (strcmp(pam, "BL62") == 0) {
query->pam = &(bl62[0]);
} else {
query->pam = &(md20[0]);
/* they didn't give us a scoring matrix; use the default, and
assume this is a fragment sequence. */
i = 1;
}
query->nfrag = Inline_Stack_Items + 1 - i;
query->fraglen = SvCUR(Inline_Stack_Item(i));
query->seq = calloc(query->nfrag * query->fraglen + 1, sizeof(char));
for(i /* set previously */ ; i < Inline_Stack_Items; i++) {
strncat(query->seq[(i-1) * query->fraglen],
SvPV_nolen(Inline_Stack_Item(i)),
query->fraglen);
}
/* make a reference to a scalar blessed into this package */
obj_ref = newSViv(0);
obj = newSVrv(obj_ref, Inline_Stack_Item(0));
sv_setiv(obj, (IV) query);
SvREADONLY_on(obj);
return obj_ref;
}
[ from my included .h file: ]
typedef struct {
char* seq;
int nfrag;
int fraglen;
int* pam;
} Query;
--
o ~ ~ ~ ~ ~ ~ o
/ Aaron J Mackey \
\ Dr. Pearson Laboratory /
\ University of Virginia \
/ (434) 924-2821 \
\ [EMAIL PROTECTED] /
o ~ ~ ~ ~ ~ ~ o