| 273 | //----------------------------------------------------------------------------- |
| 274 | |
| 275 | static void exportFunction( const EngineFunctionInfo* function, SimXMLDocument* xml ) |
| 276 | { |
| 277 | if( isExportFiltered( function ) ) |
| 278 | return; |
| 279 | |
| 280 | xml->pushNewElement( "EngineFunction" ); |
| 281 | |
| 282 | xml->setAttribute( "name", function->getExportName() ); |
| 283 | xml->setAttribute( "returnType", getTypeName( function->getReturnType() ) ); |
| 284 | xml->setAttribute( "symbol", function->getBindingName() ); |
| 285 | xml->setAttribute( "isCallback", function->isCallout() ? "1" : "0" ); |
| 286 | xml->setAttribute( "isVariadic", function->getFunctionType()->isVariadic() ? "1" : "0" ); |
| 287 | xml->setAttribute( "docs", getDocString( function ) ); |
| 288 | |
| 289 | xml->pushNewElement( "arguments" ); |
| 290 | |
| 291 | const U32 numArguments = function->getNumArguments(); |
| 292 | const U32 numDefaultArguments = ( function->getDefaultArguments() ? function->getDefaultArguments()->mNumDefaultArgs : 0 ); |
| 293 | const U32 firstDefaultArg = numArguments - numDefaultArguments; |
| 294 | |
| 295 | Vector< String > argumentNames = parseFunctionArgumentNames( function ); |
| 296 | const U32 numArgumentNames = argumentNames.size(); |
| 297 | |
| 298 | // Accumulated offset in function argument frame vector. |
| 299 | U32 argFrameOffset = 0; |
| 300 | |
| 301 | for( U32 i = 0; i < numArguments; ++ i ) |
| 302 | { |
| 303 | xml->pushNewElement( "EngineFunctionArgument" ); |
| 304 | const EngineTypeInfo* type = function->getArgumentType( i ); |
| 305 | AssertFatal( type != NULL, "exportFunction - Argument cannot have type void!" ); |
| 306 | |
| 307 | String argName; |
| 308 | if( i < numArgumentNames ) |
| 309 | argName = argumentNames[ i ]; |
| 310 | |
| 311 | xml->setAttribute( "name", argName ); |
| 312 | xml->setAttribute( "type", getTypeName( type ) ); |
| 313 | |
| 314 | if( i >= firstDefaultArg ) |
| 315 | { |
| 316 | String defaultValue = getDefaultArgumentValue( function, type, argFrameOffset ); |
| 317 | xml->setAttribute( "defaultValue", defaultValue ); |
| 318 | } |
| 319 | |
| 320 | xml->popElement(); |
| 321 | |
| 322 | if( type->getTypeKind() == EngineTypeKindStruct ) |
| 323 | argFrameOffset += type->getInstanceSize(); |
| 324 | else |
| 325 | argFrameOffset += type->getValueSize(); |
| 326 | |
| 327 | #ifdef _PACK_BUG_WORKAROUNDS |
| 328 | if( argFrameOffset % 4 > 0 ) |
| 329 | argFrameOffset += 4 - ( argFrameOffset % 4 ); |
| 330 | #endif |
| 331 | } |
| 332 |
no test coverage detected