mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
Merge pull request #2246 from lukaspj/update-cinterface
Update CInterface
This commit is contained in:
commit
644f4071ed
4 changed files with 48 additions and 9 deletions
|
|
@ -267,6 +267,9 @@ void StandardMainLoop::init()
|
||||||
|
|
||||||
ThreadPool::GlobalThreadPool::createSingleton();
|
ThreadPool::GlobalThreadPool::createSingleton();
|
||||||
|
|
||||||
|
// Set engineAPI initialized to true
|
||||||
|
engineAPI::gIsInitialized = true;
|
||||||
|
|
||||||
// Initialize modules.
|
// Initialize modules.
|
||||||
|
|
||||||
EngineModuleManager::initializeSystem();
|
EngineModuleManager::initializeSystem();
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,10 @@
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#ifndef _FIXEDTUPLE_H_
|
||||||
|
#include "fixedTuple.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef _CONSOLETYPES_H_
|
#ifndef _CONSOLETYPES_H_
|
||||||
#include "console/consoleTypes.h"
|
#include "console/consoleTypes.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -347,6 +351,8 @@ struct _EngineTrampoline< R( ArgTs ... ) >
|
||||||
{
|
{
|
||||||
typedef std::tuple<ArgTs ...> Args;
|
typedef std::tuple<ArgTs ...> Args;
|
||||||
std::tuple<ArgTs ...> argT;
|
std::tuple<ArgTs ...> argT;
|
||||||
|
typedef fixed_tuple<ArgTs ...> FixedArgs;
|
||||||
|
fixed_tuple<ArgTs ...> fixedArgT;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
|
|
@ -365,6 +371,7 @@ struct _EngineFunctionTrampoline< R(ArgTs...) > : public _EngineFunctionTrampoli
|
||||||
private:
|
private:
|
||||||
using Super = _EngineFunctionTrampolineBase< R(ArgTs...) >;
|
using Super = _EngineFunctionTrampolineBase< R(ArgTs...) >;
|
||||||
using ArgsType = typename Super::Args;
|
using ArgsType = typename Super::Args;
|
||||||
|
using FixedArgsType = typename Super::FixedArgs;
|
||||||
|
|
||||||
template<size_t ...> struct Seq {};
|
template<size_t ...> struct Seq {};
|
||||||
template<size_t N, size_t ...S> struct Gens : Gens<N-1, N-1, S...> {};
|
template<size_t N, size_t ...S> struct Gens : Gens<N-1, N-1, S...> {};
|
||||||
|
|
@ -375,12 +382,22 @@ private:
|
||||||
return R( fn(std::get<I>(args) ...) );
|
return R( fn(std::get<I>(args) ...) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<size_t ...I>
|
||||||
|
static R dispatchHelper(typename Super::FunctionType fn, const FixedArgsType& args, Seq<I...>) {
|
||||||
|
return R( fn(fixed_tuple_accessor<I>::get(args) ...) );
|
||||||
|
}
|
||||||
|
|
||||||
using SeqType = typename Gens<sizeof...(ArgTs)>::type;
|
using SeqType = typename Gens<sizeof...(ArgTs)>::type;
|
||||||
public:
|
public:
|
||||||
static R jmp(typename Super::FunctionType fn, const ArgsType& args )
|
static R jmp(typename Super::FunctionType fn, const ArgsType& args )
|
||||||
{
|
{
|
||||||
return dispatchHelper(fn, args, SeqType());
|
return dispatchHelper(fn, args, SeqType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static R jmp(typename Super::FunctionType fn, const FixedArgsType& args )
|
||||||
|
{
|
||||||
|
return dispatchHelper(fn, args, SeqType());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Trampolines for engine methods
|
// Trampolines for engine methods
|
||||||
|
|
@ -398,6 +415,7 @@ struct _EngineMethodTrampoline< Frame, R(ArgTs ...) > : public _EngineMethodTram
|
||||||
private:
|
private:
|
||||||
using Super = _EngineMethodTrampolineBase< R(ArgTs ...) >;
|
using Super = _EngineMethodTrampolineBase< R(ArgTs ...) >;
|
||||||
using ArgsType = typename _EngineFunctionTrampolineBase< R(ArgTs ...) >::Args;
|
using ArgsType = typename _EngineFunctionTrampolineBase< R(ArgTs ...) >::Args;
|
||||||
|
using FixedArgsType = typename Super::FixedArgs;
|
||||||
|
|
||||||
template<size_t ...> struct Seq {};
|
template<size_t ...> struct Seq {};
|
||||||
template<size_t N, size_t ...S> struct Gens : Gens<N-1, N-1, S...> {};
|
template<size_t N, size_t ...S> struct Gens : Gens<N-1, N-1, S...> {};
|
||||||
|
|
@ -408,6 +426,11 @@ private:
|
||||||
return R( f._exec(std::get<I>(args) ...) );
|
return R( f._exec(std::get<I>(args) ...) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<size_t ...I>
|
||||||
|
static R dispatchHelper(Frame f, const FixedArgsType& args, Seq<I...>) {
|
||||||
|
return R( f._exec(fixed_tuple_accessor<I>::get(args) ...) );
|
||||||
|
}
|
||||||
|
|
||||||
using SeqType = typename Gens<sizeof...(ArgTs)>::type;
|
using SeqType = typename Gens<sizeof...(ArgTs)>::type;
|
||||||
public:
|
public:
|
||||||
static R jmp( typename Frame::ObjectType* object, const ArgsType& args )
|
static R jmp( typename Frame::ObjectType* object, const ArgsType& args )
|
||||||
|
|
@ -417,6 +440,14 @@ public:
|
||||||
f.object = object;
|
f.object = object;
|
||||||
return dispatchHelper(f, args, SeqType());
|
return dispatchHelper(f, args, SeqType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static R jmp( typename Frame::ObjectType* object, const FixedArgsType& args )
|
||||||
|
{
|
||||||
|
|
||||||
|
Frame f;
|
||||||
|
f.object = object;
|
||||||
|
return dispatchHelper(f, args, SeqType());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
@ -683,7 +714,7 @@ public:
|
||||||
#define DefineEngineFunction( name, returnType, args, defaultArgs, usage ) \
|
#define DefineEngineFunction( name, returnType, args, defaultArgs, usage ) \
|
||||||
static inline returnType _fn ## name ## impl args; \
|
static inline returnType _fn ## name ## impl args; \
|
||||||
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \
|
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \
|
||||||
( _EngineFunctionTrampoline< returnType args >::Args a ) \
|
( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \
|
||||||
{ \
|
{ \
|
||||||
_CHECK_ENGINE_INITIALIZED( name, returnType ); \
|
_CHECK_ENGINE_INITIALIZED( name, returnType ); \
|
||||||
return EngineTypeTraits< returnType >::ReturnValue( \
|
return EngineTypeTraits< returnType >::ReturnValue( \
|
||||||
|
|
@ -702,7 +733,7 @@ public:
|
||||||
( void* ) &fn ## name, \
|
( void* ) &fn ## name, \
|
||||||
0 \
|
0 \
|
||||||
); \
|
); \
|
||||||
static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv ) \
|
static _EngineConsoleThunkType< returnType >::ReturnType _ ## name ## caster( SimObject*, S32 argc, ConsoleValueRef *argv ) \
|
||||||
{ \
|
{ \
|
||||||
return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk( \
|
return _EngineConsoleThunkType< returnType >::ReturnType( _EngineConsoleThunk< 1, returnType args >::thunk( \
|
||||||
argc, argv, &_fn ## name ## impl, _fn ## name ## DefaultArgs \
|
argc, argv, &_fn ## name ## impl, _fn ## name ## DefaultArgs \
|
||||||
|
|
@ -737,7 +768,7 @@ public:
|
||||||
|
|
||||||
#define _DefineMethodTrampoline( className, name, returnType, args ) \
|
#define _DefineMethodTrampoline( className, name, returnType, args ) \
|
||||||
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType \
|
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType \
|
||||||
fn ## className ## _ ## name ( className* object, _EngineMethodTrampoline< _ ## className ## name ## frame, returnType args >::Args a ) \
|
fn ## className ## _ ## name ( className* object, _EngineMethodTrampoline< _ ## className ## name ## frame, returnType args >::FixedArgs a )\
|
||||||
{ \
|
{ \
|
||||||
_CHECK_ENGINE_INITIALIZED( className::name, returnType ); \
|
_CHECK_ENGINE_INITIALIZED( className::name, returnType ); \
|
||||||
return EngineTypeTraits< returnType >::ReturnValue( \
|
return EngineTypeTraits< returnType >::ReturnValue( \
|
||||||
|
|
@ -820,7 +851,7 @@ public:
|
||||||
#define DefineEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \
|
#define DefineEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \
|
||||||
static inline returnType _fn ## className ## name ## impl args; \
|
static inline returnType _fn ## className ## name ## impl args; \
|
||||||
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \
|
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \
|
||||||
( _EngineFunctionTrampoline< returnType args >::Args a ) \
|
( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \
|
||||||
{ \
|
{ \
|
||||||
_CHECK_ENGINE_INITIALIZED( className::name, returnType ); \
|
_CHECK_ENGINE_INITIALIZED( className::name, returnType ); \
|
||||||
return EngineTypeTraits< returnType >::ReturnValue( \
|
return EngineTypeTraits< returnType >::ReturnValue( \
|
||||||
|
|
@ -920,7 +951,7 @@ public:
|
||||||
#define DefineNewEngineFunction( name, returnType, args, defaultArgs, usage ) \
|
#define DefineNewEngineFunction( name, returnType, args, defaultArgs, usage ) \
|
||||||
static inline returnType _fn ## name ## impl args; \
|
static inline returnType _fn ## name ## impl args; \
|
||||||
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \
|
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \
|
||||||
( _EngineFunctionTrampoline< returnType args >::Args a ) \
|
( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \
|
||||||
{ \
|
{ \
|
||||||
_CHECK_ENGINE_INITIALIZED( name, returnType ); \
|
_CHECK_ENGINE_INITIALIZED( name, returnType ); \
|
||||||
return EngineTypeTraits< returnType >::ReturnValue( \
|
return EngineTypeTraits< returnType >::ReturnValue( \
|
||||||
|
|
@ -967,7 +998,7 @@ public:
|
||||||
#define DefineNewEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \
|
#define DefineNewEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \
|
||||||
static inline returnType _fn ## className ## name ## impl args; \
|
static inline returnType _fn ## className ## name ## impl args; \
|
||||||
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \
|
TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \
|
||||||
( _EngineFunctionTrampoline< returnType args >::Args a ) \
|
( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \
|
||||||
{ \
|
{ \
|
||||||
_CHECK_ENGINE_INITIALIZED( className::name, returnType ); \
|
_CHECK_ENGINE_INITIALIZED( className::name, returnType ); \
|
||||||
return EngineTypeTraits< returnType >::ReturnValue( \
|
return EngineTypeTraits< returnType >::ReturnValue( \
|
||||||
|
|
|
||||||
|
|
@ -236,16 +236,16 @@ template< typename T >
|
||||||
struct _EngineStructTypeTraits
|
struct _EngineStructTypeTraits
|
||||||
{
|
{
|
||||||
typedef T Type;
|
typedef T Type;
|
||||||
typedef const T& ValueType;
|
typedef const T ValueType;
|
||||||
typedef void SuperType;
|
typedef void SuperType;
|
||||||
|
|
||||||
// Structs get passed in as pointers and passed out as full copies.
|
// Structs get passed in as pointers and passed out as full copies.
|
||||||
typedef T* ArgumentValueType;
|
typedef T ArgumentValueType;
|
||||||
typedef T ReturnValueType;
|
typedef T ReturnValueType;
|
||||||
typedef T DefaultArgumentValueStoreType;
|
typedef T DefaultArgumentValueStoreType;
|
||||||
|
|
||||||
typedef ReturnValueType ReturnValue;
|
typedef ReturnValueType ReturnValue;
|
||||||
static ValueType ArgumentToValue( ArgumentValueType val ) { return *val; }
|
static ValueType ArgumentToValue( ArgumentValueType val ) { return val; }
|
||||||
|
|
||||||
static const EngineTypeInfo* const TYPEINFO;
|
static const EngineTypeInfo* const TYPEINFO;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -620,3 +620,8 @@ DefineEngineFunction( getUserHomeDirectory, const char *, (), , "getUserHomeDire
|
||||||
{
|
{
|
||||||
return Platform::getUserHomeDirectory();
|
return Platform::getUserHomeDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefineEngineFunction(setMainDotCsDir, void, (const char* path), , "setMainDotCsDir()")
|
||||||
|
{
|
||||||
|
Platform::setMainDotCsDir(StringTable->insert(path));
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue