Differences between current version and previous revision of perlembed(1).
Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 2 | Last edited on Monday, June 3, 2002 6:50:44 pm | by perry | |
Older page: | version 1 | Last edited on Monday, June 3, 2002 6:50:44 pm | by perry | Revert |
@@ -113,9 +113,9 @@
When you use Perl from C, your C program
will--usually--allocate, ``run'', and deallocate a
-''PerlInterpreter'' object, which is defined by the perl
+''!
PerlInterpreter'' object, which is defined by the perl
library.
If your copy of Perl is recent enough to contain this
@@ -175,16 +175,16 @@
Perhaps those printed by
perl -MConfig -e 'print $Config{libs}'
-Provided your perl binary was properly configured and installed the __ExtUtils::Embed__ module will determine all of this information for you:
+Provided your perl binary was properly configured and installed the __!
ExtUtils::Embed__ module will determine all of this information for you:
% cc -o interp interp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
-If the __ExtUtils::Embed__ module isn't part of your Perl distribution, you can retrieve it from http://www.perl.com/perl/CPAN/modules/by-module/ExtUtils/. (If this documentation came from your Perl distribution, then you're running 5.004 or better and you already have it.)
+If the __!
ExtUtils::Embed__ module isn't part of your Perl distribution, you can retrieve it from http://www.perl.com/perl/CPAN/modules/by-module/!
ExtUtils/. (If this documentation came from your Perl distribution, then you're running 5.004 or better and you already have it.)
-The __ExtUtils::Embed__ kit on CPAN also
+The __!
ExtUtils::Embed__ kit on CPAN also
contains all source code for the examples in this document,
tests, additional examples and other information you may
find useful.
@@ -201,9 +201,9 @@
embedding:
#include
- static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
+ static !
PerlInterpreter *my_perl; /*** The Perl interpreter ***/
int main(int argc, char **argv, char **env)
{
my_perl = perl_alloc();
perl_construct(my_perl);
@@ -245,9 +245,9 @@
''showtime.c''.
#include
- static PerlInterpreter *my_perl;
+ static !
PerlInterpreter *my_perl;
int main(int argc, char **argv, char **env)
{
char *args[[] = { NULL };
my_perl = perl_alloc();
@@ -318,9 +318,9 @@
the third.
#include
- static PerlInterpreter *my_perl;
+ static !
PerlInterpreter *my_perl;
main (int argc, char **argv, char **env)
{
STRLEN n_a;
char *embedding[[] = {
@@ -451,9 +451,9 @@
return num_matches;
}
main (int argc, char **argv, char **env)
{
-PerlInterpreter *my_perl = perl_alloc();
+!
PerlInterpreter *my_perl = perl_alloc();
char *embedding[[] = {
perl_construct(my_perl);
perl_parse(my_perl, NULL, 3, embedding, NULL);
sv_setpv(text,
@@ -527,15 +527,15 @@
sub expo {
my ($a, $b) = @_;
return $a ** $b;
}
-Now I'll create a C program, ''power.c'', with a function ''PerlPower()'' that contains all the perlguts necessary to push the two arguments into ''expo()'' and to pop the return value out. Take a deep breath...
+Now I'll create a C program, ''power.c'', with a function ''!
PerlPower()'' that contains all the perlguts necessary to push the two arguments into ''expo()'' and to pop the return value out. Take a deep breath...
#include
- static PerlInterpreter *my_perl;
+ static !
PerlInterpreter *my_perl;
static void
-PerlPower(int a, int b)
+!
PerlPower(int a, int b)
{
dSP; /* initialize stack pointer */
ENTER; /* everything created after here */
SAVETMPS; /* ...is a temporary variable. */
@@ -550,9 +550,9 @@
my_perl = perl_alloc();
perl_construct( my_perl );
perl_parse(my_perl, NULL, 2, my_argv, (char **)NULL);
perl_run(my_perl);
- PerlPower(3, 4); /*** Compute 3 ** 4 ***/
+ !
PerlPower(3, 4); /*** Compute 3 ** 4 ***/
perl_destruct(my_perl);
perl_free(my_perl);
}
Compile and run:
@@ -655,9 +655,9 @@
/* 1 = clean out filename's symbol table after each request, 0 = don't */
#ifndef DO_CLEAN
#define DO_CLEAN 0
#endif
- static PerlInterpreter *perl = NULL;
+ static !
PerlInterpreter *perl = NULL;
int
main(int argc, char **argv, char **env)
{
char *embedding[[] = {
@@ -763,9 +763,9 @@
/* we're going to embed two interpreters */
#define SAY_HELLO
int main(int argc, char **argv, char **env)
{
-PerlInterpreter
+!
PerlInterpreter
*one_perl = perl_alloc(),
*two_perl = perl_alloc();
char *one_args[[] = {
PERL_SET_CONTEXT(one_perl);
@@ -836,17 +836,17 @@
That's where the glue code can be inserted to create the initial contact between Perl and linked C/C ++ routines. Let's take a look some pieces of ''perlmain.c'' to see how Perl does this:
static void xs_init (pTHX);
- EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
+ EXTERN_C void boot_!
DynaLoader (pTHX_ CV* cv);
EXTERN_C void boot_Socket (pTHX_ CV* cv);
EXTERN_C void
xs_init(pTHX)
{
char *file = __FILE__;
-/* DynaLoader is a special case */
+/* !
DynaLoader is a special case */
newXS(
-Simply put: for each extension linked with your Perl executable (determined during its initial configuration on your computer or when adding a new extension), a Perl subroutine is created to incorporate the extension's routines. Normally, that subroutine is named ''Module::bootstrap()'' and is invoked when you say ''use Module''. In turn, this hooks into an XSUB , ''boot_Module'', which creates a Perl counterpart for each of the extension's XSUBs. Don't worry about this part; leave that to the ''xsubpp'' and extension authors. If your extension is dynamically loaded, DynaLoader creates ''Module::bootstrap()'' for you on the fly. In fact, if you have a working DynaLoader then there is rarely any need to link in any other extensions statically.
+Simply put: for each extension linked with your Perl executable (determined during its initial configuration on your computer or when adding a new extension), a Perl subroutine is created to incorporate the extension's routines. Normally, that subroutine is named ''Module::bootstrap()'' and is invoked when you say ''use Module''. In turn, this hooks into an XSUB , ''boot_Module'', which creates a Perl counterpart for each of the extension's XSUBs. Don't worry about this part; leave that to the ''xsubpp'' and extension authors. If your extension is dynamically loaded, !
DynaLoader creates ''Module::bootstrap()'' for you on the fly. In fact, if you have a working !
DynaLoader then there is rarely any need to link in any other extensions statically.
Once you have this code, slap it into the second argument of
''perl_parse()'':
@@ -858,11 +858,11 @@
% cc -o interp interp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
% interp
use Socket;
-use SomeDynamicallyLoadedModule;
+use !
SomeDynamicallyLoadedModule;
print
-__ExtUtils::Embed__ can also automate writing the ''xs_init'' glue code.
+__!
ExtUtils::Embed__ can also automate writing the ''xs_init'' glue code.
% perl -MExtUtils::Embed -e xsinit -- -o perlxsi.c
% cc -c perlxsi.c `perl -MExtUtils::Embed -e ccopts`
@@ -877,16 +877,16 @@
However, there are some caveats about the command-line
examples shown. For starters, backticks won't work under the
-Win32 native command shell. The ExtUtils::Embed kit on
+Win32 native command shell. The !
ExtUtils::Embed kit on
CPAN ships with a script called
__genmake__, which generates a simple makefile to build a
program from a single C source file. It can be used like
this:
- C:ExtUtils-Embedeg
+ C:!
ExtUtils-Embedeg
You may wish to use a more robust environment such as the Microsoft Developer Studio. In this case, run this to generate perlxsi.c:
perl -MExtUtils::Embed -e xsinit
@@ -904,13 +904,13 @@
''dougm@osf.org''
''
-Doug MacEachern has an article on embedding in Volume 1,
+Doug !
MacEachern has an article on embedding in Volume 1,
Issue 4 of The Perl Journal (http://tpj.com). Doug is also
the developer of the most widely-used Perl embedding: the
mod_perl system (perl.apache.org), which embeds Perl in the
-Apache web server. Oracle, Binary Evolution, ActiveState,
+Apache web server. Oracle, Binary Evolution, !
ActiveState,
and Ben Sugars's nsapi_perl have used this model for Oracle,
Netscape and Internet Information Server Perl
plugins.
@@ -918,9 +918,9 @@
July 22, 1998
!!COPYRIGHT
-Copyright (C) 1995, 1996, 1997, 1998 Doug MacEachern and Jon
+Copyright (C) 1995, 1996, 1997, 1998 Doug !
MacEachern and Jon
Orwant. All Rights Reserved.
Permission is granted to make and distribute verbatim copies