C#: Add Duplicate method to the Array and Dictionary bindings
This commit is contained in:
parent
73fb08289a
commit
3797f19926
4 changed files with 40 additions and 0 deletions
|
@ -64,6 +64,11 @@ namespace Godot.Collections
|
|||
return safeHandle.DangerousGetHandle();
|
||||
}
|
||||
|
||||
public Array Duplicate(bool deep = false)
|
||||
{
|
||||
return new Array(godot_icall_Array_Duplicate(GetPtr(), deep));
|
||||
}
|
||||
|
||||
public Error Resize(int newSize)
|
||||
{
|
||||
return godot_icall_Array_Resize(GetPtr(), newSize);
|
||||
|
@ -178,6 +183,9 @@ namespace Godot.Collections
|
|||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static void godot_icall_Array_CopyTo(IntPtr ptr, System.Array array, int arrayIndex);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_Array_Duplicate(IntPtr ptr, bool deep);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static int godot_icall_Array_IndexOf(IntPtr ptr, object item);
|
||||
|
||||
|
@ -250,6 +258,11 @@ namespace Godot.Collections
|
|||
return from.objectArray;
|
||||
}
|
||||
|
||||
public Array<T> Duplicate(bool deep = false)
|
||||
{
|
||||
return new Array<T>(objectArray.Duplicate(deep));
|
||||
}
|
||||
|
||||
public Error Resize(int newSize)
|
||||
{
|
||||
return objectArray.Resize(newSize);
|
||||
|
|
|
@ -80,6 +80,11 @@ namespace Godot.Collections
|
|||
disposed = true;
|
||||
}
|
||||
|
||||
public Dictionary Duplicate(bool deep = false)
|
||||
{
|
||||
return new Dictionary(godot_icall_Dictionary_Duplicate(GetPtr(), deep));
|
||||
}
|
||||
|
||||
// IDictionary
|
||||
|
||||
public ICollection Keys
|
||||
|
@ -234,6 +239,9 @@ namespace Godot.Collections
|
|||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_Dictionary_ContainsKey(IntPtr ptr, object key);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static IntPtr godot_icall_Dictionary_Duplicate(IntPtr ptr, bool deep);
|
||||
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
internal extern static bool godot_icall_Dictionary_RemoveKey(IntPtr ptr, object key);
|
||||
|
||||
|
@ -313,6 +321,11 @@ namespace Godot.Collections
|
|||
return objectDict.GetPtr();
|
||||
}
|
||||
|
||||
public Dictionary<TKey, TValue> Duplicate(bool deep = false)
|
||||
{
|
||||
return new Dictionary<TKey, TValue>(objectDict.Duplicate(deep));
|
||||
}
|
||||
|
||||
// IDictionary<TKey, TValue>
|
||||
|
||||
public TValue this[TKey key]
|
||||
|
|
|
@ -103,6 +103,10 @@ void godot_icall_Array_CopyTo(Array *ptr, MonoArray *array, int array_index) {
|
|||
}
|
||||
}
|
||||
|
||||
Array *godot_icall_Array_Duplicate(Array *ptr, MonoBoolean deep) {
|
||||
return memnew(Array(ptr->duplicate(deep)));
|
||||
}
|
||||
|
||||
int godot_icall_Array_IndexOf(Array *ptr, MonoObject *item) {
|
||||
return ptr->find(GDMonoMarshal::mono_object_to_variant(item));
|
||||
}
|
||||
|
@ -224,6 +228,10 @@ MonoBoolean godot_icall_Dictionary_ContainsKey(Dictionary *ptr, MonoObject *key)
|
|||
return ptr->has(GDMonoMarshal::mono_object_to_variant(key));
|
||||
}
|
||||
|
||||
Dictionary *godot_icall_Dictionary_Duplicate(Dictionary *ptr, MonoBoolean deep) {
|
||||
return memnew(Dictionary(ptr->duplicate(deep)));
|
||||
}
|
||||
|
||||
MonoBoolean godot_icall_Dictionary_RemoveKey(Dictionary *ptr, MonoObject *key) {
|
||||
return ptr->erase(GDMonoMarshal::mono_object_to_variant(key));
|
||||
}
|
||||
|
@ -284,6 +292,7 @@ void godot_register_collections_icalls() {
|
|||
mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Clear", (void *)godot_icall_Array_Clear);
|
||||
mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Contains", (void *)godot_icall_Array_Contains);
|
||||
mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_CopyTo", (void *)godot_icall_Array_CopyTo);
|
||||
mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Duplicate", (void *)godot_icall_Array_Duplicate);
|
||||
mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_IndexOf", (void *)godot_icall_Array_IndexOf);
|
||||
mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Insert", (void *)godot_icall_Array_Insert);
|
||||
mono_add_internal_call("Godot.Collections.Array::godot_icall_Array_Remove", (void *)godot_icall_Array_Remove);
|
||||
|
@ -304,6 +313,7 @@ void godot_register_collections_icalls() {
|
|||
mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Clear", (void *)godot_icall_Dictionary_Clear);
|
||||
mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Contains", (void *)godot_icall_Dictionary_Contains);
|
||||
mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_ContainsKey", (void *)godot_icall_Dictionary_ContainsKey);
|
||||
mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Duplicate", (void *)godot_icall_Dictionary_Duplicate);
|
||||
mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_RemoveKey", (void *)godot_icall_Dictionary_RemoveKey);
|
||||
mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_Remove", (void *)godot_icall_Dictionary_Remove);
|
||||
mono_add_internal_call("Godot.Collections.Dictionary::godot_icall_Dictionary_TryGetValue", (void *)godot_icall_Dictionary_TryGetValue);
|
||||
|
|
|
@ -59,6 +59,8 @@ MonoBoolean godot_icall_Array_Contains(Array *ptr, MonoObject *item);
|
|||
|
||||
void godot_icall_Array_CopyTo(Array *ptr, MonoArray *array, int array_index);
|
||||
|
||||
Array *godot_icall_Array_Duplicate(Array *ptr, MonoBoolean deep);
|
||||
|
||||
int godot_icall_Array_IndexOf(Array *ptr, MonoObject *item);
|
||||
|
||||
void godot_icall_Array_Insert(Array *ptr, int index, MonoObject *item);
|
||||
|
@ -99,6 +101,8 @@ MonoBoolean godot_icall_Dictionary_Contains(Dictionary *ptr, MonoObject *key, Mo
|
|||
|
||||
MonoBoolean godot_icall_Dictionary_ContainsKey(Dictionary *ptr, MonoObject *key);
|
||||
|
||||
Dictionary *godot_icall_Dictionary_Duplicate(Dictionary *ptr, MonoBoolean deep);
|
||||
|
||||
MonoBoolean godot_icall_Dictionary_RemoveKey(Dictionary *ptr, MonoObject *key);
|
||||
|
||||
MonoBoolean godot_icall_Dictionary_Remove(Dictionary *ptr, MonoObject *key, MonoObject *value);
|
||||
|
|
Loading…
Reference in a new issue