00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "nel/ai/script/compilateur.h"
00025 #include "nel/ai/script/interpret_object_message.h"
00026 #include "nel/ai/script/interpret_object_manager.h"
00027 #include "nel/ai/script/interpret_actor.h"
00028 #include "nel/ai/logic/interpret_object_operator.h"
00029 #include "nel/ai/script/libcode.h"
00030 #include "nel/ai/script/test_method.h"
00031 #include "nel/ai/script/type_def.h"
00032 #include "nel/ai/script/object_unknown.h"
00033
00034
00035 namespace NLAISCRIPT
00036 {
00037 const NLAIC::CIdentType CCallPrint::IdCallPrint = NLAIC::CIdentType( "Print",
00038 NLAIC::CSelfClassFactory(CCallPrint()),
00039 NLAIC::CTypeOfObject(NLAIC::CTypeOfObject::tObject),NLAIC::CTypeOfOperator(0));
00040
00041 NLAIC::IIO *CCallPrint::inputOutput = NULL;
00042
00043 NLAIAGENT::tQueue CCallPrint::isMember(const NLAIAGENT::IVarName *className,const NLAIAGENT::IVarName *mathodName,const NLAIAGENT::IObjectIA &p) const
00044 {
00045 NLAIAGENT::CStringVarName print((const char *)IdCallPrint);
00046 NLAIAGENT::CStringVarName format("Format");
00047 NLAIAGENT::CStringVarName constructor(_CONSTRUCTOR_);
00048 NLAIAGENT::tQueue m;
00049
00050 CParam param;
00051
00052
00053 if(className != NULL)
00054 {
00055 if(*className == print)
00056 {
00057 if(*mathodName == format)
00058 {
00059 NLAISCRIPT::COperandSimple typeR(new NLAIC::CIdentType(NLAIAGENT::CStringType::IdStringType));
00060 NLAISCRIPT::CObjectUnknown *t = new NLAISCRIPT::CObjectUnknown((NLAISCRIPT::IOpType *)typeR.clone());
00061 m.push(NLAIAGENT::CIdMethod(2,0.0,NULL,t));
00062 }
00063 else
00064 if(*mathodName == print)
00065 {
00066 NLAISCRIPT::COperandVoid typeR;
00067 NLAISCRIPT::CObjectUnknown *t = new NLAISCRIPT::CObjectUnknown((NLAISCRIPT::IOpType *)typeR.clone());
00068 m.push(NLAIAGENT::CIdMethod(0,0.0,NULL,t));
00069 }
00070 else
00071 if(*mathodName == constructor && p == param)
00072 {
00073 NLAISCRIPT::COperandVoid typeR;
00074 NLAISCRIPT::CObjectUnknown *t = new NLAISCRIPT::CObjectUnknown((NLAISCRIPT::IOpType *)typeR.clone());
00075 m.push(NLAIAGENT::CIdMethod(1,0.0,NULL,t));
00076 }
00077 }
00078 }
00079 else
00080 {
00081 if(*mathodName == format)
00082 {
00083 NLAISCRIPT::COperandSimple typeR(new NLAIC::CIdentType(NLAIAGENT::CStringType::IdStringType));
00084 NLAISCRIPT::CObjectUnknown *t = new NLAISCRIPT::CObjectUnknown((NLAISCRIPT::IOpType *)typeR.clone());
00085 m.push(NLAIAGENT::CIdMethod(2,0.0,NULL,t));
00086 }
00087 else
00088 if(*mathodName == print)
00089 {
00090 NLAISCRIPT::COperandVoid typeR;
00091 NLAISCRIPT::CObjectUnknown *t = new NLAISCRIPT::CObjectUnknown((NLAISCRIPT::IOpType *)typeR.clone());
00092 m.push(NLAIAGENT::CIdMethod(0,0.0,NULL,t));
00093 }
00094 else
00095 if(*mathodName == constructor && p == param)
00096 {
00097 NLAISCRIPT::COperandVoid typeR;
00098 NLAISCRIPT::CObjectUnknown *t = new NLAISCRIPT::CObjectUnknown((NLAISCRIPT::IOpType *)typeR.clone());
00099 m.push(NLAIAGENT::CIdMethod(1,0.0,NULL,t));
00100 }
00101 }
00102 return m;
00103 }
00104
00105 NLAIAGENT::IObjectIA::CProcessResult CCallPrint::format(const NLAIAGENT::IBaseGroupType *g)
00106 {
00107 NLAIAGENT::CStringVarName str("");
00108 NLAIAGENT::CConstIteratorContener i = g->getConstIterator();
00109 while(!i.isInEnd())
00110 {
00111 std::string temp;
00112 (i++)->getDebugString(temp);
00113 str += NLAIAGENT::CStringVarName(temp.c_str());
00114 if(!i.isInEnd()) str += NLAIAGENT::CStringVarName(" ");
00115 }
00116
00117 NLAIAGENT::CStringType s(str);
00118 NLAIAGENT::IObjectIA::CProcessResult r;
00119 r.ResultState = NLAIAGENT::processIdle;
00120 r.Result = (NLAIAGENT::IObjectIA *)s.clone();
00121 return r;
00122 }
00123
00124 NLAIAGENT::IObjectIA::CProcessResult CCallPrint::printList(const NLAIAGENT::IBaseGroupType *g)
00125 {
00126 std::string str;
00127 NLAIAGENT::CConstIteratorContener i = g->getConstIterator();
00128
00129 while(!i.isInEnd())
00130 {
00131 std::string temp;
00132 (i++)->getDebugString(temp);
00133 str += temp.c_str();
00134 if(!i.isInEnd()) str += " ";
00135 }
00136
00137 NLAIAGENT::IObjectIA::CProcessResult r;
00138 NLAIC::Out("%s\n",str.c_str());
00139
00140
00141
00142 r.ResultState = NLAIAGENT::processIdle;
00143 r.Result = NULL;
00144 return r;
00145 }
00146
00147 NLAIAGENT::IObjectIA::CProcessResult CCallPrint::runMethodeMember(sint32 heritance, sint32 index, NLAIAGENT::IObjectIA *param)
00148 {
00149 switch(heritance)
00150 {
00151 case 1:
00152 return runMethodeMember(index,param);
00153 break;
00154 }
00155 NLAIAGENT::IObjectIA::CProcessResult r;
00156 r.ResultState = NLAIAGENT::processIdle;
00157 r.Result = NULL;
00158 return r;
00159 }
00160
00161 NLAIAGENT::IObjectIA::CProcessResult CCallPrint::runMethodeMember(sint32 index,NLAIAGENT::IObjectIA *param)
00162 {
00163 NLAIAGENT::IObjectIA::CProcessResult r;
00164 r.ResultState = NLAIAGENT::processIdle;
00165 r.Result = NULL;
00166 switch(index)
00167 {
00168 case 0:
00169 return printList((const NLAIAGENT::IBaseGroupType *)param);
00170 case 1:
00171 return r;
00172 case 2:
00173 return format((const NLAIAGENT::IBaseGroupType *)param);
00174 break;
00175 }
00176 return r;
00177 }
00178
00179 }