WriteIntPtr() public method

public WriteIntPtr ( int offset, IntPtr value ) : void
offset int
value System.IntPtr
return void
Esempio n. 1
0
            object INativeType.SetValue(MemoryHolder address, int offset, object value)
            {
                Pointer ptr;
                _Array  array;

                if (value == null)
                {
                    address.WriteIntPtr(offset, IntPtr.Zero);
                }
                else if (value is int)
                {
                    address.WriteIntPtr(offset, new IntPtr((int)value));
                }
                else if (value is BigInteger)
                {
                    address.WriteIntPtr(offset, new IntPtr((long)(BigInteger)value));
                }
                else if ((ptr = value as Pointer) != null)
                {
                    address.WriteIntPtr(offset, ptr._memHolder.ReadMemoryHolder(0));
                    return(PythonOps.MakeDictFromItems(ptr, "0", ptr._objects, "1"));
                }
                else if ((array = value as _Array) != null)
                {
                    address.WriteIntPtr(offset, array._memHolder);
                    return(array);
                }
                else
                {
                    throw PythonOps.TypeErrorForTypeMismatch(Name, value);
                }

                return(null);
            }
Esempio n. 2
0
 public Pointer(CData value) {
     _object = value; // Keep alive the object, more to do here.
     _memHolder = new MemoryHolder(IntPtr.Size);
     _memHolder.WriteIntPtr(0, value._memHolder);
     _memHolder.AddObject("1", value);
     if (value._objects != null) {
         _memHolder.AddObject("0", value._objects);
     }
 }
Esempio n. 3
0
 public Pointer(CData value)
 {
     _object    = value; // Keep alive the object, more to do here.
     _memHolder = new MemoryHolder(IntPtr.Size);
     _memHolder.WriteIntPtr(0, value._memHolder);
     _memHolder.AddObject("1", value);
     if (value._objects != null)
     {
         _memHolder.AddObject("0", value._objects);
     }
 }
Esempio n. 4
0
 object INativeType.SetValue(MemoryHolder address, int offset, object value)
 {
     if (value is int)
     {
         address.WriteIntPtr(offset, new IntPtr((int)value));
     }
     else if (value is BigInteger)
     {
         address.WriteIntPtr(offset, new IntPtr((long)(BigInteger)value));
     }
     else if (value is _CFuncPtr)
     {
         address.WriteIntPtr(offset, ((_CFuncPtr)value).addr);
         return(value);
     }
     else
     {
         throw PythonOps.TypeErrorForTypeMismatch("func pointer", value);
     }
     return(null);
 }
