Python ctypes.c_int16() Examples

The following are 30 code examples of ctypes.c_int16(). 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: messages.py    From olympe with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _ar_arsdk_encode_type_info(cls, ar_argtype):
        arsdk_encode_type_info_map = {
            arsdkparser.ArArgType.I8: (od.ARSDK_ARG_TYPE_I8, "i8", ctypes.c_int8),
            arsdkparser.ArArgType.U8: (od.ARSDK_ARG_TYPE_U8, "u8", ctypes.c_uint8),
            arsdkparser.ArArgType.I16: (od.ARSDK_ARG_TYPE_I16, "i16", ctypes.c_int16),
            arsdkparser.ArArgType.U16: (od.ARSDK_ARG_TYPE_U16, "u16", ctypes.c_uint16),
            arsdkparser.ArArgType.I32: (od.ARSDK_ARG_TYPE_I32, "i32", ctypes.c_int32),
            arsdkparser.ArArgType.U32: (od.ARSDK_ARG_TYPE_U32, "u32", ctypes.c_uint32),
            arsdkparser.ArArgType.I64: (od.ARSDK_ARG_TYPE_I64, "i64", ctypes.c_int64),
            arsdkparser.ArArgType.U64: (od.ARSDK_ARG_TYPE_U64, "u64", ctypes.c_uint64),
            arsdkparser.ArArgType.FLOAT: (od.ARSDK_ARG_TYPE_FLOAT, "f32", ctypes.c_float),
            arsdkparser.ArArgType.DOUBLE: (od.ARSDK_ARG_TYPE_DOUBLE, "f64", ctypes.c_double),
            arsdkparser.ArArgType.STRING: (od.ARSDK_ARG_TYPE_STRING, "cstr", od.char_pointer_cast),
            arsdkparser.ArArgType.ENUM: (od.ARSDK_ARG_TYPE_ENUM, "i32", ctypes.c_int32),
        }
        return arsdk_encode_type_info_map[ar_argtype] 
Example #2
Source File: nifpga.py    From nifpga-python with MIT License 6 votes vote down vote up
def _return_ctype(self):
        """ Returns the associated ctype of a given datatype. """
        _datatype_ctype = {
            DataType.Bool: ctypes.c_uint8,
            DataType.I8: ctypes.c_int8,
            DataType.U8: ctypes.c_uint8,
            DataType.I16: ctypes.c_int16,
            DataType.U16: ctypes.c_uint16,
            DataType.I32: ctypes.c_int32,
            DataType.U32: ctypes.c_uint32,
            DataType.I64: ctypes.c_int64,
            DataType.U64: ctypes.c_uint64,
            DataType.Sgl: ctypes.c_float,
            DataType.Dbl: ctypes.c_double,
            DataType.Fxp: ctypes.c_uint32,
            DataType.Cluster: ctypes.c_uint32,
        }
        return _datatype_ctype[self] 
Example #3
Source File: tecio_szl.py    From handyscripts with MIT License 6 votes vote down vote up
def zone_write_int16_values(file_handle, zone, var, values):
    tecio.tecZoneVarWriteInt16Values.restype=ctypes.c_int32
    tecio.tecZoneVarWriteInt16Values.argtypes=(
            ctypes.c_void_p, #file_handle
            ctypes.c_int32,  #zone
            ctypes.c_int32,  #var
            ctypes.c_int32,  #partition
            ctypes.c_int64,  #count
            ctypes.POINTER(ctypes.c_int16)) #values

    values_ptr = (ctypes.c_int16*len(values))(*values)
    ret = tecio.tecZoneVarWriteInt16Values(file_handle,
            zone,
            var,
            0,
            len(values),
            values_ptr)
    if ret != 0:
        raise Exception("zone_write_int16_values Error") 
