Skip to content

Commit

Permalink
Use System.IntPtr for size_t
Browse files Browse the repository at this point in the history
  • Loading branch information
BeanCheeseBurrito committed Aug 26, 2023
1 parent 8d19f46 commit a5ebfff
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Flecs.NET.Bindgen/Flecs.NET.Bindgen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bindgen.NET" Version="0.0.8"/>
<PackageReference Include="Bindgen.NET" Version="0.1.0"/>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Flecs.NET.Bindings/Flecs.NET.Bindings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>3.2.6.1</Version>
<Version>3.2.6.2</Version>
<Title Condition="'$(Configuration)' == 'Debug'">Flecs.NET.Bindings.Debug</Title>
<Title Condition="'$(Configuration)' == 'Release'">Flecs.NET.Bindings.Release</Title>
<Authors>BeanCheeseBurrito</Authors>
Expand Down
26 changes: 13 additions & 13 deletions src/Flecs.NET.Bindings/Flecs.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ public static unsafe partial class Native
public static extern ulong ecs_cpp_component_register(ecs_world_t* world, ulong id, byte* name, byte* symbol, int size, int alignment, byte implicit_name, byte* existing_out);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern ulong ecs_cpp_component_register_explicit(ecs_world_t* world, ulong s_id, ulong id, byte* name, byte* type_name, byte* symbol, ulong size, ulong alignment, byte is_component, byte* existing_out);
public static extern ulong ecs_cpp_component_register_explicit(ecs_world_t* world, ulong s_id, ulong id, byte* name, byte* type_name, byte* symbol, System.IntPtr size, System.IntPtr alignment, byte is_component, byte* existing_out);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern void ecs_cpp_component_validate(ecs_world_t* world, ulong id, byte* name, byte* symbol, ulong size, ulong alignment, byte implicit_name);
public static extern void ecs_cpp_component_validate(ecs_world_t* world, ulong id, byte* name, byte* symbol, System.IntPtr size, System.IntPtr alignment, byte implicit_name);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern ulong ecs_cpp_enum_constant_register(ecs_world_t* world, ulong parent, ulong id, byte* name, int value);
Expand All @@ -106,13 +106,13 @@ public static unsafe partial class Native
public static extern void ecs_cpp_enum_init(ecs_world_t* world, ulong id);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern byte* ecs_cpp_get_constant_name(byte* constant_name, byte* func_name, ulong len, ulong back_len);
public static extern byte* ecs_cpp_get_constant_name(byte* constant_name, byte* func_name, System.IntPtr len, System.IntPtr back_len);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern byte* ecs_cpp_get_symbol_name(byte* symbol_name, byte* type_name, ulong len);
public static extern byte* ecs_cpp_get_symbol_name(byte* symbol_name, byte* type_name, System.IntPtr len);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern byte* ecs_cpp_get_type_name(byte* type_name, byte* func_name, ulong len, ulong front_len);
public static extern byte* ecs_cpp_get_type_name(byte* type_name, byte* func_name, System.IntPtr len, System.IntPtr front_len);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern ecs_member_t* ecs_cpp_last_member(ecs_world_t* world, ulong type);
Expand Down Expand Up @@ -247,13 +247,13 @@ public static unsafe partial class Native
public static extern byte ecs_field_is_writeonly(ecs_iter_t* it, int index);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern ulong ecs_field_size(ecs_iter_t* it, int index);
public static extern System.IntPtr ecs_field_size(ecs_iter_t* it, int index);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern ulong ecs_field_src(ecs_iter_t* it, int index);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern void* ecs_field_w_size(ecs_iter_t* it, ulong size, int index);
public static extern void* ecs_field_w_size(ecs_iter_t* it, System.IntPtr size, int index);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern ecs_iter_t ecs_filter_chain_iter(ecs_iter_t* it, ecs_filter_t* filter);
Expand Down Expand Up @@ -1075,7 +1075,7 @@ public static unsafe partial class Native
public static extern ecs_record_t* ecs_record_find(ecs_world_t* world, ulong entity);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern void* ecs_record_get_column(ecs_record_t* r, int column, ulong c_size);
public static extern void* ecs_record_get_column(ecs_record_t* r, int column, System.IntPtr c_size);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern ulong ecs_record_get_entity(ecs_record_t* record);
Expand Down Expand Up @@ -1207,7 +1207,7 @@ public static unsafe partial class Native
public static extern void ecs_set_hooks_id(ecs_world_t* world, ulong id, ecs_type_hooks_t* hooks);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern ulong ecs_set_id(ecs_world_t* world, ulong entity, ulong id, ulong size, void* ptr);
public static extern ulong ecs_set_id(ecs_world_t* world, ulong entity, ulong id, System.IntPtr size, void* ptr);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern ulong ecs_set_interval(ecs_world_t* world, ulong tick_source, float interval);
Expand Down Expand Up @@ -1441,7 +1441,7 @@ public static unsafe partial class Native
public static extern int ecs_table_get_column_index(ecs_world_t* world, ecs_table_t* table, ulong id);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern ulong ecs_table_get_column_size(ecs_table_t* table, int index);
public static extern System.IntPtr ecs_table_get_column_size(ecs_table_t* table, int index);

