Expand EngineAPI type definitions

This commit is contained in:
Lukas Joergensen 2019-08-03 12:39:41 +02:00 committed by Lukas Aldershaab
parent f5f0eb2bb4
commit a241d27b58
13 changed files with 284 additions and 36 deletions

View file

@ -104,20 +104,6 @@ namespace engineAPI {
extern bool gIsInitialized;
}
//FIXME: this allows const char* to be used as a struct field type
// Temp support for allowing const char* to remain in the API functions as long as we
// still have the console system around. When that is purged, these definitions should
// be deleted and all const char* uses be replaced with String.
template<> struct EngineTypeTraits< const char* > : public EngineTypeTraits< String > {};
template<> inline const EngineTypeInfo* TYPE< const char* >() { return TYPE< String >(); }
/// @name Marshalling
///
/// Functions for converting to/from string-based data representations.

View file

@ -27,9 +27,22 @@
IMPLEMENT_PRIMITIVE( bool, bool,, "Boolean true/false." );
IMPLEMENT_PRIMITIVE( S8, byte,, "8bit signed integer." );
IMPLEMENT_PRIMITIVE( U8, ubyte,, "8bit unsigned integer." );
IMPLEMENT_PRIMITIVE( S16, short,, "16bit signed integer.");
IMPLEMENT_PRIMITIVE( U16, ushort,, "16bit unsigned integer.");
IMPLEMENT_PRIMITIVE( S32, int,, "32bit signed integer." );
IMPLEMENT_PRIMITIVE( U32, uint,, "32bit unsigned integer." );
IMPLEMENT_PRIMITIVE( F32, float,, "32bit single-precision floating-point." );
IMPLEMENT_PRIMITIVE( F64, double,, "64bit double-precision floating-point." );
IMPLEMENT_PRIMITIVE( String, string,, "Null-terminated UTF-16 Unicode string." );
IMPLEMENT_PRIMITIVE( void*, ptr,, "Opaque pointer." );
// Define pointer types for vectors.
IMPLEMENT_PRIMITIVE( bool*, ptr_bool,, "Pointer to a bool." );
IMPLEMENT_PRIMITIVE( U8*, ptr_ubyte,, "Pointer to an unsigned byte." );
IMPLEMENT_PRIMITIVE( U32*, ptr_uint,, "Pointer to an unsigned 32bit int." );
IMPLEMENT_PRIMITIVE( S32*, ptr_int,, "Pointer to a 32bit int." );
IMPLEMENT_PRIMITIVE( F32*, ptr_float,, "Pointer to a 32bit float." );
IMPLEMENT_PRIMITIVE( Point3F*, ptr_Point3F,, "Pointer to a Point3F struct." );
IMPLEMENT_PRIMITIVE( PlaneF*, ptr_PlaneF,, "Pointer to a PlaneF struct." );
IMPLEMENT_PRIMITIVE( PolyhedronData::Edge*, ptr_Edge,, "Pointer to an Edge struct." );
IMPLEMENT_PRIMITIVE( const UTF8**, ptr_string,, "Pointer to an UTF-8 string." );

View file

@ -27,6 +27,8 @@
#include "console/engineTypes.h"
#endif
#include "math/mPlane.h"
#include "math/mPolyhedron.h"
/// @file
/// Definitions for the core primitive types used in the
@ -37,6 +39,8 @@
DECLARE_PRIMITIVE_R( bool );
DECLARE_PRIMITIVE_R(S8);
DECLARE_PRIMITIVE_R(U8);
DECLARE_PRIMITIVE_R(S16);
DECLARE_PRIMITIVE_R(U16);
DECLARE_PRIMITIVE_R(S32);
DECLARE_PRIMITIVE_R(U32);
DECLARE_PRIMITIVE_R(F32);
@ -45,6 +49,15 @@ DECLARE_PRIMITIVE_R(U64);
DECLARE_PRIMITIVE_R(S64);
DECLARE_PRIMITIVE_R(void*);
DECLARE_PRIMITIVE_R(bool*);
DECLARE_PRIMITIVE_R(U8*);
DECLARE_PRIMITIVE_R(S32*);
DECLARE_PRIMITIVE_R(U32*);
DECLARE_PRIMITIVE_R(F32*);
DECLARE_PRIMITIVE_R(Point3F*);
DECLARE_PRIMITIVE_R(PlaneF*);
DECLARE_PRIMITIVE_R(PolyhedronData::Edge*);
DECLARE_PRIMITIVE_R(const char**);
//FIXME: this allows String to be used as a struct field type
@ -80,4 +93,12 @@ template<> struct EngineTypeTraits< const UTF16* > : public EngineTypeTraits< St
template<> inline const EngineTypeInfo* TYPE< const UTF16* >() { return TYPE< String >(); }
inline const EngineTypeInfo* TYPE( const UTF16*& ) { return TYPE< String >(); }
//FIXME: this allows const char* to be used as a struct field type
// Temp support for allowing const char* to remain in the API functions as long as we
// still have the console system around. When that is purged, these definitions should
// be deleted and all const char* uses be replaced with String.
template<> struct EngineTypeTraits< const char* > : public EngineTypeTraits< String > {};
template<> inline const EngineTypeInfo* TYPE< const char* >() { return TYPE< String >(); }
#endif // !_ENGINEPRIMITIVES_H_

View file

