Merge remote-tracking branch 'origin/master' into 1.9
# Conflicts: # Source/Engine/Content/Storage/FlaxStorage.cpp # Source/Engine/Renderer/GBufferPass.cpp
This commit is contained in:
@@ -98,7 +98,7 @@ namespace Flax.Build.Bindings
|
||||
{
|
||||
var result = NativeName;
|
||||
if (Parent != null && !(Parent is FileInfo))
|
||||
result = Parent.FullNameNative + '_' + result;
|
||||
result = Parent.FullNameNative.Replace("::", "_") + '_' + result;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,13 +267,21 @@ namespace Flax.Build.Bindings
|
||||
if (value.Contains('(') && value.Contains(')'))
|
||||
return "new " + value;
|
||||
|
||||
// Special case for non-strongly typed enums
|
||||
if (valueType != null && !value.Contains('.', StringComparison.Ordinal))
|
||||
{
|
||||
apiType = FindApiTypeInfo(buildData, valueType, caller);
|
||||
if (apiType is EnumInfo)
|
||||
return $"{apiType.Name}.{value}";
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private static string GenerateCSharpNativeToManaged(BuildData buildData, TypeInfo typeInfo, ApiTypeInfo caller, bool marshalling = false)
|
||||
{
|
||||
string result;
|
||||
if (typeInfo?.Type == null)
|
||||
if (typeInfo == null || typeInfo.Type == null)
|
||||
throw new ArgumentNullException();
|
||||
|
||||
// Use dynamic array as wrapper container for fixed-size native arrays
|
||||
@@ -1641,8 +1649,9 @@ namespace Flax.Build.Bindings
|
||||
if (internalType)
|
||||
{
|
||||
// Marshal blittable array elements back to original non-blittable elements
|
||||
string originalElementTypeMarshaller = originalElementType + "Marshaller";
|
||||
string internalElementType = $"{originalElementTypeMarshaller}.{originalElementType}Internal";
|
||||
string originalElementTypeMarshaller = $"{originalElementType}Marshaller";
|
||||
string originalElementTypeName = originalElementType.Substring(originalElementType.LastIndexOf('.') + 1); // Strip namespace
|
||||
string internalElementType = $"{originalElementTypeMarshaller}.{originalElementTypeName}Internal";
|
||||
toManagedContent.AppendLine($"unmanaged.{fieldInfo.Name} != IntPtr.Zero ? NativeInterop.ConvertArray((Unsafe.As<ManagedArray>(ManagedHandle.FromIntPtr(unmanaged.{fieldInfo.Name}).Target)).ToSpan<{internalElementType}>(), {originalElementTypeMarshaller}.ToManaged) : null;");
|
||||
toNativeContent.AppendLine($"managed.{fieldInfo.Name}?.Length > 0 ? ManagedHandle.ToIntPtr(ManagedArray.WrapNewArray(NativeInterop.ConvertArray(managed.{fieldInfo.Name}, {originalElementTypeMarshaller}.ToNative)), GCHandleType.Weak) : IntPtr.Zero;");
|
||||
freeContents.AppendLine($"if (unmanaged.{fieldInfo.Name} != IntPtr.Zero) {{ ManagedHandle handle = ManagedHandle.FromIntPtr(unmanaged.{fieldInfo.Name}); Span<{internalElementType}> values = (Unsafe.As<ManagedArray>(handle.Target)).ToSpan<{internalElementType}>(); foreach (var value in values) {{ {originalElementTypeMarshaller}.Free(value); }} (Unsafe.As<ManagedArray>(handle.Target)).Free(); handle.Free(); }}");
|
||||
|
||||
@@ -1991,13 +1991,8 @@ namespace Flax.Build.Bindings
|
||||
}
|
||||
contents.Append(')').AppendLine();
|
||||
contents.Append(" {").AppendLine();
|
||||
if (buildData.Target.IsEditor && false)
|
||||
contents.Append(" MMethod* method = nullptr;").AppendLine(); // TODO: find a better way to cache event method in editor and handle C# hot-reload
|
||||
else
|
||||
contents.Append(" static MMethod* method = nullptr;").AppendLine();
|
||||
contents.Append(" if (!method)").AppendLine();
|
||||
contents.AppendFormat(" method = {1}::TypeInitializer.GetClass()->GetMethod(\"Internal_{0}_Invoke\", {2});", eventInfo.Name, classTypeNameNative, paramsCount).AppendLine();
|
||||
contents.Append(" CHECK(method);").AppendLine();
|
||||
contents.Append(" static MMethod* method = nullptr;").AppendLine();
|
||||
contents.AppendFormat(" if (!method) {{ method = {1}::TypeInitializer.GetClass()->GetMethod(\"Internal_{0}_Invoke\", {2}); CHECK(method); }}", eventInfo.Name, classTypeNameNative, paramsCount).AppendLine();
|
||||
contents.Append(" MObject* exception = nullptr;").AppendLine();
|
||||
if (paramsCount == 0)
|
||||
contents.AppendLine(" void** params = nullptr;");
|
||||
|
||||
Reference in New Issue
Block a user