mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
parent
9d0f656be2
commit
2b48e54903
1 changed files with 7 additions and 4 deletions
|
@ -160,6 +160,9 @@ namespace System
|
||||||
String bTypeStr = TypeStr(.. scope .(), mBFieldType);
|
String bTypeStr = TypeStr(.. scope .(), mBFieldType);
|
||||||
int mask = ((1 << mBitPos) << bitCount) - (1 << mBitPos);
|
int mask = ((1 << mBitPos) << bitCount) - (1 << mBitPos);
|
||||||
|
|
||||||
|
String maskStr = scope .();
|
||||||
|
mask.ToString(maskStr, scope String()..AppendF("X{}", bitSize/4), null);
|
||||||
|
|
||||||
if ((!hasRange) && (mBFieldType.IsSigned))
|
if ((!hasRange) && (mBFieldType.IsSigned))
|
||||||
{
|
{
|
||||||
minVal = -(1<<(bitCount-1));
|
minVal = -(1<<(bitCount-1));
|
||||||
|
@ -178,9 +181,9 @@ namespace System
|
||||||
if (mBFieldType == typeof(bool))
|
if (mBFieldType == typeof(bool))
|
||||||
str.AppendF($"(({fieldInfo.Name} & {mask}) >> {mBitPos}) != 0;\n");
|
str.AppendF($"(({fieldInfo.Name} & {mask}) >> {mBitPos}) != 0;\n");
|
||||||
else if (buType.IsSigned)
|
else if (buType.IsSigned)
|
||||||
str.AppendF($"(.)((int)((({fieldInfo.Name} & 0x{mask:X16}) >> {mBitPos}) ^ 0x{1 << (bitCount - 1):X}) - 0x{1 << (bitCount - 1):X});\n");
|
str.AppendF($"(.)((int)((({fieldInfo.Name} & 0x{maskStr}) >> {mBitPos}) ^ 0x{1 << (bitCount - 1):X}) - 0x{1 << (bitCount - 1):X});\n");
|
||||||
else
|
else
|
||||||
str.AppendF($"(.)(({fieldInfo.Name} & 0x{mask:X16}) >> {mBitPos});\n");
|
str.AppendF($"(.)(({fieldInfo.Name} & 0x{maskStr}) >> {mBitPos});\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mBFieldType.IsInteger)
|
if (mBFieldType.IsInteger)
|
||||||
|
@ -222,9 +225,9 @@ namespace System
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mBFieldType == typeof(bool))
|
if (mBFieldType == typeof(bool))
|
||||||
str.AppendF($"\t\t{fieldInfo.Name} = ({fieldInfo.Name} & ({uTypeStr})~0x{mask:X16}) | (value ? 0x{mask:X16} : 0);\n");
|
str.AppendF($"\t\t{fieldInfo.Name} = ({fieldInfo.Name} & ({uTypeStr})~0x{maskStr}) | (value ? 0x{maskStr} : 0);\n");
|
||||||
else
|
else
|
||||||
str.AppendF($"\t\t{fieldInfo.Name} = ({fieldInfo.Name} & ({uTypeStr})~0x{mask:X16}) | ((({uTypeStr})value << {mBitPos}) & ({uTypeStr})0x{mask:X16});\n");
|
str.AppendF($"\t\t{fieldInfo.Name} = ({fieldInfo.Name} & ({uTypeStr})~0x{maskStr}) | ((({uTypeStr})value << {mBitPos}) & ({uTypeStr})0x{maskStr});\n");
|
||||||
|
|
||||||
str.Append("\t}\n");
|
str.Append("\t}\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue