Changeset 7188
- Timestamp:
- Aug 19, 2010, 1:23:43 PM (14 years ago)
- Location:
- code/branches/consolecommands3/src/libraries/core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands3/src/libraries/core/Executor.h
r7187 r7188 68 68 inline bool hasReturnvalue() const 69 69 { return this->functor_->hasReturnvalue(); } 70 inline Funct ionType::ValuegetType() const70 inline Functor::Type::Enum getType() const 71 71 { return this->functor_->getType(); } 72 72 inline const MultiType& getReturnvalue() const 73 73 { return this->functor_->getReturnvalue(); } 74 inline const std::string&getTypenameParam(unsigned int param) const74 inline std::string getTypenameParam(unsigned int param) const 75 75 { return this->functor_->getTypenameParam(param); } 76 inline const std::string&getTypenameReturnvalue() const76 inline std::string getTypenameReturnvalue() const 77 77 { return this->functor_->getTypenameReturnvalue(); } 78 78 -
code/branches/consolecommands3/src/libraries/core/Functor.h
r7185 r7188 42 42 { 43 43 const unsigned int MAX_FUNCTOR_ARGUMENTS = 5; 44 45 namespace FunctionType46 {47 enum Value48 {49 Member,50 ConstMember,51 Static52 };53 }54 55 44 56 45 template <class T> … … 100 89 { 101 90 public: 91 struct Type 92 { 93 enum Enum 94 { 95 Member, 96 ConstMember, 97 Static, 98 Lua 99 }; 100 }; 101 102 public: 102 103 Functor() {} 103 104 virtual ~Functor() {} … … 105 106 virtual void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0; 106 107 107 inline unsigned int getParamCount() const { return this->numParams_; }108 inline bool hasReturnvalue() const { return this->hasReturnValue_; }109 inline FunctionType::Value getType() const { return this->type_; }110 108 inline const MultiType& getReturnvalue() const { return this->returnedValue_; } 111 109 112 const std::string& getTypenameParam(unsigned int param) const { return (param < 5) ? this->typeParam_[param] : BLANKSTRING; } 113 const std::string& getTypenameReturnvalue() const { return this->typeReturnvalue_; } 110 virtual Type::Enum getType() const = 0; 111 virtual unsigned int getParamCount() const = 0; 112 virtual bool hasReturnvalue() const = 0; 113 114 virtual std::string getTypenameParam(unsigned int param) const = 0; 115 virtual std::string getTypenameReturnvalue() const = 0; 114 116 115 117 virtual void evaluateParam(unsigned int index, MultiType& param) const = 0; … … 121 123 122 124 protected: 123 unsigned int numParams_;124 bool hasReturnValue_;125 FunctionType::Value type_;126 125 MultiType returnedValue_; 127 128 std::string typeReturnvalue_;129 std::string typeParam_[MAX_FUNCTOR_ARGUMENTS];130 126 }; 131 127 … … 286 282 287 283 288 #define FUNCTOR_TYPENAME_PARAMS(numparams) FUNCTOR_TYPENAME_PARAMS##numparams 289 #define FUNCTOR_TYPENAME_PARAMS0 290 #define FUNCTOR_TYPENAME_PARAMS1 this->typeParam_[0] = typeToString<P1>(); 291 #define FUNCTOR_TYPENAME_PARAMS2 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); 292 #define FUNCTOR_TYPENAME_PARAMS3 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); this->typeParam_[2] = typeToString<P3>(); 293 #define FUNCTOR_TYPENAME_PARAMS4 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); this->typeParam_[2] = typeToString<P3>(); this->typeParam_[3] = typeToString<P4>(); 294 #define FUNCTOR_TYPENAME_PARAMS5 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); this->typeParam_[2] = typeToString<P3>(); this->typeParam_[3] = typeToString<P4>(); this->typeParam_[4] = typeToString<P5>(); 284 #define FUNCTOR_TYPENAME_PARAM(numparams) FUNCTOR_TYPENAME_PARAM##numparams 285 #define FUNCTOR_TYPENAME_PARAM0 \ 286 return BLANKSTRING 287 #define FUNCTOR_TYPENAME_PARAM1 \ 288 if (param == 0) { return typeToString<P1>(); } \ 289 else { return BLANKSTRING; } 290 #define FUNCTOR_TYPENAME_PARAM2 \ 291 if (param == 0) { return typeToString<P1>(); } \ 292 else if (param == 1) { return typeToString<P2>(); } \ 293 else { return BLANKSTRING; } 294 #define FUNCTOR_TYPENAME_PARAM3 \ 295 if (param == 0) { return typeToString<P1>(); } \ 296 else if (param == 1) { return typeToString<P2>(); } \ 297 else if (param == 2) { return typeToString<P3>(); } \ 298 else { return BLANKSTRING; } 299 #define FUNCTOR_TYPENAME_PARAM4 \ 300 if (param == 0) { return typeToString<P1>(); } \ 301 else if (param == 1) { return typeToString<P2>(); } \ 302 else if (param == 2) { return typeToString<P3>(); } \ 303 else if (param == 3) { return typeToString<P4>(); } \ 304 else { return BLANKSTRING; } 305 #define FUNCTOR_TYPENAME_PARAM5 \ 306 if (param == 0) { return typeToString<P1>(); } \ 307 else if (param == 1) { return typeToString<P2>(); } \ 308 else if (param == 2) { return typeToString<P3>(); } \ 309 else if (param == 3) { return typeToString<P4>(); } \ 310 else if (param == 4) { return typeToString<P5>(); } \ 311 else { return BLANKSTRING; } 295 312 296 313 #define FUNCTOR_TYPENAME_RETURN(returnvalue) FUNCTOR_TYPENAME_RETURN##returnvalue 297 #define FUNCTOR_TYPENAME_RETURN0 298 #define FUNCTOR_TYPENAME_RETURN1 t his->typeReturnvalue_ = typeToString<R>();314 #define FUNCTOR_TYPENAME_RETURN0 BLANKSTRING 315 #define FUNCTOR_TYPENAME_RETURN1 typeToString<R>() 299 316 300 317 … … 375 392 FunctorStatic##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \ 376 393 { \ 377 this->numParams_ = numparams; \378 this->hasReturnValue_ = returnvalue; \379 this->type_ = FunctionType::Static; \380 394 this->functionPointer_ = functionPointer; \ 381 \382 FUNCTOR_TYPENAME_PARAMS(numparams); \383 FUNCTOR_TYPENAME_RETURN(returnvalue); \384 395 } \ 385 396 \ … … 393 404 FUNCTOR_EVALUATE_PARAM(numparams); \ 394 405 } \ 406 \ 407 Functor::Type::Enum getType() const { return Functor::Type::Static; } \ 408 unsigned int getParamCount() const { return numparams; } \ 409 bool hasReturnvalue() const { return returnvalue; } \ 410 std::string getTypenameParam(unsigned int param) const { FUNCTOR_TYPENAME_PARAM(numparams); } \ 411 std::string getTypenameReturnvalue() const { return FUNCTOR_TYPENAME_RETURN(returnvalue); } \ 395 412 \ 396 413 const std::type_info& getHeaderIdentifier() const \ … … 421 438 FunctorMember##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \ 422 439 { \ 423 this->numParams_ = numparams; \424 this->hasReturnValue_ = returnvalue; \425 this->type_ = FunctionType::Member; \426 440 this->functionPointer_ = functionPointer; \ 427 441 } \ … … 442 456 FUNCTOR_EVALUATE_PARAM(numparams); \ 443 457 } \ 458 \ 459 Functor::Type::Enum getType() const { return Functor::Type::Member; } \ 460 unsigned int getParamCount() const { return numparams; } \ 461 bool hasReturnvalue() const { return returnvalue; } \ 462 std::string getTypenameParam(unsigned int param) const { FUNCTOR_TYPENAME_PARAM(numparams); } \ 463 std::string getTypenameReturnvalue() const { return FUNCTOR_TYPENAME_RETURN(returnvalue); } \ 444 464 \ 445 465 const std::type_info& getHeaderIdentifier() const \ … … 459 479 FunctorConstMember##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \ 460 480 { \ 461 this->numParams_ = numparams; \462 this->hasReturnValue_ = returnvalue; \463 this->type_ = FunctionType::ConstMember; \464 481 this->functionPointer_ = functionPointer; \ 465 482 } \ … … 479 496 FUNCTOR_EVALUATE_PARAM(numparams); \ 480 497 } \ 498 \ 499 Functor::Type::Enum getType() const { return Functor::Type::ConstMember; } \ 500 unsigned int getParamCount() const { return numparams; } \ 501 bool hasReturnvalue() const { return returnvalue; } \ 502 std::string getTypenameParam(unsigned int param) const { FUNCTOR_TYPENAME_PARAM(numparams); } \ 503 std::string getTypenameReturnvalue() const { return FUNCTOR_TYPENAME_RETURN(returnvalue); } \ 481 504 \ 482 505 const std::type_info& getHeaderIdentifier() const \ -
code/branches/consolecommands3/src/libraries/core/LuaState.h
r7179 r7188 54 54 void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null); 55 55 void evaluateParam(unsigned int index, MultiType& param) const {} 56 57 Functor::Type::Enum getType() const { return Functor::Type::Lua; } \ 58 unsigned int getParamCount() const { return 0; } 59 bool hasReturnvalue() const { return 0; } 60 std::string getTypenameParam(unsigned int param) const { return BLANKSTRING; } 61 std::string getTypenameReturnvalue() const { return BLANKSTRING; } 62 56 63 const std::type_info& getHeaderIdentifier() const { return typeid(this); } 57 64
Note: See TracChangeset
for help on using the changeset viewer.