Post merge fixes for new dotnet7

This commit is contained in:
Wojtek Figat
2023-04-17 14:04:08 +02:00
parent 67b373c6df
commit 9322a2006a
4 changed files with 14 additions and 13 deletions

View File

@@ -684,7 +684,7 @@ void NetworkReplicator::AddRPC(const ScriptingTypeHandle& typeHandle, const Stri
NetworkRpcInfo::RPCsTable[rpcName] = rpcInfo; NetworkRpcInfo::RPCsTable[rpcName] = rpcInfo;
} }
void NetworkReplicator::CSharpEndInvokeRPC(ScriptingObject* obj, const ScriptingTypeHandle& type, const StringAnsiView& name, NetworkStream* argsStream, MonoArray* targetIds) void NetworkReplicator::CSharpEndInvokeRPC(ScriptingObject* obj, const ScriptingTypeHandle& type, const StringAnsiView& name, NetworkStream* argsStream, MArray* targetIds)
{ {
EndInvokeRPC(obj, type, GetCSharpCachedName(name), argsStream, MUtils::ToSpan<uint32>(targetIds)); EndInvokeRPC(obj, type, GetCSharpCachedName(name), argsStream, MUtils::ToSpan<uint32>(targetIds));
} }

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. // Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
#pragma once #pragma once
@@ -183,7 +183,7 @@ private:
#if !COMPILE_WITHOUT_CSHARP #if !COMPILE_WITHOUT_CSHARP
API_FUNCTION(NoProxy) static void AddSerializer(const ScriptingTypeHandle& typeHandle, const Function<void(void*, void*)>& serialize, const Function<void(void*, void*)>& deserialize); API_FUNCTION(NoProxy) static void AddSerializer(const ScriptingTypeHandle& typeHandle, const Function<void(void*, void*)>& serialize, const Function<void(void*, void*)>& deserialize);
API_FUNCTION(NoProxy) static void AddRPC(const ScriptingTypeHandle& typeHandle, const StringAnsiView& name, const Function<void(void*, void*)>& execute, bool isServer, bool isClient, NetworkChannelType channel); API_FUNCTION(NoProxy) static void AddRPC(const ScriptingTypeHandle& typeHandle, const StringAnsiView& name, const Function<void(void*, void*)>& execute, bool isServer, bool isClient, NetworkChannelType channel);
API_FUNCTION(NoProxy) static void CSharpEndInvokeRPC(ScriptingObject* obj, const ScriptingTypeHandle& type, const StringAnsiView& name, NetworkStream* argsStream, MonoArray* targetIds); API_FUNCTION(NoProxy) static void CSharpEndInvokeRPC(ScriptingObject* obj, const ScriptingTypeHandle& type, const StringAnsiView& name, NetworkStream* argsStream, MArray* targetIds);
static StringAnsiView GetCSharpCachedName(const StringAnsiView& name); static StringAnsiView GetCSharpCachedName(const StringAnsiView& name);
#endif #endif
}; };

View File

@@ -1387,6 +1387,7 @@ namespace Flax.Build.Bindings
{ {
// Native struct begin // Native struct begin
// TODO: skip using this utility structure if the auto-generated C# struct is already the same as XXXInternal here below
GenerateCSharpAttributes(buildData, contents, indent, structureInfo, true); GenerateCSharpAttributes(buildData, contents, indent, structureInfo, true);
contents.Append(indent).AppendLine("[HideInEditor]"); contents.Append(indent).AppendLine("[HideInEditor]");
contents.Append(indent).AppendLine("[StructLayout(LayoutKind.Sequential)]"); contents.Append(indent).AppendLine("[StructLayout(LayoutKind.Sequential)]");
@@ -1433,7 +1434,7 @@ namespace Flax.Build.Bindings
var apiType = FindApiTypeInfo(buildData, fieldInfo.Type, structureInfo); var apiType = FindApiTypeInfo(buildData, fieldInfo.Type, structureInfo);
bool internalType = apiType is StructureInfo fieldStructureInfo && UseCustomMarshalling(buildData, fieldStructureInfo, structureInfo); bool internalType = apiType is StructureInfo fieldStructureInfo && UseCustomMarshalling(buildData, fieldStructureInfo, structureInfo);
string internalTypeMarshaler = ""; string internalTypeMarshaller = "";
if (fieldInfo.Type.IsArray && (fieldInfo.NoArray || structureInfo.IsPod)) if (fieldInfo.Type.IsArray && (fieldInfo.NoArray || structureInfo.IsPod))
{ {
@@ -1460,7 +1461,7 @@ namespace Flax.Build.Bindings
type = "IntPtr"; type = "IntPtr";
else if (fieldInfo.Type.IsPtr && !originalType.EndsWith("*")) else if (fieldInfo.Type.IsPtr && !originalType.EndsWith("*"))
type = "IntPtr"; type = "IntPtr";
else if (fieldInfo.Type.Type == "Array") else if (fieldInfo.Type.Type == "Array" || fieldInfo.Type.Type == "Span" || fieldInfo.Type.Type == "DataContainer" || fieldInfo.Type.Type == "BytesContainer")
{ {
type = "IntPtr"; type = "IntPtr";
apiType = FindApiTypeInfo(buildData, fieldInfo.Type.GenericArgs[0], structureInfo); apiType = FindApiTypeInfo(buildData, fieldInfo.Type.GenericArgs[0], structureInfo);
@@ -1476,8 +1477,8 @@ namespace Flax.Build.Bindings
type = "NativeVariant"; type = "NativeVariant";
else if (internalType) else if (internalType)
{ {
internalTypeMarshaler = type + "Marshaller"; internalTypeMarshaller = type + "Marshaller";
type = $"{internalTypeMarshaler}.{type}Internal"; type = $"{internalTypeMarshaller}.{type}Internal";
} }
//else if (type == "Guid") //else if (type == "Guid")
// type = "GuidNative"; // type = "GuidNative";
@@ -1546,7 +1547,7 @@ namespace Flax.Build.Bindings
freeContents.AppendLine($"if (unmanaged.{fieldInfo.Name} != IntPtr.Zero) {{ ManagedHandle.FromIntPtr(unmanaged.{fieldInfo.Name}).Free(); }}"); freeContents.AppendLine($"if (unmanaged.{fieldInfo.Name} != IntPtr.Zero) {{ ManagedHandle.FromIntPtr(unmanaged.{fieldInfo.Name}).Free(); }}");
freeContents2.AppendLine($"if (unmanaged.{fieldInfo.Name} != IntPtr.Zero) {{ ManagedHandle.FromIntPtr(unmanaged.{fieldInfo.Name}).Free(); }}"); freeContents2.AppendLine($"if (unmanaged.{fieldInfo.Name} != IntPtr.Zero) {{ ManagedHandle.FromIntPtr(unmanaged.{fieldInfo.Name}).Free(); }}");
} }
else if (fieldInfo.Type.Type == "Array") else if (fieldInfo.Type.Type == "Array" || fieldInfo.Type.Type == "Span" || fieldInfo.Type.Type == "DataContainer" || fieldInfo.Type.Type == "BytesContainer")
{ {
string originalElementType = originalType.Substring(0, originalType.Length - 2); string originalElementType = originalType.Substring(0, originalType.Length - 2);
if (internalType) if (internalType)
@@ -1597,10 +1598,10 @@ namespace Flax.Build.Bindings
} }
else if (internalType) else if (internalType)
{ {
toManagedContent.Append($"{internalTypeMarshaler}.ToManaged(managed.{fieldInfo.Name})"); toManagedContent.Append($"{internalTypeMarshaller}.ToManaged(managed.{fieldInfo.Name})");
toNativeContent.Append($"{internalTypeMarshaler}.ToNative(managed.{fieldInfo.Name})"); toNativeContent.Append($"{internalTypeMarshaller}.ToNative(managed.{fieldInfo.Name})");
freeContents.AppendLine($"{internalTypeMarshaler}.Free(unmanaged.{fieldInfo.Name});"); freeContents.AppendLine($"{internalTypeMarshaller}.Free(unmanaged.{fieldInfo.Name});");
freeContents2.AppendLine($"{internalTypeMarshaler}.Free(unmanaged.{fieldInfo.Name});"); freeContents2.AppendLine($"{internalTypeMarshaller}.Free(unmanaged.{fieldInfo.Name});");
} }
/*else if (originalType == "Guid") /*else if (originalType == "Guid")
{ {

View File

@@ -514,7 +514,7 @@ namespace Flax.Build.Bindings
if (typeInfo.Type == "Span" && typeInfo.GenericArgs != null) if (typeInfo.Type == "Span" && typeInfo.GenericArgs != null)
{ {
type = "MonoArray*"; type = "MonoArray*";
return "MUtils::Span({0}, " + GenerateCppGetNativeClass(buildData, typeInfo.GenericArgs[0], caller, functionInfo) + ")"; return "MUtils::Span({0}, " + GenerateCppGetMClass(buildData, typeInfo.GenericArgs[0], caller, functionInfo) + ")";
} }
// BytesContainer // BytesContainer