2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-09-09 03:01:41 -04:00

Bump .NET Version from 5 to 8

This commit is contained in:
yoyoyodog123
2024-01-11 20:44:06 -06:00
parent a94a92afb6
commit 48a1439fd9
5 changed files with 23 additions and 33 deletions

View File

@@ -11,15 +11,16 @@ public readonly struct CBool
* they only support a single bit, yes, but the minimum storage unit of a
* computer is a sbyte, so that's what we'll be using when doing operations,
* which can be later implicitely cast onto any type during usage.
*
*
* It is wise to note that C booleans are any numeric value, but allocating an
* Int64 for every CBool instance is.. well, wildly memory-inefficient. Yes, the
* process is basically treated as a 0-cost instantiation, but it's better to rely
* on explicit motivation than to blindly trust the runtime judgement on its memory
* management.
*
* management.
*
* 'value' is visible and constructable (if necessary), but impossible to modify or access.
*/
public sbyte Value
{
init; private get;
@@ -30,13 +31,14 @@ public readonly struct CBool
{
this.Value = (sbyte)(value ? 1 : 0);
}
public CBool(Int64 value)
{
this.Value = (sbyte)(value != 0 ? 1 : 0);
}
// CBool -> Native
// Allows for arithmetic between CBools and for assignment to greater integer variables.
// CBool -> Native Allows for arithmetic between CBools and for assignment to greater integer
// variables.
public static implicit operator sbyte(CBool x)
{
return x.Value;
@@ -45,11 +47,11 @@ public readonly struct CBool
// 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;
}
// Native -> CBool
// Allows native booleans to be implicitely constructed into CBools while passing parameters.
// 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) };
@@ -64,7 +66,7 @@ public readonly struct CBool
/* Arithmetic overloads
* Operations between CBools and integers are already covered by the implicit
* sbyte cast. So no need to worry about those.
*
*
* All casts return CBool, since there is no way to know if the assignment is
* to a native boolean or integer, or a CBool.
*/