ArrayType
represents C arrays
Returns a new CType representing an array data type.
CType ArrayType() type[ length] );
Type: It represents the type of the elements or variable which is going to be present in an array
length
OptionalA CType represents the newly declared array type.
TypeError
type
is not a CType, or type.size
is undefined.If the length is specifed but if it is not a valid one,then it is also thrownRangeError
size_t
and as a JavaScript number.Property | Type | Description |
elementType |
CType | The data type of the elements in an array type. Read only. |
length |
Number |
The number of elements in the array, or undefined if the array type doesn't have a specified length. Read only. |
These properties are available on all CType
objects.
Property | Type | Description |
name |
String |
The type's name. Read only. For primitive types, this is just the name of the corresponding C type. For structure and opaque pointer types, this is simply the string that was passed to the constructor. For other function, pointer, and array types, this should be a valid C type expression. |
ptr |
CType | Returns a CType representing the data type "pointer to this type". This is the result of calling ctypes.PointerType(the_type) . Read only. |
size |
Number |
The size of the type, in bytes. This is the same value as the C Note:
ctypes.void_t.size is undefined. |
CType array([n]) |
String toSource() |
String toString() |
CData sized_arraytype(); CData unsized_arraytype(length);
sized_arraytype
and unsized_arraytype
are ArrayType
CType.length
ArrayType
.A CData representing the newly allocated array.
TypeError
length
is not provided for unsized array, or is provided for sized array.Property | Type | Description |
length |
Number |
The length of the array. Read only. |
In addition, each element in the array can be referenced by index using standard bracket notation, such as myArray[index]
.
Property | Type | Description |
constructor |
CType |
The data type of the Note: This is never
ctypes.void_t or an array type with an unspecified length. |
value |
object | The JavaScript equivalent of the CData object's value. This will throw a TypeError exception if the value can't be converted. |
CData addressOfElement(idx) |
|
String toSource() |
String toString() |
Returns a new CData object of the appropriate pointer type, whose value points to the specified array element on which the method was called.
CData addressOfElement( idx );
idx
TypeError
exception is thrown.A new CData object pointing to the specified element.
ctypes.PointerType(theArrayType.constructor.elementType))
.