#ifndef Interpreter_First #define Interpreter_First #ifdef __GNUG__ #pragma interface #endif #include "Object.h" class InterpreterImpl; class Interpreter; typedef int (IntCmdProc)(void *clientData, Interpreter *interp, int argc, char *argv[]); //---- Interpreter ------------------------------------------------------------- class Interpreter : public Object { public: MetaDef(Interpreter); Interpreter(const char *name); ~Interpreter(); int Eval(const char *command); void SetResult(const char *str, bool makecopy= TRUE); const char *GetResult(); int InstallCommand(const char *cmdname, IntCmdProc *proc, void *clientdata); int LoadSourceFile(const char *fname); protected: InterpreterImpl *impl; }; //---- InterpreterImpl --------------------------------------------------------- class InterpreterImpl : public Object { public: MetaDef(InterpreterImpl); InterpreterImpl(); ~InterpreterImpl(); Interpreter *GetInterpreter(); void SetInterpreter(Interpreter *ip); virtual int Eval(const char *command); virtual void SetResult(const char *str, bool makecopy= TRUE); virtual const char *GetResult(); virtual int InstallCommand(const char *cmdname, IntCmdProc *proc, void *clientdata); virtual int LoadSourceFile(const char *fname); protected: Interpreter *interp; }; inline Interpreter *InterpreterImpl::GetInterpreter() { return interp; } inline void InterpreterImpl::SetInterpreter(Interpreter *ip) { interp= ip; } //---- inlines ----------------------------------------------------------------- inline int Interpreter::Eval(const char *command) { return impl->Eval(command); } inline void Interpreter::SetResult(const char *str, bool makecopy) { impl->SetResult(str, makecopy); } inline const char *Interpreter::GetResult() { return impl->GetResult(); } inline int Interpreter::InstallCommand(const char *n, IntCmdProc *p, void *d) { return impl->InstallCommand(n, p, d); } inline int Interpreter::LoadSourceFile(const char *fname) { return impl->LoadSourceFile(fname); } #endif