C# Class IronPython.Modules.CTypes

Provides support for interop with native code from Python code.
Afficher le fichier Open project: jschementi/iron Class Usage Examples

Private Properties

Свойство Type Description
Cast System.IntPtr
CheckBits int
EmitCDataCreation void
EnsureRefCountTable void
GetFieldInfo void
GetFieldsList IList
GetFunctionType CFuncPtrType
GetHandleFromObject System.IntPtr
GetMarshalTypeFromSize System.Type
IsPointer bool
MakeArrayType System.Reflection.Emit.ArrayType
MakePointer System.Reflection.Emit.PointerType
PerformModuleReload void
StringAt System.IntPtr
StructureCannotContainSelf System.Exception
ValidateArraySizes void
ValidateArraySizes void
ValidateArraySizes void
WStringAt System.IntPtr

Méthodes publiques

Méthode Description
@sizeof ( IronPython.Runtime.Types.PythonType type ) : int
@sizeof ( object instance ) : int
CopyComPointer ( object src, object dest ) : int
DeleteCharArrayValue ( _Array arr, object value ) : void
DeleteWCharArrayRaw ( _Array arr ) : object
DeleteWCharArrayValue ( _Array arr ) : object
FormatError ( ) : string
FormatError ( int errorCode ) : string
FreeLibrary ( BigInteger handle ) : void
FreeLibrary ( IntPtr handle ) : void
FreeLibrary ( int handle ) : void
GetCharArrayValue ( _Array arr ) : object
GetWCharArrayRaw ( _Array arr ) : object
GetWCharArrayValue ( _Array arr ) : object
LoadLibrary ( string library, [ mode ) : object
POINTER ( CodeContext context, IronPython.Runtime.Types.PythonType type ) : IronPython.Runtime.Types.PythonType

Returns a new type which represents a pointer given the existing type.

POINTER ( CodeContext context, [ name ) : IronPython.Runtime.Types.PythonType
PyObj_FromPtr ( IntPtr address ) : object

Converts an address acquired from PyObj_FromPtr or that has been marshaled as type 'O' back into an object.

PyObj_ToPtr ( object obj ) : IntPtr

Converts an object into an opaque address which can be handed out to managed code.

Py_DECREF ( object key ) : void

Decreases the ref count on an object which has been increased with Py_INCREF.

Py_INCREF ( object key ) : void

Increases the ref count on an object ensuring that it will not be collected.

SetCharArrayValue ( _Array arr, object value ) : void
SetWCharArrayRaw ( _Array arr, object value ) : void
SetWCharArrayValue ( _Array arr, object value ) : void
_buffer_info ( CData data ) : PythonTuple
_check_HRESULT ( int hresult ) : void
_unpickle ( ) : void
addressof ( CData data ) : object

returns address of C instance internal buffer. It is the callers responsibility to ensure that the provided instance will stay alive if memory in the resulting address is to be used later.

alignment ( IronPython.Runtime.Types.PythonType type ) : int

Gets the required alignment of the given type.

alignment ( object o ) : int

Gets the required alignment of an object.

byref ( CData instance, [ offset ) : object
call_cdeclfunction ( CodeContext context, BigInteger address, PythonTuple args ) : object
call_cdeclfunction ( CodeContext context, IntPtr address, PythonTuple args ) : object
call_cdeclfunction ( CodeContext context, int address, PythonTuple args ) : object
call_commethod ( ) : void
call_function ( CodeContext context, BigInteger address, PythonTuple args ) : object
call_function ( CodeContext context, IntPtr address, PythonTuple args ) : object
call_function ( CodeContext context, int address, PythonTuple args ) : object
dlopen ( string library, [ mode ) : object
get_errno ( ) : int
get_last_error ( ) : int
pointer ( CodeContext context, CData data ) : Pointer

Returns a pointer instance for the given CData

resize ( CData obj, int newSize ) : void
set_conversion_mode ( CodeContext context, string encoding, string errors ) : PythonTuple
set_errno ( ) : void
set_last_error ( int errorCode ) : void

Private Methods

Méthode Description
Cast ( IntPtr data, IntPtr obj, IntPtr type ) : IntPtr

Implementation of our cast function. data is marshalled as a void* so it ends up as an address. obj and type are marshalled as an object so we need to unmarshal them.

CheckBits ( INativeType cdata, PythonTuple pt ) : int

Verifies that the provided bit field settings are valid for this type.

EmitCDataCreation ( INativeType type, ILGenerator method, List constantPool, int constantPoolArgument ) : void

Emits the marshalling code to create a CData object for reverse marshalling.

EnsureRefCountTable ( ) : void
GetFieldInfo ( INativeType type, object o, string &fieldName, INativeType &cdata, int &bitCount ) : void

Shared helper between struct and union for getting field info and validating it.

GetFieldsList ( object fields ) : IList

Shared helper to get the _fields_ list for struct/union and validate it.

GetFunctionType ( CodeContext context, int flags ) : CFuncPtrType
GetHandleFromObject ( object dll, string errorMsg ) : IntPtr
GetMarshalTypeFromSize ( int size ) : Type

Given a specific size returns a .NET type of the equivalent size that we can use when marshalling these values across calls.

IsPointer ( IronPython.Runtime.Types.PythonType pt ) : bool
MakeArrayType ( IronPython.Runtime.Types.PythonType type, int count ) : ArrayType
MakePointer ( CodeContext context, string name, PythonDictionary dict ) : PointerType
PerformModuleReload ( IronPython.Runtime.PythonContext context, PythonDictionary dict ) : void
StringAt ( IntPtr src, int len ) : IntPtr

Helper function for translating from memset to NT's FillMemory API.

StructureCannotContainSelf ( ) : Exception
ValidateArraySizes ( IronPython.Modules.ArrayModule array, int offset, int size ) : void
ValidateArraySizes ( System.Bytes bytes, int offset, int size ) : void
ValidateArraySizes ( int arraySize, int offset, int size ) : void
WStringAt ( IntPtr src, int len ) : IntPtr

Helper function for translating from memset to NT's FillMemory API.

Method Details

@sizeof() public static méthode

public static @sizeof ( IronPython.Runtime.Types.PythonType type ) : int
type IronPython.Runtime.Types.PythonType
Résultat int

@sizeof() public static méthode

public static @sizeof ( object instance ) : int
instance object
Résultat int

CopyComPointer() public static méthode

public static CopyComPointer ( object src, object dest ) : int
src object
dest object
Résultat int

DeleteCharArrayValue() public static méthode

public static DeleteCharArrayValue ( _Array arr, object value ) : void
arr _Array
value object
Résultat void

DeleteWCharArrayRaw() public static méthode

public static DeleteWCharArrayRaw ( _Array arr ) : object
arr _Array
Résultat object

DeleteWCharArrayValue() public static méthode

public static DeleteWCharArrayValue ( _Array arr ) : object
arr _Array
Résultat object

FormatError() public static méthode

public static FormatError ( ) : string
Résultat string

FormatError() public static méthode

public static FormatError ( int errorCode ) : string
errorCode int
Résultat string

FreeLibrary() public static méthode

public static FreeLibrary ( BigInteger handle ) : void
handle Microsoft.Scripting.Math.BigInteger
Résultat void

FreeLibrary() public static méthode

public static FreeLibrary ( IntPtr handle ) : void
handle System.IntPtr
Résultat void

FreeLibrary() public static méthode

public static FreeLibrary ( int handle ) : void
handle int
Résultat void

GetCharArrayValue() public static méthode

public static GetCharArrayValue ( _Array arr ) : object
arr _Array
Résultat object

GetWCharArrayRaw() public static méthode

public static GetWCharArrayRaw ( _Array arr ) : object
arr _Array
Résultat object

GetWCharArrayValue() public static méthode

public static GetWCharArrayValue ( _Array arr ) : object
arr _Array
Résultat object

LoadLibrary() public static méthode

public static LoadLibrary ( string library, [ mode ) : object
library string
mode [
Résultat object

POINTER() public static méthode

Returns a new type which represents a pointer given the existing type.
public static POINTER ( CodeContext context, IronPython.Runtime.Types.PythonType type ) : IronPython.Runtime.Types.PythonType
context CodeContext
type IronPython.Runtime.Types.PythonType
Résultat IronPython.Runtime.Types.PythonType

POINTER() public static méthode

public static POINTER ( CodeContext context, [ name ) : IronPython.Runtime.Types.PythonType
context CodeContext
name [
Résultat IronPython.Runtime.Types.PythonType

PyObj_FromPtr() public static méthode

Converts an address acquired from PyObj_FromPtr or that has been marshaled as type 'O' back into an object.
public static PyObj_FromPtr ( IntPtr address ) : object
address System.IntPtr
Résultat object

PyObj_ToPtr() public static méthode

Converts an object into an opaque address which can be handed out to managed code.
public static PyObj_ToPtr ( object obj ) : IntPtr
obj object
Résultat System.IntPtr

Py_DECREF() public static méthode

Decreases the ref count on an object which has been increased with Py_INCREF.
public static Py_DECREF ( object key ) : void
key object
Résultat void

Py_INCREF() public static méthode

Increases the ref count on an object ensuring that it will not be collected.
public static Py_INCREF ( object key ) : void
key object
Résultat void

SetCharArrayValue() public static méthode

public static SetCharArrayValue ( _Array arr, object value ) : void
arr _Array
value object
Résultat void

SetWCharArrayRaw() public static méthode

public static SetWCharArrayRaw ( _Array arr, object value ) : void
arr _Array
value object
Résultat void

SetWCharArrayValue() public static méthode

public static SetWCharArrayValue ( _Array arr, object value ) : void
arr _Array
value object
Résultat void

_buffer_info() public static méthode

public static _buffer_info ( CData data ) : PythonTuple
data CData
Résultat PythonTuple

_check_HRESULT() public static méthode

public static _check_HRESULT ( int hresult ) : void
hresult int
Résultat void

_unpickle() public static méthode

public static _unpickle ( ) : void
Résultat void

addressof() public static méthode

returns address of C instance internal buffer. It is the callers responsibility to ensure that the provided instance will stay alive if memory in the resulting address is to be used later.
public static addressof ( CData data ) : object
data CData
Résultat object

alignment() public static méthode

Gets the required alignment of the given type.
public static alignment ( IronPython.Runtime.Types.PythonType type ) : int
type IronPython.Runtime.Types.PythonType
Résultat int

alignment() public static méthode

Gets the required alignment of an object.
public static alignment ( object o ) : int
o object
Résultat int

byref() public static méthode

public static byref ( CData instance, [ offset ) : object
instance CData
offset [
Résultat object

call_cdeclfunction() public static méthode

public static call_cdeclfunction ( CodeContext context, BigInteger address, PythonTuple args ) : object
context CodeContext
address Microsoft.Scripting.Math.BigInteger
args PythonTuple
Résultat object

call_cdeclfunction() public static méthode

public static call_cdeclfunction ( CodeContext context, IntPtr address, PythonTuple args ) : object
context CodeContext
address System.IntPtr
args PythonTuple
Résultat object

call_cdeclfunction() public static méthode

public static call_cdeclfunction ( CodeContext context, int address, PythonTuple args ) : object
context CodeContext
address int
args PythonTuple
Résultat object

call_commethod() public static méthode

public static call_commethod ( ) : void
Résultat void

call_function() public static méthode

public static call_function ( CodeContext context, BigInteger address, PythonTuple args ) : object
context CodeContext
address Microsoft.Scripting.Math.BigInteger
args PythonTuple
Résultat object

call_function() public static méthode

public static call_function ( CodeContext context, IntPtr address, PythonTuple args ) : object
context CodeContext
address System.IntPtr
args PythonTuple
Résultat object

call_function() public static méthode

public static call_function ( CodeContext context, int address, PythonTuple args ) : object
context CodeContext
address int
args PythonTuple
Résultat object

dlopen() public static méthode

public static dlopen ( string library, [ mode ) : object
library string
mode [
Résultat object

get_errno() public static méthode

public static get_errno ( ) : int
Résultat int

get_last_error() public static méthode

public static get_last_error ( ) : int
Résultat int

pointer() public static méthode

Returns a pointer instance for the given CData
public static pointer ( CodeContext context, CData data ) : Pointer
context CodeContext
data CData
Résultat System.Reflection.Pointer

resize() public static méthode

public static resize ( CData obj, int newSize ) : void
obj CData
newSize int
Résultat void

set_conversion_mode() public static méthode

public static set_conversion_mode ( CodeContext context, string encoding, string errors ) : PythonTuple
context CodeContext
encoding string
errors string
Résultat PythonTuple

set_errno() public static méthode

public static set_errno ( ) : void
Résultat void

set_last_error() public static méthode

public static set_last_error ( int errorCode ) : void
errorCode int
Résultat void