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(String )

DECLARE_PRIMITIVE_R(bool )

DECLARE_PRIMITIVE_R(F32 )

DECLARE_PRIMITIVE_R(F64 )

DECLARE_PRIMITIVE_R(S32 )

DECLARE_PRIMITIVE_R(S64 )

DECLARE_PRIMITIVE_R(S8 )

DECLARE_PRIMITIVE_R(U32 )

DECLARE_PRIMITIVE_R(U64 )

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