Example #4
Source File: test_memview.py    From angr with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def test_simple_concrete():
    s = SimState(arch="AMD64")
    addr = 0xba5e0

    def check_read(val):
        nose.tools.assert_equal(s.solver.eval(s.memory.load(addr, 8, endness=Endness.LE), cast_to=int), val)

        nose.tools.assert_equal(s.mem[addr].char.concrete, chr(val & 0xFF).encode())
        nose.tools.assert_equal(s.mem[addr].byte.concrete, val & 0xFF)

        nose.tools.assert_equal(s.mem[addr].int16_t.concrete, ctypes.c_int16(val & 0xFFFF).value)
        nose.tools.assert_equal(s.mem[addr].uint16_t.concrete, val & 0xFFFF)

        nose.tools.assert_equal(s.mem[addr].qword.concrete, val)

    s.memory.store(addr, claripy.BVV(0x11223344aabbcc7d, 64), endness=Endness.LE)
    check_read(0x11223344aabbcc7d)

    # test storing
    s.mem[addr].uint16_t = 0xef6d
    check_read(0x11223344aabbef6d) 
Example #5
Source File: utils.py    From debin with Apache License 2.0 6 votes vote down vote up
def adapt_int_width(n, width, signed=True):
    n = int(n)

    if width == 1:
        result = n
    elif width == 2:
        result = n
    elif width == 4:
        result = ctypes.c_int8(n).value if signed else ctypes.c_uint8(n).value
    elif width == 8:
        result = ctypes.c_int8(n).value if signed else ctypes.c_uint8(n).value
    elif width == 16:
        result = ctypes.c_int16(n).value if signed else ctypes.c_uint16(n).value
    elif width == 32:
        result = ctypes.c_int32(n).value if signed else ctypes.c_uint32(n).value
    elif width == 64:
        result = ctypes.c_int64(n).value if signed else ctypes.c_uint64(n).value
    else:
        result = n
    return result 
Example #6
Source File: test_square_int_array_with_struct.py    From zugbruecke with GNU Lesser General Public License v2.1 6 votes vote down vote up
def __init__(self):

		self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		self.__square_int_array_with_struct__ = self.__dll__.square_int_array_with_struct
		self.__square_int_array_with_struct__.argtypes = (
			ctypes.POINTER(int_array_data),
			ctypes.POINTER(int_array_data)
			)
		self.__square_int_array_with_struct__.memsync = [
			{
				'p': [0, 'data'],
				'l': [0, 'len'],
				't': 'c_int16'
				},
			{
				'p': [1, 'data'],
				'l': [1, 'len'],
				't': 'c_int16'
				}
			] 
Example #7
Source File: test_square_int_array_with_struct.py    From zugbruecke with GNU Lesser General Public License v2.1 6 votes vote down vote up
def square_int_array_with_struct(self, in_array):

		in_array_obj = int_array_data()
		out_array_obj = int_array_data()

		in_array_obj.data = ctypes.cast(
			ctypes.pointer((ctypes.c_int16 * len(in_array))(*in_array)),
			ctypes.POINTER(ctypes.c_int16)
			)
		in_array_obj.len = len(in_array)

		self.__square_int_array_with_struct__(
			in_array_obj,
			out_array_obj
			)

		return ctypes.cast(
			out_array_obj.data,
			ctypes.POINTER(ctypes.c_int16 * len(in_array))
			).contents[:]


# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# TEST(s)
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
Example #8
Source File: library.py    From picosdk-python-wrappers with ISC License 6 votes vote down vote up
def set_null_trigger(self, device):
        auto_trigger_after_millis = 1
        if hasattr(self, '_set_trigger') and len(self._set_trigger.argtypes) == 6:
            PS2000_NONE = 5
            return_code = self._set_trigger(c_int16(device.handle),
                                            c_int16(PS2000_NONE),
                                            c_int16(0),
                                            c_int16(0),
                                            c_int16(0),
                                            c_int16(auto_trigger_after_millis))
            if return_code == 0:
                raise InvalidTriggerParameters()
        elif hasattr(self, '_set_simple_trigger') and len(self._set_simple_trigger.argtypes) == 7:
            enabled = False
            status = self._set_simple_trigger(c_int16(device.handle),
                                              c_int16(int(enabled)),
                                              c_int32(self.PICO_CHANNEL['A']),
                                              c_int16(0),
                                              c_int32(self.PICO_THRESHOLD_DIRECTION['NONE']),
                                              c_uint32(0),
                                              c_int16(auto_trigger_after_millis))
            if status != self.PICO_STATUS['PICO_OK']:
                raise InvalidTriggerParameters("set_simple_trigger failed (%s)" % constants.pico_tag(status))
        else:
            raise NotImplementedError("not done other driver types yet") 
