powc.safearray module#

SAFEARRAY機能を提供します。

class powc.safearray.SafeArrayPtr#

ベースクラス: c_void_p

セーフ配列の管理機能を提供します。データは SAFEARRAY* として管理します。

access_data() Iterator[Array]#

セーフ配列のメモリにアクセスします。セーフ配列は列挙終了までロックされます。

access_data_mv() Iterator[memoryview]#

セーフ配列のメモリにアクセスします。セーフ配列は列挙終了までロックされます。

property bounds: tuple[tuple[int, int], ...]#

セーフ配列の各次元の範囲を取得します。

サンプル

from powc.safearray import SafeArrayPtr
from powc.variant import VARENUM

p = SafeArrayPtr.create_array(VARENUM.VT_I4, (3, 3, 5))
print(p.bounds)
# ((0, 2), (0, 2), (0, 4))
clear_data() None#

セーフ配列の各要素を解放します。

clear_data_nothrow() ComResult[None]#

セーフ配列の各要素を解放します。

clone() SafeArrayPtr#

セーフ配列の複製を取得します。

clone_nothrow() ComResult[SafeArrayPtr]#

セーフ配列の複製を取得します。

static create_array(vt: VARENUM, elements: Sequence[int], lbounds: Sequence[int] | None = None) SafeArrayPtr#

新しい多次元セーフ配列を作成します。

パラメータ:
  • vt (VARENUM) -- 要素の型。

  • elements (Sequence[int]) -- 各次元の要素数。

  • lbounds (Sequence[int] | None, optional) -- 各次元のインデックス下限値。既定値は全て0です。

例外:

ValueError -- 要素と下限のサイズが一致しない。

static create_vector(vt: VARENUM, elements: int, lbound: int = 0) SafeArrayPtr#

新しい1次元セーフ配列を作成します。

パラメータ:
  • vt (VARENUM) -- 要素の型。

  • elements (int) -- 要素数。

  • lbound (int, optional) -- 要素インデックスの下限値。既定値は0です。

static create_vector_int16(source: Sequence[int]) SafeArrayPtr#

ctypes.c_int16 の1次元セーフ配列を作成します。

static create_vector_int32(source: Sequence[int]) SafeArrayPtr#

ctypes.c_int32 の1次元セーフ配列を作成します。

static create_vector_int64(source: Sequence[int]) SafeArrayPtr#

ctypes.c_int64 の1次元セーフ配列を作成します。

static create_vector_int8(source: Sequence[int]) SafeArrayPtr#

ctypes.c_int8 の1次元セーフ配列を作成します。

static create_vector_uint16(source: Sequence[int]) SafeArrayPtr#

ctypes.c_uint16 の1次元セーフ配列を作成します。

static create_vector_uint32(source: Sequence[int]) SafeArrayPtr#

ctypes.c_uint32 の1次元セーフ配列を作成します。

static create_vector_uint64(source: Sequence[int]) SafeArrayPtr#

ctypes.c_uint64 の1次元セーフ配列を作成します。

static create_vector_uint8(source: Sequence[int]) SafeArrayPtr#

ctypes.c_uint8 の1次元セーフ配列を作成します。

property dim: int#

セーフ配列の次元数を取得します。

サンプル

from powc.safearray import SafeArrayPtr
from powc.variant import VARENUM

p = SafeArrayPtr.create_array(VARENUM.VT_I4, (3, 3, 5))
print(p.dim)
# 3
property elemsize: int#

セーフ配列の要素のバイト数を取得します。

サンプル

from powc.safearray import SafeArrayPtr
from powc.variant import VARENUM

p = SafeArrayPtr.create_array(VARENUM.VT_I4, (3, 3, 5))
print(p.elemsize)
# 4 (VT_I4のバイト数)
get_elem_at(indexes: Sequence[int], convertsNotSupportedTypeToBytes: bool = True) Any#

各次元のインデックスを指定して要素を取得します。

パラメータ:
  • indexes (Sequence[int]) -- 各次元のインデックス。

  • convertsNotSupportedTypeToBytes (bool, optional) -- 未対応の型をバイナリ表現に変換するか。偽の場合、未対応の型に対して例外を発生します。既定値は真です。

get_elemraw_at(indexes: Sequence[int]) Array#

各次元のインデックスを指定して要素のバイナリ表現を取得します。

get_elemraw_at_nothrow(indexes: Sequence[int]) ComResult[Array]#

各次元のインデックスを指定して要素のバイナリ表現を取得します。

get_lbound(dim: int) int#

指定した次元のインデックス下限を取得します。

get_lbound_nothrow(dim: int) ComResult[int]#

指定した次元のインデックス下限を取得します。

get_ubound(dim: int) int#

指定した次元のインデックス上限を取得します。

get_ubound_nothrow(dim: int) ComResult[int]#

指定した次元のインデックス上限を取得します。

property indices: tuple[int, ...]#

セーフ配列の次元数のインデックスを取得します。

サンプル

from powc.safearray import SafeArrayPtr
from powc.variant import VARENUM

p = SafeArrayPtr.create_array(VARENUM.VT_I4, (3, 3, 5))
print(p.indices)
# (0, 1, 2)
lock()#

セーフ配列のロック数を加算します。使用後は unlock() を呼び出してください

lock_nothrow() ComResult[None]#

セーフ配列のロック数を加算します。使用後は unlock() を呼び出してください

lock_scope() Iterator[SafeArrayPtr]#

セーフ配列のロックスコープを作成します。通常は with と組み合わせて使用します。

to_bstrarray() tuple[str, ...]#

セーフ配列を BSTR 型とみなした配列を作成します。

to_int32array() tuple[int, ...]#

セーフ配列を32ビット符号付き整数とみなした配列を作成します。

to_uint32array() tuple[int, ...]#

セーフ配列を32ビット符号無し整数とみなした配列を作成します。

property totallen: int#

セーフ配列の全要素数を取得します。

サンプル

from powc.safearray import SafeArrayPtr
from powc.variant import VARENUM

p = SafeArrayPtr.create_array(VARENUM.VT_I4, (3, 3, 5))
print(p.totallen)
# 11
property totalsize: int#

セーフ配列の全要素のバイト数を取得します。

サンプル

from powc.safearray import SafeArrayPtr
from powc.variant import VARENUM

p = SafeArrayPtr.create_array(VARENUM.VT_I4, (3, 3, 5))
print(p.totalsize)
# 44
unlock() None#

セーフ配列のロック数を減算します。通常は lock() の後で呼び出します。

unlock_nothrow() ComResult[None]#

セーフ配列のロック数を減算します。通常は lock() の後で呼び出します。

property vartype: VARENUM#

セーフ配列の全要素の型を取得します。

サンプル

from powc.safearray import SafeArrayPtr
from powc.variant import VARENUM

p = SafeArrayPtr.create_array(VARENUM.VT_I4, (3, 3, 5))
print(p.vartype)
# 3 (VT_I4)
property vartype_nothrow: ComResult[VARENUM]#

セーフ配列の全要素の型を取得します。

サンプル

from powc.safearray import SafeArrayPtr
from powc.variant import VARENUM

p = SafeArrayPtr.create_array(VARENUM.VT_I4, (3, 3, 5))
print(p.vartype)
# 3 (VT_I4)