Add support for DataContainer in scripting api bindings
This commit is contained in:
@@ -35,7 +35,7 @@ public:
|
||||
/// </summary>
|
||||
/// <param name="data">The data pointer to link.</param>
|
||||
/// <param name="length">The data length.</param>
|
||||
DataContainer(T* data, int32 length)
|
||||
DataContainer(const T* data, int32 length)
|
||||
: Base(data, length)
|
||||
, _isAllocated(false)
|
||||
{
|
||||
@@ -47,7 +47,17 @@ public:
|
||||
/// <param name="data">The data array to link.</param>
|
||||
template<typename AllocationType>
|
||||
DataContainer(const Array<T, AllocationType>& data)
|
||||
: Base((T*)data.Get(), data.Count())
|
||||
: Base(data.Get(), data.Count())
|
||||
, _isAllocated(false)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DataContainer"/> class.
|
||||
/// </summary>
|
||||
/// <param name="data">The data span to link.</param>
|
||||
DataContainer(const Span<T>& data)
|
||||
: Base(data.Get(), data.Length())
|
||||
, _isAllocated(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace Flax.Build.Bindings
|
||||
return false;
|
||||
|
||||
// Skip for collections
|
||||
if ((typeInfo.Type == "Array" || typeInfo.Type == "Span" || typeInfo.Type == "Dictionary" || typeInfo.Type == "HashSet") && typeInfo.GenericArgs != null)
|
||||
if ((typeInfo.Type == "Array" || typeInfo.Type == "Span" || typeInfo.Type == "DataContainer" || typeInfo.Type == "Dictionary" || typeInfo.Type == "HashSet") && typeInfo.GenericArgs != null)
|
||||
return false;
|
||||
|
||||
// Skip for special types
|
||||
|
||||
@@ -285,8 +285,8 @@ namespace Flax.Build.Bindings
|
||||
typeInfo.Type == "SoftObjectReference") && typeInfo.GenericArgs != null)
|
||||
return GenerateCSharpNativeToManaged(buildData, typeInfo.GenericArgs[0], caller);
|
||||
|
||||
// Array or Span
|
||||
if ((typeInfo.Type == "Array" || typeInfo.Type == "Span") && typeInfo.GenericArgs != null)
|
||||
// Array or Span or DataContainer
|
||||
if ((typeInfo.Type == "Array" || typeInfo.Type == "Span" || typeInfo.Type == "DataContainer") && typeInfo.GenericArgs != null)
|
||||
return GenerateCSharpNativeToManaged(buildData, typeInfo.GenericArgs[0], caller) + "[]";
|
||||
|
||||
// Dictionary
|
||||
|
||||
@@ -436,8 +436,8 @@ namespace Flax.Build.Bindings
|
||||
return "{0}.GetManagedInstance()";
|
||||
}
|
||||
|
||||
// Array or Span
|
||||
if ((typeInfo.Type == "Array" || typeInfo.Type == "Span") && typeInfo.GenericArgs != null)
|
||||
// Array or Span or DataContainer
|
||||
if ((typeInfo.Type == "Array" || typeInfo.Type == "Span" || typeInfo.Type == "DataContainer") && typeInfo.GenericArgs != null)
|
||||
{
|
||||
type = "MonoArray*";
|
||||
return "MUtils::ToArray({0}, " + GenerateCppGetNativeClass(buildData, typeInfo.GenericArgs[0], caller, functionInfo) + ")";
|
||||
@@ -638,8 +638,8 @@ namespace Flax.Build.Bindings
|
||||
return "MUtils::ToArray<" + T + ">({0})";
|
||||
}
|
||||
|
||||
// Span
|
||||
if (typeInfo.Type == "Span" && typeInfo.GenericArgs != null)
|
||||
// Span or DataContainer
|
||||
if ((typeInfo.Type == "Span" || typeInfo.Type == "DataContainer") && typeInfo.GenericArgs != null)
|
||||
{
|
||||
type = "MonoArray*";
|
||||
|
||||
@@ -780,8 +780,8 @@ namespace Flax.Build.Bindings
|
||||
if (apiType != null && apiType.IsScriptingObject)
|
||||
return $"ScriptingObject::ToManaged((ScriptingObject*){value})";
|
||||
|
||||
// Array or Span
|
||||
if ((typeInfo.Type == "Array" || typeInfo.Type == "Span") && typeInfo.GenericArgs != null && typeInfo.GenericArgs.Count >= 1)
|
||||
// Array or Span or DataContainer
|
||||
if ((typeInfo.Type == "Array" || typeInfo.Type == "Span" || typeInfo.Type == "DataContainer") && typeInfo.GenericArgs != null && typeInfo.GenericArgs.Count >= 1)
|
||||
return $"MUtils::ToArray({value}, {GenerateCppGetNativeClass(buildData, typeInfo.GenericArgs[0], caller, null)})";
|
||||
|
||||
// BytesContainer
|
||||
|
||||
Reference in New Issue
Block a user