Esempio n. 5
0
            object INativeType.SetValue(MemoryHolder /*!*/ owner, int offset, object value)
            {
                SimpleCData data = value as SimpleCData;

                if (data != null && data.NativeType == this)
                {
                    data._memHolder.CopyTo(owner, offset, ((INativeType)this).Size);
                    return(null);
                }

                switch (_type)
                {
                case SimpleTypeKind.Boolean: owner.WriteByte(offset, ModuleOps.GetBoolean(value, this)); break;

                case SimpleTypeKind.Char: owner.WriteByte(offset, ModuleOps.GetChar(value, this)); break;

                case SimpleTypeKind.SignedByte: owner.WriteByte(offset, ModuleOps.GetSignedByte(value, this)); break;

                case SimpleTypeKind.UnsignedByte: owner.WriteByte(offset, ModuleOps.GetUnsignedByte(value, this)); break;

                case SimpleTypeKind.WChar: owner.WriteInt16(offset, (short)ModuleOps.GetWChar(value, this)); break;

                case SimpleTypeKind.SignedShort: owner.WriteInt16(offset, ModuleOps.GetSignedShort(value, this)); break;

                case SimpleTypeKind.UnsignedShort: owner.WriteInt16(offset, ModuleOps.GetUnsignedShort(value, this)); break;

                case SimpleTypeKind.VariantBool: owner.WriteInt16(offset, (short)ModuleOps.GetVariantBool(value, this)); break;

                case SimpleTypeKind.SignedInt: owner.WriteInt32(offset, ModuleOps.GetSignedInt(value, this)); break;

                case SimpleTypeKind.UnsignedInt: owner.WriteInt32(offset, ModuleOps.GetUnsignedInt(value, this)); break;

                case SimpleTypeKind.UnsignedLong: owner.WriteInt32(offset, ModuleOps.GetUnsignedLong(value, this)); break;

                case SimpleTypeKind.SignedLong: owner.WriteInt32(offset, ModuleOps.GetSignedLong(value, this)); break;

                case SimpleTypeKind.Single: owner.WriteInt32(offset, ModuleOps.GetSingleBits(value)); break;

                case SimpleTypeKind.Double: owner.WriteInt64(offset, ModuleOps.GetDoubleBits(value)); break;

                case SimpleTypeKind.UnsignedLongLong: owner.WriteInt64(offset, ModuleOps.GetUnsignedLongLong(value, this)); break;

                case SimpleTypeKind.SignedLongLong: owner.WriteInt64(offset, ModuleOps.GetSignedLongLong(value, this)); break;

                case SimpleTypeKind.Object: owner.WriteIntPtr(offset, ModuleOps.GetObject(value)); break;

                case SimpleTypeKind.Pointer: owner.WriteIntPtr(offset, ModuleOps.GetPointer(value)); break;

                case SimpleTypeKind.CharPointer:
                    owner.WriteIntPtr(offset, ModuleOps.GetCharPointer(value));
                    return(value);

                case SimpleTypeKind.WCharPointer:
                    owner.WriteIntPtr(offset, ModuleOps.GetWCharPointer(value));
                    return(value);

                default:
                    throw new InvalidOperationException();
                }
                return(null);
            }
Esempio n. 6
0
            object INativeType.SetValue(MemoryHolder/*!*/ owner, int offset, object value) {
                SimpleCData data = value as SimpleCData;
                if (data != null && data.NativeType == this) {
                    data._memHolder.CopyTo(owner, offset, ((INativeType)this).Size);
                    return null;
                }

                switch (_type) {
                    case SimpleTypeKind.Boolean: owner.WriteByte(offset, ModuleOps.GetBoolean(value, this)); break;
                    case SimpleTypeKind.Char: owner.WriteByte(offset, ModuleOps.GetChar(value, this)); break;
                    case SimpleTypeKind.SignedByte: owner.WriteByte(offset, ModuleOps.GetSignedByte(value, this)); break;
                    case SimpleTypeKind.UnsignedByte: owner.WriteByte(offset, ModuleOps.GetUnsignedByte(value, this)); break;
                    case SimpleTypeKind.WChar: owner.WriteInt16(offset, (short)ModuleOps.GetWChar(value, this)); break;
                    case SimpleTypeKind.SignedShort: owner.WriteInt16(offset, ModuleOps.GetSignedShort(value, this)); break;
                    case SimpleTypeKind.UnsignedShort: owner.WriteInt16(offset, ModuleOps.GetUnsignedShort(value, this)); break;
                    case SimpleTypeKind.VariantBool: owner.WriteInt16(offset, (short)ModuleOps.GetVariantBool(value, this)); break;
                    case SimpleTypeKind.SignedInt: owner.WriteInt32(offset, ModuleOps.GetSignedInt(value, this)); break;
                    case SimpleTypeKind.UnsignedInt: owner.WriteInt32(offset, ModuleOps.GetUnsignedInt(value, this)); break;
                    case SimpleTypeKind.UnsignedLong: owner.WriteInt32(offset, ModuleOps.GetUnsignedLong(value, this)); break;
                    case SimpleTypeKind.SignedLong: owner.WriteInt32(offset, ModuleOps.GetSignedLong(value, this)); break;
                    case SimpleTypeKind.Single: owner.WriteInt32(offset, ModuleOps.GetSingleBits(value)); break;
                    case SimpleTypeKind.Double: owner.WriteInt64(offset, ModuleOps.GetDoubleBits(value)); break;
                    case SimpleTypeKind.UnsignedLongLong: owner.WriteInt64(offset, ModuleOps.GetUnsignedLongLong(value, this)); break;
                    case SimpleTypeKind.SignedLongLong: owner.WriteInt64(offset, ModuleOps.GetSignedLongLong(value, this)); break;
                    case SimpleTypeKind.Object: owner.WriteIntPtr(offset, ModuleOps.GetObject(value)); break;
                    case SimpleTypeKind.Pointer: owner.WriteIntPtr(offset, ModuleOps.GetPointer(value)); break;
                    case SimpleTypeKind.CharPointer: 
                        owner.WriteIntPtr(offset, ModuleOps.GetCharPointer(value));
                        return value;
                    case SimpleTypeKind.WCharPointer: 
                        owner.WriteIntPtr(offset, ModuleOps.GetWCharPointer(value));
                        return value;
                    default:
                        throw new InvalidOperationException();
                }
                return null;
            }
