OpenASIP 2.2
Loading...
Searching...
No Matches
TclInterpreter.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file TclInterpreter.hh
26 *
27 * The declaration of TclInterpreter class.
28 *
29 * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30 * @note reviewed 27 May 2004 by pj, jn, vpj, ll
31 * @note rating: yellow
32 */
33
34#ifndef TTA_TCL_INTERPRETER_HH
35#define TTA_TCL_INTERPRETER_HH
36
37#include <string>
38#include <tcl.h>
39
40#include "ScriptInterpreter.hh"
41#include "Exception.hh"
42
43/**
44 * Tcl implementation of ScriptInterpreter.
45 *
46 * Tcl (Tool command language) is a very simple programming language. In TCE
47 * it is used for command language for Simulator. (Maybe for some other
48 * application too.)
49 *
50 * Is able to interpret all tcl commands and user defined CustomCommands.
51 */
53public:
55 virtual ~TclInterpreter();
56
57 virtual void initialize(
58 int argc,
59 char* argv[],
61 LineReader* reader);
62
63 virtual void setVariableToInterpreter(
64 const std::string& name, const DataObject& value);
65 virtual DataObject variable(const std::string& name);
66 virtual bool interpret(const std::string& commandLine);
67 virtual void setResultToInterpreter(const DataObject& value);
68
69 static DataObject tclObjToDataObject(Tcl_Obj* object);
70 static Tcl_Obj* dataObjectToTclObj(const DataObject& object);
71
72 virtual bool processScriptFile(const std::string& scriptFileName);
73
74 static int customCommandRedirector(
75 ClientData cd,
76 Tcl_Interp* interp,
77 int objc,
78 Tcl_Obj *CONST objv[]);
79
80 virtual InterpreterContext& context() const;
81
82protected:
83 virtual void addCustomCommandToInterpreter(const CustomCommand& command);
85 const CustomCommand& command);
86
87private:
88 /// Copying not allowed.
90 /// Assignment not allowed
92
93 /// Context for interpreter.
95 /// Interpreter instance.
96 Tcl_Interp* interpreter_;
97
98};
99
100#endif
virtual InterpreterContext & context() const
static Tcl_Obj * dataObjectToTclObj(const DataObject &object)
static DataObject tclObjToDataObject(Tcl_Obj *object)
virtual void initialize(int argc, char *argv[], InterpreterContext *context, LineReader *reader)
virtual ~TclInterpreter()
virtual void addCustomCommandToInterpreter(const CustomCommand &command)
Tcl_Interp * interpreter_
Interpreter instance.
static int customCommandRedirector(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
InterpreterContext * context_
Context for interpreter.
virtual void setResultToInterpreter(const DataObject &value)
TclInterpreter & operator=(const TclInterpreter &)
Assignment not allowed.
virtual bool processScriptFile(const std::string &scriptFileName)
virtual void setVariableToInterpreter(const std::string &name, const DataObject &value)
virtual bool interpret(const std::string &commandLine)
virtual void removeCustomCommandFromInterpreter(const CustomCommand &command)
virtual DataObject variable(const std::string &name)
TclInterpreter(const TclInterpreter &)
Copying not allowed.