1N/A * Copyright (C) 1993, 1994, 1996, 1997, 1998, 1999, 1N/A * 2000, 2001, 2002, 2004, by Larry Wall and others 1N/A * You may distribute under the terms of either the GNU General Public 1N/A * License or the Artistic License, as specified in the README file. 1N/A=head1 Callback Functions 1N/A=for apidoc Ams||SAVETMPS 1N/AOpening bracket for temporaries on a callback. See C<FREETMPS> and 1N/A=for apidoc Ams||FREETMPS 1N/AClosing bracket for temporaries on a callback. See C<SAVETMPS> and 1N/A=for apidoc Ams||ENTER 1N/AOpening bracket on a callback. See C<LEAVE> and L<perlcall>. 1N/A=for apidoc Ams||LEAVE 1N/AClosing bracket on a callback. See C<ENTER> and L<perlcall>. 1N/A * Not using SOFT_CAST on SAVESPTR, SAVEGENERICSV and SAVEFREESV 1N/A * because these are used for several kinds of pointer values 1N/A/* SSNEW() temporarily allocates a specified number of bytes of data on the 1N/A * savestack. It returns an integer index into the savestack, because a 1N/A * pointer would get broken if the savestack is moved on reallocation. 1N/A * SSNEWa() works like SSNEW(), but also aligns the data to the specified 1N/A * number of bytes. MEM_ALIGNBYTES is perhaps the most useful. The 1N/A * alignment will be preserved therough savestack reallocation *only* if 1N/A * realloc returns data aligned to a size divisible by `align'! 1N/A * SSPTR() converts the index returned by SSNEW/SSNEWa() into a pointer. 1N/A/* A jmpenv packages the state required to perform a proper non-local jump. 1N/A * Note that there is a start_env initialized when perl starts, and top_env 1N/A * points to this initially, so top_env should always be non-null. 1N/A * Existence of a non-null top_env->je_prev implies it is valid to call 1N/A * longjmp() at that runlevel (we make sure start_env.je_prev is always 1N/A * null to ensure this). 1N/A * je_mustcatch, when set at any runlevel to TRUE, means eval ops must 1N/A * establish a local jmpenv to handle exception traps. Care must be taken 1N/A * to restore the previous value of je_mustcatch before exiting the 1N/A * stack frame iff JMPENV_PUSH was not called in that stack frame. 1N/A * How to build the first jmpenv. 1N/A * top_env needs to be non-zero. It points to an area 1N/A * in which longjmp() stuff is stored, as C callstack 1N/A * info there at least is thread specific this has to 1N/A * be per-thread. Otherwise a 'die' in a thread gives 1N/A * that thread the C stack of last thread to do an eval {}! 1N/A * These exception-handling macros are split up to 1N/A * ease integration with C++ exceptions. 1N/A * To use C++ try+catch to catch Perl exceptions, an extension author 1N/A * needs to first write an extern "C" function to throw an appropriate 1N/A * exception object; typically it will be or contain an integer, 1N/A * because Perl's internals use integers to track exception types: 1N/A * extern "C" { static void thrower(int i) { throw i; } } 1N/A * Then (as shown below) the author needs to use, not the simple 1N/A * JMPENV_PUSH, but several of its constitutent macros, to arrange for 1N/A * the Perl internals to call thrower() rather than longjmp() to 1N/A * report exceptions: 1N/A * JMPENV_PUSH_INIT(thrower); 1N/A * ... stuff that may throw exceptions ... 1N/A * catch (int why) { // or whatever matches thrower() 1N/A * JMPENV_POST_CATCH; 1N/A * ... // handle various Perl exception codes 1N/A * JMPENV_POP; // don't forget this! 1N/A * body of protected processing. 1N/A#
else /* !PERL_FLEXIBLE_EXCEPTIONS */ 1N/A#
endif /* PERL_FLEXIBLE_EXCEPTIONS */