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

Function exportFunction

Engine/source/console/engineXMLExport.cpp:304–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302//-----------------------------------------------------------------------------
303
304static 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//=============================================================================

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