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

Adding Perl Core functions
Hallo, I was able to integrate embedded perl into my c program.
So I am able to call perl scripts from within my program.
Now I want to call c routines from within the perl code.
How can I do so ? I have to add an extra function to perl


rds


Report this thread to moderator Post Follow-up to this message
Old Post
Guenther Sohler
04-23-05 01:56 AM


Re: Adding Perl Core functions
Guenther Sohler wrote:
> Hallo, I was able to integrate embedded perl into my c program.
> So I am able to call perl scripts from within my program.
> Now I want to call c routines from within the perl code.
> How can I do so ? I have to add an extra function to perl

Read the documentation for xs.

man perlxs

Mark

Report this thread to moderator Post Follow-up to this message
Old Post
Mark Clements
04-23-05 01:56 AM


Re: Adding Perl Core functions
In article <pan.2005.04.22.20.57.26.596993@newlogic.com>, Guenther
Sohler <guenther.sohler@newlogic.com> wrote:

> Hallo, I was able to integrate embedded perl into my c program.
> So I am able to call perl scripts from within my program.
> Now I want to call c routines from within the perl code.
> How can I do so ? I have to add an extra function to perl

Read 'perldoc perlxs'

----== Posted via mcse.ms - Unlimited-Uncensored-Secure Usenet News==-
---
http://www.mcse.ms The #1 Newsgroup Service in the World! 120,000+ New
sgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Report this thread to moderator Post Follow-up to this message
Old Post
Jim Gibson
04-23-05 01:56 AM


Re: Adding Perl Core functions
Mark Clements wrote:
> Guenther Sohler wrote:
> 
>
> Read the documentation for xs.
>
> man perlxs

Also, "perldoc perlxstut" for an XS tutorial.

And, "perldoc perl" has a section that lists a number of relevant docs,
titled "Internals and C Language Interface".

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

Report this thread to moderator Post Follow-up to this message
Old Post
Sherm Pendley
04-23-05 08:57 AM


Re: Adding Perl Core functions
"Guenther Sohler" <guenther.sohler@newlogic.com> wrote in message
news:pan.2005.04.22.20.57.26.596993@newlogic.com...
> Hallo, I was able to integrate embedded perl into my c program.
> So I am able to call perl scripts from within my program.
> Now I want to call c routines from within the perl code.
> How can I do so ? I have to add an extra function to perl
>

As an alternative to the xs approach, take a look at the Inline::C module.
See 'perldoc Inline::C-Cookbook' and 'perldoc Inline::C'.

Cheers,
Rob



Report this thread to moderator Post Follow-up to this message
Old Post
Sisyphus
04-23-05 08:57 AM


Re: Adding Perl Core functions
Hallo Rob, ( and all the Others).
Defintely I will have a look at the Inline::C Routine.
At the wend I had a look at the XS Approch(without beeing able to read
the newsgroup before.
Unfortunately the XS Approach did not really fit into my concept.
Using XS sounded like creating an extra, external Module for perl.

My Intent is following:
* I have a C program with an embedded perl interpreter
* I want to use the perl interpreter to have a scripting language for my
program
* But I want to have special program-related perl commands that act on
my programs database. If I did not want this I could use a normal perl
interpreter from the beginning
* Therefore I somehow want to register C- callback functions under a
dedicated perl function name.

I have written a c callback function, which draws a rectangle. It is
called
draw_rectangle. Then I instanciate a perl interpreter in my C program.
Then I want instruct !!!! "C" !!!! to register the callback function as
a new perl_command "draw_rectangle".
Finally I instruct the perl interpreter to execute a script from a file.
I dont mind, if the c callback functio has to evaluate the perl stack,
but It would be fine, if my function was registered in the main
namespace(no :: in function name) and if there were no measures in the
perl program to load the draw_rectangle from an external module).

There are to reasons why I dont want my "draw_rectangle" from an external
perl module
*	I dont want to keep my program as simple as possible - No extra
files if possible
*	I fear, that the extern module is not able anymore to access the
program database as it is seperated from the main program


Who has the perfect solution for me ?


On Sat,
23 Apr 2005 11:33:47 +1000, Sisyphus wrote:

>
> "Guenther Sohler" <guenther.sohler@newlogic.com> wrote in message
> news:pan.2005.04.22.20.57.26.596993@newlogic.com... 
>
> As an alternative to the xs approach, take a look at the Inline::C module.
> See 'perldoc Inline::C-Cookbook' and 'perldoc Inline::C'.
>
> Cheers,
> Rob


Report this thread to moderator Post Follow-up to this message
Old Post
Guenther Sohler
04-25-05 08:58 AM


Re: Adding Perl Core functions
[A complimentary Cc of this posting was sent to
Guenther Sohler
<guenther.sohler@newlogic.com>], who wrote in article <pan.2005.04.25.05.09.30.716067@newlo
gic.com>:
> Unfortunately the XS Approach did not really fit into my concept.
> Using XS sounded like creating an extra, external Module for perl.

Not necessarily.  First, debug it as an external module.  Then, when
things work, compile the C part into your executable.  Eval the Perl
part (if needed) from your start-perl shim before doing perl_run()
(sp?).

But usually no Perl part is required at all; see how UNIVERSAL::*
methods are implemented in Perl proper.

Hope this helps,
Ilya

Report this thread to moderator Post Follow-up to this message
Old Post
Ilya Zakharevich
04-28-05 08:59 AM


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:25 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.