當前位置: 首頁>>代碼示例>>Python>>正文


Python _ctypes.sizeof方法代碼示例

本文整理匯總了Python中_ctypes.sizeof方法的典型用法代碼示例。如果您正苦於以下問題:Python _ctypes.sizeof方法的具體用法?Python _ctypes.sizeof怎麽用?Python _ctypes.sizeof使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在_ctypes的用法示例。


在下文中一共展示了_ctypes.sizeof方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: to_c_mech

# 需要導入模塊: import _ctypes [as 別名]
# 或者: from _ctypes import sizeof [as 別名]
def to_c_mech(self):
        """
        Create the Param structure, then convert the data into byte arrays.

        :return: :class:`~pycryptoki.cryptoki.CK_MECHANISM`
        """
        super(ECDH1DeriveMechanism, self).to_c_mech()
        params = CK_ECDH1_DERIVE_PARAMS()
        params.kdf = self.params["kdf"]
        if self.params["sharedData"] is None:
            shared_data = None
            shared_data_len = 0
        else:
            shared_data, shared_data_len = to_byte_array(self.params["sharedData"])
        params.pSharedData = cast(shared_data, CK_BYTE_PTR)
        params.ulSharedDataLen = shared_data_len
        public_data, public_data_len = to_byte_array(self.params["publicData"])
        params.pPublicData = cast(public_data, CK_BYTE_PTR)
        params.ulPublicDataLen = public_data_len
        self.mech.pParameter = cast(pointer(params), c_void_p)
        self.mech.usParameterLen = CK_ULONG(sizeof(params))
        return self.mech 
開發者ID:ThalesGroup,項目名稱:pycryptoki,代碼行數:24,代碼來源:dh.py

示例2: _check_size

# 需要導入模塊: import _ctypes [as 別名]
# 或者: from _ctypes import sizeof [as 別名]
def _check_size(typ, typecode=None):
    # Check if sizeof(ctypes_type) against struct.calcsize.  This
    # should protect somewhat against a misconfigured libffi.
    from struct import calcsize
    if typecode is None:
        # Most _type_ codes are the same as used in struct
        typecode = typ._type_
    actual, required = sizeof(typ), calcsize(typecode)
    if actual != required:
        raise SystemError("sizeof(%s) wrong: %d instead of %d" % \
                          (typ, actual, required)) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:13,代碼來源:__init__.py

示例3: to_c_mech

# 需要導入模塊: import _ctypes [as 別名]
# 或者: from _ctypes import sizeof [as 別名]
def to_c_mech(self):
        """
        Create the Param structure, then convert the data into byte arrays.

        :return: :class:`~pycryptoki.cryptoki.CK_MECHANISM`

        """
        super(PRFKDFDeriveMechanism, self).to_c_mech()
        params = CK_PRF_KDF_PARAMS()
        params.prfType = self.params["prf_type"]
        if self.params["label"] is None:
            label = ""
            label_len = 0
        else:
            label, label_len = to_byte_array(self.params["label"])
        if self.params["context"] is None:
            context = ""
            context_len = 0
        else:
            context, context_len = to_byte_array(self.params["context"])
        if self.params["counter"] is None:
            counter = 1
        else:
            counter = self.params["counter"]
        ul_encoding_scheme = self.params["encoding_scheme"]

        params.pLabel = cast(label, CK_BYTE_PTR)
        params.ulLabelLen = label_len
        params.pContext = cast(context, CK_BYTE_PTR)
        params.ulContextLen = context_len
        params.ulCounter = counter
        params.ulEncodingScheme = ul_encoding_scheme
        self.mech.pParameter = cast(pointer(params), c_void_p)
        self.mech.usParameterLen = CK_ULONG(sizeof(params))
        return self.mech 
開發者ID:ThalesGroup,項目名稱:pycryptoki,代碼行數:37,代碼來源:kdf.py

示例4: create_unicode_buffer

# 需要導入模塊: import _ctypes [as 別名]
# 或者: from _ctypes import sizeof [as 別名]
def create_unicode_buffer(init, size=None):
    """create_unicode_buffer(aString) -> character array
    create_unicode_buffer(anInteger) -> character array
    create_unicode_buffer(aString, anInteger) -> character array
    """
    if isinstance(init, str):
        if size is None:
            if sizeof(c_wchar) == 2:
                # UTF-16 requires a surrogate pair (2 wchar_t) for non-BMP
                # characters (outside [U+0000; U+FFFF] range). +1 for trailing
                # NUL character.
                size = sum(2 if ord(c) > 0xFFFF else 1 for c in init) + 1
            else:
                # 32-bit wchar_t (1 wchar_t per Unicode character). +1 for
                # trailing NUL character.
                size = len(init) + 1
        buftype = c_wchar * size
        buf = buftype()
        buf.value = init
        return buf
    elif isinstance(init, int):
        buftype = c_wchar * init
        buf = buftype()
        return buf
    raise TypeError(init)


# XXX Deprecated 
開發者ID:guohuadeng,項目名稱:odoo13-x64,代碼行數:30,代碼來源:__init__.py


注:本文中的_ctypes.sizeof方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。