Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

XS question, calling anonymous function from C
In order to avoid namespace pollution, I would like to do the following
in C:

SV* sv;
char* cmd = "FileHandle->new(q(foo.c));";
sv = eval_pv(cmd, TRUE);

Now, sv points to a class instance. Is there a way to call methods of
the class from w/in C? Preferably, with arguments?

TIA


Report this thread to moderator Post Follow-up to this message
Old Post
elbob@mailinator.com
04-25-05 08:58 AM


Re: XS question, calling anonymous function from C
Hello,

elbob@mailinator.com wrote:
> In order to avoid namespace pollution, I would like to do the following
> in C:
>
> SV* sv;
> char* cmd = "FileHandle->new(q(foo.c));";
> sv = eval_pv(cmd, TRUE);
>
> Now, sv points to a class instance. Is there a way to call methods of
> the class from w/in C? Preferably, with arguments?

Found in the book "Extending and Embedding Perl",
page 265 (http://www.manning.com/jenness):


char* tidy_string (char* input) {
SV* result;
setSVpv(DEFSV, input, 0);
result = eval_pv("use Text::Autoformat; autoformat($_)", FALSE);
if (SvTRUE(ERRSV))
return NULL;
else
return SvPV_nolen(result);
}


I hope this help.
But have you tried to ask the question in the perl.xs group?

regards,
Reinhard

Report this thread to moderator Post Follow-up to this message
Old Post
Reinhard Pagitsch
04-25-05 01:58 PM


Re: XS question, calling anonymous function from C
Also sprach elbob@mailinator.com:

> In order to avoid namespace pollution, I would like to do the following
> in C:
>
> SV* sv;
> char* cmd = "FileHandle->new(q(foo.c));";
> sv = eval_pv(cmd, TRUE);
>
> Now, sv points to a class instance. Is there a way to call methods of
> the class from w/in C? Preferably, with arguments?

You can use call_method() for that. You first have to push 'sv' onto the
stack followed by all arguments the method should receive. See
perlcall.pod for details.

Tassilo
--
use bigint;
 $n=7142335034377028016139702633033737113
9054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);

Report this thread to moderator Post Follow-up to this message
Old Post
Tassilo v. Parseval
04-25-05 01:58 PM


Re: XS question, calling anonymous function from C
I was trying comp.lang.perl.xs. I *knew* I had seen that group before.
Mucho gracias! I also got on the Safari group, so now I can access
books like that. Can't get 'em where I am.

El Bob


Report this thread to moderator Post Follow-up to this message
Old Post
elbob@mailinator.com
04-25-05 08:58 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Miscellaneous archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:26 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.