You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Merge pull request #105928 from Ivorforce/cowdata-reserve-capacity
Core: Add `reserve` function to `Array`, `Vector`, and `String`
This commit is contained in:
@@ -538,7 +538,7 @@ namespace Godot.NativeInterop
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr != IntPtr.Zero ? (int)(*((ulong*)_ptr - 1)) : 0;
|
||||
get => (int)NativeFuncs.godotsharp_string_size(in this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -764,12 +764,6 @@ namespace Godot.NativeInterop
|
||||
|
||||
// There are more fields here, but we don't care as we never store this in C#
|
||||
|
||||
public readonly int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _arrayVector.Size;
|
||||
}
|
||||
|
||||
public readonly unsafe bool IsReadOnly
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -782,12 +776,6 @@ namespace Godot.NativeInterop
|
||||
{
|
||||
private IntPtr _writeProxy;
|
||||
public unsafe godot_variant* _ptr;
|
||||
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr != null ? (int)(*((ulong*)_ptr - 1)) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public readonly unsafe godot_variant* Elements
|
||||
@@ -805,7 +793,7 @@ namespace Godot.NativeInterop
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _p != null ? _p->Size : 0;
|
||||
get => (int)NativeFuncs.godotsharp_array_size(in this);
|
||||
}
|
||||
|
||||
public readonly unsafe bool IsReadOnly
|
||||
@@ -936,7 +924,7 @@ namespace Godot.NativeInterop
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr != null ? (int)(*((ulong*)_ptr - 1)) : 0;
|
||||
get => (int)NativeFuncs.godotsharp_packed_byte_array_size(in this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -967,7 +955,7 @@ namespace Godot.NativeInterop
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr != null ? (int)(*((ulong*)_ptr - 1)) : 0;
|
||||
get => (int)NativeFuncs.godotsharp_packed_int32_array_size(in this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -998,7 +986,7 @@ namespace Godot.NativeInterop
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr != null ? (int)(*((ulong*)_ptr - 1)) : 0;
|
||||
get => (int)NativeFuncs.godotsharp_packed_int64_array_size(in this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1029,7 +1017,7 @@ namespace Godot.NativeInterop
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr != null ? (int)(*((ulong*)_ptr - 1)) : 0;
|
||||
get => (int)NativeFuncs.godotsharp_packed_float32_array_size(in this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1060,7 +1048,7 @@ namespace Godot.NativeInterop
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr != null ? (int)(*((ulong*)_ptr - 1)) : 0;
|
||||
get => (int)NativeFuncs.godotsharp_packed_float64_array_size(in this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1091,7 +1079,7 @@ namespace Godot.NativeInterop
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr != null ? (int)(*((ulong*)_ptr - 1)) : 0;
|
||||
get => (int)NativeFuncs.godotsharp_packed_string_array_size(in this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1122,7 +1110,7 @@ namespace Godot.NativeInterop
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr != null ? (int)(*((ulong*)_ptr - 1)) : 0;
|
||||
get => (int)NativeFuncs.godotsharp_packed_vector2_array_size(in this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1153,7 +1141,7 @@ namespace Godot.NativeInterop
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr != null ? (int)(*((ulong*)_ptr - 1)) : 0;
|
||||
get => (int)NativeFuncs.godotsharp_packed_vector3_array_size(in this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1185,7 +1173,7 @@ namespace Godot.NativeInterop
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr != null ? (int)(*((ulong*)_ptr - 1)) : 0;
|
||||
get => (int)NativeFuncs.godotsharp_packed_vector4_array_size(in this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1217,7 +1205,7 @@ namespace Godot.NativeInterop
|
||||
public readonly unsafe int Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _ptr != null ? (int)(*((ulong*)_ptr - 1)) : 0;
|
||||
get => (int)NativeFuncs.godotsharp_packed_color_array_size(in this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -606,5 +606,31 @@ namespace Godot.NativeInterop
|
||||
// Object
|
||||
|
||||
public static partial void godotsharp_object_to_string(IntPtr ptr, out godot_string r_str);
|
||||
|
||||
// Vector
|
||||
|
||||
public static partial long godotsharp_string_size(in godot_string p_self);
|
||||
|
||||
public static partial long godotsharp_packed_byte_array_size(in godot_packed_byte_array p_self);
|
||||
|
||||
public static partial long godotsharp_packed_int32_array_size(in godot_packed_int32_array p_self);
|
||||
|
||||
public static partial long godotsharp_packed_int64_array_size(in godot_packed_int64_array p_self);
|
||||
|
||||
public static partial long godotsharp_packed_float32_array_size(in godot_packed_float32_array p_self);
|
||||
|
||||
public static partial long godotsharp_packed_float64_array_size(in godot_packed_float64_array p_self);
|
||||
|
||||
public static partial long godotsharp_packed_string_array_size(in godot_packed_string_array p_self);
|
||||
|
||||
public static partial long godotsharp_packed_vector2_array_size(in godot_packed_vector2_array p_self);
|
||||
|
||||
public static partial long godotsharp_packed_vector3_array_size(in godot_packed_vector3_array p_self);
|
||||
|
||||
public static partial long godotsharp_packed_vector4_array_size(in godot_packed_vector4_array p_self);
|
||||
|
||||
public static partial long godotsharp_packed_color_array_size(in godot_packed_color_array p_self);
|
||||
|
||||
public static partial long godotsharp_array_size(in godot_array p_self);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1568,6 +1568,54 @@ void godotsharp_object_to_string(Object *p_ptr, godot_string *r_str) {
|
||||
}
|
||||
#endif
|
||||
|
||||
int64_t godotsharp_string_size(const String *p_self) {
|
||||
return p_self->size();
|
||||
}
|
||||
|
||||
int64_t godotsharp_packed_byte_array_size(const PackedByteArray *p_self) {
|
||||
return p_self->size();
|
||||
}
|
||||
|
||||
int64_t godotsharp_packed_int32_array_size(const PackedInt32Array *p_self) {
|
||||
return p_self->size();
|
||||
}
|
||||
|
||||
int64_t godotsharp_packed_int64_array_size(const PackedInt64Array *p_self) {
|
||||
return p_self->size();
|
||||
}
|
||||
|
||||
int64_t godotsharp_packed_float32_array_size(const PackedFloat32Array *p_self) {
|
||||
return p_self->size();
|
||||
}
|
||||
|
||||
int64_t godotsharp_packed_float64_array_size(const PackedFloat64Array *p_self) {
|
||||
return p_self->size();
|
||||
}
|
||||
|
||||
int64_t godotsharp_packed_string_array_size(const PackedStringArray *p_self) {
|
||||
return p_self->size();
|
||||
}
|
||||
|
||||
int64_t godotsharp_packed_vector2_array_size(const PackedVector2Array *p_self) {
|
||||
return p_self->size();
|
||||
}
|
||||
|
||||
int64_t godotsharp_packed_vector3_array_size(const PackedVector3Array *p_self) {
|
||||
return p_self->size();
|
||||
}
|
||||
|
||||
int64_t godotsharp_packed_vector4_array_size(const PackedVector4Array *p_self) {
|
||||
return p_self->size();
|
||||
}
|
||||
|
||||
int64_t godotsharp_packed_color_array_size(const PackedColorArray *p_self) {
|
||||
return p_self->size();
|
||||
}
|
||||
|
||||
int64_t godotsharp_array_size(const Array *p_self) {
|
||||
return p_self->size();
|
||||
}
|
||||
|
||||
// The order in this array must match the declaration order of
|
||||
// the methods in 'GodotSharp/Core/NativeInterop/NativeFuncs.cs'.
|
||||
static const void *unmanaged_callbacks[]{
|
||||
@@ -1796,6 +1844,18 @@ static const void *unmanaged_callbacks[]{
|
||||
(void *)godotsharp_var_to_str,
|
||||
(void *)godotsharp_err_print_error,
|
||||
(void *)godotsharp_object_to_string,
|
||||
(void *)godotsharp_string_size,
|
||||
(void *)godotsharp_packed_byte_array_size,
|
||||
(void *)godotsharp_packed_int32_array_size,
|
||||
(void *)godotsharp_packed_int64_array_size,
|
||||
(void *)godotsharp_packed_float32_array_size,
|
||||
(void *)godotsharp_packed_float64_array_size,
|
||||
(void *)godotsharp_packed_string_array_size,
|
||||
(void *)godotsharp_packed_vector2_array_size,
|
||||
(void *)godotsharp_packed_vector3_array_size,
|
||||
(void *)godotsharp_packed_vector4_array_size,
|
||||
(void *)godotsharp_packed_color_array_size,
|
||||
(void *)godotsharp_array_size,
|
||||
};
|
||||
|
||||
const void **godotsharp::get_runtime_interop_funcs(int32_t &r_size) {
|
||||
|
||||
Reference in New Issue
Block a user