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* 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();
60 IMPORT_C int ParseAndRun(int argc = 0, char *argv[] = 0, char *envp[] = 0);
61 IMPORT_C void Destruct();
63 IMPORT_C PerlInterpreter* GetInterpreter();
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);
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);
78 PerlInterpreter* iPerl;
79 #ifdef PERL_GLOBAL_STRUCT
80 struct perl_vars* iVars;
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? */
94 void (*iStdioInitFunc)(void *);
95 void* iStdioInitCookie;
97 int ConsoleReadLine();
98 void StdioRewire(void*);
101 #define diTHX PerlInterpreter* my_perl = iPerl
102 #define diVAR struct perl_vars* my_vars = iVars
104 #ifdef PERL_GLOBAL_STRUCT
105 # define PERL_APPCTX_SET(c) ((c)->iVars->Gappctx = (c))
107 # define PERL_APPCTX_SET(c) (PL_appctx = (c))
111 #undef CopyD /* For symmetry, not for Symbian reasons. */
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)))))
117 #endif /* #ifndef __PerlBase_h__ */