MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / exportFunction

Function exportFunction

Engine/source/console/engineXMLExport.cpp:275–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273//-----------------------------------------------------------------------------
274
275static 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

Callers 1

exportScopeFunction · 0.85

Calls 15

isExportFilteredFunction · 0.85
getTypeNameFunction · 0.85
getDocStringFunction · 0.85
getDefaultArgumentValueFunction · 0.85
pushNewElementMethod · 0.80
getExportNameMethod · 0.80
getBindingNameMethod · 0.80
isCalloutMethod · 0.80
getFunctionTypeMethod · 0.80
getDefaultArgumentsMethod · 0.80
getArgumentTypeMethod · 0.80

Tested by

no test coverage detected