Torque3D Documentation / _generateds / enginePrimitives.h

enginePrimitives.h

Engine/source/console/enginePrimitives.h

Definitions for the core primitive types used in the exposed engine API.

More...

Classes:

Detailed Description

Definitions for the core primitive types used in the exposed engine API.

Public Functions

_DECLARE_TYPE_R(const UTF8 * )

_DECLARE_TYPE_R(String )

DECLARE_PRIMITIVE_R(bool * )

DECLARE_PRIMITIVE_R(bool )

DECLARE_PRIMITIVE_R(const char ** )

DECLARE_PRIMITIVE_R(F32 * )

DECLARE_PRIMITIVE_R(F32 )

DECLARE_PRIMITIVE_R(F64 )

DECLARE_PRIMITIVE_R(PlaneF * )

DECLARE_PRIMITIVE_R(Point3F * )

DECLARE_PRIMITIVE_R(PolyhedronData::Edge * )

DECLARE_PRIMITIVE_R(S16 )

DECLARE_PRIMITIVE_R(S32 * )

DECLARE_PRIMITIVE_R(S32 )

DECLARE_PRIMITIVE_R(S64 )

DECLARE_PRIMITIVE_R(S8 )

DECLARE_PRIMITIVE_R(U16 )

DECLARE_PRIMITIVE_R(U32 * )

DECLARE_PRIMITIVE_R(U32 )

DECLARE_PRIMITIVE_R(U64 )

DECLARE_PRIMITIVE_R(U8 * )

DECLARE_PRIMITIVE_R(U8 )

DECLARE_PRIMITIVE_R(void * )

TYPE(const UTF16 *& )

TYPE< const UTF16 *>()

  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 _ENGINEPRIMITIVES_H_
 25#define _ENGINEPRIMITIVES_H_
 26
 27#ifndef _ENGINETYPES_H_
 28   #include "console/engineTypes.h"
 29#endif
 30
 31#include "math/mPlane.h"
 32#include "math/mPolyhedron.h"
 33
 34/// @file
 35/// Definitions for the core primitive types used in the
 36/// exposed engine API.
 37
 38
 39
 40DECLARE_PRIMITIVE_R( bool );
 41DECLARE_PRIMITIVE_R(S8);
 42DECLARE_PRIMITIVE_R(U8);
 43DECLARE_PRIMITIVE_R(S16);
 44DECLARE_PRIMITIVE_R(U16);
 45DECLARE_PRIMITIVE_R(S32);
 46DECLARE_PRIMITIVE_R(U32);
 47DECLARE_PRIMITIVE_R(F32);
 48DECLARE_PRIMITIVE_R(F64);
 49DECLARE_PRIMITIVE_R(U64);
 50DECLARE_PRIMITIVE_R(S64);
 51DECLARE_PRIMITIVE_R(void*);
 52
 53DECLARE_PRIMITIVE_R(bool*);
 54DECLARE_PRIMITIVE_R(U8*);
 55DECLARE_PRIMITIVE_R(S32*);
 56DECLARE_PRIMITIVE_R(U32*);
 57DECLARE_PRIMITIVE_R(F32*);
 58DECLARE_PRIMITIVE_R(Point3F*);
 59DECLARE_PRIMITIVE_R(PlaneF*);
 60DECLARE_PRIMITIVE_R(PolyhedronData::Edge*);
 61DECLARE_PRIMITIVE_R(const char**);
 62
 63//FIXME: this allows String to be used as a struct field type
 64
 65// String is special in the way its data is exchanged through the API.  Through
 66// calls, strings are passed as plain, null-terminated UTF-8 character strings.
 67// In addition, strings passed back as return values from engine API functions
 68// are considered to be owned by the API layer itself.  The rule here is that such
 69// a string is only valid until the next API call is made.  Usually, control layers
 70// will immediately copy and convert strings to their own string type.
 71_DECLARE_TYPE_R(String);
 72template<>
 73struct EngineTypeTraits< String > : public _EnginePrimitiveTypeTraits< String >
 74{
 75   typedef const UTF8* ArgumentValueType;
 76   typedef const UTF8* ReturnValueType;
 77
 78   //FIXME: this needs to be sorted out; for now, we store default value literals in ASCII
 79   typedef const char* DefaultArgumentValueStoreType;
 80   
 81   static const UTF8* ReturnValue( const String& str )
 82   {
 83      static String sTemp;      
 84      sTemp = str;
 85      return sTemp.utf8();
 86   }
 87};
 88
 89// For struct fields, String cannot be used directly but "const UTF16*" must be used
 90// instead.  Make sure this works with the template machinery by redirecting the type
 91// back to String.
 92template<> struct EngineTypeTraits< const UTF16* > : public EngineTypeTraits< String> {};
 93template<> inline const EngineTypeInfo* TYPE< const UTF16*>() { return TYPE< String >(); }
 94inline const EngineTypeInfo* TYPE( const UTF16*& ) { return TYPE< String >(); }
 95
 96// Temp support for allowing const char* to remain in the API functions as long as we
 97// still have the console system around.  When that is purged, these definitions should
 98// be deleted and all const char* uses be replaced with String.
 99_DECLARE_TYPE_R(const UTF8*);
100template<>
101struct EngineTypeTraits< const UTF8* > : public _EnginePrimitiveTypeTraits< const UTF8*>
102{
103   static const UTF8* ReturnValue(const String& str)
104   {
105      static String sTemp;
106      sTemp = str;
107      return sTemp.utf8();
108   }
109};
110
111
112#endif // !_ENGINEPRIMITIVES_H_
113