41 bool retVal=
_readData(stackHandle,expectedArguments,requiredArgumentCount,functionName,
"arguments.",
"Argument ",
_inData);
48 bool retVal=
_readData(stackHandle,expectedArguments,requiredArgumentCount,functionName,
"return arguments.",
"Return argument ",
_outData);
73 bool CScriptFunctionData::_readData(
int stack,
const int* expectedArguments,
int requiredArgumentCount,
const char* functionName,
const char* argumentText1,
const char* argumentText2,std::vector<CScriptFunctionDataItem>& inOutData)
77 if (argCnt<requiredArgumentCount)
79 std::ostringstream str;
80 str <<
"Not enough " << argumentText1;
85 for (
int i=0;i<argCnt;i++)
87 if (i>=expectedArguments[0])
97 inOutData.push_back(dat);
102 if (
int(inOutData.size())<requiredArgumentCount)
104 std::ostringstream str;
105 str << argumentText2 << i+1 <<
" is not correct.";
116 if ( (tableSize>=0)!=expectingATable )
118 std::ostringstream str;
119 str << argumentText2 << i+1 <<
" is not correct.";
143 std::ostringstream str;
144 str << argumentText2 << i+1 <<
" is not correct.";
149 if ( (tableSize<expectedArguments[1+i*2+1])&&(expectedArguments[1+i*2+1]!=0) )
151 std::ostringstream str;
152 str << argumentText2 << i+1 <<
" is not correct (wrong table size).";
159 int itemCnt=tableSize;
167 inOutData.push_back(dat);
171 std::vector<bool> vect;
173 for (
int j=0;j<itemCnt;j++)
177 vect.insert(vect.begin(),val!=0);
182 inOutData.push_back(dat);
186 std::vector<int> vect;
189 vect.resize(itemCnt);
193 inOutData.push_back(dat);
197 std::vector<float> vect;
200 vect.resize(itemCnt);
204 inOutData.push_back(dat);
208 std::vector<double> vect;
211 vect.resize(itemCnt);
215 inOutData.push_back(dat);
219 std::vector<std::string> vect;
221 for (
int j=0;j<itemCnt;j++)
225 std::string str2(str);
227 vect.insert(vect.begin(),str2);
232 inOutData.push_back(dat);
236 std::ostringstream str;
237 str << argumentText2 << i+1 <<
" cannot be a table.";
246 bool failedMsgAndLeave=
false;
252 inOutData.push_back(dat);
255 failedMsgAndLeave=
true;
263 inOutData.push_back(dat);
266 failedMsgAndLeave=
true;
274 inOutData.push_back(dat);
277 failedMsgAndLeave=
true;
285 inOutData.push_back(dat);
288 failedMsgAndLeave=
true;
296 inOutData.push_back(dat);
299 failedMsgAndLeave=
true;
307 std::string str2(str);
310 inOutData.push_back(dat);
313 failedMsgAndLeave=
true;
321 if ( (l<expectedArguments[1+i*2+1])&&(expectedArguments[1+i*2+1]!=0) )
324 std::ostringstream str;
325 str << argumentText2 << i+1 <<
" is not correct (wrong buffer size).";
332 inOutData.push_back(dat);
337 failedMsgAndLeave=
true;
339 if (failedMsgAndLeave)
341 std::ostringstream str;
342 str << argumentText2 << i+1 <<
" is not correct.";
357 int itemCnt=int(inOutData.size());
359 for (
int i=0;i<itemCnt;i++)
361 if (inOutData[i].isTable())
363 if (inOutData[i].getType()==-1)
366 for (
int j=0;j<inOutData[i].getNilTableSize();j++)
373 if (inOutData[i].getType()==0)
376 for (
size_t j=0;j<inOutData[i].boolData.size();j++)
383 if (inOutData[i].getType()==1)
385 if (inOutData[i].int32Data.size()>0)
390 if (inOutData[i].getType()==2)
392 if (inOutData[i].floatData.size()>0)
397 if (inOutData[i].getType()==5)
399 if (inOutData[i].doubleData.size()>0)
404 if (inOutData[i].getType()==3)
407 for (
size_t j=0;j<inOutData[i].stringData.size();j++)
410 simPushStringOntoStack(stack,inOutData[i].stringData[j].c_str(),(
int)inOutData[i].stringData[j].length());
417 if (inOutData[i].getType()==-1)
419 if (inOutData[i].getType()==0)
421 if (inOutData[i].getType()==1)
423 if (inOutData[i].getType()==2)
425 if (inOutData[i].getType()==5)
427 if ( (inOutData[i].getType()==3)||(inOutData[i].getType()==4) )
428 simPushStringOntoStack(stack,inOutData[i].stringData[0].c_str(),(
int)inOutData[i].stringData[0].length());
std::vector< CScriptFunctionDataItem > _outData
ptrSimGetStackFloatValue simGetStackFloatValue
ptrSimGetStackFloatTable simGetStackFloatTable
ptrSimPushDoubleTableOntoStack simPushDoubleTableOntoStack
virtual ~CScriptFunctionData()
void _writeData(int stack, std::vector< CScriptFunctionDataItem > &inOutData)
bool readDataFromStack_scriptFunctionCall(int stackHandle, const int *expectedArguments, int requiredArgumentCount, const char *functionName)
std::vector< CScriptFunctionDataItem > * getInDataPtr()
ptrSimGetStackSize simGetStackSize
ptrSimGetStackInt32Value simGetStackInt32Value
#define SIM_SCRIPT_ARG_NULL_ALLOWED
ptrSimGetStackInt32Table simGetStackInt32Table
ptrSimPopStackItem simPopStackItem
std::vector< CScriptFunctionDataItem > * getOutDataPtr_scriptFunctionCall()
ptrSimPushBoolOntoStack simPushBoolOntoStack
void writeDataToStack_scriptFunctionCall(int stackHandle)
void pushOutData_scriptFunctionCall(const CScriptFunctionDataItem &dataItem)
ptrSimMoveStackItemToTop simMoveStackItemToTop
ptrSimPushTableOntoStack simPushTableOntoStack
bool _readData(int stack, const int *expectedArguments, int requiredArgumentCount, const char *functionName, const char *argumentText1, const char *argumentText2, std::vector< CScriptFunctionDataItem > &inOutData)
ptrSimPushFloatOntoStack simPushFloatOntoStack
std::vector< CScriptFunctionDataItem > _inData
ptrSimPushInt32OntoStack simPushInt32OntoStack
ptrSimGetStackBoolValue simGetStackBoolValue
ptrSimReleaseBuffer simReleaseBuffer
ptrSimInsertDataIntoStackTable simInsertDataIntoStackTable
ptrSimGetStackDoubleTable simGetStackDoubleTable
ptrSimGetStackDoubleValue simGetStackDoubleValue
bool readDataFromStack(int stackHandle, const int *expectedArguments, int requiredArgumentCount, const char *functionName)
void setNilTable(int size)
ptrSimGetStackStringValue simGetStackStringValue
ptrSimGetStackTableInfo simGetStackTableInfo
ptrSimPushStringOntoStack simPushStringOntoStack
ptrSimSetLastError simSetLastError
ptrSimPushNullOntoStack simPushNullOntoStack
void pushOutData(const CScriptFunctionDataItem &dataItem)
ptrSimIsStackValueNull simIsStackValueNull
ptrSimPushFloatTableOntoStack simPushFloatTableOntoStack
ptrSimUnfoldStackTable simUnfoldStackTable
void writeDataToStack(int stackHandle)
ptrSimPushInt32TableOntoStack simPushInt32TableOntoStack
ptrSimPushDoubleOntoStack simPushDoubleOntoStack