public static char ToDotnetChar(IshtarObject *obj, CallFrame frame) { FFI.StaticTypeOf(frame, &obj, TYPE_CHAR); var clazz = obj->decodeClass(); return((char)(int)(int *)obj->vtable[clazz.Field["!!value"].vtable_offset]); }
public static float ToDotnetFloat(IshtarObject *obj, CallFrame frame) { FFI.StaticTypeOf(frame, &obj, TYPE_R4); var clazz = obj->decodeClass(); return(BitConverter.Int32BitsToSingle((int)(int *)obj->vtable[clazz.Field["!!value"].vtable_offset])); }
public static ulong ToDotnetUInt64(IshtarObject *obj, CallFrame frame) { FFI.StaticTypeOf(frame, &obj, TYPE_U8); var clazz = obj->decodeClass(); return((ulong)(ulong *)obj->vtable[clazz.Field["!!value"].vtable_offset]); }
public static bool ToDotnetBoolean(IshtarObject *obj, CallFrame frame) { FFI.StaticTypeOf(frame, &obj, TYPE_BOOLEAN); var clazz = obj->decodeClass(); return((int)(int *)obj->vtable[clazz.Field["!!value"].vtable_offset] == 1); }
public static short ToDotnetInt16(IshtarObject *obj, CallFrame frame) { FFI.StaticTypeOf(frame, &obj, TYPE_I2); var clazz = obj->decodeClass(); return((short)(short *)obj->vtable[clazz.Field["!!value"].vtable_offset]); }
public static byte ToDotnetUInt8(IshtarObject *obj, CallFrame frame) { FFI.StaticTypeOf(frame, &obj, TYPE_U1); var clazz = obj->decodeClass(); return((byte)(byte *)obj->vtable[clazz.Field["!!value"].vtable_offset]); }
protected RuntimeLayerObject(IshtarObject *obj, CallFrame frame) { _obj = obj; _frame = frame; VM.Assert(obj->decodeClass().runtime_token == Class.runtime_token, WNE.TYPE_MISMATCH, "Mismatch type when trying create layered object.", frame); }
public static string ToDotnetString(IshtarObject *obj, CallFrame frame) { FFI.StaticTypeOf(frame, &obj, TYPE_STRING); var clazz = obj->decodeClass(); var p = (StrRef *)obj->vtable[clazz.Field["!!value"].vtable_offset]; return(StringStorage.GetString(p, frame)); }
public void SetMemory(IshtarObject *obj) { memory = obj; clazz = obj->clazz; flags = obj->flags; vtable_size = obj->vtable_size; owner = obj->owner; }
public static IshtarObject *IsInstanceOf(CallFrame frame, IshtarObject * @this, RuntimeIshtarClass @class) { if ([email protected]_inited) { @class.init_vtable(); } if (@this == null) { return(null); } if (@class.IsInterface) { return(IsInstanceOfByRef(frame, @this, @class)); } return(IsAssignableFrom(frame, @class, @this->decodeClass()) ? @this : null); }
public static X ToDotnet <X>(IshtarObject *obj, CallFrame frame) { switch (typeof(X)) { case { } when typeof(X) == typeof(nint): return((X)(object)ToDotnetPointer(obj, frame)); case { } when typeof(X) == typeof(sbyte): return((X)(object)ToDotnetInt8(obj, frame)); case { } when typeof(X) == typeof(byte): return((X)(object)ToDotnetUInt8(obj, frame)); case { } when typeof(X) == typeof(short): return((X)(object)ToDotnetInt16(obj, frame)); case { } when typeof(X) == typeof(ushort): return((X)(object)ToDotnetUInt16(obj, frame)); case { } when typeof(X) == typeof(int): return((X)(object)ToDotnetInt32(obj, frame)); case { } when typeof(X) == typeof(uint): return((X)(object)ToDotnetUInt32(obj, frame)); case { } when typeof(X) == typeof(long): return((X)(object)ToDotnetInt64(obj, frame)); case { } when typeof(X) == typeof(ulong): return((X)(object)ToDotnetUInt64(obj, frame)); case { } when typeof(X) == typeof(bool): return((X)(object)ToDotnetBoolean(obj, frame)); case { } when typeof(X) == typeof(char): return((X)(object)ToDotnetChar(obj, frame)); case { } when typeof(X) == typeof(string): return((X)(object)ToDotnetString(obj, frame)); default: VM.FastFail(WNE.TYPE_MISMATCH, $"[marshal::ToDotnet] converter for '{typeof(X).Name}' not support.", frame); return(default); } }
public static IshtarObject *ToIshtarString(IshtarObject *obj, CallFrame frame) => obj->decodeClass().TypeCode switch {
public static nint ToDotnetPointer(IshtarObject *obj, CallFrame frame) { FFI.StaticTypeOf(frame, &obj, TYPE_RAW); return((nint)obj->vtable); }
public static IshtarObject *IsInstanceOfByRef(CallFrame frame, IshtarObject *c, RuntimeIshtarClass @class) { // temporary cast to\from interface is not support frame.ThrowException(KnowTypes.IncorrectCastFault(frame)); return(c); }