[nolimips: 121] Split task.hh and task.cc

Index: trunk/ChangeLog from Benoît Perrot <benoit@lrde.epita.fr> * src/task/task.hh, src/task/task.cc: Split in... * src/task/function_task.hh, src/task/function_task.cc, * src/task/libtask.hh: These new files. * src/task/Makefile.am: Distribute new files. * src/task/task-tasks.hh, src/shell/shell-tasks.hh, * src/parse/parse-tasks.hh, src/nolimips-tasks.hh, * src/inst/inst-tasks.hh, src/vm/vm-tasks.hh: Include libtask.hh instead of task/task.hh Test invalid access to memory. Index: trunk/src/task/task.hh --- trunk/src/task/task.hh (revision 120) +++ trunk/src/task/task.hh (revision 121) @@ -72,44 +72,6 @@ deps_type dependencies_; }; - - class FunctionTask : public Task - { - public: - FunctionTask (void (*execute) (void), - const std::string& option, const std::string& module_name, - const std::string& desc, const std::string& deps = ""): - Task (option, module_name, desc, deps), - execute_ (execute) - { - } - - public: - virtual void execute() const; - - private: - void (*execute_) (void); - }; - - -#ifdef NOLIMIPS_CC_ - -# define TASK_MODULE(Name) \ - const char module_name [] = Name; -# define TASK_DECLARE(Option, Desc, Routine, Deps) \ - extern void (Routine) (void); \ - task::FunctionTask task_##Routine (Routine, \ - Option, module_name, \ - Desc, Deps) -#else // !NOLIMIPS_CC_ - -# define TASK_MODULE(Name) -# define TASK_DECLARE(Name, Help, Routine, Dependencies) \ - extern void (Routine) (void) - -#endif // NOLIMIPS_CC_ - } // namespace task #endif // !TASK_TASK_HH - Index: trunk/src/task/task-tasks.hh --- trunk/src/task/task-tasks.hh (revision 120) +++ trunk/src/task/task-tasks.hh (revision 121) @@ -19,7 +19,7 @@ #ifndef TASK_TASK_TASKS_HH # define TASK_TASK_TASKS_HH -# include "task/task.hh" +# include "task/libtask.hh" namespace task { Index: trunk/src/task/function_task.hh --- trunk/src/task/function_task.hh (revision 0) +++ trunk/src/task/function_task.hh (revision 121) @@ -0,0 +1,44 @@ +// +// This file is part of Nolimips, a MIPS simulator with unlimited registers +// Copyright (C) 2004 Akim Demaille <akim@epita.fr> and +// Benoit Perrot <benoit@lrde.epita.fr> +// +// Nolimips is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// Nolimips 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 Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +#ifndef TASK_FUNCTION_TASK_HH +# define TASK_FUNCTION_TASK_HH + +#include "task/task.hh" + +namespace task +{ + + class FunctionTask: public Task + { + public: + FunctionTask(void (*execute) (void), + const std::string& option, const std::string& module_name, + const std::string& desc, const std::string& deps = ""); + + public: + virtual void execute() const; + + private: + void (*execute_) (void); + }; + +} // namespace task + +#endif // !TASK_FUNCTION_TASK_HH Index: trunk/src/task/task.cc --- trunk/src/task/task.cc (revision 120) +++ trunk/src/task/task.cc (revision 121) @@ -71,11 +71,4 @@ // std::cout << "\t" << *i << std::endl; // } - - void - FunctionTask::execute() const - { - execute_(); - } - } // namespace task Index: trunk/src/task/libtask.hh --- trunk/src/task/libtask.hh (revision 0) +++ trunk/src/task/libtask.hh (revision 121) @@ -0,0 +1,43 @@ +// +// This file is part of Nolimips, a MIPS simulator with unlimited registers +// Copyright (C) 2004 Akim Demaille <akim@epita.fr> and +// Benoit Perrot <benoit@lrde.epita.fr> +// +// Nolimips is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// Nolimips 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 Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +#ifndef TASK_LIBTASK_HH +# define TASK_LIBTASK_HH + +# include "task/function_task.hh" + +# ifdef NOLIMIPS_CC_ + +# define TASK_MODULE(Name) \ + const char module_name [] = Name; +# define TASK_DECLARE(Option, Desc, Routine, Deps) \ + extern void (Routine) (void); \ + task::FunctionTask task_##Routine (Routine, \ + Option, module_name, \ + Desc, Deps) +# else // !NOLIMIPS_CC_ + +# define TASK_MODULE(Name) +# define TASK_DECLARE(Name, Help, Routine, Dependencies) \ + extern void (Routine) (void) + +# endif // NOLIMIPS_CC_ + +#endif // !TASK_LIBTASK_HH Index: trunk/src/task/Makefile.am --- trunk/src/task/Makefile.am (revision 120) +++ trunk/src/task/Makefile.am (revision 121) @@ -3,5 +3,7 @@ noinst_LIBRARIES = libtask.a libtask_a_SOURCES = \ task.hh task.cc \ + function_task.hh function_task.cc \ task_register.hh task_register.cc \ + libtask.hh \ task-tasks.hh task-tasks.cc Index: trunk/src/task/function_task.cc --- trunk/src/task/function_task.cc (revision 0) +++ trunk/src/task/function_task.cc (revision 121) @@ -0,0 +1,41 @@ +// +// This file is part of Nolimips, a MIPS simulator with unlimited registers +// Copyright (C) 2004 Akim Demaille <akim@epita.fr> and +// Benoit Perrot <benoit@lrde.epita.fr> +// +// Nolimips is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// Nolimips 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 Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// + +#include "task/function_task.hh" + +namespace task +{ + + FunctionTask::FunctionTask(void (*execute) (void), + const std::string& option, + const std::string& module_name, + const std::string& desc, + const std::string& deps): + Task(option, module_name, desc, deps), + execute_(execute) + {} + + void + FunctionTask::execute() const + { + execute_(); + } + +} // namespace task Index: trunk/src/vm/vm-tasks.hh --- trunk/src/vm/vm-tasks.hh (revision 120) +++ trunk/src/vm/vm-tasks.hh (revision 121) @@ -19,7 +19,7 @@ #ifndef VM_VM_TASKS_HH # define VM_VM_TASKS_HH -# include "task/task.hh" +# include "task/libtask.hh" namespace vm { Index: trunk/src/shell/shell-tasks.hh --- trunk/src/shell/shell-tasks.hh (revision 120) +++ trunk/src/shell/shell-tasks.hh (revision 121) @@ -19,7 +19,7 @@ #ifndef SHELL_SHELL_TASKS_HH # define SHELL_SHELL_TASKS_HH -# include "task/task.hh" +# include "task/libtask.hh" namespace shell { Index: trunk/src/parse/parse-tasks.hh --- trunk/src/parse/parse-tasks.hh (revision 120) +++ trunk/src/parse/parse-tasks.hh (revision 121) @@ -19,7 +19,7 @@ #ifndef PARSE_PARSE_TASKS_HH # define PARSE_PARSE_TASKS_HH -# include "task/task.hh" +# include "task/libtask.hh" namespace inst { class Program; } Index: trunk/src/nolimips-tasks.hh --- trunk/src/nolimips-tasks.hh (revision 120) +++ trunk/src/nolimips-tasks.hh (revision 121) @@ -19,7 +19,7 @@ #ifndef NOLIMIPS_TASKS_HH # define NOLIMIPS_TASKS_HH -# include "task/task.hh" +# include "task/libtask.hh" namespace nolimips { Index: trunk/src/inst/inst-tasks.hh --- trunk/src/inst/inst-tasks.hh (revision 120) +++ trunk/src/inst/inst-tasks.hh (revision 121) @@ -19,7 +19,7 @@ #ifndef INST_INST_TASKS_HH # define INST_INST_TASKS_HH -# include "task/task.hh" +# include "task/libtask.hh" namespace inst {

