Quellcode durchsuchen

Fixed type inference for nulls in console functions

Thomas "elfprince13" Dickerson vor 8 Jahren
Ursprung
Commit
3f6c269f6a

+ 3 - 3
Engine/source/T3D/aiPlayer.cpp

@@ -1317,7 +1317,7 @@ bool AIPlayer::checkInLos(GameBase* target, bool _useMuzzle, bool _checkEnabled)
    return hit;
    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"
    "@brief Check whether an object is in line of sight.\n"
    "@obj Object to check. (If blank, it will check the current target).\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"
    "@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));
    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"
    "@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"
    "@obj Object to check. (If blank, it will check the current target).\n"
    "@fov view angle in degrees.(Defaults to 45)\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();
    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"
    "@brief The distance to a given object.\n"
    "@obj Object to check. (If blank, it will check the current target).\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")
    "@checkEnabled check whether the object can take damage and if so is still alive.(Defaults to false)\n")

+ 1 - 1
Engine/source/T3D/fx/particleEmitterNode.cpp

@@ -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"
    "Assigns the datablock for this emitter node.\n"
    "@param emitterDatablock ParticleEmitterData datablock to assign\n"
    "@param emitterDatablock ParticleEmitterData datablock to assign\n"
    "@tsexample\n"
    "@tsexample\n"

+ 1 - 2
Engine/source/T3D/fx/ribbonNode.cpp

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

+ 2 - 2
Engine/source/T3D/tsStatic.cpp

@@ -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
 // 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
 // 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"
    "@brief Change one of the materials on the shape.\n\n"
 
 
    "This method changes materials per mapTo with others. The material that "
    "This method changes materials per mapTo with others. The material that "
@@ -1323,4 +1323,4 @@ DefineEngineMethod( TSStatic, getModelFile, const char *, (),,
    )
    )
 {
 {
 	return object->getShapeFileName();
 	return object->getShapeFileName();
-}
+}

+ 1 - 1
Engine/source/app/badWordFilter.cpp

@@ -254,7 +254,7 @@ DefineEngineFunction(addBadWord, bool, (const char* badWord),,
 	return gBadWordFilter->addBadWord(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"
    "@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"
    "Uses the bad word filter to determine which characters within the string will be replaced.\n\n"

+ 1 - 0
Engine/source/console/consoleTypes.h

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

+ 6 - 3
Engine/source/console/engineAPI.h

@@ -547,9 +547,12 @@ namespace engineAPI{
 			template<size_t index, size_t method_offset = 0, typename ...RealArgTs>
 			template<size_t index, size_t method_offset = 0, typename ...RealArgTs>
 			static IthArgType<index> getRealArgValue(S32 argc, ConsoleValueRef *argv, const _EngineFunctionDefaultArguments< void(RealArgTs...) >& defaultArgs)
 			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>
 			template<size_t ...I>

+ 2 - 0
Engine/source/console/engineFunctions.h

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

+ 2 - 0
Engine/source/console/enginePrimitives.h

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

+ 1 - 1
Engine/source/gfx/gfxShader.cpp

@@ -178,7 +178,7 @@ void GFXShader::_unlinkBuffer( GFXShaderConstBuffer *buf )
 
 
 
 
 DefineEngineFunction( addGlobalShaderMacro, void, 
 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 "
    "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 "
    "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 "
    "macro of the same name.  For the new macro to take effect all the shaders "

+ 2 - 2
Engine/source/gfx/video/videoCapture.cpp

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

+ 1 - 1
Engine/source/gui/core/guiCanvas.cpp

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

+ 2 - 2
Engine/source/gui/editor/guiEditCtrl.cpp

@@ -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 );
    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 );
    object->loadSelection( filename );

+ 1 - 1
Engine/source/gui/editor/guiMenuBar.cpp

@@ -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),
 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"
    "@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 menu Menu name or menu Id to add the new item to.\n"
    "@param menuItemText Text for the new menu item.\n"
    "@param menuItemText Text for the new menu item.\n"

+ 1 - 1
Engine/source/lighting/lightManager.cpp

@@ -442,7 +442,7 @@ DefineEngineFunction( setLightManager, bool, ( const char *name ),,
    return gClientSceneGraph->setLightManager( 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"
    "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 "
    "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 "
    "lighting cache files can be written to. If mode is \"forceWritable\", then the lightmaps "

+ 1 - 1
Engine/source/scene/sceneContainer.cpp

@@ -1602,7 +1602,7 @@ DefineEngineFunction( containerSearchCurrRadiusDist, F32, ( bool useClientContai
 
 
 //TODO: make RayInfo an API type
 //TODO: make RayInfo an API type
 DefineEngineFunction( containerRayCast, const char*,
 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"
    "@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 "
    "If pExempt is specified, then it is temporarily excluded from collision checks (For "

+ 1 - 1
Engine/source/sim/actionMap.cpp

@@ -1991,7 +1991,7 @@ DefineEngineMethod( ActionMap, unbindObj, bool, ( const char* device, const char
     return object->processUnbind( device, action, simObject );
     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"
    "@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 "
    "@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"
    " the ActionMap will be dumped to the console.\n"