| 302 | //----------------------------------------------------------------------------- |
| 303 | |
| 304 | static void exportFunction(const EngineFunctionInfo* function, SimXMLDocument* xml) |
| 305 | { |
| 306 | if (isExportFiltered(function)) |
| 307 | return; |
| 308 | |
| 309 | xml->pushNewElement("EngineFunction"); |
| 310 | |
| 311 | xml->setAttribute("name", function->getExportName()); |
| 312 | xml->setAttribute("returnType", getTypeName(function->getReturnType())); |
| 313 | xml->setAttribute("symbol", function->getBindingName()); |
| 314 | xml->setAttribute("isCallback", function->isCallout() ? "1" : "0"); |
| 315 | xml->setAttribute("isVariadic", function->getFunctionType()->isVariadic() ? "1" : "0"); |
| 316 | xml->setAttribute("docs", getDocString(function)); |
| 317 | |
| 318 | xml->pushNewElement("arguments"); |
| 319 | |
| 320 | const U32 numArguments = function->getNumArguments(); |
| 321 | const U32 numDefaultArguments = (function->getDefaultArguments() ? function->getDefaultArguments()->mNumDefaultArgs : 0); |
| 322 | const U32 firstDefaultArg = numArguments - numDefaultArguments; |
| 323 | |
| 324 | Vector< String > argumentNames = parseFunctionArgumentNames(function); |
| 325 | const U32 numArgumentNames = argumentNames.size(); |
| 326 | |
| 327 | for (U32 i = 0; i < numArguments; ++i) |
| 328 | { |
| 329 | xml->pushNewElement("EngineFunctionArgument"); |
| 330 | const EngineTypeInfo* type = function->getArgumentType(i); |
| 331 | AssertFatal(type != NULL, "exportFunction - Argument cannot have type void!"); |
| 332 | |
| 333 | String argName; |
| 334 | if (i < numArgumentNames) |
| 335 | argName = argumentNames[i]; |
| 336 | |
| 337 | xml->setAttribute("name", argName); |
| 338 | xml->setAttribute("type", getTypeName(type)); |
| 339 | |
| 340 | if (i >= firstDefaultArg) |
| 341 | { |
| 342 | String defaultValue = getDefaultArgumentValue(function, type, i); |
| 343 | xml->setAttribute("defaultValue", defaultValue); |
| 344 | } |
| 345 | |
| 346 | // A bit hacky, default arguments have all offsets. |
| 347 | if (function->getDefaultArguments() != NULL) |
| 348 | { |
| 349 | xml->setAttribute("offset", String::ToString(function->getDefaultArguments()->mOffsets[i])); |
| 350 | } |
| 351 | |
| 352 | xml->popElement(); |
| 353 | } |
| 354 | |
| 355 | xml->popElement(); |
| 356 | |
| 357 | xml->popElement(); |
| 358 | } |
| 359 | |
| 360 | |
| 361 | //============================================================================= |
no test coverage detected