mirror of
https://github.com/raylib-cs/raylib-cs
synced 2025-06-30 19:03:42 -04:00
BREAKING: Update names of methods, variables, and other elements (#181)
Breaking change to update naming across Raylib-cs to make it more consistent with C# naming conventions. --------- Co-authored-by: MrScautHD <65916181+MrScautHD@users.noreply.github.com>
This commit is contained in:
@ -8,21 +8,21 @@ namespace Raylib_cs
|
||||
/// </summary>
|
||||
public readonly ref struct AnsiBuffer
|
||||
{
|
||||
private readonly IntPtr data;
|
||||
private readonly IntPtr _data;
|
||||
|
||||
public AnsiBuffer(string text)
|
||||
{
|
||||
data = Marshal.StringToHGlobalAnsi(text);
|
||||
_data = Marshal.StringToHGlobalAnsi(text);
|
||||
}
|
||||
|
||||
public unsafe sbyte* AsPointer()
|
||||
{
|
||||
return (sbyte*)data.ToPointer();
|
||||
return (sbyte*)_data.ToPointer();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Marshal.FreeHGlobal(data);
|
||||
Marshal.FreeHGlobal(_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,42 +20,42 @@ namespace Raylib_cs
|
||||
*
|
||||
* 'value' is visible and constructable (if necessary), but impossible to modify or access.
|
||||
*/
|
||||
public sbyte value { init; private get; }
|
||||
public sbyte Value { init; private get; }
|
||||
|
||||
// Constructors for easier usage.
|
||||
public CBool(bool value)
|
||||
{
|
||||
this.value = (sbyte)(value ? 1 : 0);
|
||||
this.Value = (sbyte)(value ? 1 : 0);
|
||||
}
|
||||
public CBool(Int64 value)
|
||||
{
|
||||
this.value = (sbyte)(value != 0 ? 1 : 0);
|
||||
this.Value = (sbyte)(value != 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
// CBool -> Native
|
||||
// Allows for arithmetic between CBools and for assignment to greater integer variables.
|
||||
public static implicit operator sbyte(CBool x)
|
||||
{
|
||||
return x.value;
|
||||
return x.Value;
|
||||
}
|
||||
|
||||
// Allows for CBools to be implicitely assigned to a native boolean variable.
|
||||
public static implicit operator bool(CBool x)
|
||||
{
|
||||
return x.value != 0 ? true : false;
|
||||
return x.Value != 0 ? true : false;
|
||||
}
|
||||
|
||||
// Native -> CBool
|
||||
// Allows native booleans to be implicitely constructed into CBools while passing parameters.
|
||||
public static implicit operator CBool(bool x)
|
||||
{
|
||||
return new CBool { value = (sbyte)(x ? 1 : 0) };
|
||||
return new CBool { Value = (sbyte)(x ? 1 : 0) };
|
||||
}
|
||||
|
||||
// Same goes for integer numeric values (any value, so an Int64 is used).
|
||||
public static implicit operator CBool(Int64 x)
|
||||
{
|
||||
return new CBool { value = (sbyte)(x != 0 ? 1 : 0) };
|
||||
return new CBool { Value = (sbyte)(x != 0 ? 1 : 0) };
|
||||
}
|
||||
|
||||
/* Arithmetic overloads
|
||||
@ -69,13 +69,13 @@ namespace Raylib_cs
|
||||
// Addition
|
||||
public static CBool operator +(CBool left, CBool right)
|
||||
{
|
||||
return new CBool { value = (sbyte)(left.value + right.value) };
|
||||
return new CBool { Value = (sbyte)(left.Value + right.Value) };
|
||||
}
|
||||
|
||||
// Subtraction
|
||||
public static CBool operator -(CBool left, CBool right)
|
||||
{
|
||||
return new CBool { value = (sbyte)(left.value - right.value) };
|
||||
return new CBool { Value = (sbyte)(left.Value - right.Value) };
|
||||
}
|
||||
|
||||
// ToString override
|
||||
|
@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Raylib_cs
|
||||
@ -12,16 +11,16 @@ namespace Raylib_cs
|
||||
/// <summary>
|
||||
/// Filepaths max entries
|
||||
/// </summary>
|
||||
public uint capacity;
|
||||
public uint Capacity;
|
||||
|
||||
/// <summary>
|
||||
/// Filepaths entries count
|
||||
/// </summary>
|
||||
public uint count;
|
||||
public uint Count;
|
||||
|
||||
/// <summary>
|
||||
/// Filepaths entries
|
||||
/// </summary>
|
||||
public byte** paths;
|
||||
public byte** Paths;
|
||||
}
|
||||
}
|
||||
|
@ -7,31 +7,31 @@ namespace Raylib_cs
|
||||
/// <summary>
|
||||
/// Converts text to a UTF8 buffer for passing to native code
|
||||
/// </summary>
|
||||
public readonly ref struct UTF8Buffer
|
||||
public readonly ref struct Utf8Buffer
|
||||
{
|
||||
private readonly IntPtr data;
|
||||
private readonly IntPtr _data;
|
||||
|
||||
public UTF8Buffer(string text)
|
||||
public Utf8Buffer(string text)
|
||||
{
|
||||
data = Marshal.StringToCoTaskMemUTF8(text);
|
||||
_data = Marshal.StringToCoTaskMemUTF8(text);
|
||||
}
|
||||
|
||||
public unsafe sbyte* AsPointer()
|
||||
{
|
||||
return (sbyte*)data.ToPointer();
|
||||
return (sbyte*)_data.ToPointer();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Marshal.ZeroFreeCoTaskMemUTF8(data);
|
||||
Marshal.ZeroFreeCoTaskMemUTF8(_data);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Utf8StringUtils
|
||||
{
|
||||
public static UTF8Buffer ToUTF8Buffer(this string text)
|
||||
public static Utf8Buffer ToUtf8Buffer(this string text)
|
||||
{
|
||||
return new UTF8Buffer(text);
|
||||
return new Utf8Buffer(text);
|
||||
}
|
||||
|
||||
public static byte[] ToUtf8String(this string text)
|
Reference in New Issue
Block a user