summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaul Santos <raulsntos@gmail.com>2022-12-23 19:28:34 +0100
committerRaul Santos <raulsntos@gmail.com>2022-12-23 19:40:32 +0100
commit24e4ac9167e6c949a6033231848d4d778c869a3d (patch)
treeac568b8a8fc2b68558ad513961514767aec1adae
parentd0398f62f08ce0cfba80990b21c6af4181f93fe9 (diff)
C#: Rename `ConvertToX` methods
- Renamed `ConvertToX` to `ConvertToNativeX`. - Renamed `ConvertToXObject` to `ConvertToX`. - Renamed `ConvertToXManaged` to `ConvertToX`. - Fix `Signal` name in bindings generator and csharp script.
-rw-r--r--modules/mono/csharp_script.cpp2
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs4
-rw-r--r--modules/mono/editor/bindings_generator.cpp6
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs46
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs14
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs18
8 files changed, 47 insertions, 47 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index eca53c4831..26739bcdea 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -451,7 +451,7 @@ static String variant_type_to_managed_name(const String &p_var_type_name) {
}
if (p_var_type_name == Variant::get_type_name(Variant::SIGNAL)) {
- return "SignalInfo";
+ return "Signal";
}
Variant::Type var_types[] = {
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs
index 8b2f96036b..f0a6a72281 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/MarshalUtils.cs
@@ -311,12 +311,12 @@ namespace Godot.SourceGenerators
inputExpr, ")"),
// We need a special case for generic Godot collections and GodotObjectOrDerived[], because VariantUtils.ConvertTo<T> is slower
MarshalType.GodotGenericDictionary =>
- source.Append(VariantUtils, ".ConvertToDictionaryObject<",
+ source.Append(VariantUtils, ".ConvertToDictionary<",
((INamedTypeSymbol)typeSymbol).TypeArguments[0].FullQualifiedNameIncludeGlobal(), ", ",
((INamedTypeSymbol)typeSymbol).TypeArguments[1].FullQualifiedNameIncludeGlobal(), ">(",
inputExpr, ")"),
MarshalType.GodotGenericArray =>
- source.Append(VariantUtils, ".ConvertToArrayObject<",
+ source.Append(VariantUtils, ".ConvertToArray<",
((INamedTypeSymbol)typeSymbol).TypeArguments[0].FullQualifiedNameIncludeGlobal(), ">(",
inputExpr, ")"),
_ => source.Append(VariantUtils, ".ConvertTo<",
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 6559cbf75d..6cfdb15627 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -3650,7 +3650,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype = TypeInterface();
itype.name = "Signal";
itype.cname = itype.name;
- itype.proxy_name = "SignalInfo";
+ itype.proxy_name = "Signal";
itype.cs_type = itype.proxy_name;
itype.cs_in_expr = "%0";
itype.c_in = "%5using %0 %1_in = " C_METHOD_MANAGED_TO_SIGNAL "(in %1);\n";
@@ -3732,7 +3732,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.cname = itype.name;
itype.cs_out = "%5return new %2(%0(%1));";
// For generic Godot collections, Variant.From<T>/As<T> is slower, so we need this special case
- itype.cs_variant_to_managed = "VariantUtils.ConvertToArrayObject(%0)";
+ itype.cs_variant_to_managed = "VariantUtils.ConvertToArray(%0)";
itype.cs_managed_to_variant = "VariantUtils.CreateFromArray(%0)";
builtin_types.insert(itype.cname, itype);
@@ -3759,7 +3759,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype.cname = itype.name;
itype.cs_out = "%5return new %2(%0(%1));";
// For generic Godot collections, Variant.From<T>/As<T> is slower, so we need this special case
- itype.cs_variant_to_managed = "VariantUtils.ConvertToDictionaryObject(%0)";
+ itype.cs_variant_to_managed = "VariantUtils.ConvertToDictionary(%0)";
itype.cs_managed_to_variant = "VariantUtils.CreateFromDictionary(%0)";
builtin_types.insert(itype.cname, itype);
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
index 130776499b..df306e5244 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs
@@ -499,7 +499,7 @@ namespace Godot.Collections
VariantUtils.CreateFromArray(godotArray);
private static Array<T> FromVariantFunc(in godot_variant variant) =>
- VariantUtils.ConvertToArrayObject<T>(variant);
+ VariantUtils.ConvertToArray<T>(variant);
static unsafe Array()
{
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs
index cf25e1f0ae..b5a8742d3d 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs
@@ -366,7 +366,7 @@ namespace Godot.Collections
VariantUtils.CreateFromDictionary(godotDictionary);
private static Dictionary<TKey, TValue> FromVariantFunc(in godot_variant variant) =>
- VariantUtils.ConvertToDictionaryObject<TKey, TValue>(variant);
+ VariantUtils.ConvertToDictionary<TKey, TValue>(variant);
static unsafe Dictionary()
{
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs
index 6a4717f2c3..f65f926b22 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs
@@ -436,7 +436,7 @@ namespace Godot.NativeInterop
public static Godot.Object ConvertToGodotObject(in godot_variant p_var)
=> InteropUtils.UnmanagedGetManaged(ConvertToGodotObjectPtr(p_var));
- public static string ConvertToStringObject(in godot_variant p_var)
+ public static string ConvertToString(in godot_variant p_var)
{
switch (p_var.Type)
{
@@ -455,65 +455,65 @@ namespace Godot.NativeInterop
}
}
- public static godot_string_name ConvertToStringName(in godot_variant p_var)
+ public static godot_string_name ConvertToNativeStringName(in godot_variant p_var)
=> p_var.Type == Variant.Type.StringName ?
NativeFuncs.godotsharp_string_name_new_copy(p_var.StringName) :
NativeFuncs.godotsharp_variant_as_string_name(p_var);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static StringName ConvertToStringNameObject(in godot_variant p_var)
- => StringName.CreateTakingOwnershipOfDisposableValue(ConvertToStringName(p_var));
+ public static StringName ConvertToStringName(in godot_variant p_var)
+ => StringName.CreateTakingOwnershipOfDisposableValue(ConvertToNativeStringName(p_var));
- public static godot_node_path ConvertToNodePath(in godot_variant p_var)
+ public static godot_node_path ConvertToNativeNodePath(in godot_variant p_var)
=> p_var.Type == Variant.Type.NodePath ?
NativeFuncs.godotsharp_node_path_new_copy(p_var.NodePath) :
NativeFuncs.godotsharp_variant_as_node_path(p_var);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static NodePath ConvertToNodePathObject(in godot_variant p_var)
- => NodePath.CreateTakingOwnershipOfDisposableValue(ConvertToNodePath(p_var));
+ public static NodePath ConvertToNodePath(in godot_variant p_var)
+ => NodePath.CreateTakingOwnershipOfDisposableValue(ConvertToNativeNodePath(p_var));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static godot_callable ConvertToCallable(in godot_variant p_var)
+ public static godot_callable ConvertToNativeCallable(in godot_variant p_var)
=> NativeFuncs.godotsharp_variant_as_callable(p_var);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Callable ConvertToCallableManaged(in godot_variant p_var)
- => Marshaling.ConvertCallableToManaged(ConvertToCallable(p_var));
+ public static Callable ConvertToCallable(in godot_variant p_var)
+ => Marshaling.ConvertCallableToManaged(ConvertToNativeCallable(p_var));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static godot_signal ConvertToSignal(in godot_variant p_var)
+ public static godot_signal ConvertToNativeSignal(in godot_variant p_var)
=> NativeFuncs.godotsharp_variant_as_signal(p_var);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Signal ConvertToSignalManaged(in godot_variant p_var)
- => Marshaling.ConvertSignalToManaged(ConvertToSignal(p_var));
+ public static Signal ConvertToSignal(in godot_variant p_var)
+ => Marshaling.ConvertSignalToManaged(ConvertToNativeSignal(p_var));
- public static godot_array ConvertToArray(in godot_variant p_var)
+ public static godot_array ConvertToNativeArray(in godot_variant p_var)
=> p_var.Type == Variant.Type.Array ?
NativeFuncs.godotsharp_array_new_copy(p_var.Array) :
NativeFuncs.godotsharp_variant_as_array(p_var);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Collections.Array ConvertToArrayObject(in godot_variant p_var)
- => Collections.Array.CreateTakingOwnershipOfDisposableValue(ConvertToArray(p_var));
+ public static Collections.Array ConvertToArray(in godot_variant p_var)
+ => Collections.Array.CreateTakingOwnershipOfDisposableValue(ConvertToNativeArray(p_var));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Array<T> ConvertToArrayObject<T>(in godot_variant p_var)
- => Array<T>.CreateTakingOwnershipOfDisposableValue(ConvertToArray(p_var));
+ public static Array<T> ConvertToArray<T>(in godot_variant p_var)
+ => Array<T>.CreateTakingOwnershipOfDisposableValue(ConvertToNativeArray(p_var));
- public static godot_dictionary ConvertToDictionary(in godot_variant p_var)
+ public static godot_dictionary ConvertToNativeDictionary(in godot_variant p_var)
=> p_var.Type == Variant.Type.Dictionary ?
NativeFuncs.godotsharp_dictionary_new_copy(p_var.Dictionary) :
NativeFuncs.godotsharp_variant_as_dictionary(p_var);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Dictionary ConvertToDictionaryObject(in godot_variant p_var)
- => Dictionary.CreateTakingOwnershipOfDisposableValue(ConvertToDictionary(p_var));
+ public static Dictionary ConvertToDictionary(in godot_variant p_var)
+ => Dictionary.CreateTakingOwnershipOfDisposableValue(ConvertToNativeDictionary(p_var));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Dictionary<TKey, TValue> ConvertToDictionaryObject<TKey, TValue>(in godot_variant p_var)
- => Dictionary<TKey, TValue>.CreateTakingOwnershipOfDisposableValue(ConvertToDictionary(p_var));
+ public static Dictionary<TKey, TValue> ConvertToDictionary<TKey, TValue>(in godot_variant p_var)
+ => Dictionary<TKey, TValue>.CreateTakingOwnershipOfDisposableValue(ConvertToNativeDictionary(p_var));
public static byte[] ConvertAsPackedByteArrayToSystemArray(in godot_variant p_var)
{
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs
index ebfc713ee4..3d64533269 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs
@@ -315,13 +315,13 @@ public partial class VariantUtils
return UnsafeAsT(ConvertToPlane(variant));
if (typeof(T) == typeof(Callable))
- return UnsafeAsT(ConvertToCallableManaged(variant));
+ return UnsafeAsT(ConvertToCallable(variant));
if (typeof(T) == typeof(Signal))
- return UnsafeAsT(ConvertToSignalManaged(variant));
+ return UnsafeAsT(ConvertToSignal(variant));
if (typeof(T) == typeof(string))
- return UnsafeAsT(ConvertToStringObject(variant));
+ return UnsafeAsT(ConvertToString(variant));
if (typeof(T) == typeof(byte[]))
return UnsafeAsT(ConvertAsPackedByteArrayToSystemArray(variant));
@@ -360,19 +360,19 @@ public partial class VariantUtils
return UnsafeAsT(ConvertToSystemArrayOfRID(variant));
if (typeof(T) == typeof(StringName))
- return UnsafeAsT(ConvertToStringNameObject(variant));
+ return UnsafeAsT(ConvertToStringName(variant));
if (typeof(T) == typeof(NodePath))
- return UnsafeAsT(ConvertToNodePathObject(variant));
+ return UnsafeAsT(ConvertToNodePath(variant));
if (typeof(T) == typeof(RID))
return UnsafeAsT(ConvertToRID(variant));
if (typeof(T) == typeof(Godot.Collections.Dictionary))
- return UnsafeAsT(ConvertToDictionaryObject(variant));
+ return UnsafeAsT(ConvertToDictionary(variant));
if (typeof(T) == typeof(Godot.Collections.Array))
- return UnsafeAsT(ConvertToArrayObject(variant));
+ return UnsafeAsT(ConvertToArray(variant));
if (typeof(T) == typeof(Variant))
return UnsafeAsT(Variant.CreateCopyingBorrowed(variant));
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs
index c4c53a39f9..da12309217 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Variant.cs
@@ -212,7 +212,7 @@ public partial struct Variant : IDisposable
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public string AsString() =>
- VariantUtils.ConvertToStringObject((godot_variant)NativeVar);
+ VariantUtils.ConvertToString((godot_variant)NativeVar);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Vector2 AsVector2() =>
@@ -280,11 +280,11 @@ public partial struct Variant : IDisposable
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Callable AsCallable() =>
- VariantUtils.ConvertToCallableManaged((godot_variant)NativeVar);
+ VariantUtils.ConvertToCallable((godot_variant)NativeVar);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Signal AsSignal() =>
- VariantUtils.ConvertToSignalManaged((godot_variant)NativeVar);
+ VariantUtils.ConvertToSignal((godot_variant)NativeVar);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public byte[] AsByteArray() =>
@@ -329,11 +329,11 @@ public partial struct Variant : IDisposable
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Collections.Dictionary<TKey, TValue> AsGodotDictionary<TKey, TValue>() =>
- VariantUtils.ConvertToDictionaryObject<TKey, TValue>((godot_variant)NativeVar);
+ VariantUtils.ConvertToDictionary<TKey, TValue>((godot_variant)NativeVar);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Collections.Array<T> AsGodotArray<T>() =>
- VariantUtils.ConvertToArrayObject<T>((godot_variant)NativeVar);
+ VariantUtils.ConvertToArray<T>((godot_variant)NativeVar);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public StringName[] AsSystemArrayOfStringName() =>
@@ -353,11 +353,11 @@ public partial struct Variant : IDisposable
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public StringName AsStringName() =>
- VariantUtils.ConvertToStringNameObject((godot_variant)NativeVar);
+ VariantUtils.ConvertToStringName((godot_variant)NativeVar);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public NodePath AsNodePath() =>
- VariantUtils.ConvertToNodePathObject((godot_variant)NativeVar);
+ VariantUtils.ConvertToNodePath((godot_variant)NativeVar);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public RID AsRID() =>
@@ -365,11 +365,11 @@ public partial struct Variant : IDisposable
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Collections.Dictionary AsGodotDictionary() =>
- VariantUtils.ConvertToDictionaryObject((godot_variant)NativeVar);
+ VariantUtils.ConvertToDictionary((godot_variant)NativeVar);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Collections.Array AsGodotArray() =>
- VariantUtils.ConvertToArrayObject((godot_variant)NativeVar);
+ VariantUtils.ConvertToArray((godot_variant)NativeVar);
// Explicit conversion operators to supported types