@ -25,32 +25,42 @@
#include "core/util/tVector.h"
#include "core/util/uuid.h"
#include "core/color.h"
#include "math/mPolyhedron.h"
IMPLEMENT_STRUCT(PlaneF,
PlaneF, ,
"")
IMPLEMENT_STRUCT( Vector< bool >,
BoolVector,,
FIELD(x, x, 1, "")
FIELD(y, y, 1, "")
FIELD(z, z, 1, "")
FIELD(d, d, 1, "")
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( PolyhedronData::Edge,
Edge,,
"" )
FIELD_AS(U32, face, face, 2, "")
FIELD_AS(U32, vertex, vertex, 2, "")
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Vector< S32 >,
IntVector,,
"" )
IMPLEMENT_STRUCT(Torque::UUID,
UUID, ,
"")
Torque::UUIDEngineExport::getAField(),
Torque::UUIDEngineExport::getBField(),
Torque::UUIDEngineExport::getCField(),
Torque::UUIDEngineExport::getDField(),
Torque::UUIDEngineExport::getEField(),
Torque::UUIDEngineExport::getFField(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Vector< F32 >,
FloatVector,,
"" )
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Torque::UUID,
UUID,,
"" )
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( ColorI,
ColorI,,
"RGBA color quadruple in 8bit integer precision per channel." )
@ -73,3 +83,74 @@ IMPLEMENT_STRUCT( LinearColorF,
FIELD( alpha, alpha, 1, "Alpha channel value." )
END_IMPLEMENT_STRUCT;
// Vectors
IMPLEMENT_STRUCT( Vector< bool >,
BoolVector,,
"" )
VectorFieldEngineExport::getElementCountField< bool >(),
VectorFieldEngineExport::getArraySizeField< bool >(),
VectorFieldEngineExport::getArrayField< bool >(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Vector< S32 >,
IntVector,,
"" )
VectorFieldEngineExport::getElementCountField< S32 >(),
VectorFieldEngineExport::getArraySizeField< S32 >(),
VectorFieldEngineExport::getArrayField< S32 >(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Vector< F32 >,
FloatVector,,
"" )
VectorFieldEngineExport::getElementCountField< F32 >(),
VectorFieldEngineExport::getArraySizeField< F32 >(),
VectorFieldEngineExport::getArrayField< F32 >(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT( Vector< Point3F >,
Point3FVector,,
"" )
VectorFieldEngineExport::getElementCountField< Point3F >(),
VectorFieldEngineExport::getArraySizeField< Point3F >(),
VectorFieldEngineExport::getArrayField< Point3F >(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT(Vector< PlaneF >,
PlaneFVector, ,
"")
VectorFieldEngineExport::getElementCountField< PlaneF >(),
VectorFieldEngineExport::getArraySizeField< PlaneF >(),
VectorFieldEngineExport::getArrayField< PlaneF >(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT(Vector< PolyhedronData::Edge >,
EdgeVector, ,
"")
VectorFieldEngineExport::getElementCountField< PolyhedronData::Edge >(),
VectorFieldEngineExport::getArraySizeField< PolyhedronData::Edge >(),
VectorFieldEngineExport::getArrayField< PolyhedronData::Edge >(),
END_IMPLEMENT_STRUCT;
IMPLEMENT_STRUCT(Vector< const char* >,
StringVector, ,
"")
VectorFieldEngineExport::getElementCountField< const char* >(),
VectorFieldEngineExport::getArraySizeField< const char* >(),
VectorFieldEngineExport::getArrayField< const char* >(),
END_IMPLEMENT_STRUCT;

View file

@ -27,6 +27,8 @@
#include "console/engineTypes.h"
#endif
#include "math/mPlane.h"
#include "math/mPolyhedron.h"
/// @file
/// Definitions for the core engine structured types.
@ -44,6 +46,12 @@ class LinearColorF;
DECLARE_STRUCT_R(Vector< bool >);
DECLARE_STRUCT_R(Vector< S32 >);
DECLARE_STRUCT_R(Vector< F32 >);
DECLARE_STRUCT_R(Vector< Point3F >);
DECLARE_STRUCT_R(PlaneF);
DECLARE_STRUCT_R(Vector< PlaneF >);
DECLARE_STRUCT_R(PolyhedronData::Edge);
DECLARE_STRUCT_R(Vector< PolyhedronData::Edge >);
DECLARE_STRUCT_R(Vector< const char* >);
DECLARE_STRUCT_R(Torque::UUID);
DECLARE_STRUCT_R(ColorI);
DECLARE_STRUCT_R(LinearColorF);

View file

@ -564,12 +564,18 @@ namespace _Private {
///
#define _FIELD( fieldName, exportName, numElements, doc ) \
{ #exportName, doc, numElements, TYPE( ( ( ThisType* ) 16 )->fieldName ), (U32)FIELDOFFSET( fieldName ) } // Artificial offset to avoid compiler warnings.
#define FIELD( fieldName, exportName, numElements, doc ) \
{ #exportName, doc, numElements, TYPE( ( ( ThisType* ) 16 )->fieldName ), (U32)FIELDOFFSET( fieldName ) }, // Artificial offset to avoid compiler warnings.
_FIELD(fieldName, exportName, numElements, doc),
///
#define _FIELD_AS( type, fieldName, exportName, numElements, doc ) \
{ #exportName, doc, numElements, TYPE( *( ( type* ) &( ( ThisType* ) 16 )->fieldName ) ), (U32)FIELDOFFSET( fieldName ) } // Artificial offset to avoid compiler warnings.
#define FIELD_AS( type, fieldName, exportName, numElements, doc ) \
{ #exportName, doc, numElements, TYPE( *( ( type* ) &( ( ThisType* ) 16 )->fieldName ) ), (U32)FIELDOFFSET( fieldName ) }, // Artificial offset to avoid compiler warnings.
_FIELD_AS(type, fieldName, exportName, numElements, doc),
///
#define FIELDOFFSET( fieldName ) \