Python ctypes.alignment() Examples

The following are 19 code examples of ctypes.alignment(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module ctypes , or try the search function .
Example #1
Source File: backend_ctypes.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #2
Source File: backend_ctypes.py    From odoo12-x64 with GNU General Public License v3.0 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #3
Source File: _dtype_ctypes.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _from_ctypes_structure(t):
    for item in t._fields_:
        if len(item) > 2:
            raise TypeError(
                "ctypes bitfields have no dtype equivalent")

    if hasattr(t, "_pack_"):
        formats = []
        offsets = []
        names = []
        current_offset = 0
        for fname, ftyp in t._fields_:
            names.append(fname)
            formats.append(dtype_from_ctypes_type(ftyp))
            # Each type has a default offset, this is platform dependent for some types.
            effective_pack = min(t._pack_, ctypes.alignment(ftyp))
            current_offset = ((current_offset + effective_pack - 1) // effective_pack) * effective_pack
            offsets.append(current_offset)
            current_offset += ctypes.sizeof(ftyp)

        return np.dtype(dict(
            formats=formats,
            offsets=offsets,
            names=names,
            itemsize=ctypes.sizeof(t)))
    else:
        fields = []
        for fname, ftyp in t._fields_:
            fields.append((fname, dtype_from_ctypes_type(ftyp)))

        # by default, ctypes structs are aligned
        return np.dtype(fields, align=True) 
Example #4
Source File: backend_ctypes.py    From quickstart-redhat-openshift with Apache License 2.0 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #5
Source File: _dtype_ctypes.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def _from_ctypes_structure(t):
    for item in t._fields_:
        if len(item) > 2:
            raise TypeError(
                "ctypes bitfields have no dtype equivalent")

    if hasattr(t, "_pack_"):
        formats = []
        offsets = []
        names = []
        current_offset = 0
        for fname, ftyp in t._fields_:
            names.append(fname)
            formats.append(dtype_from_ctypes_type(ftyp))
            # Each type has a default offset, this is platform dependent for some types.
            effective_pack = min(t._pack_, ctypes.alignment(ftyp))
            current_offset = ((current_offset + effective_pack - 1) // effective_pack) * effective_pack
            offsets.append(current_offset)
            current_offset += ctypes.sizeof(ftyp)

        return np.dtype(dict(
            formats=formats,
            offsets=offsets,
            names=names,
            itemsize=ctypes.sizeof(t)))
    else:
        fields = []
        for fname, ftyp in t._fields_:
            fields.append((fname, dtype_from_ctypes_type(ftyp)))

        # by default, ctypes structs are aligned
        return np.dtype(fields, align=True) 
Example #6
Source File: backend_ctypes.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #7
Source File: backend_ctypes.py    From quickstart-git2s3 with Apache License 2.0 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #8
Source File: backend_ctypes.py    From quickstart-git2s3 with Apache License 2.0 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #9
Source File: backend_ctypes.py    From scalyr-agent-2 with Apache License 2.0 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #10
Source File: backend_ctypes.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #11
Source File: _dtype_ctypes.py    From recruit with Apache License 2.0 5 votes vote down vote up
def _from_ctypes_structure(t):
    for item in t._fields_:
        if len(item) > 2:
            raise TypeError(
                "ctypes bitfields have no dtype equivalent")

    if hasattr(t, "_pack_"):
        formats = []
        offsets = []
        names = []
        current_offset = 0
        for fname, ftyp in t._fields_:
            names.append(fname)
            formats.append(dtype_from_ctypes_type(ftyp))
            # Each type has a default offset, this is platform dependent for some types.
            effective_pack = min(t._pack_, ctypes.alignment(ftyp))
            current_offset = ((current_offset + effective_pack - 1) // effective_pack) * effective_pack
            offsets.append(current_offset)
            current_offset += ctypes.sizeof(ftyp)

        return np.dtype(dict(
            formats=formats,
            offsets=offsets,
            names=names,
            itemsize=ctypes.sizeof(t)))
    else:
        fields = []
        for fname, ftyp in t._fields_:
            fields.append((fname, dtype_from_ctypes_type(ftyp)))

        # by default, ctypes structs are aligned
        return np.dtype(fields, align=True) 
Example #12
Source File: _dtype_ctypes.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def _from_ctypes_structure(t):
    for item in t._fields_:
        if len(item) > 2:
            raise TypeError(
                "ctypes bitfields have no dtype equivalent")

    if hasattr(t, "_pack_"):
        formats = []
        offsets = []
        names = []
        current_offset = 0
        for fname, ftyp in t._fields_:
            names.append(fname)
            formats.append(dtype_from_ctypes_type(ftyp))
            # Each type has a default offset, this is platform dependent for some types.
            effective_pack = min(t._pack_, ctypes.alignment(ftyp))
            current_offset = ((current_offset + effective_pack - 1) // effective_pack) * effective_pack
            offsets.append(current_offset)
            current_offset += ctypes.sizeof(ftyp)

        return np.dtype(dict(
            formats=formats,
            offsets=offsets,
            names=names,
            itemsize=ctypes.sizeof(t)))
    else:
        fields = []
        for fname, ftyp in t._fields_:
            fields.append((fname, dtype_from_ctypes_type(ftyp)))

        # by default, ctypes structs are aligned
        return np.dtype(fields, align=True) 
Example #13
Source File: backend_ctypes.py    From teleport with Apache License 2.0 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #14
Source File: backend_ctypes.py    From teleport with Apache License 2.0 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #15
Source File: backend_ctypes.py    From SwiftKitten with MIT License 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #16
Source File: backend_ctypes.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #17
Source File: _dtype_ctypes.py    From Mastering-Elasticsearch-7.0 with MIT License 5 votes vote down vote up
def _from_ctypes_structure(t):
    for item in t._fields_:
        if len(item) > 2:
            raise TypeError(
                "ctypes bitfields have no dtype equivalent")

    if hasattr(t, "_pack_"):
        formats = []
        offsets = []
        names = []
        current_offset = 0
        for fname, ftyp in t._fields_:
            names.append(fname)
            formats.append(dtype_from_ctypes_type(ftyp))
            # Each type has a default offset, this is platform dependent for some types.
            effective_pack = min(t._pack_, ctypes.alignment(ftyp))
            current_offset = ((current_offset + effective_pack - 1) // effective_pack) * effective_pack
            offsets.append(current_offset)
            current_offset += ctypes.sizeof(ftyp)

        return np.dtype(dict(
            formats=formats,
            offsets=offsets,
            names=names,
            itemsize=ctypes.sizeof(t)))
    else:
        fields = []
        for fname, ftyp in t._fields_:
            fields.append((fname, dtype_from_ctypes_type(ftyp)))

        # by default, ctypes structs are aligned
        return np.dtype(fields, align=True) 
Example #18
Source File: backend_ctypes.py    From oss-ftp with MIT License 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype) 
Example #19
Source File: backend_ctypes.py    From bioforum with MIT License 5 votes vote down vote up
def _alignment(cls):
        return ctypes.alignment(cls._ctype)