Esempio n. 7
0
            object INativeType.SetValue(MemoryHolder address, int offset, object value) {
                Pointer ptr;
                _Array array;
                if (value == null) {
                    address.WriteIntPtr(offset, IntPtr.Zero);
                }  else if (value is int) {
                    address.WriteIntPtr(offset, new IntPtr((int)value));
                } else if (value is BigInteger) {
                    address.WriteIntPtr(offset, new IntPtr((long)(BigInteger)value));
                } else if ((ptr = value as Pointer) != null) {
                    address.WriteIntPtr(offset, ptr._memHolder.ReadMemoryHolder(0));
                    return PythonOps.MakeDictFromItems(ptr, "0", ptr._objects, "1");
                } else if ((array = value as _Array) != null) {
                    address.WriteIntPtr(offset, array._memHolder);
                    return array;
                } else {
                    throw PythonOps.TypeErrorForTypeMismatch(Name, value);
                }

                return null;
            }
Esempio n. 8
0
            void INativeType.SetValue(MemoryHolder address, int offset, object value) {
                if (value is int) {
                    address.WriteIntPtr(offset, new IntPtr((int)value));
                } else if (value is BigInteger) {
                    address.WriteIntPtr(offset, new IntPtr(((BigInteger)value).ToInt64()));
                } else {
                    Pointer ptr = value as Pointer;
                    if (ptr != null) {
                        address.WriteIntPtr(offset, ptr._memHolder.ReadMemoryHolder(0));
                    } else {
                        throw new NotImplementedException("pointer set value");
                    }
                }

            }
Esempio n. 9
0
            object INativeType.SetValue(MemoryHolder address, int offset, object value) {
                Pointer ptr;
                _Array array;
                if (value == null) {
                    address.WriteIntPtr(offset, IntPtr.Zero);
                }  else if (value is int) {
                    address.WriteIntPtr(offset, new IntPtr((int)value));
                } else if (value is BigInteger) {
                    address.WriteIntPtr(offset, new IntPtr(((BigInteger)value).ToInt64()));
                } else if ((ptr = value as Pointer) != null) {
                    address.WriteIntPtr(offset, ptr._memHolder.ReadMemoryHolder(0));
                } else if ((array = value as _Array) != null) {
                    // TODO: Need to keep alive the array after this
                    address.WriteIntPtr(offset, array._memHolder);
                } else {
                    throw PythonOps.TypeErrorForTypeMismatch(Name, value);
                }

                return null;
            }
Esempio n. 10
0
 public Pointer(CData value) {
     _object = value; // Keep alive the object, more to do here.
     _memHolder = new MemoryHolder(IntPtr.Size);
     _memHolder.WriteIntPtr(0, value._memHolder);
 }