Fixed type inference for nulls in console functions

This commit is contained in:
Thomas "elfprince13" Dickerson 2017-01-06 14:50:41 -05:00
parent 733fd3ef6d
commit 88106f9032
17 changed files with 29 additions and 22 deletions

View file

@ -1317,7 +1317,7 @@ bool AIPlayer::checkInLos(GameBase* target, bool _useMuzzle, bool _checkEnabled)
return hit;
}
DefineEngineMethod(AIPlayer, checkInLos, bool, (ShapeBase* obj, bool useMuzzle, bool checkEnabled),(NULL, false, false),
DefineEngineMethod(AIPlayer, checkInLos, bool, (ShapeBase* obj, bool useMuzzle, bool checkEnabled),(nullAsType<ShapeBase*>(), false, false),
"@brief Check whether an object is in line of sight.\n"
"@obj Object to check. (If blank, it will check the current target).\n"
"@useMuzzle Use muzzle position. Otherwise use eye position. (defaults to false).\n"
@ -1366,7 +1366,7 @@ bool AIPlayer::checkInFoV(GameBase* target, F32 camFov, bool _checkEnabled)
return (dot > mCos(camFov));
}
DefineEngineMethod(AIPlayer, checkInFoV, bool, (ShapeBase* obj, F32 fov, bool checkEnabled), (NULL, 45.0f, false),
DefineEngineMethod(AIPlayer, checkInFoV, bool, (ShapeBase* obj, F32 fov, bool checkEnabled), (nullAsType<ShapeBase*>(), 45.0f, false),
"@brief Check whether an object is within a specified veiw cone.\n"
"@obj Object to check. (If blank, it will check the current target).\n"
"@fov view angle in degrees.(Defaults to 45)\n"
@ -1440,7 +1440,7 @@ F32 AIPlayer::getTargetDistance(GameBase* target, bool _checkEnabled)
return (getPosition() - target->getPosition()).len();
}
DefineEngineMethod(AIPlayer, getTargetDistance, F32, (ShapeBase* obj, bool checkEnabled), (NULL, false),
DefineEngineMethod(AIPlayer, getTargetDistance, F32, (ShapeBase* obj, bool checkEnabled), (nullAsType<ShapeBase*>(), false),
"@brief The distance to a given object.\n"
"@obj Object to check. (If blank, it will check the current target).\n"
"@checkEnabled check whether the object can take damage and if so is still alive.(Defaults to false)\n")

View file

@ -395,7 +395,7 @@ void ParticleEmitterNode::setEmitterDataBlock(ParticleEmitterData* data)
}
DefineEngineMethod(ParticleEmitterNode, setEmitterDataBlock, void, (ParticleEmitterData* emitterDatablock), (NULL),
DefineEngineMethod(ParticleEmitterNode, setEmitterDataBlock, void, (ParticleEmitterData* emitterDatablock), (nullAsType<ParticleEmitterData*>()),
"Assigns the datablock for this emitter node.\n"
"@param emitterDatablock ParticleEmitterData datablock to assign\n"
"@tsexample\n"

View file

@ -39,7 +39,6 @@ ConsoleDocClass( RibbonNodeData,
ConsoleDocClass( RibbonNode, ""
);
//-----------------------------------------------------------------------------
// RibbonNodeData
//-----------------------------------------------------------------------------
@ -299,7 +298,7 @@ void RibbonNode::setRibbonDatablock(RibbonData* data)
mRibbonDatablock = data;
}
DefineEngineMethod(RibbonNode, setRibbonDatablock, void, (RibbonData* ribbonDatablock), (0),
DefineEngineMethod(RibbonNode, setRibbonDatablock, void, (RibbonData* ribbonDatablock), (nullAsType<RibbonData*>()),
"Assigns the datablock for this ribbon node.\n"
"@param ribbonDatablock RibbonData datablock to assign\n"
"@tsexample\n"

View file

@ -1256,7 +1256,7 @@ DefineEngineMethod( TSStatic, getTargetCount, S32,(),,
// This method is able to change materials per map to with others. The material that is being replaced is being mapped to
// unmapped_mat as a part of this transition
DefineEngineMethod( TSStatic, changeMaterial, void, ( const char* mapTo, Material* oldMat, Material* newMat ),("",NULL,NULL),
DefineEngineMethod( TSStatic, changeMaterial, void, ( const char* mapTo, Material* oldMat, Material* newMat ),("",nullAsType<Material*>(),nullAsType<Material*>()),
"@brief Change one of the materials on the shape.\n\n"
"This method changes materials per mapTo with others. The material that "
@ -1323,4 +1323,4 @@ DefineEngineMethod( TSStatic, getModelFile, const char *, (),,
)
{
return object->getShapeFileName();
}
}

View file

@ -254,7 +254,7 @@ DefineEngineFunction(addBadWord, bool, (const char* badWord),,
return gBadWordFilter->addBadWord(badWord);
}
DefineEngineFunction(filterString, const char *, (const char* baseString, const char* replacementChars), (NULL, NULL),
DefineEngineFunction(filterString, const char *, (const char* baseString, const char* replacementChars), (nullAsType<const char*>(), nullAsType<const char*>()),
"@brief Replaces the characters in a string with designated text\n\n"
"Uses the bad word filter to determine which characters within the string will be replaced.\n\n"

View file

@ -39,6 +39,7 @@
#include "console/engineStructs.h"
#endif
template<typename T> constexpr T nullAsType(){ return nullptr; }
/// @file
/// Legacy TS-based console type definitions.

View file

@ -547,9 +547,12 @@ namespace engineAPI{
template<size_t index, size_t method_offset = 0, typename ...RealArgTs>
static IthArgType<index> getRealArgValue(S32 argc, ConsoleValueRef *argv, const _EngineFunctionDefaultArguments< void(RealArgTs...) >& defaultArgs)
{
return (startArgc + index) < argc
? EngineUnmarshallData< IthArgType<index> >()( argv[ startArgc + index ] )
: std::get<index + method_offset>(defaultArgs.mArgs);
if((startArgc + index) < argc)
{
return EngineUnmarshallData< IthArgType<index> >()( argv[ startArgc + index ] );
} else {
return std::get<index + method_offset>(defaultArgs.mArgs);
}
}
template<size_t ...I>

View file

@ -23,6 +23,8 @@
#ifndef _ENGINEFUNCTIONS_H_
#define _ENGINEFUNCTIONS_H_
#include <tuple>
#ifndef _ENGINEEXPORTS_H_
#include "console/engineExports.h"
#endif

View file

@ -41,6 +41,8 @@ DECLARE_PRIMITIVE_R(S32);
DECLARE_PRIMITIVE_R(U32);
DECLARE_PRIMITIVE_R(F32);
DECLARE_PRIMITIVE_R(F64);
DECLARE_PRIMITIVE_R(U64);
DECLARE_PRIMITIVE_R(S64);
DECLARE_PRIMITIVE_R(void*);

View file

@ -178,7 +178,7 @@ void GFXShader::_unlinkBuffer( GFXShaderConstBuffer *buf )
DefineEngineFunction( addGlobalShaderMacro, void,
( const char *name, const char *value ), ( NULL ),
( const char *name, const char *value ), ( nullAsType<const char*>() ),
"Adds a global shader macro which will be merged with the script defined "
"macros on every shader. The macro will replace the value of an existing "
"macro of the same name. For the new macro to take effect all the shaders "

View file

@ -340,7 +340,7 @@ DefineEngineFunction( stopVideoCapture, void, (),,
DefineEngineFunction( playJournalToVideo, void,
( const char *journalFile, const char *videoFile, const char *encoder, F32 framerate, Point2I resolution ),
( NULL, "THEORA", 30.0f, Point2I::Zero ),
( nullAsType<const char*>(), "THEORA", 30.0f, Point2I::Zero ),
"Load a journal file and capture it video.\n"
"@ingroup Rendering\n" )
{
@ -357,4 +357,4 @@ DefineEngineFunction( playJournalToVideo, void,
VIDCAP->waitForCanvas();
Journal::Play( journalFile );
}
}

View file

@ -2147,7 +2147,7 @@ ConsoleDocFragment _popDialog2(
"void popDialog();"
);
DefineConsoleMethod( GuiCanvas, popDialog, void, (GuiControl * gui), (NULL), "(GuiControl ctrl=NULL)"
DefineConsoleMethod( GuiCanvas, popDialog, void, (GuiControl * gui), (nullAsType<GuiControl*>()), "(GuiControl ctrl=NULL)"
"@hide")
{
if (gui)

View file

@ -2582,7 +2582,7 @@ DefineConsoleMethod( GuiEditCtrl, moveSelection, void, (S32 dx, S32 dy), , "Move
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, saveSelection, void, (const char * filename), (NULL), "( string fileName=null ) - Save selection to file or clipboard.")
DefineConsoleMethod( GuiEditCtrl, saveSelection, void, (const char * filename), (nullAsType<const char*>()), "( string fileName=null ) - Save selection to file or clipboard.")
{
object->saveSelection( filename );
@ -2590,7 +2590,7 @@ DefineConsoleMethod( GuiEditCtrl, saveSelection, void, (const char * filename),
//-----------------------------------------------------------------------------
DefineConsoleMethod( GuiEditCtrl, loadSelection, void, (const char * filename), (NULL), "( string fileName=null ) - Load selection from file or clipboard.")
DefineConsoleMethod( GuiEditCtrl, loadSelection, void, (const char * filename), (nullAsType<const char*>()), "( string fileName=null ) - Load selection from file or clipboard.")
{
object->loadSelection( filename );

View file

@ -216,7 +216,7 @@ DefineEngineMethod(GuiMenuBar, addMenu, void, (const char* menuText, S32 menuId)
}
DefineEngineMethod(GuiMenuBar, addMenuItem, void, (const char* targetMenu, const char* menuItemText, S32 menuItemId, const char* accelerator, int checkGroup, const char *cmd),
("","",0,NULL,-1,""),
("","",0,nullAsType<const char*>(),-1,""),
"@brief Adds a menu item to the specified menu. The menu argument can be either the text of a menu or its id.\n\n"
"@param menu Menu name or menu Id to add the new item to.\n"
"@param menuItemText Text for the new menu item.\n"

View file

@ -442,7 +442,7 @@ DefineEngineFunction( setLightManager, bool, ( const char *name ),,
return gClientSceneGraph->setLightManager( name );
}
DefineEngineFunction( lightScene, bool, ( const char *completeCallbackFn, const char *mode ), ( NULL, NULL ),
DefineEngineFunction( lightScene, bool, ( const char *completeCallbackFn, const char *mode ), ( nullAsType<const char*>(), nullAsType<const char*>() ),
"Will generate static lighting for the scene if supported by the active light manager.\n\n"
"If mode is \"forceAlways\", the lightmaps will be regenerated regardless of whether "
"lighting cache files can be written to. If mode is \"forceWritable\", then the lightmaps "

View file

@ -1602,7 +1602,7 @@ DefineEngineFunction( containerSearchCurrRadiusDist, F32, ( bool useClientContai
//TODO: make RayInfo an API type
DefineEngineFunction( containerRayCast, const char*,
( Point3F start, Point3F end, U32 mask, SceneObject *pExempt, bool useClientContainer ), ( NULL, false ),
( Point3F start, Point3F end, U32 mask, SceneObject *pExempt, bool useClientContainer ), ( nullAsType<SceneObject*>(), false ),
"@brief Cast a ray from start to end, checking for collision against items matching mask.\n\n"
"If pExempt is specified, then it is temporarily excluded from collision checks (For "

View file

@ -1991,7 +1991,7 @@ DefineEngineMethod( ActionMap, unbindObj, bool, ( const char* device, const char
return object->processUnbind( device, action, simObject );
}
DefineEngineMethod( ActionMap, save, void, ( const char* fileName, bool append ), ( NULL, false ),
DefineEngineMethod( ActionMap, save, void, ( const char* fileName, bool append ), ( nullAsType<const char*>(), false ),
"@brief Saves the ActionMap to a file or dumps it to the console.\n\n"
"@param fileName The file path to save the ActionMap to. If a filename is not specified "
" the ActionMap will be dumped to the console.\n"