Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8092 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 1, 2006, 6:15:11 PM (19 years ago)
Author:
bensch
Message:

some exeutors

Location:
branches/script_engine/src/lib
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/lib/gui/gl_gui/signal_connector.cc

    r8048 r8092  
    9292  {
    9393    if (this->isValid())
    94       (*this->exec)(this->object, 0, NULL);
     94    {
     95      static int count = 0;
     96      (*this->exec)(this->object, count, NULL);
     97    }
    9598  }
    9699
     
    102105  {
    103106    if (exec != NULL && object != NULL)
    104       (*this->exec)(this->object, 1, (void*)&value0);
     107    {
     108      static int count = 1;
     109      (*this->exec)(this->object, count, (void*)&value0);
     110    }
    105111  }
    106112
     
    114120    if (exec != NULL && object != NULL)
    115121    {
     122      static int count = 2;
    116123      MultiType mt[] = { value0, value1 };
    117       (*this->exec)(this->object, 2, mt);
     124      (*this->exec)(this->object, count, mt);
    118125    }
    119126  }
     
    129136    if (exec != NULL && object != NULL)
    130137    {
     138      static int count = 3;
    131139      MultiType mt[] = { value0, value1, value2 };
    132       (*this->exec)(this->object, 3, mt);
     140      (*this->exec)(this->object, count, mt);
    133141    }
    134142  }
     
    145153    if (exec != NULL && object != NULL)
    146154    {
     155      static int count = 4;
    147156      MultiType mt[] = { value0, value1, value2, value3 };
    148       (*this->exec)(this->object, 4, mt);
     157      (*this->exec)(this->object, count, mt);
    149158    }
    150159  }
     
    162171    if (exec != NULL && object != NULL)
    163172    {
     173      static int count = 5;
    164174      MultiType mt[] = { value0, value1, value2, value3, value4 };
    165       (*this->exec)(this->object, 5, mt);
     175      (*this->exec)(this->object, count, mt);
    166176    }
    167177  }
  • branches/script_engine/src/lib/script_engine/lunar.h

    r8073 r8092  
    66
    77#include "luaincl.h"
     8#include "executor/executor_lua.h"
    89
    910
  • branches/script_engine/src/lib/util/executor/executor.h

    r8048 r8092  
    5353    // EXECUTE
    5454    /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    55     virtual void operator()(BaseObject* object, unsigned int count, void* values) const = 0;
     55    virtual void operator()(BaseObject* object, int& count, void* values) const = 0;
    5656    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
    5757    virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0;
  • branches/script_engine/src/lib/util/executor/executor_functional.h

    r8048 r8092  
    123123
    124124  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    125   virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     125  virtual void operator()(BaseObject* object, int& count, void* values) const
    126126  {
    127127    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)();
     
    163163
    164164  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    165   virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     165  virtual void operator()(BaseObject* object, int& count, void* values) const
    166166  {
    167167    const MultiType* mt = (const MultiType*)values;
     
    227227
    228228  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    229   virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     229  virtual void operator()(BaseObject* object, int& count, void* values) const
    230230  {
    231231    const MultiType* mt = (const MultiType*)values;
     
    282282
    283283  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    284   virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     284  virtual void operator()(BaseObject* object, int& count, void* values) const
    285285  {
    286286    const MultiType* mt = (const MultiType*)values;
     
    340340
    341341  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    342   virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     342  virtual void operator()(BaseObject* object, int& count, void* values) const
    343343  {
    344344    const MultiType* mt = (const MultiType*)values;
     
    400400
    401401  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    402   virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     402  virtual void operator()(BaseObject* object, int& count, void* values) const
    403403  {
    404404    const MultiType* mt = (const MultiType*)values;
  • branches/script_engine/src/lib/util/executor/executor_lua.cc

    r8057 r8092  
    1818#include "executor_lua.h"
    1919
    20 template<> bool fromLua<bool>(lua_state* state, int index) { return lua_toboolean(state, index); };
    21 template<> int fromLua<int>(lua_state* state, int index) { return (int)lua_toumber(state, index); };
    22 template<> unsigned int fromLua<unsigned int>(lua_state* state, int index) { return (unsigned int)lua_tonumber(state, index); };
    23 template<> float fromLua<float>(lua_state* state, int index) { return (float)lua_tonumber(state, index); };
    24 template<> char fromLua<char>(lua_state* state, int index) { reutnr (char)lua_tonumber(state, index); };
    25 template<> const std::string& fromLua<const std::string&>(lua_state* state, int index) { return lua_tostring(state, index); };
     20template<> bool fromLua<bool>(lua_State* state, int index) { return lua_toboolean(state, index); };
     21template<> int fromLua<int>(lua_State* state, int index) { return (int)lua_toumber(state, index); };
     22template<> unsigned int fromLua<unsigned int>(lua_State* state, int index) { return (unsigned int)lua_tonumber(state, index); };
     23template<> float fromLua<float>(lua_State* state, int index) { return (float)lua_tonumber(state, index); };
     24template<> char fromLua<char>(lua_State* state, int index) { reutnr (char)lua_tonumber(state, index); };
     25template<> const std::string& fromLua<const std::string&>(lua_State* state, int index) { return lua_tostring(state, index); };
    2626
    2727
    2828
    29 template<> void toLua<bool>(lua_state* state, bool value) { lua_pushboolean(state, (int) value); };
    30 template<> void toLua<int>(lua_state* state, int value)  { lua_pushnumber(state, (lua_Number) value); };
    31 template<> void toLua<unsigned int>(lua_state* state, unsigned int value){ lua_pushnumber(state, (lua_Number) value); };
    32 template<> void toLua<float>(lua_state* state, float value) { lua_pushnumber(state, (lua_Number) value); };
    33 template<> void toLua<char>(lua_state* state, char value) { lua_pushnumber(state, (lua_Number) value); };
    34 template<> void toLua<const std::string&>(lua_state* state, const std::string& value) {lua_pushstring (state, value.c_str()); }
     29template<> void toLua<bool>(lua_State* state, bool value) { lua_pushboolean(state, (int) value); };
     30template<> void toLua<int>(lua_State* state, int value)  { lua_pushnumber(state, (lua_Number) value); };
     31template<> void toLua<unsigned int>(lua_State* state, unsigned int value){ lua_pushnumber(state, (lua_Number) value); };
     32template<> void toLua<float>(lua_State* state, float value) { lua_pushnumber(state, (lua_Number) value); };
     33template<> void toLua<char>(lua_State* state, char value) { lua_pushnumber(state, (lua_Number) value); };
     34template<> void toLua<const std::string&>(lua_State* state, const std::string& value) {lua_pushstring (state, value.c_str()); }
  • branches/script_engine/src/lib/util/executor/executor_lua.h

    r8057 r8092  
    99#include "executor.h"
    1010#include "compiler.h"
    11 
     11#include "debug.h"
    1212#include "luaincl.h"
    1313
    1414
    1515
    16 template<typename type> type fromLua(lua_state* state, int index) { PRINTF(1)("NOT IMPLEMENTED\n"); };
    17 template<> bool fromLua<bool>(lua_state* state, int index);
    18 template<> int fromLua<int>(lua_state* state, int index);
    19 template<> unsigned int fromLua<unsigned int>(lua_state* state, int index);
    20 template<> float fromLua<float>(lua_state* state, int index);
    21 template<> char fromLua<char>(lua_state* state, int index);
    22 template<> const std::string& fromLua<const std::string&>(lua_state* state, int index);
    23 
    24 
    25 template<typename type> void toLua(lua_state* state, type value) { PRINTF(1)("NOT IMPLEMENTED\n"); };
    26 template<> void toLua<bool>(lua_state* state, bool value);
    27 template<> void toLua<int>(lua_state* state, int value);
    28 template<> void toLua<unsigned int>(lua_state* state, unsigned int value);
    29 template<> void toLua<float>(lua_state* state, float value);
    30 template<> void toLua<char>(lua_state* state, char value);
    31 template<> void toLua<const std::string&>(lua_state* state, const std::string& value);
     16template<typename type> type fromLua(lua_State* state, int index) { PRINTF(1)("NOT IMPLEMENTED\n"); };
     17template<> bool fromLua<bool>(lua_State* state, int index);
     18template<> int fromLua<int>(lua_State* state, int index);
     19template<> unsigned int fromLua<unsigned int>(lua_State* state, int index);
     20template<> float fromLua<float>(lua_State* state, int index);
     21template<> char fromLua<char>(lua_State* state, int index);
     22template<> const std::string& fromLua<const std::string&>(lua_State* state, int index);
     23
     24
     25template<typename type> void toLua(lua_State* state, type value) { PRINTF(1)("NOT IMPLEMENTED\n"); };
     26template<> void toLua<bool>(lua_State* state, bool value);
     27template<> void toLua<int>(lua_State* state, int value);
     28template<> void toLua<unsigned int>(lua_State* state, unsigned int value);
     29template<> void toLua<float>(lua_State* state, float value);
     30template<> void toLua<char>(lua_State* state, char value);
     31template<> void toLua<const std::string&>(lua_State* state, const std::string& value);
    3232
    3333// FORWARD DECLARATION
     
    3737//// 0 ////
    3838///////////
    39 //! Executes a Function with a lua_state* parameter.
     39//! Executes a Function with a lua_State* parameter.
    4040template<class T> class ExecutorLua0 : public Executor
    4141{
     
    6262    }
    6363
    64     virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     64    virtual void operator()(BaseObject* object, int& count, void* values) const
    6565    {
    6666      (dynamic_cast<T*>(object)->*(functionPointer))();
     67      count = 0;
    6768    }
    6869
     
    7273    virtual Executor* clone () const
    7374    {
    74       return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer));
     75      return new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer));
    7576    }
    7677};
     
    8182//// 1 ////
    8283///////////
    83 //! Executes a Function with a lua_state* parameter.
     84//! Executes a Function with a lua_State* parameter.
    8485template<class T, typename type0> class ExecutorLua1 : public Executor
    8586{
     
    8990     * @param function a Function to call
    9091     */
    91     ExecutorLua0(void(T::*function)(type0))
     92    ExecutorLua1(void(T::*function)(type0))
    9293        : Executor(ExecutorParamType<type0>())
    9394    {
     
    106107    }
    107108
    108     virtual void operator()(BaseObject* object, unsigned int count, void* values) const
    109     {
    110       lua_state* state = (lua_state*)values;
     109    virtual void operator()(BaseObject* object, int& count, void* values) const
     110    {
     111      lua_State* state = (lua_State*)values;
     112      count = 0;
    111113
    112114      (dynamic_cast<T*>(object)->*(functionPointer))(fromLua<type0>(state, 1));
     
    118120    virtual Executor* clone () const
    119121    {
    120       return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer));
     122      return new ExecutorLua1<T, type0>((this->functionPointer));
    121123    }
    122124};
     
    127129//// 2 ////
    128130///////////
    129 //! Executes a Function with a lua_state* parameter.
    130 template<class T, typename type0, typename type1> class ExecutorLua1 : public Executor
    131 {
    132   public:
    133     /**
    134      * @brief Constructor of a ExecutorXML
    135      * @param function a Function to call
    136      */
    137     ExecutorLua0(void(T::*function)(type0, type1))
     131//! Executes a Function with a lua_State* parameter.
     132template<class T, typename type0, typename type1> class ExecutorLua2 : public Executor
     133{
     134  public:
     135    /**
     136     * @brief Constructor of a ExecutorXML
     137     * @param function a Function to call
     138     */
     139    ExecutorLua2(void(T::*function)(type0, type1))
    138140        : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>())
    139141    {
     
    152154    }
    153155
    154     virtual void operator()(BaseObject* object, unsigned int count, void* values) const
    155     {
    156       lua_state* state = (lua_state*)values;
     156    virtual void operator()(BaseObject* object, int& count, void* values) const
     157    {
     158      lua_State* state = (lua_State*)values;
     159      count = 0;
    157160
    158161      (dynamic_cast<T*>(object)->*(functionPointer))(
     
    166169    virtual Executor* clone () const
    167170    {
    168       return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer));
    169     }
    170 };
     171      return new ExecutorLua2<T, type0, type1>(this->functionPointer);
     172    }
     173};
     174
     175
     176
     177
     178
     179
     180
     181////////////////////
     182///// WITH RET /////
     183////////////////////
     184
     185///////////
     186//// 2 ////
     187///////////
     188//! Executes a Function with a lua_State* parameter.
     189template<class T, typename ret, typename type0, typename type1> class ExecutorLua2ret : public Executor
     190{
     191  public:
     192    /**
     193     * @brief Constructor of a ExecutorXML
     194     * @param function a Function to call
     195     */
     196    ExecutorLua2ret(ret (T::*function)(type0, type1))
     197        : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>())
     198    {
     199      this->functionPointer = function;
     200      this->functorType = Executor_Objective | Executor_NoLoadString;
     201    }
     202
     203    /**
     204     * @brief executes the Command on BaseObject
     205     * @param object the BaseObject to execute this Executor on
     206     * @param loadString ignored in this case
     207     */
     208    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     209    {
     210      PRINTF(1)("no usefull executor\n");
     211    }
     212
     213    virtual void operator()(BaseObject* object, int& count, void* values) const
     214    {
     215      lua_State* state = (lua_State*)values;
     216      count = 1;
     217
     218      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     219        fromLua<type0>(state, 1),
     220        fromLua<type1>(state, 2) ));
     221    }
     222
     223    /**
     224     * @returns a _new_ Copy of this Executor
     225     */
     226    virtual Executor* clone () const
     227    {
     228      return new ExecutorLua2ret<T, ret, type0, type1>(this->functionPointer);
     229    }
     230};
     231
     232
     233
     234
    171235
    172236
  • branches/script_engine/src/lib/util/executor/executor_xml.h

    r8051 r8092  
    6565    }
    6666
    67     virtual void operator()(BaseObject* object, unsigned int count, void* values) const
     67    virtual void operator()(BaseObject* object, int& count, void* values) const
    6868    {
    6969      PRINTF(1)("missuse of XML-operator, OR IMPLEMENT.\n");
Note: See TracChangeset for help on using the changeset viewer.