Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
###############################################typedef struct _mystruct1 { int val; int (* init) (void *object1, void **object2); } mystruct1; typedef struct _mystruct2 { mystruct *ptr; } mystruct2;
############################################### and I want to be able to say the same from perl, i.e.:mystruct2 *mine; int res; struct obj *object1, **object2; ..... mine->ptr->val = 100; res = mine->ptr->init(object1, object2);
###############################################print "$mine->{"ptr"}->{"val"}"; # This seems to work $mine->{"ptr"}->{"init"}(object1, object2); # This does not work
###############################################rh = (HV *)sv_2mortal((SV *)newHV()); hv_store(rh, "val", 3, newSViv(mine->ptr->val), 0); hv_store(rh, "init", 4, newRV((SV *)mine->ptr->init), 0); # This line +did not work
but both statements failed ...if (SvROK ((SV *) mine->ptr->init)) { type = SvTYPE(SvRV((SV *)mine->ptr->init)); printf ("Something ..%d", type); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to pass a function reference from C to perl
by Matts (Deacon) on May 21, 2002 at 19:20 UTC | |
by Anonymous Monk on May 22, 2002 at 11:03 UTC | |
|
Re: How to pass a function reference from C to perl
by rsteinke (Scribe) on May 21, 2002 at 22:18 UTC |