diff --git a/include/dynamic-graph/#shell-procedure.h# b/include/dynamic-graph/#shell-procedure.h# deleted file mode 100644 index 3f80f0109a1da2b456545a95623c4b99183830ca..0000000000000000000000000000000000000000 --- a/include/dynamic-graph/#shell-procedure.h# +++ /dev/null @@ -1,97 +0,0 @@ -// -*- mode: c++ -*- -// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse, -// JRL, CNRS/AIST. -// -// This file is part of dynamic-graph. -// dynamic-graph is free software: you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License -// as published by the Free Software Foundation, either version 3 of -// the License, or (at your option) any later version. -// -// dynamic-graph is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Lesser Public License for more details. You should have -// received a copy of the GNU Lesser General Public License along with -// dynamic-graph. If not, see <http://www.gnu.org/licenses/>. - -#ifndef DYNAMIC_GRAPH_SHELL_PROCEDURE_H -# define DYNAMIC_GRAPH_SHELL_PROCEDURE_H -# incxlude <string> -# include <map> -# include <sstream> -# include <list> -# include <vector> - -# include <dynamic-graph/exception-factory.h> -# include <dynamic-graph/interpreter.h> -# include <dynamic-graph/config-shell-procedure.hh> - -/// \ingroup dgraph -/// -/// \brief This plugin exposes shell commands relative to the script -/// language constructs such as procedures and for loops. -/// -/// For more information, load the plugin and type help in a shell. -class DG_SHELLPROCEDURE_DLLAPI ShellProcedure -{ - public: - /// \brief Symbolizes a function call in the dynamic-graph language. - struct Instruction - { - /// \brief Command name. - std::string cmd; - /// \brief Arguments lists. - std::vector<std::string> args; - - std::vector<int> params; - }; - - /// \brief Symbolizes a procedure in the dynamic-graph language. - struct Procedure - { - /// \brief Store the procedure body. - std::list<Instruction> instructions; - /// \brief Store the procedure arguments. - std::vector<std::string> params; - - /// \brief Reset the procedure. - void clear () - { - instructions.clear (); - params.clear (); - } - }; - - /// \brief Map procedure name to their body. - typedef std::map<std::string, Procedure> ProcedureList; - - public: - std::string procName; - ProcedureList procedureList; - Procedure currentProc; - - public: - void cmdStartProcedure (const std::string& cmd, - std::istringstream& args, - std::ostream& os); - - void cmdContinueProcedure (const std::string& cmd, - std::istringstream& args, - std::ostream& os); - - void cmdEndProcedure (const std::string& cmd, - std::istringstream& args, - std::ostream& os); - - void cmdProcedure (const std::string& procname, - const std::string& cmd, - std::istringstream& args, - std::ostream& os); - - static void cmdFor (const std::string& cmd, - std::istringstream& args, - std::ostream& os); -}; - -#endif //! DYNAMIC_GRAPH_SHELL_PROCEDURE_H diff --git a/include/dynamic-graph/.#shell-procedure.h b/include/dynamic-graph/.#shell-procedure.h deleted file mode 120000 index 0287ba36e7a1769d634cd17e7ab431d83a0b052d..0000000000000000000000000000000000000000 --- a/include/dynamic-graph/.#shell-procedure.h +++ /dev/null @@ -1 +0,0 @@ -thomas@cleo.16209:1293725997 \ No newline at end of file diff --git a/share/dynamic-graph/script/shell.dg b/share/dynamic-graph/script/shell.dg index 35aed3c3f5a49388bc023310b80c5d060fa438c2..7e106069109399df6757e8f0d25726ad5fd6fa95 100644 --- a/share/dynamic-graph/script/shell.dg +++ b/share/dynamic-graph/script/shell.dg @@ -1,4 +1,4 @@ -import shell-functions +import "shell-functions" # DO NOT MOVE THIS LINE: comments are not implemented before. # Copyright 2010, Thomas Moulard, JRL, CNRS/AIST. @@ -20,4 +20,4 @@ import shell-functions # This file should ALWAYS be imported as it provides core features # such as comments. -import shell-procedure +import "shell-procedure" diff --git a/share/dynamic-graph/script/tracer.dg b/share/dynamic-graph/script/tracer.dg index f47d38734ad3913b80a395f988091904aefe004f..f675315983528657d3b6042431dc3a8b0067167b 100644 --- a/share/dynamic-graph/script/tracer.dg +++ b/share/dynamic-graph/script/tracer.dg @@ -1,4 +1,4 @@ -import shell.dg +import "shell.dg" # Copyright 2010, Thomas Moulard, JRL, CNRS/AIST. # . # This file is part of dynamic-graph. @@ -19,5 +19,5 @@ import shell.dg # The tracer can be used to log signal values without # intefering with the real-time properties of dynamic-graph. -import tracer-real-time -import tracer +import "tracer-real-time" +import "tracer" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 25f51daed0f7405c2796fe3175725209afc1ff79..b5f61b38f3cb100862936e8ec9513a2deb081814 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -62,4 +62,6 @@ DYNAMIC_GRAPH_TEST(custom-entity) DYNAMIC_GRAPH_TEST(factory) DYNAMIC_GRAPH_TEST(pool) DYNAMIC_GRAPH_TEST(signal-time-dependent) -DYNAMIC_GRAPH_TEST(interpreter) \ No newline at end of file + +DYNAMIC_GRAPH_TEST(interpreter) +DYNAMIC_GRAPH_TEST(interpreter-tracer) diff --git a/tests/data/interpreter-tracer.dg b/tests/data/interpreter-tracer.dg new file mode 100644 index 0000000000000000000000000000000000000000..feb47a808f13db12a5b2b057c0c78105727005c0 --- /dev/null +++ b/tests/data/interpreter-tracer.dg @@ -0,0 +1,10 @@ +import "tracer" + +new Tracer tracer +tracer.open /tmp debug.dat +tracer.add tracer.triger +tracer.start +tracer.stop +tracer.clear +tracer.record +tracer.close diff --git a/tests/interpreter-tracer.cpp b/tests/interpreter-tracer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c672b0adc04c9e6dc040ac84b564be72a37583d7 --- /dev/null +++ b/tests/interpreter-tracer.cpp @@ -0,0 +1,51 @@ +// Copyright 2010 Thomas Moulard. +// +// This file is part of dynamic-graph. +// dynamic-graph is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// dynamic-graph is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// You should have received a copy of the GNU Lesser General Public License +// along with dynamic-graph. If not, see <http://www.gnu.org/licenses/>. + +#include <sstream> +#include <dynamic-graph/exception-factory.h> +#include <dynamic-graph/interpreter.h> +#include <dynamic-graph/plugin-loader.h> + +#define BOOST_TEST_MODULE tracer + +#include <boost/test/unit_test.hpp> +#include <boost/test/output_test_stream.hpp> + +#include "interpreter.h" + +using boost::test_tools::output_test_stream; + +// Check that plug-in loading/unloading is working. +BOOST_AUTO_TEST_CASE (cmd_tracer) +{ + dynamicgraph::PluginLoader pl; + dynamicgraph::Interpreter shell (&pl); + + // Push paths. + { + RUN_COMMAND ("pushImportPaths", TESTS_DATADIR); + BOOST_CHECK (output.is_empty ()); + } + { + RUN_COMMAND ("pushImportPaths", TESTS_PLUGINDIR); + BOOST_CHECK (output.is_empty ()); + } + + // Import tracer.dg + { + RUN_COMMAND ("import", "interpreter-tracer.dg"); + BOOST_CHECK (output.is_empty ()); + } +} diff --git a/tests/interpreter.cpp b/tests/interpreter.cpp index 1412cc1b1af412fd740d864c2ff5520797e482ee..4d457f7912638c023a43cc6abb128b3f95e7029c 100644 --- a/tests/interpreter.cpp +++ b/tests/interpreter.cpp @@ -23,6 +23,8 @@ #include <boost/test/unit_test.hpp> #include <boost/test/output_test_stream.hpp> +#include "interpreter.h" + using boost::test_tools::output_test_stream; // This unit test checks the dynamic-graph interpreter @@ -31,23 +33,6 @@ using boost::test_tools::output_test_stream; // It may be split in several tests in the future if this // becomes too big. - -#define RUN_COMMAND(CMD, ARGS) \ - output_test_stream output; \ - std::stringstream ss; \ - std::string cmd = CMD; \ - ss << ARGS; \ - std::istringstream args (ss.str ()); \ - shell.cmd (cmd, args, output) - -#define RUN_COMMAND_NOARG(CMD) \ - output_test_stream output; \ - std::stringstream ss; \ - std::string cmd = CMD; \ - std::istringstream args (ss.str ()); \ - shell.cmd (cmd, args, output) - - // Simple test to check the shell default constructor. BOOST_AUTO_TEST_CASE (constructor) { diff --git a/tests/interpreter.h b/tests/interpreter.h new file mode 100644 index 0000000000000000000000000000000000000000..cd156195065eb5c0e718a9f6c1ae4bca6db26975 --- /dev/null +++ b/tests/interpreter.h @@ -0,0 +1,34 @@ +// Copyright 2010 Thomas Moulard. +// +// This file is part of dynamic-graph. +// dynamic-graph is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// dynamic-graph is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// You should have received a copy of the GNU Lesser General Public License +// along with dynamic-graph. If not, see <http://www.gnu.org/licenses/>. + +#ifndef DYNAMIC_GRAPH_TESTS_INTERPRETER_H +# define DYNAMIC_GRAPH_TESTS_INTERPRETER_H + +# define RUN_COMMAND(CMD, ARGS) \ + output_test_stream output; \ + std::stringstream ss; \ + std::string cmd = CMD; \ + ss << ARGS; \ + std::istringstream args (ss.str ()); \ + shell.cmd (cmd, args, output) + +# define RUN_COMMAND_NOARG(CMD) \ + output_test_stream output; \ + std::stringstream ss; \ + std::string cmd = CMD; \ + std::istringstream args (ss.str ()); \ + shell.cmd (cmd, args, output) + +#endif //! DYNAMIC_GRAPH_TESTS_INTERPRETER_H