Merge branch 'marshalling_scriptingobject_changes' of https://github.com/GoaLitiuM/FlaxEngine into GoaLitiuM-marshalling_scriptingobject_changes

# Conflicts:
#	Source/Engine/Engine/NativeInterop.Unmanaged.cs
#	Source/Engine/Scripting/Runtime/DotNet.cpp
This commit is contained in:
Wojtek Figat
2023-09-28 18:41:20 +02:00
14 changed files with 1020 additions and 461 deletions

View File

@@ -51,6 +51,15 @@ public:
/// <param name="name">The assembly name.</param>
MAssembly(MDomain* domain, const StringAnsiView& name);
/// <summary>
/// Initializes a new instance of the <see cref="MAssembly"/> class.
/// </summary>
/// <param name="domain">The assembly domain.</param>
/// <param name="name">The assembly name.</param>
/// <param name="fullname">The assembly full name.</param>
/// <param name="handle">The managed handle of the assembly.</param>
MAssembly(MDomain* domain, const StringAnsiView& name, const StringAnsiView& fullname, void* handle);
/// <summary>
/// Finalizes an instance of the <see cref="MAssembly"/> class.
/// </summary>

View File

@@ -48,6 +48,18 @@ MAssembly::MAssembly(MDomain* domain, const StringAnsiView& name)
{
}
MAssembly::MAssembly(MDomain* domain, const StringAnsiView& name, const StringAnsiView& fullname, void* handle)
: _domain(domain)
, _isLoaded(false)
, _isLoading(false)
, _hasCachedClasses(false)
, _reloadCount(0)
, _name(name)
, _fullname(fullname)
, _handle(handle)
{
}
MAssembly::~MAssembly()
{
Unload();

View File

@@ -190,4 +190,13 @@ public:
static MClass* Double;
static MClass* String;
};
/// <summary>
/// Utilities for ScriptingObject management.
/// </summary>
struct FLAXENGINE_API ScriptingObject
{
static void SetInternalValues(MObject* object, void* unmanagedPtr, const Guid* id);
static MObject* CreateScriptingObject(MClass* klass, void* unmanagedPtr, const Guid* id);
};
};

View File

@@ -19,6 +19,7 @@ protected:
#elif USE_NETCORE
void* _handle;
void* _type;
int32 _fieldOffset;
#endif
MClass* _parentClass;
@@ -35,7 +36,7 @@ public:
#if USE_MONO
explicit MField(MonoClassField* monoField, const char* name, MClass* parentClass);
#elif USE_NETCORE
MField(MClass* parentClass, void* handle, const char* name, void* type, MFieldAttributes attributes);
MField(MClass* parentClass, void* handle, const char* name, void* type, int fieldOffset, MFieldAttributes attributes);
#endif
public:
@@ -102,6 +103,16 @@ public:
/// <param name="result">The return value of undefined type.</param>
void GetValue(MObject* instance, void* result) const;
/// <summary>
/// Retrieves value currently set in the field on the specified object instance. If field is static object instance can be null.
/// </summary>
/// <remarks>
/// Value will be a pointer.
/// </remarks>
/// <param name="instance">The object of given type to get value from.</param>
/// <param name="result">The return value of undefined type.</param>
void GetValueReference(MObject* instance, void* result) const;
/// <summary>
/// Retrieves value currently set in the field on the specified object instance. If field is static object instance can be null. If returned value is a value type it will be boxed.
/// </summary>