Properly specify type of console types with a different native type

This commit is contained in:
Lukas Aldershaab 2020-10-18 02:27:01 +02:00
parent 763c205451
commit 9c4191702c
2 changed files with 22 additions and 2 deletions

View file

@ -284,6 +284,26 @@ const EngineTypeInfo* _MAPTYPE() { return TYPE< T >(); }
}; \
ConsoleType ## type gConsoleType ## type ## Instance;
#define ConsoleMappedType( typeName, type, consoleType, nativeType, typePrefix ) \
S32 type; \
class ConsoleType##type : public ConsoleBaseType \
{ \
public: \
typedef nativeType T; \
ConsoleType##type() \
: ConsoleBaseType( sizeof( nativeType ), &type, #type ) \
{ \
mTypeInfo = _MAPTYPE< consoleType >(); \
} \
virtual void setData(void *dptr, S32 argc, const char **argv, const EnumTable *tbl, BitSet32 flag); \
virtual const char *getData(void *dptr, const EnumTable *tbl, BitSet32 flag ); \
virtual const char *getTypeClassName() { return #typeName ; } \
virtual void *getNativeVariable() { T* var = new T; return (void*)var; } \
virtual void deleteNativeVariable(void* var) { T* nativeVar = reinterpret_cast<T*>(var); delete nativeVar; } \
virtual StringTableEntry getTypePrefix( void ) const { return StringTable->insert( typePrefix ); } \
}; \
ConsoleType ## type gConsoleType ## type ## Instance;
#define ImplementConsoleTypeCasters( type, nativeType ) \
const char *castConsoleTypeToString( _ConsoleConstType< nativeType >::ConstType &arg ) { return Con::getData(type, const_cast< nativeType* >( &arg ), 0); } \
bool castConsoleTypeFromString( nativeType &arg, const char *str ) { Con::setData(type, const_cast< nativeType* >( &arg ), 0, 1, &str); return true; } \

View file

@ -376,7 +376,7 @@ ConsoleSetType( TypeMatrixF )
//-----------------------------------------------------------------------------
// TypeMatrixPosition
//-----------------------------------------------------------------------------
ConsoleType(MatrixPosition, TypeMatrixPosition, MatrixF, "")
ConsoleMappedType(MatrixPosition, TypeMatrixPosition, Point3F, MatrixF, "")
ConsoleGetType( TypeMatrixPosition )
{
@ -411,7 +411,7 @@ ConsoleSetType( TypeMatrixPosition )
//-----------------------------------------------------------------------------
// TypeMatrixRotation
//-----------------------------------------------------------------------------
ConsoleType(MatrixRotation, TypeMatrixRotation, MatrixF, "")
ConsoleMappedType(MatrixRotation, TypeMatrixRotation, AngAxisF, MatrixF, "")
ConsoleGetType( TypeMatrixRotation )
{