diff --git a/Engine/source/app/mainLoop.cpp b/Engine/source/app/mainLoop.cpp index b08363f8a..36998169f 100644 --- a/Engine/source/app/mainLoop.cpp +++ b/Engine/source/app/mainLoop.cpp @@ -267,6 +267,9 @@ void StandardMainLoop::init() ThreadPool::GlobalThreadPool::createSingleton(); + // Set engineAPI initialized to true + engineAPI::gIsInitialized = true; + // Initialize modules. EngineModuleManager::initializeSystem(); diff --git a/Engine/source/console/engineAPI.h b/Engine/source/console/engineAPI.h index ab1717745..5fa20a82c 100644 --- a/Engine/source/console/engineAPI.h +++ b/Engine/source/console/engineAPI.h @@ -26,6 +26,10 @@ #include #include +#ifndef _FIXEDTUPLE_H_ +#include "fixedTuple.h" +#endif + #ifndef _CONSOLETYPES_H_ #include "console/consoleTypes.h" #endif @@ -347,6 +351,8 @@ struct _EngineTrampoline< R( ArgTs ... ) > { typedef std::tuple Args; std::tuple argT; + typedef fixed_tuple FixedArgs; + fixed_tuple fixedArgT; }; template< typename T > @@ -365,6 +371,7 @@ struct _EngineFunctionTrampoline< R(ArgTs...) > : public _EngineFunctionTrampoli private: using Super = _EngineFunctionTrampolineBase< R(ArgTs...) >; using ArgsType = typename Super::Args; + using FixedArgsType = typename Super::FixedArgs; template struct Seq {}; template struct Gens : Gens {}; @@ -374,6 +381,11 @@ private: static R dispatchHelper(typename Super::FunctionType fn, const ArgsType& args, Seq) { return R( fn(std::get(args) ...) ); } + + template + static R dispatchHelper(typename Super::FunctionType fn, const FixedArgsType& args, Seq) { + return R( fn(fixed_tuple_accessor::get(args) ...) ); + } using SeqType = typename Gens::type; public: @@ -381,6 +393,11 @@ public: { return dispatchHelper(fn, args, SeqType()); } + + static R jmp(typename Super::FunctionType fn, const FixedArgsType& args ) + { + return dispatchHelper(fn, args, SeqType()); + } }; // Trampolines for engine methods @@ -398,6 +415,7 @@ struct _EngineMethodTrampoline< Frame, R(ArgTs ...) > : public _EngineMethodTram private: using Super = _EngineMethodTrampolineBase< R(ArgTs ...) >; using ArgsType = typename _EngineFunctionTrampolineBase< R(ArgTs ...) >::Args; + using FixedArgsType = typename Super::FixedArgs; template struct Seq {}; template struct Gens : Gens {}; @@ -408,6 +426,11 @@ private: return R( f._exec(std::get(args) ...) ); } + template + static R dispatchHelper(Frame f, const FixedArgsType& args, Seq) { + return R( f._exec(fixed_tuple_accessor::get(args) ...) ); + } + using SeqType = typename Gens::type; public: static R jmp( typename Frame::ObjectType* object, const ArgsType& args ) @@ -417,6 +440,14 @@ public: f.object = object; 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 ) \ static inline returnType _fn ## name ## impl args; \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \ - ( _EngineFunctionTrampoline< returnType args >::Args a ) \ + ( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \ { \ _CHECK_ENGINE_INITIALIZED( name, returnType ); \ return EngineTypeTraits< returnType >::ReturnValue( \ @@ -702,7 +733,7 @@ public: ( void* ) &fn ## name, \ 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( \ argc, argv, &_fn ## name ## impl, _fn ## name ## DefaultArgs \ @@ -737,7 +768,7 @@ public: #define _DefineMethodTrampoline( className, name, returnType, args ) \ 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 ); \ return EngineTypeTraits< returnType >::ReturnValue( \ @@ -820,7 +851,7 @@ public: #define DefineEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \ static inline returnType _fn ## className ## name ## impl args; \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \ - ( _EngineFunctionTrampoline< returnType args >::Args a ) \ + ( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \ { \ _CHECK_ENGINE_INITIALIZED( className::name, returnType ); \ return EngineTypeTraits< returnType >::ReturnValue( \ @@ -920,7 +951,7 @@ public: #define DefineNewEngineFunction( name, returnType, args, defaultArgs, usage ) \ static inline returnType _fn ## name ## impl args; \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## name \ - ( _EngineFunctionTrampoline< returnType args >::Args a ) \ + ( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \ { \ _CHECK_ENGINE_INITIALIZED( name, returnType ); \ return EngineTypeTraits< returnType >::ReturnValue( \ @@ -967,7 +998,7 @@ public: #define DefineNewEngineStaticMethod( className, name, returnType, args, defaultArgs, usage ) \ static inline returnType _fn ## className ## name ## impl args; \ TORQUE_API EngineTypeTraits< returnType >::ReturnValueType fn ## className ## _ ## name \ - ( _EngineFunctionTrampoline< returnType args >::Args a ) \ + ( _EngineFunctionTrampoline< returnType args >::FixedArgs a ) \ { \ _CHECK_ENGINE_INITIALIZED( className::name, returnType ); \ return EngineTypeTraits< returnType >::ReturnValue( \ diff --git a/Engine/source/console/engineTypes.h b/Engine/source/console/engineTypes.h index 2217ee770..51d2ef84d 100644 --- a/Engine/source/console/engineTypes.h +++ b/Engine/source/console/engineTypes.h @@ -236,16 +236,16 @@ template< typename T > struct _EngineStructTypeTraits { typedef T Type; - typedef const T& ValueType; + typedef const T ValueType; typedef void SuperType; // Structs get passed in as pointers and passed out as full copies. - typedef T* ArgumentValueType; + typedef T ArgumentValueType; typedef T ReturnValueType; typedef T DefaultArgumentValueStoreType; typedef ReturnValueType ReturnValue; - static ValueType ArgumentToValue( ArgumentValueType val ) { return *val; } + static ValueType ArgumentToValue( ArgumentValueType val ) { return val; } static const EngineTypeInfo* const TYPEINFO; }; diff --git a/Engine/source/platform/platformFileIO.cpp b/Engine/source/platform/platformFileIO.cpp index 788ed4f62..58123dbb1 100644 --- a/Engine/source/platform/platformFileIO.cpp +++ b/Engine/source/platform/platformFileIO.cpp @@ -620,3 +620,8 @@ DefineEngineFunction( getUserHomeDirectory, const char *, (), , "getUserHomeDire { return Platform::getUserHomeDirectory(); } + +DefineEngineFunction(setMainDotCsDir, void, (const char* path), , "setMainDotCsDir()") +{ + Platform::setMainDotCsDir(StringTable->insert(path)); +} \ No newline at end of file