"Benoît" == Benoît Perrot <benoit@lrde.epita.fr> writes:
Index: trunk/ChangeLog from Benoît Perrot <benoit@lrde.epita.fr>
* src/task/task.hh, src/task/task.cc: Split in... * src/task/function_task.hh, src/task/function_task.cc, * src/task/libtask.hh: These new files. * src/task/Makefile.am: Distribute new files. * src/task/task-tasks.hh, src/shell/shell-tasks.hh, * src/parse/parse-tasks.hh, src/nolimips-tasks.hh, * src/inst/inst-tasks.hh, src/vm/vm-tasks.hh: Include libtask.hh instead of task/task.hh
Are there any differences with tc's?

Akim Demaille <akim@epita.fr> writes:
"Benoît" == Benoît Perrot <benoit@lrde.epita.fr> writes:
Index: trunk/ChangeLog from Benoît Perrot <benoit@lrde.epita.fr>
* src/task/task.hh, src/task/task.cc: Split in... * src/task/function_task.hh, src/task/function_task.cc, * src/task/libtask.hh: These new files. * src/task/Makefile.am: Distribute new files. * src/task/task-tasks.hh, src/shell/shell-tasks.hh, * src/parse/parse-tasks.hh, src/nolimips-tasks.hh, * src/inst/inst-tasks.hh, src/vm/vm-tasks.hh: Include libtask.hh instead of task/task.hh
Are there any differences with tc's?
No -- formals order, may be. I put a "shared copyright" to your name and mine on most of these files (as I did for misc's files); if you want me to explicitely refer to TC, let me know, I would be pleased to do it. -- Noe

"Benoît" == Benoît Perrot <benoit@lrde.epita.fr> writes:
Are there any differences with tc's?
No -- formals order, may be.
I put a "shared copyright" to your name and mine on most of these files (as I did for misc's files); if you want me to explicitely refer to TC, let me know, I would be pleased to do it.
I would like to have Tasks portable to other projects, so I'm interested in knowing if there are actual differences.

Akim Demaille <akim@epita.fr> writes:
I would like to have Tasks portable to other projects, so I'm interested in knowing if there are actual differences.
The main true difference between TC's and Nolimips' tasks systems is that TC's relies on argp (using char*) whereas Nolimips uses its own command line parser (autonomous, implemented with std::string). ... You will respond me that the Task system might benefit from argp's subparsers :) (Damn! :) While talking about the tasks: I am planning to move each \(.*\)-tasks.* files from their directories to the source root, to make each module/library... ah... "pure" (no!! don't kill me, Yann! :) What do you think about that? Do you see anything against it? -- Noe

"Benoît" == Benoît Perrot <benoit@lrde.epita.fr> writes:
While talking about the tasks: I am planning to move each \(.*\)-tasks.* files from their directories to the source root, to make each module/library... ah... "pure" (no!! don't kill me, Yann! :) What do you think about that? Do you see anything against it?
What's the point? Have you read closely the coding style? http://www.lrde.epita.fr/~akim/compil/assignments.html#File-Conventions

Akim Demaille <akim@epita.fr> writes:
Have you read closely the coding style?
http://www.lrde.epita.fr/~akim/compil/assignments.html#File-Conventions HEUM HEUM :) _Exactly_ :)
<noobMode> Ohhhh THE coding style... [The Force music theme] I think I can remember... [Scrrriitch] ... But!!! Wasn't there a non-sense in it!? </noobMode> See: -- Rule: lib*.*: Pure interface [...] -- Rule: tasks.*: Impure interface and in corresponding Makefile.am: libXXX_a_SOURCES = \ libXXX.hh libXXX.hxx libXXX.cc \ tasks.hh tasks.cc The library libXXX.a (which matches lib*.*) contains the symbols, so the impureness of the Darks Side's tasks.*! So strictly speaking: 1. lib*.* is not the good regexp (yes, it *is* a stupid comment :) 2. lib*.* cannot be used without the task library Here are the points: for the moment, in Nolimips as well as in TC, libraries _are_ impure, and cannot be used without libtask.a. Since I really think that lib*.* is the good regexp for pureness :), I propose to move the tasks.* files from their subdirectories to the source root, so that libraries would be pure and independant from libtask, making the lone impure objects to be {tc,nolimips} executables. Or else? (c) Arf. And now my basquaise chicken is burning :) -- Noe

"Benoît" == Benoît Perrot <benoit@lrde.epita.fr> writes:
The library libXXX.a (which matches lib*.*) contains the symbols, so the impureness of the Darks Side's tasks.*!
This, I agree, is not a nice feature. But it's a better one than having the description of the tasks of a module *outside* the module itself.
So strictly speaking: 1. lib*.* is not the good regexp (yes, it *is* a stupid comment :)
I don't get it.
2. lib*.* cannot be used without the task library
This is different: don't link them into the lib*. This is also something I'd like to tc.
Since I really think that lib*.* is the good regexp for pureness :), I propose to move the tasks.* files from their subdirectories to the source root, so that libraries would be pure and independant from libtask, making the lone impure objects to be {tc,nolimips} executables.
I see no implication here.
participants (2)
-
Akim Demaille
-
Noe