Example #9
Source File: test_callback_simple_struct.py    From zugbruecke with GNU Lesser General Public License v2.1 6 votes vote down vote up
def __init__(self):

		self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		self.__sum_elements_from_callback_in_struct__ = self.__dll__.sum_elements_from_callback_in_struct
		self.__sum_elements_from_callback_in_struct__.argtypes = (ctypes.POINTER(conveyor_belt_data),)
		self.__sum_elements_from_callback_in_struct__.restype = ctypes.c_int16

		self.DATA = [1, 6, 8, 4, 9, 7, 4, 2, 5, 2]

		@conveyor_belt
		def get_data(index):
			print((index, self.DATA[index]))
			return self.DATA[index]

		self.__get_data__ = get_data 
Example #10
Source File: library.py    From picosdk-python-wrappers with ISC License 6 votes vote down vote up
def _python_get_unit_info(self, handle, info_type):
        string_size = 255
        info = self._create_empty_string_buffer()
        if len(self._get_unit_info.argtypes) == 4:
            info_len = self._get_unit_info(c_int16(handle), info, c_int16(string_size), c_int16(info_type))
            if info_len > 0:
                return info.value[:info_len]
        elif len(self._get_unit_info.argtypes) == 5:
            required_size = c_int16(0)
            status = self._get_unit_info(c_int16(handle),
                                         info,
                                         c_int16(string_size),
                                         byref(required_size),
                                         c_uint32(info_type))
            if status == self.PICO_STATUS['PICO_OK']:
                if required_size.value < string_size:
                    return info.value[:required_size.value]
        return "" 
Example #11
Source File: test_callback_simple.py    From zugbruecke with GNU Lesser General Public License v2.1 6 votes vote down vote up
def __init__(self):

		self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		conveyor_belt = ctypes.WINFUNCTYPE(ctypes.c_int16, ctypes.c_int16)

		self.__sum_elements_from_callback__ = self.__dll__.sum_elements_from_callback
		self.__sum_elements_from_callback__.argtypes = (ctypes.c_int16, conveyor_belt)
		self.__sum_elements_from_callback__.restype = ctypes.c_int16

		self.DATA = [1, 6, 8, 4, 9, 7, 4, 2, 5, 2]

		@conveyor_belt
		def get_data(index):
			print((index, self.DATA[index]))
			return self.DATA[index]

		self.__get_data__ = get_data 
Example #12
Source File: library.py    From picosdk-python-wrappers with ISC License 6 votes vote down vote up
def _python_open_any_unit(self, resolution):
        status = None
        if len(self._open_unit.argtypes) == 3:
            if resolution is None:
                resolution = self.DEFAULT_RESOLUTION
            chandle = c_int16()
            cresolution = c_int32()
            cresolution.value = resolution
            status = self._open_unit(byref(chandle), None, cresolution)
            handle = chandle.value
        elif len(self._open_unit.argtypes) == 2:
            chandle = c_int16()
            status = self._open_unit(byref(chandle), None)
            handle = chandle.value
        else:
            handle = self._open_unit()

        return handle, status 
Example #13
Source File: test_square_int_array.py    From zugbruecke with GNU Lesser General Public License v2.1 6 votes vote down vote up
def square_int_array(self, in_array):

		in_array_p = ctypes.cast(
			ctypes.pointer((ctypes.c_int16 * len(in_array))(*in_array)),
			ctypes.POINTER(ctypes.c_int16)
			)
		out_array_p = ctypes.pointer(ctypes.c_void_p())

		self.__square_int_array__(
			in_array_p,
			out_array_p,
			ctypes.c_int16(len(in_array))
			)

		return ctypes.cast(
			out_array_p.contents,
			ctypes.POINTER(ctypes.c_int16 * len(in_array))
			).contents[:]


# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# TEST(s)
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
Example #14
Source File: test_square_int_array.py    From zugbruecke with GNU Lesser General Public License v2.1 6 votes vote down vote up
def __init__(self):

		self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		self.__square_int_array__ = self.__dll__.square_int_array
		self.__square_int_array__.argtypes = (
			ctypes.POINTER(ctypes.c_int16),
			ctypes.c_void_p,
			ctypes.c_int16
			)
		self.__square_int_array__.memsync = [
			{
				'p': [0],
				'l': [2],
				't': 'c_int16'
				},
			{
				'p': [1, -1],
				'l': [2],
				't': 'c_int16'
				}
			] 
Example #15
Source File: test_fibonacci_sequence.py    From zugbruecke with GNU Lesser General Public License v2.1 5 votes vote down vote up
def __init__(self):

		self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		self.__fibonacci_sequence__ = self.__dll__.fibonacci_sequence_a
		self.__fibonacci_sequence__.argtypes = (ctypes.c_int16,)
		self.__fibonacci_sequence__.restype = ctypes.POINTER(int_array_data)
		self.__fibonacci_sequence__.memsync = [
			{
				'p': ['r', 'data'],
				'l': ['r', 'len'],
				't': 'c_int16'
				}
			] 
Example #16
Source File: test_sqrt_int.py    From zugbruecke with GNU Lesser General Public License v2.1 5 votes vote down vote up
def __init__(self):

		self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		self.sqrt_int = self.__dll__.sqrt_int
		self.sqrt_int.argtypes = (ctypes.c_int16,)
		self.sqrt_int.restype = ctypes.c_int16


# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# TEST(s)
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
Example #17
Source File: test_get_const_int.py    From zugbruecke with GNU Lesser General Public License v2.1 5 votes vote down vote up
def test_sqrt_int_with_list():

		dll = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		get_const_int = dll.get_const_int
		get_const_int.argtypes = []
		get_const_int.restype = ctypes.c_int16

		assert 7 == get_const_int() 
Example #18
Source File: test_get_const_int.py    From zugbruecke with GNU Lesser General Public License v2.1 5 votes vote down vote up
def test_sqrt_int_with_tuple():

		dll = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		get_const_int = dll.get_const_int
		get_const_int.argtypes = tuple()
		get_const_int.restype = ctypes.c_int16

		assert 7 == get_const_int() 
Example #19
Source File: test_apply_filter_to_image.py    From zugbruecke with GNU Lesser General Public License v2.1 5 votes vote down vote up
def apply_filter_to_image(self, in_image):

		width = len(in_image[0])
		height = len(in_image)

		in_image_ctypes = image_data()
		out_image_ctypes = image_data()

		in_image_ctypes.width = ctypes.c_int16(width)
		in_image_ctypes.height = ctypes.c_int16(height)
		in_image_ctypes.data = ctypes.cast(
			ctypes.pointer((ctypes.c_int16 * (width * height))(*self.matrix_to_array(in_image))),
			ctypes.POINTER(ctypes.c_int16)
			)

		self.__apply_filter_to_image__(
			ctypes.pointer(in_image_ctypes),
			ctypes.pointer(out_image_ctypes),
			self.__filter_edge_detection__
			)

		return self.array_to_matrix(
			ctypes.cast(out_image_ctypes.data, ctypes.POINTER(ctypes.c_int16 * (width * height))).contents[:],
			width,
			height
			) 
