_prog
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled
This commit is contained in:
@@ -68,13 +68,13 @@ public:
|
||||
struct FLAXENGINE_API Object
|
||||
{
|
||||
static MObject* Box(void* value, const MClass* klass);
|
||||
static void* Unbox(MObject* obj);
|
||||
static void Unbox(MObject* obj, void* dest);
|
||||
static void* Unbox(const MObject* obj);
|
||||
static void Unbox(const MObject* obj, void* dest);
|
||||
static MObject* New(const MClass* klass);
|
||||
static void Init(MObject* obj);
|
||||
static MClass* GetClass(MObject* obj);
|
||||
static MString* ToString(MObject* obj);
|
||||
static int32 GetHashCode(MObject* obj);
|
||||
static void Init(const MObject* obj);
|
||||
static MClass* GetClass(const MObject* obj);
|
||||
static MString* ToString(const MObject* obj);
|
||||
static int32 GetHashCode(const MObject* obj);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -82,11 +82,11 @@ public:
|
||||
/// </summary>
|
||||
struct FLAXENGINE_API String
|
||||
{
|
||||
static MString* GetEmpty(MDomain* domain = nullptr);
|
||||
static MString* New(const char* str, int32 length, MDomain* domain = nullptr);
|
||||
static MString* New(const Char* str, int32 length, MDomain* domain = nullptr);
|
||||
static void Free(MString* obj);
|
||||
static StringView GetChars(MString* obj);
|
||||
static MString* GetEmpty(const MDomain* domain = nullptr);
|
||||
static MString* New(const char* str, int32 length, const MDomain* domain = nullptr);
|
||||
static MString* New(const Char* str, int32 length, const MDomain* domain = nullptr);
|
||||
static void Free(const MString* obj);
|
||||
static StringView GetChars(const MString* obj);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -96,11 +96,11 @@ public:
|
||||
{
|
||||
static MArray* New(const MClass* elementKlass, int32 length);
|
||||
static void Free(const MArray* array);
|
||||
static MClass* GetClass(MClass* elementKlass);
|
||||
static MClass* GetClass(const MClass* elementKlass);
|
||||
static MClass* GetArrayClass(const MArray* obj);
|
||||
static int32 GetLength(const MArray* obj);
|
||||
static void* GetAddress(const MArray* obj);
|
||||
static MArray* Unbox(MObject* obj);
|
||||
static MArray* Unbox(const MObject* obj);
|
||||
|
||||
template<typename T>
|
||||
FORCE_INLINE static T* GetAddress(const MArray* obj)
|
||||
@@ -114,8 +114,8 @@ public:
|
||||
/// </summary>
|
||||
struct FLAXENGINE_API GCHandle
|
||||
{
|
||||
static MGCHandle New(MObject* obj, bool pinned = false);
|
||||
static MGCHandle NewWeak(MObject* obj, bool trackResurrection = false);
|
||||
static MGCHandle New(const MObject* obj, bool pinned = false);
|
||||
static MGCHandle NewWeak(const MObject* obj, bool trackResurrection = false);
|
||||
static MObject* GetTarget(const MGCHandle& handle);
|
||||
static void Free(const MGCHandle& handle);
|
||||
};
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
/// </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 GetValue(MObject* instance, void* result) const;
|
||||
void GetValue(const 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.
|
||||
@@ -116,14 +116,14 @@ public:
|
||||
/// </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;
|
||||
void GetValueReference(const 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>
|
||||
/// <param name="instance">The object of given type to get value from.</param>
|
||||
/// <returns>The boxed value object.</returns>
|
||||
MObject* GetValueBoxed(MObject* instance) const;
|
||||
MObject* GetValueBoxed(const MObject* instance) const;
|
||||
|
||||
/// <summary>
|
||||
/// Sets a value for the field on the specified object instance. If field is static object instance can be null.
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
/// </remarks>
|
||||
/// <param name="instance">The object of given type to set value to.</param>
|
||||
/// <param name="value">Th value of undefined type.</param>
|
||||
void SetValue(MObject* instance, void* value) const;
|
||||
void SetValue(const MObject* instance, void* value) const;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
|
||||
#if USE_CSHARP
|
||||
|
||||
/*static_assert(TIsPODType<int>::Value, "int not pod type?");
|
||||
static_assert(TIsPODType<Float3>::Value, "Float3 not pod type?");
|
||||
static_assert(!TIsPODType<ScriptingObject>::Value, "ScriptingObject not pod type?");
|
||||
static_assert(TIsPODType<Char>::Value, "Char not pod type?");
|
||||
static_assert(TIsPODType<char>::Value, "char not pod type?");*/
|
||||
|
||||
struct Version;
|
||||
class CultureInfo;
|
||||
template<typename AllocationType>
|
||||
@@ -49,6 +55,12 @@ struct MConverter
|
||||
{
|
||||
MObject* Box(const T& data, const MClass* klass);
|
||||
void Unbox(T& result, MObject* data);
|
||||
/*template<typename U>
|
||||
void ToManaged(U& result, const T& data);
|
||||
template<typename U>
|
||||
void ToNative(T& result, const U& data);
|
||||
void ToManaged(MObject*& result, const T& data);
|
||||
void ToNative(T& result, const MObject*& data);*/
|
||||
void FreeManaged(MObject* data);
|
||||
void ToManagedArray(MArray* result, const Span<T>& data);
|
||||
void ToNativeArray(Span<T>& result, const MArray* data);
|
||||
@@ -61,6 +73,16 @@ struct NativeArray
|
||||
{
|
||||
T* data;
|
||||
int32 length;
|
||||
|
||||
FORCE_INLINE operator T*() const
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
FORCE_INLINE Span<T> ToSpan() const
|
||||
{
|
||||
return Span<T>(data, length);
|
||||
}
|
||||
};
|
||||
|
||||
#if USE_NETCORE
|
||||
@@ -79,6 +101,16 @@ struct MConverter<bool>
|
||||
MCore::Object::Unbox(data, &result);
|
||||
}
|
||||
|
||||
void ToManaged(bool& result, const bool& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToNative(bool& result, const bool& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void FreeManaged(MObject* data)
|
||||
{
|
||||
}
|
||||
@@ -116,6 +148,16 @@ struct MConverter<T, typename TEnableIf<TAnd<TIsPODType<T>, TNot<TIsBaseOf<class
|
||||
MCore::Object::Unbox(data, &result);
|
||||
}
|
||||
|
||||
void ToManaged(T& result, const T& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToNative(T& result, const T& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToManagedArray(MArray* result, const Span<T>& data)
|
||||
{
|
||||
Platform::MemoryCopy(MCore::Array::GetAddress(result), data.Get(), data.Length() * sizeof(T));
|
||||
@@ -162,6 +204,16 @@ struct MConverter<String>
|
||||
//#endif
|
||||
}
|
||||
|
||||
void ToManaged(String& result, const String& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToNative(String& result, const String& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToManagedArray(MArray* result, const Span<String>& data)
|
||||
{
|
||||
if (data.Length() == 0)
|
||||
@@ -212,6 +264,16 @@ struct MConverter<StringAnsi>
|
||||
result = MUtils::ToStringAnsi((MString*)data);
|
||||
}
|
||||
|
||||
void ToManaged(StringAnsi& result, const StringAnsi& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToNative(StringAnsi& result, const StringAnsi& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToManagedArray(MArray* result, const Span<StringAnsi>& data)
|
||||
{
|
||||
if (data.Length() == 0)
|
||||
@@ -262,6 +324,16 @@ struct MConverter<StringView>
|
||||
result = MUtils::ToString((MString*)data);
|
||||
}
|
||||
|
||||
void ToManaged(StringView& result, const StringView& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToNative(StringView& result, const StringView& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToManagedArray(MArray* result, const Span<StringView>& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
@@ -316,6 +388,16 @@ struct MConverter<Variant>
|
||||
result = MUtils::UnboxVariant(data);
|
||||
}
|
||||
|
||||
void ToManaged(Variant& result, const Variant& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToNative(Variant& result, const Variant& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToManagedArray(MArray* result, const Span<Variant>& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
@@ -365,6 +447,18 @@ struct MConverter<T*, typename TEnableIf<TIsBaseOf<class ScriptingObject, T>::Va
|
||||
result = (T*)ScriptingObject::ToNative(data);
|
||||
}
|
||||
|
||||
void ToManaged(MObject*& result, const T* data)
|
||||
{
|
||||
//PLATFORM_DEBUG_BREAK; // FIXME
|
||||
result = data ? data->GetOrCreateManagedInstance() : nullptr;
|
||||
}
|
||||
|
||||
void ToNative(T*& result, const MObject* data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
result = (T*)ScriptingObject::ToNative(data);
|
||||
}
|
||||
|
||||
void ToManagedArray(MArray* result, const Span<T*>& data)
|
||||
{
|
||||
if (data.Length() == 0)
|
||||
@@ -405,9 +499,29 @@ struct MConverter<T, typename TEnableIf<TIsBaseOf<class ScriptingObject, T>::Val
|
||||
return data.GetOrCreateManagedInstance();
|
||||
}
|
||||
|
||||
void ToManagedArray(MArray* result, const Span<T>& data)
|
||||
void ToManaged(MObject*& result, const T& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToNative(T& result, const MObject*& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
/*void ToManaged(MObject*& result, const T*& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToNative(T*& result, const MObject*& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}*/
|
||||
|
||||
void ToManagedArray(MArray* result, const Span<T>& data)
|
||||
{
|
||||
//PLATFORM_DEBUG_BREAK; // FIXME
|
||||
if (data.Length() == 0)
|
||||
return;
|
||||
MObject** objects = (MObject**)Allocator::Allocate(data.Length() * sizeof(MObject*));
|
||||
@@ -449,6 +563,16 @@ struct MConverter<ScriptingObjectReference<T>>
|
||||
result = (T*)ScriptingObject::ToNative(data);
|
||||
}
|
||||
|
||||
void ToManaged(MObject*& result, const ScriptingObjectReference<T>& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToNative(ScriptingObjectReference<T>& result, const MObject*& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToManagedArray(MArray* result, const Span<ScriptingObjectReference<T>>& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
@@ -501,6 +625,17 @@ struct MConverter<AssetReference<T>>
|
||||
result = (T*)ScriptingObject::ToNative(data);
|
||||
}
|
||||
|
||||
void ToManaged(MObject*& result, const AssetReference<T>& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
result = data.GetManagedInstance();
|
||||
}
|
||||
|
||||
void ToNative(AssetReference<T>& result, const MObject* data)
|
||||
{
|
||||
result = (T*)ScriptingObject::ToNative(data);
|
||||
}
|
||||
|
||||
void ToManagedArray(MArray* result, const Span<AssetReference<T>>& data)
|
||||
{
|
||||
if (data.Length() == 0)
|
||||
@@ -538,6 +673,29 @@ class SoftAssetReference;
|
||||
template<typename T>
|
||||
struct MConverter<SoftAssetReference<T>>
|
||||
{
|
||||
|
||||
template <typename U>
|
||||
void ToManaged(U& result, const SoftAssetReference<T>& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
void ToNative(SoftAssetReference<T>& result, const U& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToManaged(MObject*& result, const SoftAssetReference<T>& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToNative(SoftAssetReference<T>& result, const MObject*& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToManagedArray(MArray* result, const Span<SoftAssetReference<T>>& data)
|
||||
{
|
||||
//PLATFORM_DEBUG_BREAK; // FIXME
|
||||
@@ -575,6 +733,16 @@ struct MConverter<SoftAssetReference<T>>
|
||||
template<typename T>
|
||||
struct MConverter<Array<T>>
|
||||
{
|
||||
void ToManaged(Array<T>& result, const Array<T>& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
void ToNative(Array<T>& result, const Array<T>& data)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
}
|
||||
|
||||
MObject* Box(const Array<T>& data, const MClass* klass)
|
||||
{
|
||||
PLATFORM_DEBUG_BREAK; // FIXME
|
||||
@@ -877,12 +1045,36 @@ namespace MUtils
|
||||
return arr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new managed array of data and copies contents from given native array.
|
||||
/// </summary>
|
||||
/// <param name="data">The array object.</param>
|
||||
/// <param name="valueClass">The array values type class.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
/*template<typename T, typename U>
|
||||
NativeArray<U> ToManagedArrayWrapper(const Span<T>& data, const MClass* valueClass)
|
||||
{
|
||||
if (!valueClass)
|
||||
return nullptr;
|
||||
MArray* result = MCore::Array::New(valueClass, data.Length());
|
||||
MConverter<T> converter;
|
||||
converter.ToManagedArray(result, data);
|
||||
return result;
|
||||
|
||||
// System.Runtime.InteropServices.Marshalling.ArrayMarshaller uses CoTask memory alloc to native data pointer
|
||||
NativeArray<U> arr;
|
||||
arr.length = data.Count();
|
||||
arr.data = (U*)MCore::GC::AllocateMemory(arr.length * sizeof(U), true);
|
||||
Platform::MemoryCopy(arr.data, data.Get(), arr.length * sizeof(U));
|
||||
return arr;
|
||||
}*/
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
template<typename T, typename AllocationType = HeapAllocation>
|
||||
/*template<typename T, typename AllocationType = HeapAllocation>
|
||||
FORCE_INLINE NativeArray<T> ToNativeArrayWrapper(const Array<T, AllocationType>& data)
|
||||
{
|
||||
// System.Runtime.InteropServices.Marshalling.ArrayMarshaller uses CoTask memory alloc to native data pointer
|
||||
@@ -893,22 +1085,233 @@ namespace MUtils
|
||||
return arr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
template<typename T, typename U, typename AllocationType = HeapAllocation>
|
||||
FORCE_INLINE NativeArray<U> ToNativeArrayWrapper(const Array<T, AllocationType>& data)
|
||||
{
|
||||
// System.Runtime.InteropServices.Marshalling.ArrayMarshaller uses CoTask memory alloc to native data pointer
|
||||
NativeArray<U> arr;
|
||||
arr.length = data.Count();
|
||||
arr.data = (U*)MCore::GC::AllocateMemory(arr.length * sizeof(U), true);
|
||||
|
||||
// Convert to managed
|
||||
MConverter<T, U> converter;
|
||||
for (int i = 0; i < arr.length; ++i)
|
||||
arr.data[i] = converter.ToManaged(data[i]);
|
||||
return arr;
|
||||
}*/
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
template<typename T, typename U>
|
||||
FORCE_INLINE NativeArray<U> ToManagedArrayWrapperConvert(const Span<T>& data)
|
||||
{
|
||||
// System.Runtime.InteropServices.Marshalling.ArrayMarshaller uses CoTask memory alloc to native data pointer
|
||||
NativeArray<U> arr;
|
||||
arr.length = data.Length();
|
||||
arr.data = arr.length > 0 ? (U*)MCore::GC::AllocateMemory(arr.length * sizeof(U), true) : nullptr;
|
||||
|
||||
// Convert to managed
|
||||
MConverter<T, U> converter;
|
||||
for (int i = 0; i < arr.length; ++i)
|
||||
converter.ToManaged(arr.data[i], data[i]);
|
||||
return arr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
template<typename T>
|
||||
FORCE_INLINE NativeArray<T> ToNativeArrayWrapper(const Span<T>& data)
|
||||
FORCE_INLINE NativeArray<T> ToNativeArrayWrapperConvertGeneric(const Span<MObject*>& data)
|
||||
{
|
||||
// System.Runtime.InteropServices.Marshalling.ArrayMarshaller uses CoTask memory alloc to native data pointer
|
||||
NativeArray<T> arr;
|
||||
arr.length = data.Length();
|
||||
arr.data = (T*)MCore::GC::AllocateMemory(arr.length * sizeof(T), true);
|
||||
arr.data = arr.length > 0 ? (T*)MCore::GC::AllocateMemory(arr.length * sizeof(T), true) : nullptr;
|
||||
|
||||
// Convert to managed
|
||||
MConverter<T> converter;
|
||||
for (int i = 0; i < arr.length; ++i)
|
||||
{
|
||||
converter.ToNative(arr.data[i], data[i]);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
template<typename T, typename AllocationType = HeapAllocation>
|
||||
FORCE_INLINE void ToNativeArrayWrapperConvertGeneric(const Span<MObject*>& data, Array<T, AllocationType>& array)
|
||||
{
|
||||
if (!array.IsEmpty())
|
||||
PLATFORM_DEBUG_BREAK; // TODO: does the array require ClearDelete instead?
|
||||
|
||||
auto length = data.Length();
|
||||
array.Resize(length, false);
|
||||
//array.Clear();
|
||||
//array.EnsureCapacity(length);
|
||||
|
||||
MConverter<T> converter;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
// Make sure the destination is default initialized first
|
||||
//array.AddUninitialized();
|
||||
//array.AddDefault();
|
||||
//T& dest = array.Get()[i];
|
||||
//new(&dest)AssetReference<T>();
|
||||
|
||||
// Convert from managed
|
||||
converter.ToNative(array.Get()[i], data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
template<typename T, typename U>
|
||||
FORCE_INLINE NativeArray<T> ToNativeArrayWrapperConvert(const Span<U>& data)
|
||||
{
|
||||
// System.Runtime.InteropServices.Marshalling.ArrayMarshaller uses CoTask memory alloc to native data pointer
|
||||
NativeArray<T> arr;
|
||||
arr.length = data.Length();
|
||||
arr.data = arr.length > 0 ? (T*)MCore::GC::AllocateMemory(arr.length * sizeof(T), true) : nullptr;
|
||||
|
||||
// Convert to managed
|
||||
MConverter<T, U> converter;
|
||||
for (int i = 0; i < arr.length; ++i)
|
||||
converter.ToNative(arr.data[i], data[i]);
|
||||
return arr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
template<typename T>
|
||||
FORCE_INLINE NativeArray<T> ToNativeArrayWrapperCopy(const Span<T>& data)
|
||||
{
|
||||
// System.Runtime.InteropServices.Marshalling.ArrayMarshaller uses CoTask memory alloc to native data pointer
|
||||
NativeArray<T> arr;
|
||||
arr.length = data.Length();
|
||||
arr.data = arr.length > 0 ? (T*)MCore::GC::AllocateMemory(arr.length * sizeof(T), true) : nullptr;
|
||||
Platform::MemoryCopy(arr.data, data.Get(), arr.length * sizeof(T));
|
||||
return arr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
/*FORCE_INLINE NativeArray<Char> ToManagedArrayWrapper(const Span<Char>& data)
|
||||
{
|
||||
// System.Runtime.InteropServices.Marshalling.ArrayMarshaller uses CoTask memory alloc to native data pointer
|
||||
NativeArray<Char> arr;
|
||||
arr.length = data.Length();
|
||||
arr.data = (Char*)MCore::GC::AllocateMemory(arr.length * sizeof(Char), true);
|
||||
Platform::MemoryCopy(arr.data, data.Get(), arr.length * sizeof(Char));
|
||||
return arr;
|
||||
}*/
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
template<typename T>
|
||||
FORCE_INLINE NativeArray<T> ToManagedArrayWrapperConvert(const Span<T>& data)
|
||||
{
|
||||
// System.Runtime.InteropServices.Marshalling.ArrayMarshaller uses CoTask memory alloc to native data pointer
|
||||
NativeArray<T> arr;
|
||||
arr.length = data.Length();
|
||||
arr.data = arr.length > 0 ? (T*)MCore::GC::AllocateMemory(arr.length * sizeof(T), true) : nullptr;
|
||||
//Platform::MemoryCopy(arr.data, data.Get(), arr.length * sizeof(T));
|
||||
|
||||
// Convert to managed
|
||||
MConverter<T> converter;
|
||||
for (int i = 0; i < arr.length; ++i)
|
||||
converter.ToManaged(arr.data[i], data[i]);
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
template<typename T>
|
||||
FORCE_INLINE NativeArray<T> ToManagedArrayWrapperCopy(const Span<T>& data)
|
||||
{
|
||||
// System.Runtime.InteropServices.Marshalling.ArrayMarshaller uses CoTask memory alloc to native data pointer
|
||||
NativeArray<T> arr;
|
||||
arr.length = data.Length();
|
||||
arr.data = arr.length > 0 ? (T*)MCore::GC::AllocateMemory(arr.length * sizeof(T), true) : nullptr;
|
||||
Platform::MemoryCopy(arr.data, data.Get(), arr.length * sizeof(T));
|
||||
return arr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
/*template<typename T>
|
||||
FORCE_INLINE NativeArray<MObject*> ToManagedArrayWrapperPointer(const Span<T*>& data)
|
||||
{
|
||||
// System.Runtime.InteropServices.Marshalling.ArrayMarshaller uses CoTask memory alloc to native data pointer
|
||||
NativeArray<MObject*> arr;
|
||||
arr.length = data.Length();
|
||||
arr.data = (MObject**)MCore::GC::AllocateMemory(arr.length * sizeof(MObject*), true);
|
||||
|
||||
// Convert to managed
|
||||
MConverter<T*> converter;
|
||||
for (int i = 0; i < arr.length; ++i)
|
||||
{
|
||||
MObject*& ptr = arr.data[i];
|
||||
const T& asd = data[i];
|
||||
converter.ToManaged(ptr, asd);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}*/
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
/// <returns>The output array.</returns>
|
||||
template<class T>
|
||||
FORCE_INLINE NativeArray<MObject*> ToManagedArrayWrapperPointer(const Span<T>& data)
|
||||
{
|
||||
// System.Runtime.InteropServices.Marshalling.ArrayMarshaller uses CoTask memory alloc to native data pointer
|
||||
NativeArray<MObject*> arr;
|
||||
arr.length = data.Length();
|
||||
arr.data = arr.length > 0 ? (MObject**)MCore::GC::AllocateMemory(arr.length * sizeof(MObject*), true) : nullptr;
|
||||
|
||||
// Convert to managed
|
||||
MConverter<T> converter;
|
||||
for (int i = 0; i < arr.length; ++i)
|
||||
converter.ToManaged(arr.data[i], data[i]);
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allocates new boolean array and copies data from the given unmanaged data container. The managed runtime is responsible for releasing the returned array data.
|
||||
/// </summary>
|
||||
|
||||
@@ -399,15 +399,15 @@ MObject* MCore::Object::Box(void* value, const MClass* klass)
|
||||
return (MObject*)CallStaticMethod<void*, void*, void*>(BoxValuePtr, klass->_handle, value);
|
||||
}
|
||||
|
||||
void* MCore::Object::Unbox(MObject* obj)
|
||||
void* MCore::Object::Unbox(const MObject* obj)
|
||||
{
|
||||
CRASH; // Should not be used anymore
|
||||
}
|
||||
|
||||
void MCore::Object::Unbox(MObject* obj, void* dest)
|
||||
void MCore::Object::Unbox(const MObject* obj, void* dest)
|
||||
{
|
||||
static void* UnboxValuePtr = GetStaticMethodPointer(TEXT("UnboxValue"));
|
||||
return CallStaticMethod<void, void*, void*>(UnboxValuePtr, obj, dest);
|
||||
return CallStaticMethod<void, const void*, void*>(UnboxValuePtr, obj, dest);
|
||||
}
|
||||
|
||||
MObject* MCore::Object::New(const MClass* klass)
|
||||
@@ -416,61 +416,61 @@ MObject* MCore::Object::New(const MClass* klass)
|
||||
return (MObject*)CallStaticMethod<void*, void*>(NewObjectPtr, klass->_handle);
|
||||
}
|
||||
|
||||
void MCore::Object::Init(MObject* obj)
|
||||
void MCore::Object::Init(const MObject* obj)
|
||||
{
|
||||
static void* ObjectInitPtr = GetStaticMethodPointer(TEXT("ObjectInit"));
|
||||
CallStaticMethod<void, void*>(ObjectInitPtr, obj);
|
||||
CallStaticMethod<void, const void*>(ObjectInitPtr, obj);
|
||||
}
|
||||
|
||||
MClass* MCore::Object::GetClass(MObject* obj)
|
||||
MClass* MCore::Object::GetClass(const MObject* obj)
|
||||
{
|
||||
ASSERT(obj);
|
||||
static void* GetObjectClassPtr = GetStaticMethodPointer(TEXT("GetObjectClass"));
|
||||
return (MClass*)CallStaticMethod<MClass*, void*>(GetObjectClassPtr, obj);
|
||||
return (MClass*)CallStaticMethod<MClass*, const void*>(GetObjectClassPtr, obj);
|
||||
}
|
||||
|
||||
MString* MCore::Object::ToString(MObject* obj)
|
||||
MString* MCore::Object::ToString(const MObject* obj)
|
||||
{
|
||||
static void* GetObjectStringPtr = GetStaticMethodPointer(TEXT("GetObjectString"));
|
||||
return (MString*)CallStaticMethod<void*, void*>(GetObjectStringPtr, obj);
|
||||
return (MString*)CallStaticMethod<void*, const void*>(GetObjectStringPtr, obj);
|
||||
}
|
||||
|
||||
int32 MCore::Object::GetHashCode(MObject* obj)
|
||||
int32 MCore::Object::GetHashCode(const MObject* obj)
|
||||
{
|
||||
static void* GetObjectStringPtr = GetStaticMethodPointer(TEXT("GetObjectHashCode"));
|
||||
return CallStaticMethod<int32, void*>(GetObjectStringPtr, obj);
|
||||
return CallStaticMethod<int32, const void*>(GetObjectStringPtr, obj);
|
||||
}
|
||||
|
||||
MString* MCore::String::GetEmpty(MDomain* domain)
|
||||
MString* MCore::String::GetEmpty(const MDomain* domain)
|
||||
{
|
||||
static void* GetStringEmptyPtr = GetStaticMethodPointer(TEXT("GetStringEmpty"));
|
||||
return (MString*)CallStaticMethod<void*>(GetStringEmptyPtr);
|
||||
}
|
||||
|
||||
MString* MCore::String::New(const char* str, int32 length, MDomain* domain)
|
||||
MString* MCore::String::New(const char* str, int32 length, const MDomain* domain)
|
||||
{
|
||||
static void* NewStringUTF8Ptr = GetStaticMethodPointer(TEXT("NewStringUTF8"));
|
||||
return (MString*)CallStaticMethod<void*, const char*, int>(NewStringUTF8Ptr, str, length);
|
||||
}
|
||||
|
||||
MString* MCore::String::New(const Char* str, int32 length, MDomain* domain)
|
||||
MString* MCore::String::New(const Char* str, int32 length, const MDomain* domain)
|
||||
{
|
||||
static void* NewStringUTF16Ptr = GetStaticMethodPointer(TEXT("NewStringUTF16"));
|
||||
return (MString*)CallStaticMethod<void*, const Char*, int>(NewStringUTF16Ptr, str, length);
|
||||
}
|
||||
|
||||
StringView MCore::String::GetChars(MString* obj)
|
||||
StringView MCore::String::GetChars(const MString* obj)
|
||||
{
|
||||
int32 length = 0;
|
||||
static void* GetStringPointerPtr = GetStaticMethodPointer(TEXT("GetStringPointer"));
|
||||
const Char* chars = CallStaticMethod<const Char*, void*, int*>(GetStringPointerPtr, obj, &length);
|
||||
const Char* chars = CallStaticMethod<const Char*, const void*, int*>(GetStringPointerPtr, obj, &length);
|
||||
return StringView(chars, length);
|
||||
}
|
||||
|
||||
void MCore::String::Free(MString* obj)
|
||||
void MCore::String::Free(const MString* obj)
|
||||
{
|
||||
static void* FreeStringPtr = GetStaticMethodPointer(TEXT("FreeString"));
|
||||
CallStaticMethod<void, void*>(FreeStringPtr, obj);
|
||||
CallStaticMethod<void, const void*>(FreeStringPtr, obj);
|
||||
}
|
||||
|
||||
MArray* MCore::Array::New(const MClass* elementKlass, int32 length)
|
||||
@@ -485,7 +485,7 @@ void MCore::Array::Free(const MArray* array)
|
||||
CallStaticMethod<void, void*>(FreeArrayPtr, (void*)array);
|
||||
}
|
||||
|
||||
MClass* MCore::Array::GetClass(MClass* elementKlass)
|
||||
MClass* MCore::Array::GetClass(const MClass* elementKlass)
|
||||
{
|
||||
static void* GetArrayTypeFromElementTypePtr = GetStaticMethodPointer(TEXT("GetArrayTypeFromElementType"));
|
||||
MType* typeHandle = (MType*)CallStaticMethod<void*, void*>(GetArrayTypeFromElementTypePtr, elementKlass->_handle);
|
||||
@@ -511,24 +511,24 @@ void* MCore::Array::GetAddress(const MArray* obj)
|
||||
return CallStaticMethod<void*, void*>(GetArrayPointerPtr, (void*)obj);
|
||||
}
|
||||
|
||||
MArray* MCore::Array::Unbox(MObject* obj)
|
||||
MArray* MCore::Array::Unbox(const MObject* obj)
|
||||
{
|
||||
static void* GetArrayPtr = GetStaticMethodPointer(TEXT("GetArray"));
|
||||
return (MArray*)CallStaticMethod<void*, void*>(GetArrayPtr, (void*)obj);
|
||||
}
|
||||
|
||||
MGCHandle MCore::GCHandle::New(MObject* obj, bool pinned)
|
||||
MGCHandle MCore::GCHandle::New(const MObject* obj, bool pinned)
|
||||
{
|
||||
ASSERT(obj);
|
||||
static void* NewGCHandlePtr = GetStaticMethodPointer(TEXT("NewGCHandle"));
|
||||
return (MGCHandle)CallStaticMethod<void*, void*, bool>(NewGCHandlePtr, obj, pinned);
|
||||
return (MGCHandle)CallStaticMethod<void*, const void*, bool>(NewGCHandlePtr, obj, pinned);
|
||||
}
|
||||
|
||||
MGCHandle MCore::GCHandle::NewWeak(MObject* obj, bool trackResurrection)
|
||||
MGCHandle MCore::GCHandle::NewWeak(const MObject* obj, bool trackResurrection)
|
||||
{
|
||||
ASSERT(obj);
|
||||
static void* NewGCHandleWeakPtr = GetStaticMethodPointer(TEXT("NewGCHandleWeak"));
|
||||
return (MGCHandle)CallStaticMethod<void*, void*, bool>(NewGCHandleWeakPtr, obj, trackResurrection);
|
||||
return (MGCHandle)CallStaticMethod<void*, const void*, bool>(NewGCHandleWeakPtr, obj, trackResurrection);
|
||||
}
|
||||
|
||||
MObject* MCore::GCHandle::GetTarget(const MGCHandle& handle)
|
||||
@@ -1387,28 +1387,28 @@ int32 MField::GetOffset() const
|
||||
return _fieldOffset;
|
||||
}
|
||||
|
||||
void MField::GetValue(MObject* instance, void* result) const
|
||||
void MField::GetValue(const MObject* instance, void* result) const
|
||||
{
|
||||
static void* FieldGetValuePtr = GetStaticMethodPointer(TEXT("FieldGetValue"));
|
||||
CallStaticMethod<void, void*, void*, void*>(FieldGetValuePtr, instance, _handle, result);
|
||||
CallStaticMethod<void, const void*, void*, void*>(FieldGetValuePtr, instance, _handle, result);
|
||||
}
|
||||
|
||||
void MField::GetValueReference(MObject* instance, void* result) const
|
||||
void MField::GetValueReference(const MObject* instance, void* result) const
|
||||
{
|
||||
static void* FieldGetValueReferencePtr = GetStaticMethodPointer(TEXT("FieldGetValueReference"));
|
||||
CallStaticMethod<void, void*, void*, int, void*>(FieldGetValueReferencePtr, instance, _handle, _fieldOffset, result);
|
||||
CallStaticMethod<void, const void*, void*, int, void*>(FieldGetValueReferencePtr, instance, _handle, _fieldOffset, result);
|
||||
}
|
||||
|
||||
MObject* MField::GetValueBoxed(MObject* instance) const
|
||||
MObject* MField::GetValueBoxed(const MObject* instance) const
|
||||
{
|
||||
static void* FieldGetValueBoxedPtr = GetStaticMethodPointer(TEXT("FieldGetValueBoxed"));
|
||||
return CallStaticMethod<MObject*, void*, void*>(FieldGetValueBoxedPtr, instance, _handle);
|
||||
return CallStaticMethod<MObject*, const void*, void*>(FieldGetValueBoxedPtr, instance, _handle);
|
||||
}
|
||||
|
||||
void MField::SetValue(MObject* instance, void* value) const
|
||||
void MField::SetValue(const MObject* instance, void* value) const
|
||||
{
|
||||
static void* FieldSetValuePtr = GetStaticMethodPointer(TEXT("FieldSetValue"));
|
||||
CallStaticMethod<void, void*, void*, void*>(FieldSetValuePtr, instance, _handle, value);
|
||||
CallStaticMethod<void, const void*, void*, void*>(FieldSetValuePtr, instance, _handle, value);
|
||||
}
|
||||
|
||||
bool MField::HasAttribute(const MClass* klass) const
|
||||
|
||||
@@ -245,7 +245,7 @@ void* ScriptingObject::ToInterface(ScriptingObject* obj, const ScriptingTypeHand
|
||||
return result;
|
||||
}
|
||||
|
||||
ScriptingObject* ScriptingObject::ToNative(MObject* obj)
|
||||
ScriptingObject* ScriptingObject::ToNative(const MObject* obj)
|
||||
{
|
||||
ScriptingObject* ptr = nullptr;
|
||||
#if USE_CSHARP
|
||||
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
return (T*)ToInterface(obj, T::TypeInitializer);
|
||||
}
|
||||
|
||||
static ScriptingObject* ToNative(MObject* obj);
|
||||
static ScriptingObject* ToNative(const MObject* obj);
|
||||
|
||||
FORCE_INLINE static MObject* ToManaged(const ScriptingObject* obj)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user