dynamicTypes.h

Engine/source/console/dynamicTypes.h

Support for legacy TorqueScript console types.

More...

Classes:

class

Information about a console type.

Console Type Macros

define
_ConsoleBitfieldType(typeName, type, nativeType)     type; \
   ( type, nativeType ) \
   class BitfieldConsoleType ## type : public  \
   { \
   public: \
      BitfieldConsoleType ## type() \
         : ( sizeof( nativeType ), &type, #type ) \
      { \
         mTypeInfo = < nativeType >(); \
      } \
      virtual  char *getTypeClassName() { return #typeName; } \
      virtual        *getNativeVariable() { return  nativeType; } \
      virtual         deleteNativeVariable(* var) { nativeType* nativeVar = reinterpret_cast< nativeType* >( var ); delete nativeVar; }\
   }; \
   BitfieldConsoleType ## type gConsoleType ## type ## Instance;
define
_ConsoleEnumType(typeName, type, nativeType)     type; \
   ( type, nativeType ) \
   class EnumConsoleType ## type : public  \
   { \
   public: \
      EnumConsoleType ## type() \
         : ( sizeof( nativeType ), &type, #type ) \
      { \
         mTypeInfo = < nativeType >(); \
      } \
      virtual  char *getTypeClassName() { return #typeName; } \
      virtual        *getNativeVariable() { return  nativeType; } \
      virtual         deleteNativeVariable(* var) { nativeType* nativeVar = reinterpret_cast< nativeType* >( var ); delete nativeVar; }\
   }; \
   EnumConsoleType ## type gConsoleType ## type ## Instance;
define
ConsoleGetType(type)     char *##type::getData( *dptr,   *tbl,  flag)
define
ConsoleMappedType(typeName, type, consoleType, nativeType, typePrefix)     type; \
   class ##type : public  \
   { \
   public: \
      typedef nativeType ; \
      ##type() \
         : ( sizeof( nativeType ), &type, #type ) \
      { \
         mTypeInfo = < consoleType >(); \
      } \
      virtual  setData( *dptr,  argc,  char **argv,   *tbl,  flag); \
      virtual  char *getData( *dptr,   *tbl,  flag ); \
      virtual  char *getTypeClassName() { return #typeName ; } \
      virtual        *getNativeVariable() { * var =  ; return (*)var; } \
      virtual         deleteNativeVariable(* var) { * nativeVar = reinterpret_cast<*>(var); delete nativeVar; } \
      virtual  getTypePrefix(  )  { return ->insert( typePrefix ); } \
   }; \
    ## type gConsoleType ## type ## Instance;
define
ConsolePrepType(typeName, type, nativeType)     type; \
   class ##type : public  \
   { \
   public: \
      typedef nativeType ; \
      ##type() \
         : ( sizeof( nativeType ), &type, #type ) \
      { \
         mTypeInfo = < nativeType >(); \
      } \
      virtual  setData( *dptr,  argc,  char **argv,   *tbl,  flag); \
      virtual  char *getData( *dptr,   *tbl,  flag ); \
      virtual  char *getTypeClassName() { return #typeName ; } \
      virtual        *getNativeVariable() { * var =  ; return (*)var; } \
      virtual         deleteNativeVariable(* var) { * nativeVar = reinterpret_cast<*>(var); delete nativeVar; } \
      virtual  char *prepData( char *data, char *buffer,  bufferLen); \
   }; \
    ## type gConsoleType ## type ## Instance;
define
ConsoleProcessData(type)     char *##type::prepData( char *data, char *buffer,  bufferSz)
define
ConsoleSetType(type)     ##type::setData( *dptr,  argc,  char **argv,   *tbl,  flag)
define
ConsoleType(typeName, type, nativeType, typePrefix)     type; \
   class ConsoleType##type : public  \
   { \
   public: \
      typedef nativeType ; \
      ConsoleType##type() \
         : ( sizeof( nativeType ), &type, #type ) \
      { \
         mTypeInfo = < nativeType >(); \
      } \
      virtual  setData( *dptr,  argc,  char **argv,   *tbl,  flag); \
      virtual  char *getData( *dptr,   *tbl,  flag ); \
      virtual  char *getTypeClassName() { return #typeName ; } \
      virtual        *getNativeVariable() { * var =  ; return (*)var; } \
      virtual         deleteNativeVariable(* var) { * nativeVar = reinterpret_cast<*>(var); delete nativeVar; } \
      virtual  getTypePrefix(  )  { return ->insert( typePrefix ); } \
   }; \
   ConsoleType ## type gConsoleType ## type ## Instance;
define
ConsoleTypeFieldPrefix(type, typePrefix)     ##type::getTypePrefix(  )  { return ->insert( typePrefix ); }
define
DefineBitfieldType(type)    ( type ); \
   (  ## type, type );
define
DefineBitfieldType_R(type)    ( type ); \
   (  ## type, type );
define
DefineConsoleType(type, nativeType)    extern  type; \
   extern  char* castConsoleTypeToString( < nativeType >::ConstType &arg ); \
   extern bool castConsoleTypeFromString( nativeType &arg,  char *str ); \
   template<>  < nativeType >();
define
DefineEnumType(type)    ( type ); \
   (  ## type, type );
define
DefineEnumType_R(type)    ( type ); \
   (  ## type, type );
define
DefineUnmappedConsoleType(type, nativeType)    ( type, nativeType ) \
   template<> inline  * < nativeType >() { return ; }
define
ImplementBitfieldType(type, doc)    ( type,  ## type, type ) \
   ( type, type,, doc )
define
ImplementConsoleTypeCasters(type, nativeType)     char *castConsoleTypeToString( < nativeType >::ConstType &arg ) { return (type, const_cast< nativeType* >( &arg ), 0); } \
   bool castConsoleTypeFromString( nativeType &arg,  char *str ) { (type, const_cast< nativeType* >( &arg ), 0, 1, &str); return true; } \
   template<>  < nativeType >() { return type; }
define
ImplementEnumType(type, doc)    ( type,  ## type, type ) \
   ( type, type,, doc )

Public Functions

Return the type ID for the primary console type associated with the given native type.

Detailed Description

Support for legacy TorqueScript console types.

Console Type Macros

_ConsoleBitfieldType(typeName, type, nativeType)     type; \
   ( type, nativeType ) \
   class BitfieldConsoleType ## type : public  \
   { \
   public: \
      BitfieldConsoleType ## type() \
         : ( sizeof( nativeType ), &type, #type ) \
      { \
         mTypeInfo = < nativeType >(); \
      } \
      virtual  char *getTypeClassName() { return #typeName; } \
      virtual        *getNativeVariable() { return  nativeType; } \
      virtual         deleteNativeVariable(* var) { nativeType* nativeVar = reinterpret_cast< nativeType* >( var ); delete nativeVar; }\
   }; \
   BitfieldConsoleType ## type gConsoleType ## type ## Instance;
_ConsoleEnumType(typeName, type, nativeType)     type; \
   ( type, nativeType ) \
   class EnumConsoleType ## type : public  \
   { \
   public: \
      EnumConsoleType ## type() \
         : ( sizeof( nativeType ), &type, #type ) \
      { \
         mTypeInfo = < nativeType >(); \
      } \
      virtual  char *getTypeClassName() { return #typeName; } \
      virtual        *getNativeVariable() { return  nativeType; } \
      virtual         deleteNativeVariable(* var) { nativeType* nativeVar = reinterpret_cast< nativeType* >( var ); delete nativeVar; }\
   }; \
   EnumConsoleType ## type gConsoleType ## type ## Instance;
ConsoleGetType(type)     char *##type::getData( *dptr,   *tbl,  flag)
ConsoleMappedType(typeName, type, consoleType, nativeType, typePrefix)     type; \
   class ##type : public  \
   { \
   public: \
      typedef nativeType ; \
      ##type() \
         : ( sizeof( nativeType ), &type, #type ) \
      { \
         mTypeInfo = < consoleType >(); \
      } \
      virtual  setData( *dptr,  argc,  char **argv,   *tbl,  flag); \
      virtual  char *getData( *dptr,   *tbl,  flag ); \
      virtual  char *getTypeClassName() { return #typeName ; } \
      virtual        *getNativeVariable() { * var =  ; return (*)var; } \
      virtual         deleteNativeVariable(* var) { * nativeVar = reinterpret_cast<*>(var); delete nativeVar; } \
      virtual  getTypePrefix(  )  { return ->insert( typePrefix ); } \
   }; \
    ## type gConsoleType ## type ## Instance;
ConsolePrepType(typeName, type, nativeType)     type; \
   class ##type : public  \
   { \
   public: \
      typedef nativeType ; \
      ##type() \
         : ( sizeof( nativeType ), &type, #type ) \
      { \
         mTypeInfo = < nativeType >(); \
      } \
      virtual  setData( *dptr,  argc,  char **argv,   *tbl,  flag); \
      virtual  char *getData( *dptr,   *tbl,  flag ); \
      virtual  char *getTypeClassName() { return #typeName ; } \
      virtual        *getNativeVariable() { * var =  ; return (*)var; } \
      virtual         deleteNativeVariable(* var) { * nativeVar = reinterpret_cast<*>(var); delete nativeVar; } \
      virtual  char *prepData( char *data, char *buffer,  bufferLen); \
   }; \
    ## type gConsoleType ## type ## Instance;
ConsoleProcessData(type)     char *##type::prepData( char *data, char *buffer,  bufferSz)
ConsoleSetType(type)     ##type::setData( *dptr,  argc,  char **argv,   *tbl,  flag)
ConsoleType(typeName, type, nativeType, typePrefix)     type; \
   class ConsoleType##type : public  \
   { \
   public: \
      typedef nativeType ; \
      ConsoleType##type() \
         : ( sizeof( nativeType ), &type, #type ) \
      { \
         mTypeInfo = < nativeType >(); \
      } \
      virtual  setData( *dptr,  argc,  char **argv,   *tbl,  flag); \
      virtual  char *getData( *dptr,   *tbl,  flag ); \
      virtual  char *getTypeClassName() { return #typeName ; } \
      virtual        *getNativeVariable() { * var =  ; return (*)var; } \
      virtual         deleteNativeVariable(* var) { * nativeVar = reinterpret_cast<*>(var); delete nativeVar; } \
      virtual  getTypePrefix(  )  { return ->insert( typePrefix ); } \
   }; \
   ConsoleType ## type gConsoleType ## type ## Instance;
ConsoleTypeFieldPrefix(type, typePrefix)     ##type::getTypePrefix(  )  { return ->insert( typePrefix ); }
DefineBitfieldType(type)    ( type ); \
   (  ## type, type );
DefineBitfieldType_R(type)    ( type ); \
   (  ## type, type );
DefineConsoleType(type, nativeType)    extern  type; \
   extern  char* castConsoleTypeToString( < nativeType >::ConstType &arg ); \
   extern bool castConsoleTypeFromString( nativeType &arg,  char *str ); \
   template<>  < nativeType >();
DefineEnumType(type)    ( type ); \
   (  ## type, type );
DefineEnumType_R(type)    ( type ); \
   (  ## type, type );
DefineUnmappedConsoleType(type, nativeType)    ( type, nativeType ) \
   template<> inline  * < nativeType >() { return ; }
EndImplementBitfieldType()    
EndImplementEnumType()    
ImplementBitfieldType(type, doc)    ( type,  ## type, type ) \
   ( type, type,, doc )
ImplementConsoleTypeCasters(type, nativeType)     char *castConsoleTypeToString( < nativeType >::ConstType &arg ) { return (type, const_cast< nativeType* >( &arg ), 0); } \
   bool castConsoleTypeFromString( nativeType &arg,  char *str ) { (type, const_cast< nativeType* >( &arg ), 0, 1, &str); return true; } \
   template<>  < nativeType >() { return type; }
ImplementEnumType(type, doc)    ( type,  ## type, type ) \
   ( type, type,, doc )

Public Functions

_MAPTYPE()

TYPEID()

Return the type ID for the primary console type associated with the given native type.

There can only be one console type associated with a C++ type. This is referred to as the primary console type.

return:

The type ID of the primary console type for "T".

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _DYNAMIC_CONSOLETYPES_H_
 25#define _DYNAMIC_CONSOLETYPES_H_
 26
 27#ifndef _CONSOLE_H_
 28#include "console/console.h"
 29#endif
 30
 31#ifndef _STRINGFUNCTIONS_H_
 32#include "core/strings/stringFunctions.h"
 33#endif
 34
 35#ifndef _ENGINETYPEINFO_H_
 36#include "console/engineTypeInfo.h"
 37#endif
 38
 39#ifndef _STRINGTABLE_H_
 40#include "core/stringTable.h"
 41#endif
 42
 43/// @file
 44/// Support for legacy TorqueScript console types.
 45
 46
 47/// Information about a console type.
 48class ConsoleBaseType
 49{
 50   protected:
 51
 52      /// Unique numeric type ID.
 53      S32 mTypeID;
 54            
 55      /// Size of a single data value point.
 56      dsize_t mTypeSize;
 57      
 58      /// Name of this console type (TypeXXX).
 59      StringTableEntry mTypeName;
 60      
 61      /// Name of GuiInspectorField subclass to instantiate for field edit controls in
 62      /// inspectors.
 63      const char* mInspectorFieldType;
 64
 65      /// Next item in the list of all console types.
 66      ConsoleBaseType* mListNext;
 67
 68      /// Type info object for the engine type corresponding to this console type.
 69      /// Since several console types may be mapped to a single native type, this type info
 70      /// instance may be shared by multiple ConsoleBaseType instances.
 71      /// NULL if the console type is not mapped to an engine API type.
 72      const EngineTypeInfo* mTypeInfo;
 73      
 74      /// Total number of defined console types.  This is used to generate unique IDs for each type.
 75      static S32 smConsoleTypeCount;
 76
 77      /// We maintain a linked list of all console types; this is its head.
 78      static ConsoleBaseType* smListHead;
 79
 80      /// The constructor is responsible for linking an element into the
 81      /// master list, registering the type ID, etc.
 82      ConsoleBaseType( const S32 size, S32 *idPtr, const char *aTypeName );
 83
 84      /// Destructor is private to avoid people mucking up the list.
 85      ~ConsoleBaseType() {}
 86 
 87   public:
 88
 89      /// @name cbt_list List Interface
 90      ///
 91      /// Interface for accessing/traversing the list of types.
 92
 93      /// Get the head of the list.
 94      static ConsoleBaseType *getListHead();
 95
 96      /// Get the item that follows this item in the list.
 97      ConsoleBaseType *getListNext() const
 98      {
 99         return mListNext;
100      }
101
102      /// @}
103
104      /// Called once to initialize the console type system.
105      static void initialize();
106
107      /// Call me to get a pointer to a type's info.
108      static ConsoleBaseType *getType( const S32 typeID );
109
110      /// Call to get a pointer to a type's info
111      static ConsoleBaseType *getTypeByName( const char *typeName );
112      static ConsoleBaseType *getTypeByClassName( const char *typeName );
113      
114      /// Return the unique numeric ID of this type.
115      S32 getTypeID() const { return mTypeID; }
116      
117      /// Return the size of a single value in bytes.
118      S32 getTypeSize() const { return mTypeSize; }
119      
120      /// Return the console type name (TypeXXX).
121      StringTableEntry getTypeName() const { return mTypeName; }
122      
123      /// Return the type info for the engine type corresponding to this console type or NULL if
124      /// there is no mapping for the console type.
125      const EngineTypeInfo* getTypeInfo() const { return mTypeInfo; }
126            
127      /// Return the documentation string for this type.
128      const char* getDocString() const { return getTypeInfo() ? getTypeInfo()->getDocString() : ""; }
129      
130      /// Return the EnumTable for this type (only for enumeration types).
131      const EngineEnumTable* getEnumTable() const { return getTypeInfo() ? getTypeInfo()->getEnumTable() : NULL; }
132      
133      /// Return the name of the GuiInspectorField subclass that fields of this
134      /// type should use for editing.
135      const char* getInspectorFieldType() { return mInspectorFieldType; }
136      
137      /// Set the name of the GuiInspectorField subclass that fields of this type
138      /// should use for editing.
139      void setInspectorFieldType( const char* type ) { mInspectorFieldType = type; }
140      
141      /// @name Value Handling Interface
142      /// @{
143
144      virtual void setData( void* dptr, S32 argc, const char** argv, const EnumTable* tbl, BitSet32 flag ) = 0;
145      virtual const char* getData( void* dptr, const EnumTable* tbl, BitSet32 flag ) = 0;
146      virtual const char* getTypeClassName() = 0;
147      
148      /// Allocate a single value.
149      virtual void* getNativeVariable() = 0;
150      
151      /// Delete a single value allocated with getNativeVariable().
152      virtual void deleteNativeVariable(void* var) = 0;
153      
154      /// Return true if this is datablock object type.
155      virtual const bool isDatablock() { return false; };
156      
157      virtual const char* prepData( const char* data, char* buffer, U32 bufferLen ) { return data; };
158
159      virtual StringTableEntry getTypePrefix(void) const { return StringTable->EmptyString(); }
160      
161      /// @}
162};
163
164
165class EnumConsoleBaseType : public ConsoleBaseType
166{
167   public:
168   
169      typedef ConsoleBaseType Parent;
170      
171   protected:
172   
173      EnumConsoleBaseType( S32 size, S32* idPtr, const char* typeName )
174         : Parent( size, idPtr, typeName ) {}
175         
176   public:
177
178      virtual const char* getData(void *dptr, const EnumTable *tbl, BitSet32 flag)
179      {
180         S32 dptrVal = *( S32* ) dptr;
181         if( !tbl ) tbl = getEnumTable();
182         const U32 numEnums = tbl->getNumValues();
183         for( U32 i = 0; i < numEnums; ++ i )
184            if( dptrVal == ( *tbl )[ i ].mInt )
185               return ( *tbl )[ i ].mName;
186         return "";
187      }
188      virtual void setData(void *dptr, S32 argc, const char **argv, const EnumTable *tbl, BitSet32 flag)
189      {
190         if( argc != 1 ) return;
191         if( !tbl ) tbl = getEnumTable();
192         S32 val = 0;
193         const U32 numEnums = tbl->getNumValues();
194         for( U32 i = 0; i < numEnums; ++ i )
195            if( dStricmp( argv[ 0 ], ( *tbl )[ i ].mName ) == 0 )
196            {
197               val = ( *tbl )[ i ].mInt;
198               break;
199            }
200         *( ( S32* ) dptr ) = val;
201      }
202};
203
204
205class BitfieldConsoleBaseType : public ConsoleBaseType
206{
207   public:
208   
209      typedef ConsoleBaseType Parent;
210      
211   protected:
212   
213      BitfieldConsoleBaseType( S32 size, S32* idPtr, const char* typeName )
214         : Parent( size, idPtr, typeName ) {}
215         
216   public:
217
218      virtual const char* getData( void* dptr, const EnumTable*, BitSet32 )
219      {
220         static const U32 bufSize = 256;
221         char* returnBuffer = Con::getReturnBuffer(bufSize);
222         dSprintf(returnBuffer, bufSize, "0x%08x", *((S32 *) dptr) );
223         return returnBuffer;
224      }
225      virtual void setData( void* dptr, S32 argc, const char** argv, const EnumTable*, BitSet32 )
226      {
227         if( argc != 1 ) return; \
228         *((S32 *) dptr) = dAtoui(argv[0],0); \
229      }
230};
231
232
233
234template< typename T >
235struct _ConsoleConstType
236{
237   typedef const T ConstType;
238};
239
240/// Return the type ID for the primary console type associated with the given native type.
241///
242/// There can only be one console type associated with a C++ type.  This is referred to as the primary
243/// console type.
244///
245/// @return The type ID of the primary console type for "T".
246template< typename T >
247S32 TYPEID() { return T::_smTypeId; } // Default assumes a structured type storing its ID in a static member variable.
248
249
250// Helper to allow to override certain mappings.
251template< typename T >
252const EngineTypeInfo* _MAPTYPE() { return TYPE< T >(); }
253
254
255/// @name Console Type Macros
256/// @{
257
258#define DefineConsoleType( type, nativeType ) \
259   extern S32 type; \
260   extern const char* castConsoleTypeToString( _ConsoleConstType< nativeType >::ConstType &arg ); \
261   extern bool castConsoleTypeFromString( nativeType &arg, const char *str ); \
262   template<> S32 TYPEID< nativeType >();
263   
264#define DefineUnmappedConsoleType( type, nativeType ) \
265   DefineConsoleType( type, nativeType ) \
266   template<> inline const EngineTypeInfo* _MAPTYPE< nativeType >() { return NULL; }
267
268#define ConsoleType( typeName, type, nativeType, typePrefix ) \
269   S32 type; \
270   class ConsoleType##type : public ConsoleBaseType \
271   { \
272   public: \
273      typedef nativeType T; \
274      ConsoleType##type() \
275         : ConsoleBaseType( sizeof( nativeType ), &type, #type ) \
276      { \
277         mTypeInfo = _MAPTYPE< nativeType >(); \
278      } \
279      virtual void setData(void *dptr, S32 argc, const char **argv, const EnumTable *tbl, BitSet32 flag); \
280      virtual const char *getData(void *dptr, const EnumTable *tbl, BitSet32 flag ); \
281      virtual const char *getTypeClassName() { return #typeName ; } \
282      virtual void       *getNativeVariable() { T* var = new T; return (void*)var; } \
283      virtual void        deleteNativeVariable(void* var) { T* nativeVar = reinterpret_cast<T*>(var); delete nativeVar; } \
284      virtual StringTableEntry getTypePrefix( void ) const { return StringTable->insert( typePrefix ); } \
285   }; \
286   ConsoleType ## type gConsoleType ## type ## Instance;
287
288#define ConsoleMappedType( typeName, type, consoleType, nativeType, typePrefix ) \
289   S32 type; \
290   class ConsoleType##type : public ConsoleBaseType \
291   { \
292   public: \
293      typedef nativeType T; \
294      ConsoleType##type() \
295         : ConsoleBaseType( sizeof( nativeType ), &type, #type ) \
296      { \
297         mTypeInfo = _MAPTYPE< consoleType >(); \
298      } \
299      virtual void setData(void *dptr, S32 argc, const char **argv, const EnumTable *tbl, BitSet32 flag); \
300      virtual const char *getData(void *dptr, const EnumTable *tbl, BitSet32 flag ); \
301      virtual const char *getTypeClassName() { return #typeName ; } \
302      virtual void       *getNativeVariable() { T* var = new T; return (void*)var; } \
303      virtual void        deleteNativeVariable(void* var) { T* nativeVar = reinterpret_cast<T*>(var); delete nativeVar; } \
304      virtual StringTableEntry getTypePrefix( void ) const { return StringTable->insert( typePrefix ); } \
305   }; \
306   ConsoleType ## type gConsoleType ## type ## Instance;
307
308#define ImplementConsoleTypeCasters( type, nativeType ) \
309   const char *castConsoleTypeToString( _ConsoleConstType< nativeType >::ConstType &arg ) { return Con::getData(type, const_cast< nativeType* >( &arg ), 0); } \
310   bool castConsoleTypeFromString( nativeType &arg, const char *str ) { Con::setData(type, const_cast< nativeType* >( &arg ), 0, 1, &str); return true; } \
311   template<> S32 TYPEID< nativeType >() { return type; }
312
313
314#define ConsolePrepType( typeName, type, nativeType ) \
315   S32 type; \
316   class ConsoleType##type : public ConsoleBaseType \
317   { \
318   public: \
319      typedef nativeType T; \
320      ConsoleType##type() \
321         : ConsoleBaseType( sizeof( nativeType ), &type, #type ) \
322      { \
323         mTypeInfo = _MAPTYPE< nativeType >(); \
324      } \
325      virtual void setData(void *dptr, S32 argc, const char **argv, const EnumTable *tbl, BitSet32 flag); \
326      virtual const char *getData(void *dptr, const EnumTable *tbl, BitSet32 flag ); \
327      virtual const char *getTypeClassName() { return #typeName ; } \
328      virtual void       *getNativeVariable() { T* var = new T; return (void*)var; } \
329      virtual void        deleteNativeVariable(void* var) { T* nativeVar = reinterpret_cast<T*>(var); delete nativeVar; } \
330      virtual const char *prepData(const char *data, char *buffer, U32 bufferLen); \
331   }; \
332   ConsoleType ## type gConsoleType ## type ## Instance;
333
334#define ConsoleTypeFieldPrefix( type, typePrefix ) \
335   StringTableEntry ConsoleType##type::getTypePrefix( void ) const { return StringTable->insert( typePrefix ); }
336
337#define ConsoleSetType( type ) \
338   void ConsoleType##type::setData(void *dptr, S32 argc, const char **argv, const EnumTable *tbl, BitSet32 flag)
339
340#define ConsoleGetType( type ) \
341   const char *ConsoleType##type::getData(void *dptr, const EnumTable *tbl, BitSet32 flag)
342
343#define ConsoleProcessData( type ) \
344   const char *ConsoleType##type::prepData(const char *data, char *buffer, U32 bufferSz)
345   
346   
347#define DefineEnumType( type ) \
348   DECLARE_ENUM( type ); \
349   DefineConsoleType( Type ## type, type );
350
351#define DefineEnumType_R( type ) \
352   DECLARE_ENUM_R( type ); \
353   DefineConsoleType( Type ## type, type );
354
355#define _ConsoleEnumType( typeName, type, nativeType ) \
356   S32 type; \
357   ImplementConsoleTypeCasters( type, nativeType ) \
358   class EnumConsoleType ## type : public EnumConsoleBaseType \
359   { \
360   public: \
361      EnumConsoleType ## type() \
362         : EnumConsoleBaseType( sizeof( nativeType ), &type, #type ) \
363      { \
364         mTypeInfo = _MAPTYPE< nativeType >(); \
365      } \
366      virtual const char *getTypeClassName() { return #typeName; } \
367      virtual void       *getNativeVariable() { return new nativeType; } \
368      virtual void        deleteNativeVariable(void* var) { nativeType* nativeVar = reinterpret_cast< nativeType* >( var ); delete nativeVar; }\
369   }; \
370   EnumConsoleType ## type gConsoleType ## type ## Instance;
371
372#define ImplementEnumType( type, doc ) \
373   _ConsoleEnumType( type, Type ## type, type ) \
374   IMPLEMENT_ENUM( type, type,, doc )
375   
376#define EndImplementEnumType \
377   END_IMPLEMENT_ENUM
378
379
380#define DefineBitfieldType( type ) \
381   DECLARE_BITFIELD( type ); \
382   DefineConsoleType( Type ## type, type );
383
384#define DefineBitfieldType_R( type ) \
385   DECLARE_BITFIELD_R( type ); \
386   DefineConsoleType( Type ## type, type );
387
388#define _ConsoleBitfieldType( typeName, type, nativeType ) \
389   S32 type; \
390   ImplementConsoleTypeCasters( type, nativeType ) \
391   class BitfieldConsoleType ## type : public BitfieldConsoleBaseType \
392   { \
393   public: \
394      BitfieldConsoleType ## type() \
395         : BitfieldConsoleBaseType( sizeof( nativeType ), &type, #type ) \
396      { \
397         mTypeInfo = _MAPTYPE< nativeType >(); \
398      } \
399      virtual const char *getTypeClassName() { return #typeName; } \
400      virtual void       *getNativeVariable() { return new nativeType; } \
401      virtual void        deleteNativeVariable(void* var) { nativeType* nativeVar = reinterpret_cast< nativeType* >( var ); delete nativeVar; }\
402   }; \
403   BitfieldConsoleType ## type gConsoleType ## type ## Instance;
404      
405#define ImplementBitfieldType( type, doc ) \
406   _ConsoleBitfieldType( type, Type ## type, type ) \
407   IMPLEMENT_BITFIELD( type, type,, doc )
408   
409#define EndImplementBitfieldType \
410   END_IMPLEMENT_BITFIELD
411
412/// @}
413
414#endif
415