35 lines
1.7 KiB
C#
35 lines
1.7 KiB
C#
using System.Numerics;
|
|
|
|
namespace BlendFile.CompatTypes;
|
|
|
|
public readonly struct uchar {
|
|
public uchar Value => _value;
|
|
|
|
private readonly byte _value;
|
|
|
|
public uchar(byte value) => _value = value;
|
|
public uchar(uchar value) => _value = value._value;
|
|
|
|
public static explicit operator byte(uchar value) => value._value;
|
|
public static implicit operator uchar(byte value) => new(value);
|
|
|
|
public static explicit operator sbyte(uchar value) => (sbyte)value._value;
|
|
public static implicit operator uchar(sbyte value) => new((byte)value);
|
|
|
|
public static explicit operator int(uchar value) => value._value;
|
|
public static implicit operator uchar(int value) => new((byte)value);
|
|
|
|
public static uchar operator +(uchar left, uchar right) => left.Value + right.Value;
|
|
public static uchar operator -(uchar left, uchar right) => left.Value - right.Value;
|
|
public static uchar operator *(uchar left, uchar right) => left.Value * right.Value;
|
|
public static uchar operator /(uchar left, uchar right) => left.Value / right.Value;
|
|
public static uchar operator %(uchar left, uchar right) => left.Value % right.Value;
|
|
public static uchar operator &(uchar left, uchar right) => left.Value & right.Value;
|
|
public static uchar operator |(uchar left, uchar right) => left.Value | right.Value;
|
|
public static uchar operator ^(uchar left, uchar right) => left.Value ^ right.Value;
|
|
public static uchar operator <<(uchar left, byte right) => left.Value << right;
|
|
public static uchar operator >>(uchar left, byte right) => left.Value >> right;
|
|
public static uchar operator ++(uchar value) => new (value.Value + 1);
|
|
public static uchar operator --(uchar value) => new (value.Value - 1);
|
|
}
|