rsteinke has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to provide a tied hash interface to a C object in my XS code. The OUTPUT section of my typemap looks like
which I was expecting to return a tied HV reference. However, in my test codeT_TIED_HASH { SV* tie = NEWSV(0, 0); HV* hash = newHV(); /* Get a blessed reference to the pointer, */ sv_setref_pv(tie, CLASS, (void*)$var); /* and tie it to a hash. */ hv_magic(hash, (GV*)tie, PERL_MAGIC_tied); $arg = newRV_noinc((SV*)hash); }
the first test succeeds, but the second fails. Ideas?my $obj = new TiedXS(1); ok($obj); ok(tied $obj);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using hv_magic() in typemap to create a tied object
by ysth (Canon) on Aug 04, 2004 at 15:37 UTC | |
by ysth (Canon) on Aug 04, 2004 at 15:47 UTC | |
by rsteinke (Scribe) on Aug 04, 2004 at 15:42 UTC | |
by rsteinke (Scribe) on Aug 04, 2004 at 15:51 UTC |