enginePrimitives.h
Engine/source/console/enginePrimitives.h
Definitions for the core primitive types used in the exposed engine API.
Classes:
Public Functions
DECLARE_PRIMITIVE_R(bool )
Detailed Description
Definitions for the core primitive types used in the exposed engine API.
Public Functions
_DECLARE_TYPE_R(String )
DECLARE_PRIMITIVE_R(bool )
DECLARE_PRIMITIVE_R(F32 )
DECLARE_PRIMITIVE_R(F64 )
DECLARE_PRIMITIVE_R(S32 )
DECLARE_PRIMITIVE_R(S8 )
DECLARE_PRIMITIVE_R(U32 )
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 32/// @file 33/// Definitions for the core primitive types used in the 34/// exposed engine API. 35 36 37 38DECLARE_PRIMITIVE_R( bool ); 39DECLARE_PRIMITIVE_R(S8); 40DECLARE_PRIMITIVE_R(U8); 41DECLARE_PRIMITIVE_R(S32); 42DECLARE_PRIMITIVE_R(U32); 43DECLARE_PRIMITIVE_R(F32); 44DECLARE_PRIMITIVE_R(F64); 45DECLARE_PRIMITIVE_R(void*); 46 47 48//FIXME: this allows String to be used as a struct field type 49 50// String is special in the way its data is exchanged through the API. Through 51// calls, strings are passed as plain, null-terminated UTF-16 character strings. 52// In addition, strings passed back as return values from engine API functions 53// are considered to be owned by the API layer itself. The rule here is that such 54// a string is only valid until the next API call is made. Usually, control layers 55// will immediately copy and convert strings to their own string type. 56_DECLARE_TYPE_R(String); 57template<> 58struct EngineTypeTraits< String > : public _EnginePrimitiveTypeTraits< String > 59{ 60 typedef const UTF16* ArgumentValueType; 61 typedef const UTF16* ReturnValueType; 62 63 //FIXME: this needs to be sorted out; for now, we store default value literals in ASCII 64 typedef const char* DefaultArgumentValueStoreType; 65 66 static const UTF16* ReturnValue( const String& str ) 67 { 68 static String sTemp; 69 sTemp = str; 70 return sTemp.utf16(); 71 } 72}; 73 74 75// For struct fields, String cannot be used directly but "const UTF16*" must be used 76// instead. Make sure this works with the template machinery by redirecting the type 77// back to String. 78template<> struct EngineTypeTraits< const UTF16* > : public EngineTypeTraits< String> {}; 79template<> inline const EngineTypeInfo* TYPE< const UTF16*>() { return TYPE< String >(); } 80inline const EngineTypeInfo* TYPE( const UTF16*& ) { return TYPE< String >(); } 81 82#endif // !_ENGINEPRIMITIVES_H_ 83
