本文整理汇总了C#中IronPython.Modules.MemoryHolder.ReadInt16方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryHolder.ReadInt16方法的具体用法?C# MemoryHolder.ReadInt16怎么用?C# MemoryHolder.ReadInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronPython.Modules.MemoryHolder
的用法示例。
在下文中一共展示了MemoryHolder.ReadInt16方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadChar
/// <summary>
/// Helper function for reading char/wchar's. This is used for reading from
/// arrays and pointers to avoid creating lots of 1-char strings.
/// </summary>
internal char ReadChar(MemoryHolder/*!*/ owner, int offset) {
switch (_type) {
case SimpleTypeKind.Char: return (char)owner.ReadByte(offset);
case SimpleTypeKind.WChar: return (char)owner.ReadInt16(offset);
default: throw new InvalidOperationException();
}
}
示例2: switch
object INativeType.GetValue(MemoryHolder/*!*/ owner, object readingFrom, int offset, bool raw) {
object res;
switch (_type) {
case SimpleTypeKind.Boolean: res = owner.ReadByte(offset) != 0 ? ScriptingRuntimeHelpers.True : ScriptingRuntimeHelpers.False; break;
case SimpleTypeKind.Char: res = new string((char)owner.ReadByte(offset), 1); break;
case SimpleTypeKind.SignedByte: res = GetIntReturn((int)(sbyte)owner.ReadByte(offset)); break;
case SimpleTypeKind.UnsignedByte: res = GetIntReturn((int)owner.ReadByte(offset)); break;
case SimpleTypeKind.SignedShort: res = GetIntReturn((int)owner.ReadInt16(offset)); break;
case SimpleTypeKind.WChar: res = new string((char)owner.ReadInt16(offset), 1); break;
case SimpleTypeKind.UnsignedShort: res = GetIntReturn((int)(ushort)owner.ReadInt16(offset)); break;
case SimpleTypeKind.VariantBool: res = owner.ReadInt16(offset) != 0 ? ScriptingRuntimeHelpers.True : ScriptingRuntimeHelpers.False; break;
case SimpleTypeKind.SignedInt: res = GetIntReturn((int)owner.ReadInt32(offset)); break;
case SimpleTypeKind.UnsignedInt: res = GetIntReturn((uint)owner.ReadInt32(offset)); break;
case SimpleTypeKind.UnsignedLong: res = GetIntReturn((uint)owner.ReadInt32(offset)); break;
case SimpleTypeKind.SignedLong: res = GetIntReturn(owner.ReadInt32(offset)); break;
case SimpleTypeKind.Single: res = GetSingleReturn(owner.ReadInt32(offset)); break;
case SimpleTypeKind.Double: res = GetDoubleReturn(owner.ReadInt64(offset)); break;
case SimpleTypeKind.UnsignedLongLong: res = GetIntReturn((ulong)owner.ReadInt64(offset)); break;
case SimpleTypeKind.SignedLongLong: res = GetIntReturn(owner.ReadInt64(offset)); break;
case SimpleTypeKind.Object: res = GetObjectReturn(owner.ReadIntPtr(offset)); break;
case SimpleTypeKind.Pointer: res = owner.ReadIntPtr(offset).ToPython(); break;
case SimpleTypeKind.CharPointer: res = owner.ReadMemoryHolder(offset).ReadAnsiString(0); break;
case SimpleTypeKind.WCharPointer: res = owner.ReadMemoryHolder(offset).ReadUnicodeString(0); break;
default:
throw new InvalidOperationException();
}
if (!raw && IsSubClass) {
res = PythonCalls.Call(this, res);
}
return res;
}