On 16 May 2002 at 7:59, Gerald Richter wrote:

> Hi,
> 
> this seems not the best list for this sort of questions, it's a list
> about Embperl.....
> 
> Anyway a short answer:
> 
> Yes, you have to set the magic on all elements of hash/array. There is
> no simple way to do it (at least not in 5.6.1) to get your C code called
> directly.
> 
> There is some way to have a Perl callback (that's for tied hashs/arrays
> in Perl), when any access to the array/hash is made. This Perl callback
> could in turn call your C code, but there is no direct way.
> 
> The best way to understand what Perl is doing, is to go to the Perl
> source and read sv.c,av.c and hv.c.
> 
> Gerald
> 
> 
> 
> ----- Original Message -----
> From: "Cory C. Albrecht" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, May 11, 2002 8:24 PM
> Subject: magic for variables to link with the C vars where perl is
> embedded into
> 
> 
> > Hello All,
> >
> > I'm writing an app which uses perl as it's scripting langauge and I've
> > just gotten around to using magic to link the C variables for my app's
> > preferences to variables in the embedded perl so scripts can change
> > the preferences. Magic for SVs turned out to be simpler than I
> > expected, but  magic for HVs ans AVs looks like it's going to be much
> > more complicated.
> >
> > For arrays and hashes, am I going to have to manually set magic for
> > each  individual SV element? And for arrays of arrays or arrays of
> > hashes,  too?
> >
> > I don't quite understand what the hv_magic() function is supposed to
> > do.  In perlguts "Assigning Magic" it just says "This simply calls
> > sv_magic  and coerces the gv argument into an SV." But hv_magic()
> > doesn't have the  last 2 parameters that sv_magic() does. Can I do
> > something like this:
> >
> >         av = get_av("my_array", TRUE);
> >         sv_magic((SV *)av, NULL, 'U', (char *)data, sizeof(data)); mg
> >         = mg_find((SV *)av, 'U'); mg->mg_virtual = (MGVTBL *)calloc(1,
> >         sizeof(MGVTBL)); mg->mg_virtual->svt_get = GetLinkedVar;
> >         mg->mg_virtual->svt_get = SetLinkedVar;
> >
> > and if yes, then in GetLinkedVar() and SetLinkedVar() how do I tell
> > what  element of the array I am accessing? It would be nice if there
> > was a  function av_magic() that had all the parameters of sv_magic(),
> > but when  mg_virtual->svt_get was called for this AV, in addition to
> > the SV * and  MAGIC * paramters there would be a third one indicating
> > the actual array  element that SV * is. Doing that coudl remove the
> > necessity for have to  set magic on each inidvidual SV in an array.
> >
> > I'd really appreciate it if anybody could point me to any examples of
> > using magic to link perl arrays/hashes to C/C++ variables, or fuller
> > documentation/examples than exist in perlguts.
> >
> > Thanks in advance.
> > --
> > Cory C. Albrecht
> > Access denied - nah nah na nah nah!
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED] For
> > additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 
> -------------------------------------------------------------
> Gerald Richter    ecos electronic communication services gmbh
> Internetconnect * Webserver/-design/-datenbanken * Consulting
> 
> Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
> E-Mail:     [EMAIL PROTECTED]         Voice:    +49 6133 925131
> WWW:        http://www.ecos.de      Fax:      +49 6133 925152
> -------------------------------------------------------------
> 
> 
> 
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: [EMAIL PROTECTED] For additional
> commands, e-mail: [EMAIL PROTECTED]
> 

--
Cory C. Albrecht
A competent and reliable dishwasher never starves.
 -- Robert A. Heinlein



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to