C# Class IronPython.Modules.MemoryHolder

A wrapper around allocated memory to ensure it gets released and isn't accessed when it could be finalized.
Inheritance: System.Runtime.ConstrainedExecution.CriticalFinalizerObject
Mostrar archivo Open project: jschementi/iron Class Usage Examples

Public Methods

Method Description
CopyFrom ( IntPtr source, IntPtr size ) : void

Copies the data in data into this MemoryHolder.

CopyTo ( MemoryHolder destAddress, int writeOffset, int size ) : void

Copies memory from one location to another keeping the associated memory holders alive during the operation.

GetSubBlock ( int offset ) : MemoryHolder
MemoryHolder ( IntPtr data, int size ) : System

Creates a new MemoryHolder at the specified address which is not tracked by us and we will never free.

MemoryHolder ( IntPtr data, int size, MemoryHolder parent ) : System

Creates a new MemoryHolder at the specified address which will keep alive the parent memory holder.

ReadByte ( int offset ) : byte
ReadInt16 ( int offset ) : short
ReadInt32 ( int offset ) : int
ReadInt64 ( int offset ) : long
ReadIntPtr ( int offset ) : IntPtr
ReadMemoryHolder ( int offset ) : MemoryHolder
WriteByte ( int offset, byte value ) : void
WriteInt16 ( int offset, short value ) : void
WriteInt32 ( int offset, int value ) : void
WriteInt64 ( int offset, long value ) : void
WriteIntPtr ( int offset, IntPtr value ) : void
WriteIntPtr ( int offset, MemoryHolder address ) : void

Private Methods

Method Description
AddObject ( object key, object value ) : void

Used to track the lifetime of objects when one memory region depends upon another memory region. For example if you have an array of objects that each have an element which has it's own lifetime the array needs to keep the individual elements alive. The keys used here match CPython's keys as tested by CPython's test_ctypes. Typically they are a string which is the array index, "ffffffff" when from_buffer is used, or when it's a simple type there's just a string instead of the full dictionary - we store that under the key "str".

EnsureObjects ( ) : PythonDictionary
MemoryHolder ( int size ) : System
ReadAnsiString ( IntPtr addr, int offset ) : string
ReadAnsiString ( IntPtr addr, int offset, int length ) : string
ReadAnsiString ( int offset ) : string
ReadAnsiString ( int offset, int length ) : string
ReadUnicodeString ( int offset ) : string
ReadUnicodeString ( int offset, int length ) : string
WriteAnsiString ( int offset, string value ) : void
WriteUnicodeString ( int offset, string value ) : void

Method Details

CopyFrom() public method

Copies the data in data into this MemoryHolder.
public CopyFrom ( IntPtr source, IntPtr size ) : void
source System.IntPtr
size System.IntPtr
return void

CopyTo() public method

Copies memory from one location to another keeping the associated memory holders alive during the operation.
public CopyTo ( MemoryHolder destAddress, int writeOffset, int size ) : void
destAddress MemoryHolder
writeOffset int
size int
return void

GetSubBlock() public method

public GetSubBlock ( int offset ) : MemoryHolder
offset int
return MemoryHolder

MemoryHolder() public method

Creates a new MemoryHolder at the specified address which is not tracked by us and we will never free.
public MemoryHolder ( IntPtr data, int size ) : System
data System.IntPtr
size int
return System

MemoryHolder() public method

Creates a new MemoryHolder at the specified address which will keep alive the parent memory holder.
public MemoryHolder ( IntPtr data, int size, MemoryHolder parent ) : System
data System.IntPtr
size int
parent MemoryHolder
return System

ReadByte() public method

public ReadByte ( int offset ) : byte
offset int
return byte

ReadInt16() public method

public ReadInt16 ( int offset ) : short
offset int
return short

ReadInt32() public method

public ReadInt32 ( int offset ) : int
offset int
return int

ReadInt64() public method

public ReadInt64 ( int offset ) : long
offset int
return long

ReadIntPtr() public method

public ReadIntPtr ( int offset ) : IntPtr
offset int
return System.IntPtr

ReadMemoryHolder() public method

public ReadMemoryHolder ( int offset ) : MemoryHolder
offset int
return MemoryHolder

WriteByte() public method

public WriteByte ( int offset, byte value ) : void
offset int
value byte
return void

WriteInt16() public method

public WriteInt16 ( int offset, short value ) : void
offset int
value short
return void

WriteInt32() public method

public WriteInt32 ( int offset, int value ) : void
offset int
value int
return void

WriteInt64() public method

public WriteInt64 ( int offset, long value ) : void
offset int
value long
return void

WriteIntPtr() public method

public WriteIntPtr ( int offset, IntPtr value ) : void
offset int
value System.IntPtr
return void

WriteIntPtr() public method

public WriteIntPtr ( int offset, MemoryHolder address ) : void
offset int
address MemoryHolder
return void