Merge branch 'master' of https://gitlab.flaxengine.com/flax/flaxengine
This commit is contained in:
@@ -62,7 +62,39 @@ namespace Flax.Build.Bindings
|
||||
if (value.StartsWith("TEXT(\"") && value.EndsWith("\")"))
|
||||
return value.Substring(5, value.Length - 6);
|
||||
|
||||
// In-built constants
|
||||
switch (value)
|
||||
{
|
||||
case "nullptr":
|
||||
case "NULL":
|
||||
case "String::Empty":
|
||||
case "StringView::Empty": return "null";
|
||||
case "MAX_int8": return "sbyte.MaxValue";
|
||||
case "MAX_uint8": return "byte.MaxValue";
|
||||
case "MAX_int16": return "short.MaxValue";
|
||||
case "MAX_uint16": return "ushort.MaxValue";
|
||||
case "MAX_int32": return "int.MaxValue";
|
||||
case "MAX_uint32": return "uint.MaxValue";
|
||||
case "MAX_int64": return "long.MaxValue";
|
||||
case "MAX_uint64": return "ulong.MaxValue";
|
||||
case "MAX_float": return "float.MaxValue";
|
||||
case "MAX_double": return "double.MaxValue";
|
||||
case "true":
|
||||
case "false": return value;
|
||||
}
|
||||
|
||||
// Numbers
|
||||
if (float.TryParse(value, out _) || (value[value.Length - 1] == 'f' && float.TryParse(value.Substring(0, value.Length - 1), out _)))
|
||||
return value;
|
||||
|
||||
value = value.Replace("::", ".");
|
||||
var dot = value.LastIndexOf('.');
|
||||
ApiTypeInfo apiType = null;
|
||||
if (dot != -1)
|
||||
{
|
||||
var type = new TypeInfo { Type = value.Substring(0, dot) };
|
||||
apiType = FindApiTypeInfo(buildData, type, caller);
|
||||
}
|
||||
|
||||
if (attribute)
|
||||
{
|
||||
@@ -95,45 +127,23 @@ namespace Flax.Build.Bindings
|
||||
case "Quaternion.Identity": return "typeof(Quaternion), \"0,0,0,1\"";
|
||||
}
|
||||
|
||||
// Enums
|
||||
if (apiType != null && apiType.IsEnum)
|
||||
return value;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Skip constants unsupported in C#
|
||||
var dot = value.LastIndexOf('.');
|
||||
if (dot != -1)
|
||||
{
|
||||
var type = new TypeInfo { Type = value.Substring(0, dot) };
|
||||
var apiType = FindApiTypeInfo(buildData, type, caller);
|
||||
if (apiType != null && apiType.IsStruct)
|
||||
return null;
|
||||
}
|
||||
if (apiType != null && apiType.IsStruct)
|
||||
return null;
|
||||
|
||||
// Special case for value constructors
|
||||
if (value.Contains('(') && value.Contains(')'))
|
||||
return "new " + value;
|
||||
|
||||
// Convert from C++ to C#
|
||||
switch (value)
|
||||
{
|
||||
case "nullptr":
|
||||
case "NULL":
|
||||
case "String.Empty":
|
||||
case "StringView.Empty": return "null";
|
||||
|
||||
case "MAX_int8": return "sbyte.MaxValue";
|
||||
case "MAX_uint8": return "byte.MaxValue";
|
||||
case "MAX_int16": return "short.MaxValue";
|
||||
case "MAX_uint16": return "ushort.MaxValue";
|
||||
case "MAX_int32": return "int.MaxValue";
|
||||
case "MAX_uint32": return "uint.MaxValue";
|
||||
case "MAX_int64": return "long.MaxValue";
|
||||
case "MAX_uint64": return "ulong.MaxValue";
|
||||
case "MAX_float": return "float.MaxValue";
|
||||
case "MAX_double": return "double.MaxValue";
|
||||
|
||||
default: return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private static string GenerateCSharpNativeToManaged(BuildData buildData, TypeInfo typeInfo, ApiTypeInfo caller)
|
||||
|
||||
@@ -2091,7 +2091,8 @@ namespace Flax.Build.Bindings
|
||||
header.Append(" for (int32 i = 0; i < data.Length(); i++)").AppendLine();
|
||||
header.AppendFormat(" mono_array_set(result, {0}Managed, i, ToManaged(data[i]));", apiType.Name).AppendLine();
|
||||
header.Append(" }").AppendLine();
|
||||
header.AppendFormat(" void ToNativeArray(Array<{0}>& result, MonoArray* data, int32 length)", fullName).AppendLine();
|
||||
header.Append(" template<typename AllocationType = HeapAllocation>").AppendLine();
|
||||
header.AppendFormat(" void ToNativeArray(Array<{0}, AllocationType>& result, MonoArray* data, int32 length)", fullName).AppendLine();
|
||||
header.Append(" {").AppendLine();
|
||||
header.Append(" for (int32 i = 0; i < length; i++)").AppendLine();
|
||||
header.AppendFormat(" result.Add(ToNative(mono_array_get(data, {0}Managed, i)));", apiType.Name).AppendLine();
|
||||
@@ -2271,7 +2272,8 @@ namespace Flax.Build.Bindings
|
||||
header.Append(" mono_array_setref(result, i, Box(data[i]));").AppendLine();
|
||||
header.Append(" }").AppendLine();
|
||||
|
||||
header.AppendFormat(" void ToNativeArray(Array<{0}>& result, MonoArray* data, int32 length)", fullName).AppendLine();
|
||||
header.Append(" template<typename AllocationType = HeapAllocation>").AppendLine();
|
||||
header.AppendFormat(" void ToNativeArray(Array<{0}, AllocationType>& result, MonoArray* data, int32 length)", fullName).AppendLine();
|
||||
header.Append(" {").AppendLine();
|
||||
header.Append(" for (int32 i = 0; i < length; i++)").AppendLine();
|
||||
header.AppendFormat(" Unbox(result[i], (MonoObject*)mono_array_addr_with_size(data, sizeof({0}Managed), length));", fullName).AppendLine();
|
||||
|
||||
@@ -76,6 +76,10 @@ namespace Flax.Build.Bindings
|
||||
if (commentLine.StartsWith("// "))
|
||||
commentLine = "/// " + commentLine.Substring(3);
|
||||
|
||||
// Fix inlined summary
|
||||
if (commentLine.StartsWith("/// <summary>") && commentLine.EndsWith("</summary>"))
|
||||
commentLine = "/// " + commentLine.Substring(13, commentLine.Length - 23);
|
||||
|
||||
context.StringCache.Insert(0, commentLine);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user