Re: [perl #36959] List Constructor Operator - Undefined Values
[p5sagit/p5-mst-13.2.git] / symbian / PerlBase.h
CommitLineData
27da23d5 1/* Copyright (c) 2004-2005 Nokia. All rights reserved. */
2
3/* The CPerlBase class is licensed under the same terms as Perl itself. */
4
5/* See PerlBase.pod for documentation. */
6
7#ifndef __PerlBase_h__
8#define __PerlBase_h__
9
10#include <e32base.h>
11
12#if !defined(PERL_MINIPERL) && !defined(PERL_PERL)
13# ifndef PERL_IMPLICIT_CONTEXT
14# define PERL_IMPLICIT_CONTEXT
15# endif
16# ifndef PERL_MULTIPLICITY
17# define PERL_MULTIPLICITY
18# endif
19# ifndef PERL_GLOBAL_STRUCT
20# define PERL_GLOBAL_STRUCT
21# endif
22# ifndef PERL_GLOBAL_STRUCT_PRIVATE
23# define PERL_GLOBAL_STRUCT_PRIVATE
24# endif
25#endif
26
27#include "EXTERN.h"
28#include "perl.h"
29
30typedef enum {
31 EPerlNone,
32 EPerlAllocated,
33 EPerlConstructed,
34 EPerlParsed,
35 EPerlRunning,
36 EPerlTerminated,
37 EPerlPaused,
38 EPerlSuccess,
39 EPerlFailure,
40 EPerlDestroying
41} TPerlState;
42
43class PerlConsole;
44
45class CPerlBase : public CBase
46{
47 public:
48 CPerlBase();
49 IMPORT_C virtual ~CPerlBase();
50 IMPORT_C static CPerlBase* NewInterpreterL(TBool iCloseStdlib = ETrue,
51 void (*aStdioInitFunc)(void*) = NULL,
52 void *aStdioInitCookie = NULL);
53 IMPORT_C static CPerlBase* NewInterpreterLC(TBool iCloseStdlib = ETrue,
54 void (*aStdioInitFunc)(void*) = NULL,
55 void *aStdioInitCookie = NULL);
56 IMPORT_C TInt RunScriptL(const TDesC& aFileName, int argc = 2, char **argv = NULL, char *envp[] = NULL);
57 IMPORT_C int Parse(int argc = 0, char *argv[] = NULL, char *envp[] = NULL);
58 IMPORT_C void SetupExit();
59 IMPORT_C int Run();
60 IMPORT_C int ParseAndRun(int argc = 0, char *argv[] = 0, char *envp[] = 0);
61 IMPORT_C void Destruct();
62
63 IMPORT_C PerlInterpreter* GetInterpreter();
64
65 // These two really should be private but when not using PERLIO
66 // certain C callback functions of STDLIB need to be able to call
67 // these. In general, all the console related functionality is
68 // intentionally hidden and underdocumented.
69 int ConsoleRead(const int fd, char* buf, int n);
70 int ConsoleWrite(const int fd, const char* buf, int n);
71
72 // Having these public does not feel right, but maybe someone needs
73 // to do creative things with them.
74 int (*iReadFunc)(const int fd, char *buf, int n);
75 int (*iWriteFunc)(const int fd, const char *buf, int n);
76
77 protected:
78 PerlInterpreter* iPerl;
79#ifdef PERL_GLOBAL_STRUCT
80 struct perl_vars* iVars;
81#else
82 void* iAppCtx;
83#endif
84 TPerlState iState;
85
86 private:
87
88 void ConstructL();
89 CConsoleBase* iConsole; /* The screen. */
90 TUint16* iConsoleBuffer; /* The UTF-16 characters. */
91 TUint iConsoleUsed; /* How many in iConsoleBuffer. */
92 TBool iCloseStdlib; /* Close STDLIB on exit? */
93
94 void (*iStdioInitFunc)(void *);
95 void* iStdioInitCookie;
96
97 int ConsoleReadLine();
98 void StdioRewire(void*);
99};
100
101#define diTHX PerlInterpreter* my_perl = iPerl
102#define diVAR struct perl_vars* my_vars = iVars
103
104#ifdef PERL_GLOBAL_STRUCT
105# define PERL_APPCTX_SET(c) ((c)->iVars->Gappctx = (c))
106#else
107# define PERL_APPCTX_SET(c) (PL_appctx = (c))
108#endif
109
110#undef Copy
111#undef CopyD /* For symmetry, not for Symbian reasons. */
112#undef New
113#define PerlCopy(s,d,n,t) (MEM_WRAP_CHECK(n,t), (void)memcpy((char*)(d),(char*)(s), (n) * sizeof(t)))
114#define PerlCopyD(s,d,n,t) (MEM_WRAP_CHECK(n,t), memcpy((char*)(d),(char*)(s), (n) * sizeof(t)))
115#define PerlNew(x,v,n,t) (v = (MEM_WRAP_CHECK(n,t), (t*)safemalloc((MEM_SIZE)((n)*sizeof(t)))))
116
117#endif /* #ifndef __PerlBase_h__ */
118