SFML.Net icon indicating copy to clipboard operation
SFML.Net copied to clipboard

Inconsistent Type Mapping Of Size_T Parameters

Open charleyah opened this issue 3 years ago • 0 comments

PInvoke methods and callbacks with size_t parameters or returns is inconsistently typed across SFML.Net.

Majority use uint

  • sfVideoMode_getFullScreenModes
  • sfRenderTexture_drawPrimitives
  • sfRenderWindow_drawPrimitives
  • sfShader_setFloatUniformArray
  • sfShader_setVec2UniformArray
  • sfShader_setVec3UniformArray
  • sfShader_setVec4UniformArray
  • sfShader_setMat3UniformArray
  • sfShader_setMat4UniformArray
  • sfShape_create
  • sfText_findCharacterPos
  • sfVertexArray_getVertexCount
  • sfVertexArray_getVertex
  • sfVertexArray_resize
  • sfSoundRecorder_create
  • sfSoundRecorder_getAvailableDevices

A few others use ulong

  • sfFront_createFromMemory
  • sfImage_createFromMemory
  • sfTexture_createFromMemory
  • sfMusic_createFromMemory
  • sfSoundBuffer_createFromMemory

given that size_t size is platform dependent, I believe in C# you'd normally use IntPtr, UIntPtr or the newer nint or nuint types in place of size_t. I'm not sure in detail what the consequences are for the current mappings of size_t but I think this was worth raising going forward as .NET does have preferred types for platform dependent sized types.

charleyah avatar Jan 13 '22 20:01 charleyah