Revert "_assetref setunsafe (unstable buggy)"
This reverts commit 89d359e0078bbec8c84cad07950ad5df6df46fc3.
This commit is contained in:
@@ -217,17 +217,6 @@ public:
|
||||
{
|
||||
OnSet(asset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the asset reference without binding the events.
|
||||
/// This should only be used cautiously in cases where the reference needs to be held for a short time (for example in while marshalling managed types).
|
||||
/// </summary>
|
||||
/// <param name="asset">The asset.</param>
|
||||
void SetUnsafe(T* asset)
|
||||
{
|
||||
ASSERT(_asset == nullptr || asset == nullptr);
|
||||
_asset = asset;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -715,16 +715,8 @@ namespace Flax.Build.Bindings
|
||||
// For non-pod types converting only, other API converts managed to unmanaged object in C# wrapper code)
|
||||
if (CppNonPodTypesConvertingGeneration)
|
||||
{
|
||||
if (typeInfo.Type == "AssetReference")
|
||||
{
|
||||
type = "MObject*";
|
||||
return "(" + typeInfo.GenericArgs[0].Type + "*)ScriptingObject::ToNative({0})";
|
||||
}
|
||||
else
|
||||
{
|
||||
type = "MObject*";
|
||||
return "(" + typeInfo.GenericArgs[0].Type + "*)ScriptingObject::ToNative({0})";
|
||||
}
|
||||
type = "MObject*";
|
||||
return "(" + typeInfo.GenericArgs[0].Type + "*)ScriptingObject::ToNative({0})";
|
||||
}
|
||||
|
||||
type = typeInfo.GenericArgs[0].Type + '*';
|
||||
@@ -1272,7 +1264,7 @@ namespace Flax.Build.Bindings
|
||||
callParams += parameterInfo.Name;
|
||||
callParams += "Temp";
|
||||
}
|
||||
// Instruct for more optimized value move operation
|
||||
// Instruct for more optoimized value move operation
|
||||
else if (parameterInfo.Type.IsMoveRef)
|
||||
{
|
||||
callParams += $"MoveTemp({param})";
|
||||
@@ -1365,27 +1357,6 @@ namespace Flax.Build.Bindings
|
||||
}
|
||||
}
|
||||
|
||||
// Free special native resources
|
||||
bool needsCleanup = false;
|
||||
for (var i = 0; i < functionInfo.Parameters.Count; i++)
|
||||
{
|
||||
var parameterInfo = functionInfo.Parameters[i];
|
||||
if (/*CppParamsThatNeedConversion[i] ||*/ CppParamsThatNeedLocalVariable[i])
|
||||
{
|
||||
needsCleanup = true;
|
||||
//break;
|
||||
//if (parameterInfo.Type.Type == "AssetReference")
|
||||
var apiType = FindApiTypeInfo(buildData, parameterInfo.Type, caller);
|
||||
if (apiType != null && apiType.IsStruct && !apiType.IsPod)
|
||||
contents.Append(indent).AppendFormat("FreeNative({0}Temp);", parameterInfo.Name).AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
if (needsCleanup)
|
||||
{
|
||||
//contents.Append(indent).AppendFormat("FreeNative({0});", parameterInfo.Name, value).AppendLine();
|
||||
}
|
||||
|
||||
if (!useInlinedReturn && !functionInfo.Glue.UseReferenceForResult && !functionInfo.ReturnType.IsVoid)
|
||||
{
|
||||
contents.Append(indent).Append("return __result;").AppendLine();
|
||||
@@ -2966,7 +2937,6 @@ namespace Flax.Build.Bindings
|
||||
header.AppendLine("namespace {");
|
||||
header.AppendFormat("{0} ToManaged(const {1}& value);", wrapperName, fullName).AppendLine();
|
||||
header.AppendFormat("{1} ToNative(const {0}& value);", wrapperName, fullName).AppendLine();
|
||||
header.AppendFormat("void FreeNative({0}& value);", fullName).AppendLine();
|
||||
header.AppendLine("}");
|
||||
|
||||
// Generate MConverter for a structure
|
||||
@@ -3068,30 +3038,13 @@ namespace Flax.Build.Bindings
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fieldInfo.Type.Type == "AssetReference" && !string.IsNullOrEmpty(wrapper))
|
||||
header.AppendFormat(" result.{0}.SetUnsafe({1});", fieldInfo.Name, string.Format(wrapper, string.Format("value.{0}", fieldInfo.Name))).AppendLine();
|
||||
else if (string.IsNullOrEmpty(wrapper))
|
||||
if (string.IsNullOrEmpty(wrapper))
|
||||
header.AppendFormat(" result.{0} = value.{0};", fieldInfo.Name).AppendLine();
|
||||
else
|
||||
header.AppendFormat(" result.{0} = {1};", fieldInfo.Name, string.Format(wrapper, string.Format("value.{0}", fieldInfo.Name))).AppendLine();
|
||||
}
|
||||
header.Append(" return result;").AppendLine();
|
||||
header.Append('}').AppendLine();
|
||||
|
||||
// Generate cleanup function for native resources
|
||||
header.AppendLine();
|
||||
header.AppendFormat("void FreeNative({0}& value)", fullName).AppendLine();
|
||||
header.Append('{').AppendLine();
|
||||
for (var i = 0; i < fields.Count; i++)
|
||||
{
|
||||
var fieldInfo = fields[i];
|
||||
if (fieldInfo.IsStatic || fieldInfo.IsConstexpr)
|
||||
continue;
|
||||
|
||||
if (fieldInfo.Type.Type == "AssetReference")
|
||||
header.AppendFormat(" value.{0}.SetUnsafe(nullptr);", fieldInfo.Name).AppendLine();
|
||||
}
|
||||
header.Append('}').AppendLine();
|
||||
header.AppendLine("}");
|
||||
}
|
||||
else if (classInfo != null)
|
||||
|
||||
Reference in New Issue
Block a user