Fixed SHDotNetRuntime::IsLoaded() giving incorrect data and updated qualifiers and comment formats
This commit is contained in:
parent
9a97d12d96
commit
12cfbb9952
|
@ -23,26 +23,43 @@ of DigiPen Institute of Technology is prohibited.
|
|||
|
||||
namespace SHADE
|
||||
{
|
||||
/********************************************************************************//*!
|
||||
@brief Class that encapsulates the state of the .NET Core Runtime lifecycle.
|
||||
*//*********************************************************************************/
|
||||
/*************************************************************************************/
|
||||
/*!
|
||||
|
||||
class SHDotNetRuntime
|
||||
|
||||
\brief
|
||||
Class that encapsulates the state of the .NET Core Runtime lifecycle.
|
||||
|
||||
*/
|
||||
/*************************************************************************************/
|
||||
|
||||
class SHDotNetRuntime
|
||||
{
|
||||
public:
|
||||
/*----------------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Constructors/Destructor */
|
||||
/*----------------------------------------------------------------------------------*/
|
||||
/****************************************************************************//*!
|
||||
@brief Default constructor that immediately initializes the CoreCLR.
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/***********************************************************************************/
|
||||
/*!
|
||||
|
||||
@param[in] autoInit
|
||||
\brief
|
||||
Default constructor that immediately initializes the CoreCLR.
|
||||
|
||||
\param autoInit
|
||||
If true, loads the CoreCLR by calling Init().
|
||||
*//*****************************************************************************/
|
||||
|
||||
*/
|
||||
/***********************************************************************************/
|
||||
SHDotNetRuntime(bool autoInit = true);
|
||||
/****************************************************************************//*!
|
||||
@brief Destructor that unloads the CoreCLR if it has not been unloaded
|
||||
yet.
|
||||
*//*****************************************************************************/
|
||||
/***********************************************************************************/
|
||||
/*!
|
||||
|
||||
\brief
|
||||
Destructor that unloads the CoreCLR if it has not been unloaded yet.
|
||||
|
||||
*/
|
||||
/***********************************************************************************/
|
||||
~SHDotNetRuntime();
|
||||
|
||||
// Disallow copy and moving
|
||||
|
@ -52,58 +69,78 @@ namespace SHADE
|
|||
/*----------------------------------------------------------------------------------*/
|
||||
/* Lifecycle Functions */
|
||||
/*----------------------------------------------------------------------------------*/
|
||||
/****************************************************************************//*!
|
||||
@brief Loads the CoreCLR and grabs pointers to bootstrapping functions and
|
||||
kickstarts the CoreCLR.
|
||||
/***********************************************************************************/
|
||||
/*!
|
||||
|
||||
@throws SystemExitException
|
||||
\brief
|
||||
Loads the CoreCLR and grabs pointers to bootstrapping functions and kickstarts the
|
||||
CoreCLR.
|
||||
|
||||
\throws std::runtime_error
|
||||
Thrown if there is a failure in loading the CLR and related functions.
|
||||
*//*****************************************************************************/
|
||||
void Init();
|
||||
/****************************************************************************//*!
|
||||
@brief Unloads the CoreCLR.
|
||||
|
||||
@throws SystemExitException
|
||||
*/
|
||||
/***********************************************************************************/
|
||||
void Init();
|
||||
/***********************************************************************************/
|
||||
/*!
|
||||
|
||||
\brief
|
||||
Unloads the CoreCLR.
|
||||
|
||||
\throws std::runtime_error
|
||||
Thrown if there is a failure in unloading the CLR.
|
||||
*//*****************************************************************************/
|
||||
|
||||
*/
|
||||
/***********************************************************************************/
|
||||
void Exit();
|
||||
|
||||
/*----------------------------------------------------------------------------------*/
|
||||
/* Usage Functions */
|
||||
/*----------------------------------------------------------------------------------*/
|
||||
/****************************************************************************//*!
|
||||
@brief Checks if the DotNetRuntime has successfully been initialised.
|
||||
/***********************************************************************************/
|
||||
/*!
|
||||
|
||||
@return True if this DotNetRuntime has been initialised.
|
||||
*//*****************************************************************************/
|
||||
inline bool IsLoaded() { return coreClr != nullptr; }
|
||||
/****************************************************************************//*!
|
||||
@brief Retrieves a function pointer from the a CLR assembly based on the
|
||||
specified assembly, type and function names.
|
||||
\brief
|
||||
Checks if the DotNetRuntime has successfully been initialised.
|
||||
|
||||
@tparam FunctionType
|
||||
Type of the function pointer that the specified function name will
|
||||
provide.
|
||||
\return
|
||||
True if this DotNetRuntime has been initialised.
|
||||
|
||||
@params[in] assemblyName
|
||||
*/
|
||||
/***********************************************************************************/
|
||||
inline bool IsLoaded() const noexcept { return initialised; }
|
||||
|
||||
/***********************************************************************************/
|
||||
/*!
|
||||
|
||||
\brief
|
||||
Retrieves a function pointer from the a CLR assembly based on the specified
|
||||
assembly, type and function names.
|
||||
|
||||
\tparam FunctionType
|
||||
Type of the function pointer that the specified function name will provide.
|
||||
\param assemblyName
|
||||
Name of the CoreCLR assembly that contains the function.
|
||||
@params[in] typeName
|
||||
Name of the CoreCLR type in the assembly that contains the function.
|
||||
Nested types are separated by a period(.).
|
||||
@params[in] functionName
|
||||
\param typeName
|
||||
Name of the CoreCLR type in the assembly that contains the function. Nested types
|
||||
are separated by a period(.).
|
||||
\param functionName
|
||||
Name of the CoreCLR function to get a pointer to.
|
||||
\return
|
||||
Pointer to the function in the assembly that was specified.
|
||||
|
||||
@returns Pointer to the function in the assembly that was specified.
|
||||
*//*****************************************************************************/
|
||||
*/
|
||||
/***********************************************************************************/
|
||||
template<typename FunctionType>
|
||||
FunctionType GetFunctionPtr(const std::string_view& assemblyName,
|
||||
const std::string_view& typeName,
|
||||
const std::string_view& functionName);
|
||||
const std::string_view& functionName) const;
|
||||
|
||||
private:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Data Members */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
bool initialised = false;
|
||||
// References to CoreCLR key components
|
||||
HMODULE coreClr = nullptr;
|
||||
|
@ -114,34 +151,55 @@ namespace SHADE
|
|||
coreclr_create_delegate_ptr createManagedDelegate = nullptr;
|
||||
coreclr_shutdown_ptr shutdownCoreClr = nullptr;
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* Helper Functions */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/****************************************************************************//*!
|
||||
@brief Retrieves a function pointer from the CoreCLR based on the specified
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/***********************************************************************************/
|
||||
/*!
|
||||
|
||||
\brief
|
||||
Retrieves a function pointer from the CoreCLR based on the specified
|
||||
function name.
|
||||
|
||||
@tparam FunctionType
|
||||
Type of the function pointer that the specified function name will
|
||||
provide.
|
||||
|
||||
@params[in] functionName
|
||||
\tparam FunctionType
|
||||
Type of the function pointer that the specified function name will provide.
|
||||
\param functionName
|
||||
Name of the CoreCLR function to get a pointer to.
|
||||
\return
|
||||
Pointer to the function in the CoreCLR that was specified.
|
||||
|
||||
@returns Pointer to the function in the CoreCLR that was specified.
|
||||
*//*****************************************************************************/
|
||||
*/
|
||||
/***********************************************************************************/
|
||||
template<typename FunctionType>
|
||||
FunctionType getCoreClrFunctionPtr(const std::string& functionName);
|
||||
/****************************************************************************//*!
|
||||
@brief Compiles a semicolon separated string of trusted platform assemblies by
|
||||
/***********************************************************************************/
|
||||
/*!
|
||||
|
||||
\brief
|
||||
Compiles a semicolon separated string of trusted platform assemblies by
|
||||
searching the specified directory.
|
||||
|
||||
@params[in] directory
|
||||
\param directory
|
||||
Path to the directory where the trusted platform assemblies reside.
|
||||
\return
|
||||
Semicolon separated string of trusted platform assemblies.
|
||||
|
||||
@returns Semicolon separated string of trusted platform assemblies.
|
||||
*//*****************************************************************************/
|
||||
*/
|
||||
/***********************************************************************************/
|
||||
static std::string buildTpaList(const std::string& directory);
|
||||
/***********************************************************************************/
|
||||
/*!
|
||||
|
||||
\brief
|
||||
Takes in a Win32 result code and throws an exception it if there is an error.
|
||||
|
||||
\param errMsg
|
||||
Error message to display if the resultCode is a failure code.
|
||||
\param resultCode
|
||||
Result code of the function to check.
|
||||
|
||||
*/
|
||||
/***********************************************************************************/
|
||||
static void throwIfFailed(const std::string& errMsg, int resultCode);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace SHADE
|
|||
template<typename FunctionType>
|
||||
FunctionType SHDotNetRuntime::GetFunctionPtr(const std::string_view & assemblyName,
|
||||
const std::string_view & typeName,
|
||||
const std::string_view & functionName)
|
||||
const std::string_view & functionName) const
|
||||
{
|
||||
FunctionType managedDelegate = nullptr;
|
||||
int result = createManagedDelegate
|
||||
|
|
Loading…
Reference in New Issue