Home | History | Annotate | Download | only in perl5
      1 /* -----------------------------------------------------------------------------
      2  * perlmain.i
      3  *
      4  * Code to statically rebuild perl5.
      5  * ----------------------------------------------------------------------------- */
      6 
      7 #ifdef AUTODOC
      8 %subsection "perlmain.i"
      9 %text %{
     10 This module provides support for building a new version of the
     11 Perl executable.  This will be necessary on systems that do
     12 not support shared libraries and may be necessary with C++
     13 extensions.
     14 
     15 This module may only build a stripped down version of the
     16 Perl executable.   Thus, it may be necessary (or desirable)
     17 to hand-edit this file for your particular application.  To
     18 do this, simply copy this file from swig_lib/perl5/perlmain.i
     19 to your working directory and make the appropriate modifications.
     20 
     21 This library file works with Perl 5.003.  It may work with earlier
     22 versions, but it hasn't been tested.  As far as I know, this
     23 library is C++ safe.
     24 %}
     25 #endif
     26 
     27 %{
     28 
     29 static void xs_init _((pTHX));
     30 static PerlInterpreter *my_perl;
     31 
     32 int perl_eval(char *string) {
     33   char *argv[2];
     34   argv[0] = string;
     35   argv[1] = (char *) 0;
     36   return perl_call_argv("eval",0,argv);
     37 }
     38 
     39 int
     40 main(int argc, char **argv, char **env)
     41 {
     42     int exitstatus;
     43 
     44     my_perl = perl_alloc();
     45     if (!my_perl)
     46        exit(1);
     47     perl_construct( my_perl );
     48 
     49     exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL );
     50     if (exitstatus)
     51 	exit( exitstatus );
     52 
     53     /* Initialize all of the module variables */
     54 
     55     exitstatus = perl_run( my_perl );
     56 
     57     perl_destruct( my_perl );
     58     perl_free( my_perl );
     59 
     60     exit( exitstatus );
     61 }
     62 
     63 /* Register any extra external extensions */
     64 
     65 /* Do not delete this line--writemain depends on it */
     66 /* EXTERN_C void boot_DynaLoader _((CV* cv)); */
     67 
     68 static void
     69 xs_init(pTHX)
     70 {
     71 /*  dXSUB_SYS; */
     72     char *file = __FILE__;
     73     {
     74       /*        newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); */
     75 	newXS(SWIG_name, SWIG_init, file);
     76 #ifdef SWIGMODINIT
     77 	SWIGMODINIT
     78 #endif
     79     }
     80 }
     81 
     82 %}
     83