return PerlIO_vprintf(stream, format, arglist);
}
+#undef PERLVAR
+#define PERLVAR(x, y)
+#undef PERLVARI
+#define PERLVARI(x, y, z) x = z;
+#undef PERLVARIC
+#define PERLVARIC(x, y, z) x = z;
+
CPerlObj::CPerlObj(IPerlMem* ipM, IPerlEnv* ipE, IPerlStdIO* ipStd,
IPerlLIO* ipLIO, IPerlDir* ipD, IPerlSock* ipS, IPerlProc* ipP)
{
memset(((char*)this)+sizeof(void*), 0, sizeof(CPerlObj)-sizeof(void*));
+
+#include "thrdvar.h"
+#include "intrpvar.h"
+#include "perlvars.h"
+
piMem = ipM;
piENV = ipE;
piStdIO = ipStd;
void
CPerlObj::Init(void)
{
- curcop = &compiling;
- cxstack_ix = -1;
- cxstack_max = 128;
- chopset = " \n-";
-#ifdef USE_THREADS
- threadsv_names = THREADSV_NAMES;
- tmps_ix = -1;
- tmps_floor = -1;
-#endif
- maxo = MAXO;
- sh_path = SH_PATH;
- runops = FUNC_NAME_TO_PTR(RUNOPS_DEFAULT);
-#ifdef CSH
- cshname = CSH;
-#endif
- rsfp = Nullfp;
- expect = XSTATE;
-#ifdef USE_LOCALE_COLLATE
- collation_standard = TRUE;
- collxfrm_mult = 2;
-#endif
-#ifdef USE_LOCALE_NUMERIC
- numeric_standard = TRUE;
- numeric_local = TRUE;
-#endif /* !USE_LOCALE_NUMERIC */
-
-/* constants (these are not literals to facilitate pointer comparisons) */
- Yes = "1";
- No = "";
- hexdigit = "0123456789abcdef0123456789ABCDEFx";
- patleave = "\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}";
- splitstr = " ";
- perl_destruct_level = 0;
- maxsysfd = MAXSYSFD;
- statname = Nullsv;
- maxscream = -1;
- op_mask = NULL;
- dlmax = 128;
- curcopdb = NULL;
- copline = NOLINE;
- laststatval = -1;
- laststype = OP_STAT;
- generation = 100;
-
#ifdef WIN32
New(2904, environ, 1, char*);
*environ = NULL;
*/
+
+/*
+ PerlXXX_YYY explained - DickH and DougL @ ActiveState.com
+
+XXX := functional group
+YYY := stdlib/OS function name
+
+Continuing with the theme of PerlIO, all OS functionality was
+encapsulated into one of several interfaces.
+
+PerlIO - stdio
+PerlLIO - low level I/O
+PerlMem - malloc, realloc, free
+PerlDir - directory related
+PerlEnv - process environment handling
+PerlProc - process control
+PerlSock - socket functions
+
+
+The features of this are:
+1. All OS dependant code is in the Perl Host and not the Perl Core.
+ (At least this is the holy grail goal of this work)
+2. The Perl Host (see perl.h for description) can provide a new and
+ improved interface to OS functionality if required.
+3. Developers can easily hook into the OS calls for instrumentation
+ or diagnostic purposes.
+
+What was changed to do this:
+1. All calls to OS functions were replaced with PerlXXX_YYY
+
+*/
+
+
+
#ifndef __Inc__IPerlDir___
#define __Inc__IPerlDir___
#endif /* PERL_FOR_X2P */
#ifdef PERL_OBJECT
+
+/* PERL_OBJECT explained - DickH and DougL @ ActiveState.com
+
+Defining PERL_OBJECT turns on creation of a C++ object that
+contains all writable core perl global variables and functions.
+Stated another way, all necessary global variables and functions
+are members of a big C++ object. This object's class is CPerlObj.
+This allows a Perl Host to have multiple, independent perl
+interpreters in the same process space. This is very important on
+Win32 systems as the overhead of process creation is quite high --
+this could be even higher than the script compile and execute time
+for small scripts.
+
+The perl executable implementation on Win32 is composed of perl.exe
+(the Perl Host) and perlX.dll. (the Perl Core). This allows the
+same Perl Core to easily be embedded in other applications that use
+the perl interpreter.
+
++-----------+
+| Perl Host |
++-----------+
+ ^
+ |
+ v
++-----------+ +-----------+
+| Perl Core |<->| Extension |
++-----------+ +-----------+ ...
+
+Defining PERL_OBJECT has the following effects:
+
+PERL CORE
+1. CPerlObj is defined (this is the PERL_OBJECT)
+2. all static functions that needed to access either global
+variables or functions needed are made member functions
+3. all writable static variables are made member variables
+4. all global variables and functions are defined as:
+ #define var CPerlObj::Perl_var
+ #define func CPerlObj::Perl_func
+ * these are in objpp.h
+This necessitated renaming some local variables and functions that
+had the same name as a global variable or function. This was
+probably a _good_ thing anyway.
+
+
+EXTENSIONS
+1. Access to global variables and perl functions is through a
+pointer to the PERL_OBJECT. This pointer type is CPerlObj*. This is
+made transparent to extension developers by the following macros:
+ #define var pPerl->Perl_var
+ #define func pPerl->Perl_func
+ * these are done in ObjXSub.h
+This requires that the extension be compiled as C++, which means
+that the code must be ANSI C and not K&R C. For K&R extensions,
+please see the C API notes located in Win32/GenCAPI.pl. This script
+creates a PerlCAPI.lib that provides a K & R compatible C interface
+to the PERL_OBJECT.
+2. Local variables and functions cannot have the same name as perl's
+variables or functions since the macros will redefine these. Look for
+this if you get some strange error message and it does not look like
+the code that you had written. This often happens with variables that
+are local to a function.
+
+PERL HOST
+1. The perl host is linked with perlX.lib to get perl_alloc. This
+function will return a pointer to CPerlObj (the PERL_OBJECT). It
+takes pointers to the various PerlXXX_YYY interfaces (see ipdir.h for
+information on this).
+2. The perl host calls the same functions as normally would be
+called in setting up and running a perl script, except that the
+functions are now member functions of the PERL_OBJECT.
+
+*/
+
+
class CPerlObj;
#define STATIC
PERLVAR(Gnice_chunk_size, U32) /* how nice the chunk of memory is */
#ifdef PERL_OBJECT
-PERLVAR(Grunops, runops_proc_t)
+PERLVARI(Grunops, runops_proc_t, RUNOPS_DEFAULT)
#else
PERLVARI(Grunops, runops_proc_t *, RUNOPS_DEFAULT)
#endif
#define REG_SEEN_LOOKBEHIND 2
#define REG_SEEN_GPOS 4
-#ifdef DEBUGGING
-EXT char *colors[4]; /* not dEXT since we do EXTERN/INTERN.h shuffle */
-#endif
! IF "$(CCTYPE)" == "MSVC20"
OPTIMIZE = -Od $(RUNTIME) -Z7 -D_DEBUG -DDEBUGGING
! ELSE
-OPTIMIZE = -Od $(RUNTIME)d -Z7 -D_DEBUG -DDEBUGGING
+OPTIMIZE = -Od $(RUNTIME)d -Zi -D_DEBUG -DDEBUGGING
! ENDIF
LINK_DBG = -debug -pdb:none
!ELSE
.IF "$(CCTYPE)" == "MSVC20"
OPTIMIZE = -Od $(RUNTIME) -Z7 -D_DEBUG -DDEBUGGING
.ELSE
-OPTIMIZE = -Od $(RUNTIME)d -Z7 -D_DEBUG -DDEBUGGING
+OPTIMIZE = -Od $(RUNTIME)d -Zi -D_DEBUG -DDEBUGGING
.ENDIF
LINK_DBG = -debug -pdb:none
.ELSE