PointerType 编辑

PointerType represents C pointer.

Syntax

Returns a new CType object describing a new pointer data type.

CType PointerType(
  type
);
Parameters
type
Specifies the type to which the pointer type points. This can be any CType object to declare the new type as a pointer to that type.
Return value

A CType object describing the newly created data type.

Exceptions thrown
TypeError
Thrown if the parameter isn't a CType.
Examples

Creating a type "pointer to 32-bit integer" looks like this:

var intPtrType = new ctypes.PointerType(ctypes.int32_t);

Properties

PropertyTypeDescription
targetTypeCTypeThe type of object the pointer points to. Read only.

Properties inherited from CType

These properties are available on all CType objects.

PropertyTypeDescription
nameString

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.

ptrCTypeReturns a CType representing the data type "pointer to this type". This is the result of calling ctypes.PointerType(the_type). Read only.
sizeNumber

The size of the type, in bytes. This is the same value as the C sizeof. Read only.

Note: ctypes.void_t.size is undefined.

Method overview

Methods inherited from CType

CType array([n])
String toSource()
String toString()

PointerType CData Syntax

CData pointertype();
pointertype is PointerType CType.
Return value

A CData representing the newly allocated pointer.

PointerType CData Properties

PropertyTypeDescription
contentsCDataReading this property returns a CData object referring to the pointed-to contents of the object. Writing to this value writes the C conversion of the data into the pointed-to memory. If converting the data fails, a TypeError exception is thrown.

Properties inherited from CData

PropertyTypeDescription
constructorCType

The data type of the CData object, as a CType. Read only.

Note: This is never ctypes.void_t or an array type with an unspecified length.
valueobjectThe JavaScript equivalent of the CData object's value. This will throw a TypeError exception if the value can't be converted.

PointerType CData Method_overview

bool isNull()

Methods inherited from CData

CData address()
String toSource()
String toString()

PointerType CData Methods

isNull()

Determines whether or not the pointer's value is null.

bool isNull();
Parameters

None.

Return value

true if the pointer's value is null, otherwise false.

See Also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:87 次

字数:8579

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文