PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Lib/perl5/perlmain.i

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