[System.Runtime.InteropServices.DllImport(BindgenInternal.DllImportPath, CallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl)]
public static extern int ecs_table_get_depth(ecs_world_t* world, ecs_table_t* table, ulong rel);
Expand Down Expand Up @@ -4565,13 +4565,13 @@ public partial struct EcsOpaque

public System.IntPtr clear; // delegate* unmanaged<void*, void>

public System.IntPtr ensure_element; // delegate* unmanaged<void*, ulong, void*>
public System.IntPtr ensure_element; // delegate* unmanaged<void*, System.IntPtr, void*>

public System.IntPtr ensure_member; // delegate* unmanaged<void*, byte*, void*>

public System.IntPtr count; // delegate* unmanaged<void*, ulong>
public System.IntPtr count; // delegate* unmanaged<void*, System.IntPtr>

public System.IntPtr resize; // delegate* unmanaged<void*, ulong, void>
public System.IntPtr resize; // delegate* unmanaged<void*, System.IntPtr, void>
}

public partial struct EcsPipelineStats
Expand Down
4 changes: 2 additions & 2 deletions src/Flecs.NET/Core/Component.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public Component(ecs_world_t* world, string? name = null, bool allowTag = true,
ecs_cpp_component_validate(
world, id, nativeName,
nativeSymbolName,
(ulong)Type<TComponent>.GetSize(),
(ulong)Type<TComponent>.GetAlignment(),
(IntPtr)Type<TComponent>.GetSize(),
(IntPtr)Type<TComponent>.GetAlignment(),
Macros.Bool(implicitName)
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Flecs.NET/Core/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ public ref Entity Disable<TFirst, TSecond>()
/// <returns></returns>
public ref Entity SetPtr(ulong componentId, int size, void* data)
{
ecs_set_id(World, Id, componentId, (ulong)size, data);
ecs_set_id(World, Id, componentId, (IntPtr)size, data);

Check failure on line 1601 in src/Flecs.NET/Core/Entity.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Argument 4: cannot convert from 'System.IntPtr' to 'int'
return ref this;
}

Expand All @@ -1611,7 +1611,7 @@ public ref Entity SetPtr(ulong componentId, int size, void* data)
/// <returns></returns>
public ref Entity SetPtr(ulong componentId, ulong size, void* data)
{
ecs_set_id(World, Id, componentId, size, data);
ecs_set_id(World, Id, componentId, (IntPtr)size, data);

Check failure on line 1614 in src/Flecs.NET/Core/Entity.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Argument 4: cannot convert from 'System.IntPtr' to 'int'
return ref this;
}

Expand All @@ -1625,7 +1625,7 @@ public ref Entity SetPtr(ulong componentId, void* data)
{
EcsComponent* ecsComponent = (EcsComponent*)ecs_get_id(World, componentId, FLECS_IDEcsComponentID_);
Assert.True(ecsComponent != null, nameof(ECS_INVALID_PARAMETER));
ecs_set_id(World, Id, componentId, (ulong)ecsComponent->size, data);
ecs_set_id(World, Id, componentId, (IntPtr)ecsComponent->size, data);

Check failure on line 1628 in src/Flecs.NET/Core/Entity.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Argument 4: cannot convert from 'System.IntPtr' to 'int'
return ref this;
}

Expand Down Expand Up @@ -2374,7 +2374,7 @@ private ref Entity SetInternal<T>(ulong id, ref T component)
fixed (void* data = &component)
{
IntPtr ptr = default;
ecs_set_id(World, Id, id, (ulong)size, isRef ? Managed.AllocGcHandle(&ptr, ref component) : data);
ecs_set_id(World, Id, id, (IntPtr)size, isRef ? Managed.AllocGcHandle(&ptr, ref component) : data);

Check failure on line 2377 in src/Flecs.NET/Core/Entity.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Argument 4: cannot convert from 'System.IntPtr' to 'int'
return ref this;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/Flecs.NET/Core/Iter.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections;
using Flecs.NET.Utilities;
using static Flecs.NET.Bindings.Native;
Expand Down Expand Up @@ -229,7 +230,7 @@ public int FieldCount()
/// <returns></returns>
public ulong Size(int index)
{
return ecs_field_size(Handle, index);
return (ulong)ecs_field_size(Handle, index);
}

/// <summary>
Expand Down Expand Up @@ -381,7 +382,7 @@ private Column<T> GetField<T>(int index)
bool isShared = ecs_field_is_self(Handle, index) == 0;
int count = isShared ? 1 : Handle->count;

void* ptr = ecs_field_w_size(Handle, (ulong)Managed.ManagedSize<T>(), index);
void* ptr = ecs_field_w_size(Handle, (IntPtr)Managed.ManagedSize<T>(), index);

Check failure on line 385 in src/Flecs.NET/Core/Iter.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Argument 2: cannot convert from 'System.IntPtr' to 'int'

Check failure on line 385 in src/Flecs.NET/Core/Iter.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Argument 2: cannot convert from 'System.IntPtr' to 'int'
return new Column<T>(ptr, count, isShared);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Flecs.NET/Core/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static ulong IdExplicit(ecs_world_t* world, string? name = null, bool all
RawId = ecs_cpp_component_register_explicit(
world, RawId, id,
nativeName, nativeTypeName, nativeSymbolName,
(ulong)Size, (ulong)Alignment,
(IntPtr)Size, (IntPtr)Alignment,
Macros.Bool(isComponent), (byte*)existing
);

Expand Down
5 changes: 3 additions & 2 deletions src/Flecs.NET/Core/UntypedComponent.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Flecs.NET.Utilities;
using static Flecs.NET.Bindings.Native;

Expand Down Expand Up @@ -167,7 +168,7 @@ public ref UntypedComponent Constant(string name, int value)
ulong id = ecs_entity_init(World, &desc);
Assert.True(id != 0, nameof(ECS_INTERNAL_ERROR));

ecs_set_id(World, id, Macros.Pair(EcsConstant, FLECS_IDecs_i32_tID_), sizeof(int), &value);
ecs_set_id(World, id, Macros.Pair(EcsConstant, FLECS_IDecs_i32_tID_), (IntPtr)sizeof(int), &value);

Check failure on line 171 in src/Flecs.NET/Core/UntypedComponent.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Argument 4: cannot convert from 'System.IntPtr' to 'int'

Check failure on line 171 in src/Flecs.NET/Core/UntypedComponent.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Argument 4: cannot convert from 'System.IntPtr' to 'int'
return ref this;
}

Expand All @@ -190,7 +191,7 @@ public ref UntypedComponent Bit(string name, uint value)
ulong id = ecs_entity_init(World, &desc);
Assert.True(id != 0, nameof(ECS_INTERNAL_ERROR));

ecs_set_id(World, id, Macros.Pair(EcsConstant, FLECS_IDecs_u32_tID_), sizeof(uint), &value);
ecs_set_id(World, id, Macros.Pair(EcsConstant, FLECS_IDecs_u32_tID_), (IntPtr)sizeof(uint), &value);

Check failure on line 194 in src/Flecs.NET/Core/UntypedComponent.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Argument 4: cannot convert from 'System.IntPtr' to 'int'

Check failure on line 194 in src/Flecs.NET/Core/UntypedComponent.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Argument 4: cannot convert from 'System.IntPtr' to 'int'
return ref this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Flecs.NET/Flecs.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>3.2.6-build.2</Version>
<Version>3.2.6-build.3</Version>
<Title Condition="'$(Configuration)' == 'Debug'">Flecs.NET.Debug</Title>
<Title Condition="'$(Configuration)' == 'Release'">Flecs.NET.Release</Title>
<Authors>BeanCheeseBurrito</Authors>
Expand Down

0 comments on commit a5ebfff

Please sign in to comment.