Torque3D Documentation / _generateds / engineTypeInfo.cpp

engineTypeInfo.cpp

Engine/source/console/engineTypeInfo.cpp

More...

Public Variables

Public Functions

DefineNewEngineMethod(EngineTypeInfo , getSuperType , const EngineTypeInfo * , () , "Get the type that this type subtypes <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">from.\n</a>" "@return The supertype info instance or NULL." )
DefineNewEngineMethod(EngineTypeInfo , getTypeKind , EngineTypeKind , () , "Get the kind of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">type.\n</a>" "@return The type kind." )
IMPLEMENT_ENUM(EngineTypeKind , EngineTypeKind , ReflectionAPI , "Kinding <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> engine types. Engine types are segregated into kinds which " "are <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> types what types are <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> values, i.e. <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> is an instance of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> type " "and <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> type is an instance of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">kind.\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">internal\n\n</a>" )
IMPLEMENT_NONINSTANTIABLE_CLASS(EngineTypeInfo , "Information about an engine type." )

Detailed Description

Public Variables

 END_IMPLEMENT_ENUM 

Public Functions

DefineNewEngineMethod(EngineTypeInfo , getSuperType , const EngineTypeInfo * , () , "Get the type that this type subtypes <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">from.\n</a>" "@return The supertype info instance or NULL." )

DefineNewEngineMethod(EngineTypeInfo , getTypeKind , EngineTypeKind , () , "Get the kind of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">type.\n</a>" "@return The type kind." )

IMPLEMENT_ENUM(EngineTypeKind , EngineTypeKind , ReflectionAPI , "Kinding <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> engine types. Engine types are segregated into kinds which " "are <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> types what types are <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> values, i.e. <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> is an instance of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> type " "and <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> type is an instance of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">kind.\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">internal\n\n</a>" )

IMPLEMENT_NONINSTANTIABLE_CLASS(EngineTypeInfo , "Information about an engine type." )

  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#include "console/engineTypeInfo.h"
 25#include "console/engineAPI.h"
 26#include "core/strings/stringFunctions.h"
 27
 28
 29IMPLEMENT_ENUM( EngineTypeKind,
 30   EngineTypeKind, ReflectionAPI,
 31   "Kinding for engine types.  Engine types are segregated into kinds which "
 32   "are to types what types are to values, i.e. a value is an instance of a type "
 33   "and a type is an instance of a kind.\n"
 34   "@internal\n\n")
 35   { EngineTypeKindPrimitive, "Primitive", "Atomic data." },
 36   { EngineTypeKindEnum, "Enum", "Enumeration." },
 37   { EngineTypeKindBitfield, "Bitfield", "Bitfield." },
 38   { EngineTypeKindFunction, "Function", "Function pointer." },
 39   { EngineTypeKindStruct, "Struct", "Structured value." },
 40   { EngineTypeKindClass, "Class", "EngineObject value." },
 41END_IMPLEMENT_ENUM;
 42
 43IMPLEMENT_NONINSTANTIABLE_CLASS( EngineTypeInfo,
 44   "Information about an engine type." )
 45   PROPERTY( TypeKind, 1, "Kind of type.", 0 )
 46   PROPERTY( SuperType, 1, "<a href="/coding/file/rapidjson_8h/#rapidjson_8h_1a1d1cfd8ffb84e947f82999c682b666a7">Type</a> that this type subtypes from.", 0 )
 47END_IMPLEMENT_CLASS;
 48
 49U32 EngineTypeInfo::smNumTypes;
 50const EngineTypeInfo* EngineTypeInfo::smFirst;
 51
 52
 53//-----------------------------------------------------------------------------
 54
 55EngineTypeInfo::EngineTypeInfo( const char* typeName, EngineExportScope* scope, EngineTypeKind kind, U32 instanceSize, const char* docString )
 56   : SuperType( typeName, scope, docString ),
 57     mTypeKind( kind ),
 58     mInstanceSize( instanceSize ),
 59     mEnumTable( NULL ),
 60     mFieldTable( NULL ),
 61     mPropertyTable( NULL ),
 62     mArgumentTypeTable(NULL),
 63     mSuperType( NULL ),
 64     mNext( smFirst )
 65{
 66   mExportKind = EngineExportKindType;
 67   
 68   smFirst = this;
 69   smNumTypes ++;
 70}
 71
 72//-----------------------------------------------------------------------------
 73
 74const EngineTypeInfo* EngineTypeInfo::getTypeInfoByName( const char* typeName )
 75{
 76   for( const EngineTypeInfo* typeInfo = getFirstType(); typeInfo != NULL; typeInfo = typeInfo->getNextType() )
 77      if( dStricmp( typeInfo->getTypeName(), typeName ) == 0 )
 78         return typeInfo;
 79         
 80   return NULL;
 81}
 82
 83//-----------------------------------------------------------------------------
 84
 85U32 EngineTypeInfo::getValueSize() const
 86{
 87   switch( getTypeKind() )
 88   {
 89      case EngineTypeKindPrimitive:
 90      case EngineTypeKindEnum:
 91      case EngineTypeKindBitfield:
 92         return mInstanceSize;
 93         
 94      case EngineTypeKindStruct:
 95      case EngineTypeKindFunction:
 96      case EngineTypeKindClass:
 97         return sizeof( void* );
 98   }
 99   
100   AssertFatal( false, "EngineTypeInfo - unknown type kind!" );
101   return U32( -1 );
102}
103
104//-----------------------------------------------------------------------------
105
106bool EngineTypeInfo::isSubtypeOf( const EngineTypeInfo* type ) const
107{
108   for( const EngineTypeInfo* p = this; p != NULL; p = p->getSuperType() )
109      if( p == type )
110         return true;
111         
112   return false;
113}
114
115//-----------------------------------------------------------------------------
116
117bool EngineTypeInfo::constructInstance( void* ptr ) const
118{
119   AssertFatal( !isAbstract(), "EngineTypeInfo::constructInstance - Called on abstract type!" );
120   return false;
121}
122
123//-----------------------------------------------------------------------------
124
125void EngineTypeInfo::destructInstance( void* ptr ) const
126{
127   AssertFatal( !isAbstract(), "EngineTypeInfo::destructInstance - Called on abstract type!" );
128}
129
130//=============================================================================
131//    API.
132//=============================================================================
133// MARK: ---- API ----
134
135//-----------------------------------------------------------------------------
136
137DefineNewEngineMethod( EngineTypeInfo, getTypeKind, EngineTypeKind, (),,
138   "Get the kind of the type.\n"
139   "@return The type kind." )
140{
141   return object->getTypeKind();
142}
143
144//-----------------------------------------------------------------------------
145
146DefineNewEngineMethod( EngineTypeInfo, getSuperType, const EngineTypeInfo*, (),,
147   "Get the type that this type subtypes from.\n"
148   "@return The supertype info instance or NULL." )
149{
150   return object->getSuperType();
151}
152