From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/test__method_8cpp-source.html | 417 +++++++++++++++++++++++++ 1 file changed, 417 insertions(+) create mode 100644 docs/doxygen/nel/test__method_8cpp-source.html (limited to 'docs/doxygen/nel/test__method_8cpp-source.html') diff --git a/docs/doxygen/nel/test__method_8cpp-source.html b/docs/doxygen/nel/test__method_8cpp-source.html new file mode 100644 index 00000000..f19e50da --- /dev/null +++ b/docs/doxygen/nel/test__method_8cpp-source.html @@ -0,0 +1,417 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

test_method.cpp

Go to the documentation of this file.
00001 
+00006 /* Copyright, 2000 Nevrax Ltd.
+00007  *
+00008  * This file is part of NEVRAX NEL.
+00009  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00010  * it under the terms of the GNU General Public License as published by
+00011  * the Free Software Foundation; either version 2, or (at your option)
+00012  * any later version.
+00013 
+00014  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00017  * General Public License for more details.
+00018 
+00019  * You should have received a copy of the GNU General Public License
+00020  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00022  * MA 02111-1307, USA.
+00023  */
+00024 #include <time.h>
+00025 #include "nel/ai/script/compilateur.h"
+00026 #include "nel/ai/script/interpret_object_message.h"
+00027 #include "nel/ai/script/interpret_object_manager.h"
+00028 #include "nel/ai/script/interpret_actor.h"
+00029 #include "nel/ai/script/test_method.h"
+00030 #include "nel/ai/script/type_def.h"
+00031 #include "nel/ai/script/object_unknown.h"
+00032 #include "nel/ai/agent/agent_digital.h"
+00033 
+00034 
+00035 namespace NLAISCRIPT
+00036 {
+00037         CLibTest test;
+00038         const NLAIC::CIdentType CLibTest::IdLibTest = NLAIC::CIdentType("External",
+00039                                                                                                                                         NLAIC::CSelfClassFactory(test),
+00040                                                                                                                                         NLAIC::CTypeOfObject(NLAIC::CTypeOfObject::tObject),NLAIC::CTypeOfOperator(0));
+00041 
+00042         //const char *IsNULL = ;
+00043         CLibTest::CMethodCall **CLibTest::StaticMethod = NULL;
+00044         /*{
+00045                 
+00046 
+00047                 CLibTest::CMethodCall(  _CONSTRUCTOR_,
+00048                                                                 CLibTest::TConst, NULL,
+00049                                                                 CLibTest::CheckCount,
+00050                                                                 0,
+00051                                                                 new CObjectUnknown(new NLAISCRIPT::COperandVoid)),
+00052 
+00053                 CLibTest::CMethodCall(  "IsNotNull", 
+00054                                                                 CLibTest::TIsNULL, NULL,
+00055                                                                 CLibTest::CheckCount,
+00056                                                                 1,
+00057                                                                 new CObjectUnknown(new COperandSimple(new NLAIC::CIdentType(NLAIAGENT::DigitalType::IdDigitalType)))),
+00058 
+00059                 CLibTest::CMethodCall(  "Rand", 
+00060                                                                 CLibTest::TRand1, 
+00061                                                                 new NLAISCRIPT::CParam(1,new NLAISCRIPT::COperandSimpleListOr(2,
+00062                                                                                                                         new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType),
+00063                                                                                                                         new NLAIC::CIdentType(NLAIAGENT::DigitalType::IdDigitalType))),
+00064                                                                 CLibTest::CheckAll,
+00065                                                                 1,
+00066                                                                 new CObjectUnknown(new COperandSimple(new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType)))),
+00067 
+00068                 CLibTest::CMethodCall(  "Rand", 
+00069                                                                 CLibTest::TRand2, 
+00070                                                                 new NLAISCRIPT::CParam(2,new NLAISCRIPT::COperandSimpleListOr(2,
+00071                                                                                                                         new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType),
+00072                                                                                                                         new NLAIC::CIdentType(NLAIAGENT::DigitalType::IdDigitalType)),
+00073                                                                                                                         new NLAISCRIPT::COperandSimpleListOr(2,
+00074                                                                                                                         new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType),
+00075                                                                                                                         new NLAIC::CIdentType(NLAIAGENT::DigitalType::IdDigitalType))),
+00076                                                                 CLibTest::CheckAll,
+00077                                                                 2,
+00078                                                                 new CObjectUnknown(new COperandSimple(new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType))))
+00079         };*/
+00080         void CLibTest::initClass()
+00081         {
+00082                 CLibTest::StaticMethod = new CLibTest::CMethodCall *[CLibTest::TLastM];
+00083 
+00084                 CLibTest::StaticMethod[CLibTest::TConst] = new CLibTest::CMethodCall(   _CONSTRUCTOR_,
+00085                                                                                         CLibTest::TConst, NULL,
+00086                                                                                         CLibTest::CheckCount,
+00087                                                                                         0,
+00088                                                                                         new CObjectUnknown(new NLAISCRIPT::COperandVoid));
+00089 
+00090                 CLibTest::StaticMethod[CLibTest::TIsNULL] = new CLibTest::CMethodCall(  
+00091                                                                                                 "IsNotNull", 
+00092                                                                                                 CLibTest::TIsNULL, NULL,
+00093                                                                                                 CLibTest::CheckCount,
+00094                                                                                                 1,
+00095                                                                                                 new CObjectUnknown(new COperandSimple(new NLAIC::CIdentType(NLAIAGENT::DigitalType::IdDigitalType))));
+00096 
+00097                 CLibTest::StaticMethod[CLibTest::TRand1] = new CLibTest::CMethodCall(
+00098                                                                                         "Rand", 
+00099                                                                                         CLibTest::TRand1, 
+00100                                                                                         new NLAISCRIPT::CParam(1,new NLAISCRIPT::COperandSimpleListOr(2,
+00101                                                                                                                                                 new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType),
+00102                                                                                                                                                 new NLAIC::CIdentType(NLAIAGENT::DigitalType::IdDigitalType))),
+00103                                                                                         CLibTest::CheckAll,
+00104                                                                                         1,
+00105                                                                                         new CObjectUnknown(new COperandSimple(new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType))));
+00106 
+00107                 CLibTest::StaticMethod[CLibTest::TRand2] = new CLibTest::CMethodCall(
+00108                                                                                         "Rand", 
+00109                                                                                         CLibTest::TRand2, 
+00110                                                                                         new NLAISCRIPT::CParam(2,new NLAISCRIPT::COperandSimpleListOr(2,
+00111                                                                                                                                                 new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType),
+00112                                                                                                                                                 new NLAIC::CIdentType(NLAIAGENT::DigitalType::IdDigitalType)),
+00113                                                                                                                                                 new NLAISCRIPT::COperandSimpleListOr(2,
+00114                                                                                                                                                 new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType),
+00115                                                                                                                                                 new NLAIC::CIdentType(NLAIAGENT::DigitalType::IdDigitalType))),
+00116                                                                                         CLibTest::CheckAll,
+00117                                                                                         2,
+00118                                                                                         new CObjectUnknown(new COperandSimple(new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType))));
+00119 
+00120                 CLibTest::StaticMethod[CLibTest::TDiscretRand] = new CLibTest::CMethodCall(
+00121                                                                                         "DRand", 
+00122                                                                                         CLibTest::TDiscretRand, 
+00123                                                                                         new NLAISCRIPT::CParam(2,new NLAISCRIPT::COperandSimpleListOr(2,
+00124                                                                                                                                                 new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType),
+00125                                                                                                                                                 new NLAIC::CIdentType(NLAIAGENT::DigitalType::IdDigitalType)),
+00126                                                                                                                                                 new NLAISCRIPT::COperandSimpleListOr(2,
+00127                                                                                                                                                 new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType),
+00128                                                                                                                                                 new NLAIC::CIdentType(NLAIAGENT::DigitalType::IdDigitalType))),
+00129                                                                                         CLibTest::CheckAll,
+00130                                                                                         2,
+00131                                                                                         new CObjectUnknown(new COperandSimple(new NLAIC::CIdentType(NLAIAGENT::DDigitalType::IdDDigitalType))));
+00132 
+00133         }
+00134 
+00135         void CLibTest::releaseClass()
+00136         {
+00137                 int i;
+00138                 for(i = 0; i < CLibTest::TLastM; i++)
+00139                 {
+00140                         delete CLibTest::StaticMethod[i];
+00141                 }
+00142                 delete CLibTest::StaticMethod;
+00143         }
+00144 
+00145 
+00146         CLibTest::CLibTest()
+00147         {       
+00148 
+00149                 //srand(clock());
+00150 
+00151         }
+00152         sint32 CLibTest::isClassInheritedFrom(const NLAIAGENT::IVarName &className) const
+00153         {
+00154                 NLAIAGENT::CStringVarName check((const char *)IdLibTest);
+00155 
+00156                 if(className == check)
+00157                 {
+00158                         return 0;
+00159                 }
+00160                 else return -1;         
+00161         }
+00162 
+00163         NLAIAGENT::tQueue CLibTest::isMember(const NLAIAGENT::IVarName *className,const NLAIAGENT::IVarName *methodName,const NLAIAGENT::IObjectIA &param) const
+00164         {
+00165                 NLAIAGENT::tQueue r;
+00166                 NLAIAGENT::CStringVarName check((const char *)IdLibTest);
+00167 
+00168                 if(className == NULL || *className == check)
+00169                 {
+00170                         sint i;
+00171                         CLibTest::TMethodNumDef index;
+00172                         for(i = 0; i < CLibTest::TLastM; i ++)
+00173                         {
+00174                                 if(CLibTest::StaticMethod[i]->MethodName == *methodName)
+00175                                 {
+00176                                         index = (CLibTest::TMethodNumDef)CLibTest::StaticMethod[i]->Index;
+00177                                         switch(CLibTest::StaticMethod[i]->CheckArgType)
+00178                                         {
+00179                                                 case CLibTest::CheckAll:
+00180                                                 {
+00181                                                         double d = ((NLAISCRIPT::CParam &)*CLibTest::StaticMethod[i]->ArgType).eval((NLAISCRIPT::CParam &)param);
+00182                                                         if(d >= 0.0)
+00183                                                         {                                                                                                                               
+00184                                                                 CLibTest::StaticMethod[i]->ReturnValue->incRef();
+00185                                                                 r.push(NLAIAGENT::CIdMethod((CLibTest::getMethodIndexSize() + CLibTest::StaticMethod[i]->Index),
+00186                                                                                                                         0.0,
+00187                                                                                                                         NULL,
+00188                                                                                                                         CLibTest::StaticMethod[i]->ReturnValue));
+00189                                                                 return r;
+00190                                                         }
+00191                                                 }
+00192                                                 break;
+00193                                                 case CLibTest::CheckCount:
+00194                                                 {
+00195                                                         if(((NLAISCRIPT::CParam &)param).size() == CLibTest::StaticMethod[i]->ArgCount)
+00196                                                         {                                                                                                                               
+00197                                                                 CLibTest::StaticMethod[i]->ReturnValue->incRef();
+00198                                                                 r.push(NLAIAGENT::CIdMethod((CLibTest::getMethodIndexSize() + CLibTest::StaticMethod[i]->Index),
+00199                                                                                                                         0.0,
+00200                                                                                                                         NULL,
+00201                                                                                                                         CLibTest::StaticMethod[i]->ReturnValue ));
+00202                                                                 return r;
+00203                                                         }
+00204                                                 }
+00205                                                 break;
+00206 
+00207                                         case CLibTest::DoNotCheck:
+00208                                                 {                                                                                                               
+00209                                                         CLibTest::StaticMethod[i]->ReturnValue->incRef();
+00210                                                         r.push(NLAIAGENT::CIdMethod((CLibTest::getMethodIndexSize() + CLibTest::StaticMethod[i]->Index),
+00211                                                                                                                 0.0,
+00212                                                                                                                 NULL,
+00213                                                                                                                 CLibTest::StaticMethod[i]->ReturnValue));
+00214                                                         return r;                                               
+00215                                                 }
+00216                                                 break;                                  
+00217                                         }
+00218                                 }
+00219 
+00220                         }                       
+00221                 }
+00222                 return r;
+00223         }               
+00224 
+00225         NLAIAGENT::IObjectIA::CProcessResult CLibTest::runMethodeMember(sint32 heritance, sint32 index, NLAIAGENT::IObjectIA *)
+00226         {
+00227                 return NLAIAGENT::IObjectIA::ProcessRun;
+00228         }
+00229 
+00230         NLAIAGENT::IObjectIA::CProcessResult CLibTest::runMethodeMember(sint32 index,NLAIAGENT::IObjectIA *p)
+00231         {               
+00232                 NLAIAGENT::IObjectIA::CProcessResult r;
+00233 
+00234                 switch(index)
+00235                 {
+00236                 case CLibTest::TIsNULL:
+00237                         {
+00238                                 NLAIAGENT::IObjectIA *param = (NLAIAGENT::IObjectIA *)((NLAIAGENT::IBaseGroupType *)p)->get();
+00239                                 if( ((const NLAIC::CTypeOfObject &)param->getType()) & NLAIC::CTypeOfObject::tNombre)
+00240                                 {                       
+00241                                         param->incRef();
+00242                                         r.Result = param;
+00243                                         return r;
+00244                                 }
+00245                                 else
+00246                                 {
+00247                                         r.Result = new NLAIAGENT::DigitalType(1.0);
+00248                                         return r;
+00249                                 }
+00250                         }
+00251                         break;
+00252                 case CLibTest::TRand1:
+00253                         {
+00254                                 NLAIAGENT::DDigitalType *param = (NLAIAGENT::DDigitalType *)((NLAIAGENT::IBaseGroupType *)p)->get();
+00255                                 r.Result = new NLAIAGENT::DDigitalType(rand(0.0,param->getNumber()));
+00256                                 return r;
+00257                         }                       
+00258 
+00259                 case CLibTest::TRand2:
+00260                         {
+00261                                 NLAIAGENT::CIteratorContener iter = ((NLAIAGENT::IBaseGroupType *)p)->getIterator();
+00262                                 NLAIAGENT::DDigitalType *p1 = (NLAIAGENT::DDigitalType *)(iter ++);
+00263                                 NLAIAGENT::DDigitalType *p2 = (NLAIAGENT::DDigitalType *)(iter ++);
+00264                                 r.Result = new NLAIAGENT::DDigitalType(rand(p1->getNumber(),p2->getNumber()));
+00265                                 return r;
+00266                         }
+00267 
+00268                 case CLibTest::TDiscretRand:
+00269                         {
+00270                                 NLAIAGENT::CIteratorContener iter = ((NLAIAGENT::IBaseGroupType *)p)->getIterator();
+00271                                 NLAIAGENT::DDigitalType *p1 = (NLAIAGENT::DDigitalType *)(iter ++);
+00272                                 NLAIAGENT::DDigitalType *p2 = (NLAIAGENT::DDigitalType *)(iter ++);
+00273                                 r.Result = new NLAIAGENT::DDigitalType((double)dRand((sint)p1->getNumber(), (sint)p2->getNumber()));
+00274                                 return r;
+00275                         }
+00276 /*
+00277                 case TIdle:
+00278                         {
+00279                                 r.ResultState =  NLAIAGENT::processIdle;
+00280                                 r.Result = new NLAIAGENT::DigitalType( CEntityState::Idle );
+00281                         }
+00282                         break;
+00283 
+00284                 case TWalk:
+00285                         {
+00286                                 r.ResultState =  NLAIAGENT::processIdle;
+00287                                 r.Result = new NLAIAGENT::DigitalType( CEntityState::Idle );
+00288                         }
+00289                         break;
+00290 
+00291                 case TYes:
+00292                         {
+00293                                 r.ResultState =  NLAIAGENT::processIdle;
+00294                                 r.Result = new NLAIAGENT::DigitalType( CEntityState::Idle );
+00295                         }
+00296                         break;
+00297 
+00298                 case TNo:
+00299                         {
+00300                                 r.ResultState =  NLAIAGENT::processIdle;
+00301                                 r.Result = new NLAIAGENT::DigitalType( CEntityState::Idle );
+00302                         }
+00303                         break;
+00304 
+00305                 case TWave:
+00306                         {
+00307                                 r.ResultState =  NLAIAGENT::processIdle;
+00308                                 r.Result = new NLAIAGENT::DigitalType( CEntityState::Idle );
+00309                         }
+00310                         break;
+00311 
+00312                 case TBow:
+00313                         {
+00314                                 r.ResultState =  NLAIAGENT::processIdle;
+00315                                 r.Result = new NLAIAGENT::DigitalType( CEntityState::Idle );
+00316                         }
+00317                         break;
+00318                         */
+00319                 }
+00320                 return r;
+00321         }
+00322 
+00323         double CLibTest::rand(double d1, double d2) const
+00324         {
+00325                 double r = ((double)::rand() - (((double)RAND_MAX)/2));
+00326 
+00327                 r /= ((double)RAND_MAX);
+00328 
+00329                 return d1 + r*(d2 - d1);
+00330 
+00331         }
+00332 
+00333         sint CLibTest::dRand(sint d1, sint d2) const
+00334         {
+00335                 //srand((sint16)clock() );
+00336                 sint ra = ::rand();
+00337                 sint d = (d2 - d1);
+00338                 if(d < 0) d = -d;
+00339                 if(!d) d = 1;
+00340                 sint r = d1 + (ra%d);
+00341 
+00342                 return r;
+00343 
+00344         }
+00345 
+00346 }
+00347 
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1