Example #20
Source File: test_callback_optional.py    From zugbruecke with GNU Lesser General Public License v2.1 5 votes vote down vote up
def __init__(self):

		self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		conveyor_belt = ctypes.WINFUNCTYPE(ctypes.c_int16, ctypes.c_int16)

		self.__use_optional_callback__ = self.__dll__.use_optional_callback_a
		self.__use_optional_callback__.argtypes = (ctypes.c_int16, conveyor_belt)
		self.__use_optional_callback__.restype = ctypes.c_int16

		@conveyor_belt
		def process_data(in_data):
			return in_data ** 2

		self.__process_data__ = process_data 
Example #21
Source File: test_get_const_int.py    From zugbruecke with GNU Lesser General Public License v2.1 5 votes vote down vote up
def test_sqrt_int():

		dll = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		get_const_int = dll.get_const_int
		get_const_int.restype = ctypes.c_int16

		assert 7 == get_const_int() 
Example #22
Source File: test_ctypeslib.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_struct_array_pointer(self):
        from ctypes import c_int16, Structure, pointer

        class Struct(Structure):
            _fields_ = [('a', c_int16)]

        Struct3 = 3 * Struct

        c_array = (2 * Struct3)(
            Struct3(Struct(a=1), Struct(a=2), Struct(a=3)),
            Struct3(Struct(a=4), Struct(a=5), Struct(a=6))
        )

        expected = np.array([
            [(1,), (2,), (3,)],
            [(4,), (5,), (6,)],
        ], dtype=[('a', np.int16)])

        def check(x):
            assert_equal(x.dtype, expected.dtype)
            assert_equal(x, expected)

        # all of these should be equivalent
        check(as_array(c_array))
        check(as_array(pointer(c_array), shape=()))
        check(as_array(pointer(c_array[0]), shape=(2,)))
        check(as_array(pointer(c_array[0][0]), shape=(2, 3))) 
Example #23
Source File: test_ctypeslib.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def test_struct_array_pointer(self):
        from ctypes import c_int16, Structure, pointer

        class Struct(Structure):
            _fields_ = [('a', c_int16)]

        Struct3 = 3 * Struct

        c_array = (2 * Struct3)(
            Struct3(Struct(a=1), Struct(a=2), Struct(a=3)),
            Struct3(Struct(a=4), Struct(a=5), Struct(a=6))
        )

        expected = np.array([
            [(1,), (2,), (3,)],
            [(4,), (5,), (6,)],
        ], dtype=[('a', np.int16)])

        def check(x):
            assert_equal(x.dtype, expected.dtype)
            assert_equal(x, expected)

        # all of these should be equivalent
        check(as_array(c_array))
        check(as_array(pointer(c_array), shape=()))
        check(as_array(pointer(c_array[0]), shape=(2,)))
        check(as_array(pointer(c_array[0][0]), shape=(2, 3))) 
Example #24
Source File: test_vector3d_add.py    From zugbruecke with GNU Lesser General Public License v2.1 5 votes vote down vote up
def __init__(self):

		self.__dll__ = ctypes.windll.LoadLibrary('tests/demo_dll.dll')

		self.__vector3d_add_array__ = self.__dll__.vector3d_add_array
		self.__vector3d_add_array__.argtypes = (ctypes.POINTER(vector3d), ctypes.c_int16)
		self.__vector3d_add_array__.restype = ctypes.POINTER(vector3d)
		self.__vector3d_add_array__.memsync = [
			{
				'p': [0],
				'l': [1],
				't': 'vector3d'
				}
			] 
Example #25
Source File: test_error_callargs.py    From zugbruecke with GNU Lesser General Public License v2.1 5 votes vote down vote up
def test_error_callargs_configured_too_few_args():

	dll = ctypes.windll.LoadLibrary('tests/demo_dll.dll')
	subtract_ints = dll.subtract_ints
	subtract_ints.argtypes = (ctypes.c_int16, ctypes.c_int16)
	subtract_ints.restype = ctypes.c_int16

	with pytest.raises(TypeError):
		a = subtract_ints(7) 
