mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-11-04 12:51:48 +00:00
Removed Mono Runtime stuff
This commit is contained in:
+57
-7
@@ -1,11 +1,28 @@
|
||||
// Based on the Decimal implementation from the Mono Runtime: https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mcs/class/referencesource/mscorlib/system/decimal.cs
|
||||
// Originally licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using Bon.Integrated;
|
||||
using Bon;
|
||||
using Bon.Integrated;
|
||||
|
||||
namespace GlitchyEngine.Scripting;
|
||||
|
||||
/// A struct providing access to the components of a mono decimal.
|
||||
struct MonoDecimal
|
||||
/// A struct compatible with the Decimal type form the .Net Runtime.
|
||||
struct Decimal
|
||||
{
|
||||
// Sign mask for the flags field. A value of zero in this bit indicates a
|
||||
// positive Decimal value, and a value of one in this bit indicates a
|
||||
// negative Decimal value.
|
||||
//
|
||||
// Look at OleAut's DECIMAL_NEG constant to check for negative values
|
||||
// in native code.
|
||||
private const uint32 SignMask = 0x80000000u;
|
||||
|
||||
// Scale mask for the flags field. This byte in the flags field contains
|
||||
// the power of 10 to divide the Decimal value by. The scale byte must
|
||||
// contain a value between 0 and 28 inclusive.
|
||||
private const uint32 ScaleMask = 0x00FF0000u;
|
||||
|
||||
[Bitfield<uint16>(.Private, .BitsAt(16, 0), "_dontUse", .Read)]
|
||||
[Bitfield<uint8>(.Public, .BitsAt(8, 16), "Exponent")]
|
||||
[Bitfield<uint8>(.Private, .BitsAt(7, 24), "_dontUse2")]
|
||||
@@ -20,15 +37,48 @@ struct MonoDecimal
|
||||
|
||||
static this
|
||||
{
|
||||
gBonEnv.typeHandlers.Add(typeof(MonoDecimal),
|
||||
gBonEnv.typeHandlers.Add(typeof(Decimal),
|
||||
((.)new => AssetSerialize, new => AssetDeserialize));
|
||||
}
|
||||
|
||||
public this()
|
||||
{
|
||||
_high = 0;
|
||||
_low = 0;
|
||||
_mid = 0;
|
||||
_flags = 0;
|
||||
}
|
||||
|
||||
public this(int value)
|
||||
{
|
||||
var value;
|
||||
if (value >= 0)
|
||||
{
|
||||
_flags = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_flags = SignMask;
|
||||
value = -value;
|
||||
}
|
||||
_low = (uint32)value;
|
||||
_mid = (uint32)(value >> 32);
|
||||
_high = 0;
|
||||
}
|
||||
|
||||
public this(uint value)
|
||||
{
|
||||
_flags = 0;
|
||||
_low = (uint32)value;
|
||||
_mid = (uint32)(value >> 32);
|
||||
_high = 0;
|
||||
}
|
||||
|
||||
static void AssetSerialize(BonWriter writer, ValueView value, BonEnvironment environment, SerializeValueState state)
|
||||
{
|
||||
Log.EngineLogger.Assert(value.type == typeof(Self));
|
||||
|
||||
MonoDecimal decimal = value.Get<MonoDecimal>();
|
||||
Decimal decimal = value.Get<Decimal>();
|
||||
|
||||
decimal.ToString(writer.outStr);
|
||||
}
|
||||
@@ -86,11 +136,11 @@ struct MonoDecimal
|
||||
strBuffer.Append('m');
|
||||
}
|
||||
|
||||
public static Result<MonoDecimal> Parse(StringView strBuffer)
|
||||
public static Result<Decimal> Parse(StringView strBuffer)
|
||||
{
|
||||
var strBuffer;
|
||||
|
||||
MonoDecimal result = .();
|
||||
Decimal result = .();
|
||||
|
||||
if (strBuffer.StartsWith('-'))
|
||||
{
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Mono;
|
||||
using GlitchyEngine.Core;
|
||||
using System.Diagnostics;
|
||||
|
||||
|
||||
@@ -48,17 +48,6 @@ class EntitySerializerWrapper : NewScriptClass
|
||||
_createSerializationContextMethod(serializerPtr);
|
||||
}
|
||||
|
||||
/*public void ClearSerializationContext(ScriptInstanceSerializer serializer)
|
||||
{
|
||||
void* serializerPtr = Internal.UnsafeCastToPtr(serializer);
|
||||
|
||||
MonoException* exception = null;
|
||||
_clearSerializationContextMethod(serializerPtr, &exception);
|
||||
|
||||
if (exception != null)
|
||||
ScriptEngine.[Friend]HandleMonoException(exception, null);
|
||||
}*/
|
||||
|
||||
public void DestroySerializationContext(ScriptInstanceSerializer serializer)
|
||||
{
|
||||
void* serializerPtr = Internal.UnsafeCastToPtr(serializer);
|
||||
|
||||
@@ -186,7 +186,6 @@ static class ScriptEngine
|
||||
public static void Init()
|
||||
{
|
||||
InitRuntime();
|
||||
//InitMono();
|
||||
|
||||
LoadScriptAssemblies();
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ static class ScriptGlue
|
||||
});
|
||||
}
|
||||
|
||||
/// Gets the entity with the given id. Throws a mono exception, if the entity doesn't exist.
|
||||
/// Gets the entity with the given id. Returns an .Err if it doesn't exist.
|
||||
static Result<Entity> GetEntitySafe(UUID entityId)
|
||||
{
|
||||
if (ScriptEngine.Context.GetEntityByID(entityId) case .Ok(let entity))
|
||||
@@ -625,7 +625,6 @@ static class ScriptGlue
|
||||
return .ArgumentError;
|
||||
}
|
||||
|
||||
//return scriptComponent.Instance.MonoInstance;
|
||||
return .Ok;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using GlitchyEngine.Core;
|
||||
using GlitchyEngine.Scripting;
|
||||
using Mono;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Bon.Integrated;
|
||||
@@ -315,7 +314,7 @@ class SerializedObject
|
||||
Serialize.Value(writer, GetFieldDataAs<double>(field.Data), environment);
|
||||
case .Decimal:
|
||||
writer.Type("decimal");
|
||||
Serialize.Value(writer, GetFieldDataAs<MonoDecimal>(field.Data), environment);
|
||||
Serialize.Value(writer, GetFieldDataAs<Decimal>(field.Data), environment);
|
||||
|
||||
case .Enum:
|
||||
writer.Type("Enum");
|
||||
@@ -499,7 +498,7 @@ class SerializedObject
|
||||
if (reader.inStr.StartsWith('m'))
|
||||
reader.inStr.RemoveFromStart(1);
|
||||
|
||||
MonoDecimal decimalValue = Try!(MonoDecimal.Parse(numberView));
|
||||
Decimal decimalValue = Try!(Decimal.Parse(numberView));
|
||||
fieldType = .Decimal;
|
||||
object.SetRawData(fieldType, decimalValue, ref fieldData);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ using GlitchyEngine.Core;
|
||||
using Box2D;
|
||||
using GlitchyEngine.Content;
|
||||
using GlitchyEngine.Scripting;
|
||||
using Mono;
|
||||
|
||||
namespace GlitchyEngine.World
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user