1 /* Copyright (c) 2004-2005 Nokia. All rights reserved. */
3 /* The CPerlBase class is licensed under the same terms as Perl itself. */
5 /* See PerlBase.pod for documentation. */
12 #if !defined(PERL_MINIPERL) && !defined(PERL_PERL)
13 # ifndef PERL_IMPLICIT_CONTEXT
14 # define PERL_IMPLICIT_CONTEXT
16 # ifndef PERL_MULTIPLICITY
17 # define PERL_MULTIPLICITY
19 # ifndef PERL_GLOBAL_STRUCT
20 # define PERL_GLOBAL_STRUCT
22 # ifndef PERL_GLOBAL_STRUCT_PRIVATE
23 # define PERL_GLOBAL_STRUCT_PRIVATE
45 class CPerlBase : public CBase
49 IMPORT_C virtual ~CPerlBase();
50 IMPORT_C static CPerlBase* NewInterpreter(TBool aCloseStdlib = ETrue,
51 void (*aStdioInitFunc)(void*) = NULL,
52 void *aStdioInitCookie = NULL);
53 IMPORT_C static CPerlBase* NewInterpreterL(TBool aCloseStdlib = ETrue,
54 void (*aStdioInitFunc)(void*) = NULL,
55 void *aStdioInitCookie = NULL);
56 IMPORT_C static CPerlBase* NewInterpreterLC(TBool iCloseStdlib = ETrue,
57 void (*aStdioInitFunc)(void*) = NULL,
58 void *aStdioInitCookie = NULL);
59 IMPORT_C TInt RunScriptL(const TDesC& aFileName, int argc = 2, char **argv = NULL, char *envp[] = NULL);
60 IMPORT_C int Parse(int argc = 0, char *argv[] = NULL, char *envp[] = NULL);
61 IMPORT_C void SetupExit();
63 IMPORT_C int ParseAndRun(int argc = 0, char *argv[] = 0, char *envp[] = 0);
64 IMPORT_C void Destruct();
66 IMPORT_C PerlInterpreter* GetInterpreter();
68 // These two really should be private but when not using PERLIO
69 // certain C callback functions of STDLIB need to be able to call
70 // these. In general, all the console related functionality is
71 // intentionally hidden and underdocumented.
72 int ConsoleRead(const int fd, char* buf, int n);
73 int ConsoleWrite(const int fd, const char* buf, int n);
75 // Having these public does not feel right, but maybe someone needs
76 // to do creative things with them.
77 int (*iReadFunc)(const int fd, char *buf, int n);
78 int (*iWriteFunc)(const int fd, const char *buf, int n);
81 PerlInterpreter* iPerl;
82 #ifdef PERL_GLOBAL_STRUCT
83 struct perl_vars* iVars;
91 CConsoleBase* iConsole; /* The screen. */
92 TUint16* iConsoleBuffer; /* The UTF-16 characters. */
93 TUint iConsoleUsed; /* How many in iConsoleBuffer. */
94 TBool iCloseStdlib; /* Close STDLIB on exit? */
96 void (*iStdioInitFunc)(void *);
97 void* iStdioInitCookie;
99 int ConsoleReadLine();
100 void StdioRewire(void*);
103 #define diTHX PerlInterpreter* my_perl = iPerl
104 #define diVAR struct perl_vars* my_vars = iVars
106 #ifdef PERL_GLOBAL_STRUCT
107 # define PERL_APPCTX_SET(c) ((c)->iVars->Gappctx = (c))
109 # define PERL_APPCTX_SET(c) (PL_appctx = (c))
113 #undef CopyD /* For symmetry, not for Symbian reasons. */
115 #define PerlCopy(s,d,n,t) (MEM_WRAP_CHECK(n,t), (void)memcpy((char*)(d),(char*)(s), (n) * sizeof(t)))
116 #define PerlCopyD(s,d,n,t) (MEM_WRAP_CHECK(n,t), memcpy((char*)(d),(char*)(s), (n) * sizeof(t)))
117 #define PerlNew(x,v,n,t) (v = (MEM_WRAP_CHECK(n,t), (t*)safemalloc((MEM_SIZE)((n)*sizeof(t)))))
119 // This is like the Symbian _LIT() but without the embedded L prefix,
120 // which enables using #defined constants (which need to carry their
123 # define _LIT_NO_L(n, s) static const TLitC<sizeof(s)/2> n={sizeof(s)/2-1,s}
124 #endif // #ifndef _LIT_NO_L
126 #endif /* #ifndef __PerlBase_h__ */