Example #26
Source File: test_ctypeslib.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_struct_array_pointer(self):
        from ctypes import c_int16, Structure, pointer

        class Struct(Structure):
            _fields_ = [('a', c_int16)]

        Struct3 = 3 * Struct

        c_array = (2 * Struct3)(
            Struct3(Struct(a=1), Struct(a=2), Struct(a=3)),
            Struct3(Struct(a=4), Struct(a=5), Struct(a=6))
        )

        expected = np.array([
            [(1,), (2,), (3,)],
            [(4,), (5,), (6,)],
        ], dtype=[('a', np.int16)])

        def check(x):
            assert_equal(x.dtype, expected.dtype)
            assert_equal(x, expected)

        # all of these should be equivalent
        check(as_array(c_array))
        check(as_array(pointer(c_array), shape=()))
        check(as_array(pointer(c_array[0]), shape=(2,)))
        check(as_array(pointer(c_array[0][0]), shape=(2, 3))) 
Example #27
Source File: uwsgi_structs.py    From uwsgi-tools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def from_buffer(cls, buffer, offset=0):
        key_size = ctypes.c_int16.from_buffer(buffer, offset).value
        offset += ctypes.sizeof(ctypes.c_int16)
        key = (ctypes.c_char * key_size).from_buffer(buffer, offset).value
        offset += ctypes.sizeof(ctypes.c_char * key_size)
        val_size = ctypes.c_int16.from_buffer(buffer, offset).value
        offset += ctypes.sizeof(ctypes.c_int16)
        val = (ctypes.c_char * val_size).from_buffer(buffer, offset).value

        return cls(key_size, key, val_size, val) 
Example #28
Source File: library.py    From picosdk-python-wrappers with ISC License 5 votes vote down vote up
def maximum_value(self, device):
        if not hasattr(self, '_maximum_value'):
            return (2**15)-1
        max_adc = c_int16(0)
        self._maximum_value(c_int16(device.handle), byref(max_adc))
        return max_adc.value 
Example #29
Source File: test_ctypeslib.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_struct_array_pointer(self):
        from ctypes import c_int16, Structure, pointer

        class Struct(Structure):
            _fields_ = [('a', c_int16)]

        Struct3 = 3 * Struct

        c_array = (2 * Struct3)(
            Struct3(Struct(a=1), Struct(a=2), Struct(a=3)),
            Struct3(Struct(a=4), Struct(a=5), Struct(a=6))
        )

        expected = np.array([
            [(1,), (2,), (3,)],
            [(4,), (5,), (6,)],
        ], dtype=[('a', np.int16)])

        def check(x):
            assert_equal(x.dtype, expected.dtype)
            assert_equal(x, expected)

        # all of these should be equivalent
        check(as_array(c_array))
        check(as_array(pointer(c_array), shape=()))
        check(as_array(pointer(c_array[0]), shape=(2,)))
        check(as_array(pointer(c_array[0][0]), shape=(2, 3))) 
Example #30
Source File: fortran32.py    From msl-loadlib with MIT License 5 votes vote down vote up
def sum_16bit(self, a, b):
        """Add two 16-bit signed integers
        
        Python only has one :class:`int` data type to represent integer values.
        The :meth:`~.fortran32.Fortran32.sum_16bit` method converts the data 
        types of `a` and `b` to be :class:`ctypes.c_int16`.

        The corresponding FORTRAN code is

        .. code-block:: fortran

            function sum_16bit(a, b) result(value)
                !DEC$ ATTRIBUTES DLLEXPORT, ALIAS:'sum_16bit' :: sum_16bit
                implicit none
                integer(2) :: a, b, value
                value = a + b
            end function sum_16bit

        See the corresponding 64-bit :meth:`~.fortran64.Fortran64.sum_16bit` method.

        Parameters
        ----------
        a : :class:`int`
            The first 16-bit signed integer.
        b : :class:`int`
            The second 16-bit signed integer.

        Returns
        -------
        :class:`int`
            The sum of `a` and `b`.
        """
        ac = ctypes.c_int16(a)
        bc = ctypes.c_int16(b)
        self.lib.sum_16bit.restype = ctypes.c_int16
        return self.lib.sum_16bit(ctypes.byref(ac), ctypes.byref(bc))