… | |
… | |
953 | A header file that contains the prototypes of the few symbols "exported" |
953 | A header file that contains the prototypes of the few symbols "exported" |
954 | by bundle.c, and also exposes the perl headers to the application. |
954 | by bundle.c, and also exposes the perl headers to the application. |
955 | |
955 | |
956 | =over 4 |
956 | =over 4 |
957 | |
957 | |
958 | =item staticperl_init () |
958 | =item staticperl_init (xs_init = 0) |
959 | |
959 | |
960 | Initialises the perl interpreter. You can use the normal perl functions |
960 | Initialises the perl interpreter. You can use the normal perl functions |
961 | after calling this function, for example, to define extra functions or |
961 | after calling this function, for example, to define extra functions or |
962 | to load a .pm file that contains some initialisation code, or the main |
962 | to load a .pm file that contains some initialisation code, or the main |
963 | program function: |
963 | program function: |
… | |
… | |
970 | } |
970 | } |
971 | |
971 | |
972 | static void |
972 | static void |
973 | run_myapp(void) |
973 | run_myapp(void) |
974 | { |
974 | { |
975 | staticperl_init (); |
975 | staticperl_init (0); |
976 | newXSproto ("myapp::xsfunction", xsfunction, __FILE__, "$$;$"); |
976 | newXSproto ("myapp::xsfunction", xsfunction, __FILE__, "$$;$"); |
977 | eval_pv ("require myapp::main", 1); // executes "myapp/main.pm" |
977 | eval_pv ("require myapp::main", 1); // executes "myapp/main.pm" |
978 | } |
978 | } |
979 | |
979 | |
|
|
980 | When your bootcode already wants to access some XS functions at |
|
|
981 | compiletime, then you need to supply an C<xs_init> function pointer that |
|
|
982 | is called as soon as perl is initialised enough to define XS functions, |
|
|
983 | but before the preamble code is executed: |
|
|
984 | |
|
|
985 | static void |
|
|
986 | xs_init (pTHX) |
|
|
987 | { |
|
|
988 | newXSproto ("myapp::xsfunction", xsfunction, __FILE__, "$$;$"); |
|
|
989 | } |
|
|
990 | |
|
|
991 | static void |
|
|
992 | run_myapp(void) |
|
|
993 | { |
|
|
994 | staticperl_init (xs_init); |
|
|
995 | } |
|
|
996 | |
|
|
997 | =item staticperl_cleanup () |
|
|
998 | |
|
|
999 | In the unlikely case that you want to destroy the perl interpreter, here |
|
|
1000 | is the corresponding function. |
|
|
1001 | |
980 | =item staticperl_xs_init (pTHX) |
1002 | =item staticperl_xs_init (pTHX) |
981 | |
1003 | |
982 | Sometimes you need direct control over C<perl_parse> and C<perl_run>, in |
1004 | Sometimes you need direct control over C<perl_parse> and C<perl_run>, in |
983 | which case you do not want to use C<staticperl_init> but call them on your |
1005 | which case you do not want to use C<staticperl_init> but call them on your |
984 | own. |
1006 | own. |
985 | |
1007 | |
986 | Then you need this function - either pass it directly as the C<xs_init> |
1008 | Then you need this function - either pass it directly as the C<xs_init> |
987 | function to C<perl_parse>, or call it from your own C<xs_init> function. |
1009 | function to C<perl_parse>, or call it as one of the first things from your |
988 | |
1010 | own C<xs_init> function. |
989 | =item staticperl_cleanup () |
|
|
990 | |
|
|
991 | In the unlikely case that you want to destroy the perl interpreter, here |
|
|
992 | is the corresponding function. |
|
|
993 | |
1011 | |
994 | =item PerlInterpreter *staticperl |
1012 | =item PerlInterpreter *staticperl |
995 | |
1013 | |
996 | The perl interpreter pointer used by staticperl. Not normally so useful, |
1014 | The perl interpreter pointer used by staticperl. Not normally so useful, |
997 | but there it is. |
1015 | but there it is. |