python类c_short()的实例源码

pypyodbc.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _NumOfCols(self):
        """Get the number of cols"""
        if not self.connection:
            self.close()

        NOC = c_short()
        ret = SQLNumResultCols(self.stmt_h, ADDR(NOC))
        if ret != SQL_SUCCESS:
            check_success(self, ret)
        return NOC.value
test_parameters.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_byref_pointer(self):
        # The from_param class method of POINTER(typ) classes accepts what is
        # returned by byref(obj), it type(obj) == typ
        from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref
        LPINT = POINTER(c_int)

        LPINT.from_param(byref(c_int(42)))

        self.assertRaises(TypeError, LPINT.from_param, byref(c_short(22)))
        if c_int != c_long:
            self.assertRaises(TypeError, LPINT.from_param, byref(c_long(22)))
        self.assertRaises(TypeError, LPINT.from_param, byref(c_uint(22)))
test_parameters.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_byref_pointerpointer(self):
        # See above
        from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref

        LPLPINT = POINTER(POINTER(c_int))
        LPLPINT.from_param(byref(pointer(c_int(42))))

        self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_short(22))))
        if c_int != c_long:
            self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_long(22))))
        self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_uint(22))))
instructions.py 文件源码 项目:pytari2600 作者: ajgrah2000 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def addc(self, a, b, c):

        if 0 == self.pc_state.P.get_D():
            r  = ctypes.c_short(a + b + c).value
            rc = ctypes.c_byte(a + b + c).value
            self.pc_state.P.set_N((0,1)[0x80 == (rc & 0x80)])
            self.pc_state.P.set_Z((0,1)[rc == 0x0])
            self.pc_state.P.set_V((0,1)[rc != r])   # Overflow

            r = ((a & 0xFF) + (b & 0xFF) + c) & 0xFFFF
            self.pc_state.P.set_C((0,1)[0x100 == (r & 0x100)])
            result = (a + b + c)
        elif 1 == self.pc_state.P.get_D():
            # Decimal Addition
            # FIXME need to fix flags
            #
            r = ctypes.c_short(((a >> 4) & 0xF)* 10+ ((a & 0xF) %10) + ((b>>4) & 0xF)* 10 + ((b & 0xF) %10) + c).value
            rc = ctypes.c_byte(a + b + c).value # ???? TODO
            self.pc_state.P.set_N((0,1)[r < 0])
            self.pc_state.P.set_Z((0,1)[rc == 0x0])
            # self.pc_state.P.V = (rc != r) ? 1:0;   # Overflow

            self.pc_state.P.set_C((0,1)[(r > 99) or (r < 0)])
            result = (((((r/10) % 10) << 4) & 0xf0) + (r%10))

        return result & 0xFF
instructions.py 文件源码 项目:pytari2600 作者: ajgrah2000 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def subc(self, a, b, c):

        if 0 == self.pc_state.P.get_D():
            r  = ctypes.c_short(ctypes.c_byte(a).value - ctypes.c_byte(b).value - ctypes.c_byte(c).value).value
            rs = ctypes.c_byte((a - b - c) & 0xFF).value
            self.pc_state.P.set_N((0,1)[0x80 == (rs & 0x80)]) # Negative
            self.pc_state.P.set_Z((0,1)[rs == 0])   # Zero
            self.pc_state.P.set_V((0,1)[r != rs])   # Overflow

            r = a - b - c 
            self.pc_state.P.set_C((1,0)[0x100 == (r & 0x100)]) # Carry (not borrow
            result = a - b - c
        elif 1 == self.pc_state.P.get_D():
            # Decimal subtraction
            # FIXME need to fix flags

            r = ctypes.c_short(((a >> 4) & 0xF)* 10+ ((a & 0xF) %10) - (((b>>4) & 0xF)* 10 + ((b & 0xF) %10)) - c).value

            # rc = a + b + c
            self.pc_state.P.set_N((0,1)[r < 0])
            self.pc_state.P.set_Z((0,1)[r == 0x0])
            #  Need to check/fix conditions for V
            # self.pc_state.P.V = (rc != r) ? 1:0;   # Overflow
            self.pc_state.P.set_V(1)   # Overflow

            self.pc_state.P.set_C((0,1)[(r >= 0) and (r <= 99)])
            result = (((int(r/10) % 10) << 4) & 0xf0) + (r%10)

        return result & 0xFF
instructions.py 文件源码 项目:pytari2600 作者: ajgrah2000 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def cmp(self, a, b):
        r = ctypes.c_short(ctypes.c_byte(a).value - ctypes.c_byte(b).value).value
        rs = ctypes.c_byte(a - b).value
        self.pc_state.P.set_N((0,1)[0x80 == (rs & 0x80)])    # Negative
        self.pc_state.P.set_Z((0,1)[rs == 0])              # Zero
        r = (a & 0xFF) - (b & 0xFF)
        self.pc_state.P.set_C((1,0)[0x100 == (r & 0x100)]) # Carry (not borrow)
instructions.py 文件源码 项目:pytari2600 作者: ajgrah2000 项目源码 文件源码 阅读 44 收藏 0 点赞 0 评论 0
def addc(self, a, b, c):

        if 0 == self.pc_state.P.get_D():
            r  = ctypes.c_short(a + b + c).value
            rc = ctypes.c_byte(a + b + c).value
            self.pc_state.P.set_N((0,1)[0x80 == (rc & 0x80)])
            self.pc_state.P.set_Z((0,1)[rc == 0x0])
            self.pc_state.P.set_V((0,1)[rc != r])   # Overflow

            r = ((a & 0xFF) + (b & 0xFF) + c) & 0xFFFF
            self.pc_state.P.set_C((0,1)[0x100 == (r & 0x100)])
            result = (a + b + c)
        elif 1 == self.pc_state.P.get_D():
            # Decimal Addition
            # FIXME need to fix flags
            #
            r = ctypes.c_short(((a >> 4) & 0xF)* 10+ ((a & 0xF) %10) + ((b>>4) & 0xF)* 10 + ((b & 0xF) %10) + c).value
            rc = ctypes.c_byte(a + b + c).value # ???? TODO
            self.pc_state.P.set_N((0,1)[r < 0])
            self.pc_state.P.set_Z((0,1)[rc == 0x0])
            # self.pc_state.P.V = (rc != r) ? 1:0;   # Overflow

            self.pc_state.P.set_C((0,1)[(r > 99) or (r < 0)])
            result = ((((int(r/10) % 10) << 4) & 0xf0) + (r%10))

        return result & 0xFF
instructions.py 文件源码 项目:pytari2600 作者: ajgrah2000 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def subc(self, a, b, c):

        if 0 == self.pc_state.P.get_D():
            r  = ctypes.c_short(ctypes.c_byte(a).value - ctypes.c_byte(b).value - ctypes.c_byte(c).value).value
            rs = ctypes.c_byte((a - b - c) & 0xFF).value
            self.pc_state.P.set_N((0,1)[0x80 == (rs & 0x80)]) # Negative
            self.pc_state.P.set_Z((0,1)[rs == 0])   # Zero
            self.pc_state.P.set_V((0,1)[r != rs])   # Overflow

            r = a - b - c 
            self.pc_state.P.set_C((1,0)[0x100 == (r & 0x100)]) # Carry (not borrow
            result = a - b - c
        elif 1 == self.pc_state.P.get_D():
            # Decimal subtraction
            # FIXME need to fix flags

            r = ctypes.c_short(((a >> 4) & 0xF)* 10+ ((a & 0xF) %10) - (((b>>4) & 0xF)* 10 + ((b & 0xF) %10)) - c).value

            # rc = a + b + c
            self.pc_state.P.set_N((0,1)[r < 0])
            self.pc_state.P.set_Z((0,1)[r == 0x0])
            #  Need to check/fix conditions for V
            # self.pc_state.P.V = (rc != r) ? 1:0;   # Overflow
            self.pc_state.P.set_V(1)   # Overflow

            self.pc_state.P.set_C((0,1)[(r >= 0) and (r <= 99)])
            result = (((int(r/10) % 10) << 4) & 0xf0) + (r%10)

        return result & 0xFF
MsgArg.py 文件源码 项目:alljoyn_python 作者: glennpierce 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def GetInt16(self):
        value = C.c_short()
        self._GetInt16(self.handle, C.byref(value))
        return value.value
pypyodbc.py 文件源码 项目:Problematica-public 作者: TechMaz 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _NumOfCols(self):
        """Get the number of cols"""
        if not self.connection:
            self.close()

        NOC = c_short()
        ret = SQLNumResultCols(self.stmt_h, ADDR(NOC))
        if ret != SQL_SUCCESS:
            check_success(self, ret)
        return NOC.value
test_parameters.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_byref_pointer(self):
        # The from_param class method of POINTER(typ) classes accepts what is
        # returned by byref(obj), it type(obj) == typ
        from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref
        LPINT = POINTER(c_int)

        LPINT.from_param(byref(c_int(42)))

        self.assertRaises(TypeError, LPINT.from_param, byref(c_short(22)))
        if c_int != c_long:
            self.assertRaises(TypeError, LPINT.from_param, byref(c_long(22)))
        self.assertRaises(TypeError, LPINT.from_param, byref(c_uint(22)))
test_parameters.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_byref_pointerpointer(self):
        # See above
        from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref

        LPLPINT = POINTER(POINTER(c_int))
        LPLPINT.from_param(byref(pointer(c_int(42))))

        self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_short(22))))
        if c_int != c_long:
            self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_long(22))))
        self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_uint(22))))
test_parameters.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_array_pointers(self):
        from ctypes import c_short, c_uint, c_int, c_long, POINTER
        INTARRAY = c_int * 3
        ia = INTARRAY()
        self.assertEqual(len(ia), 3)
        self.assertEqual([ia[i] for i in range(3)], [0, 0, 0])

        # Pointers are only compatible with arrays containing items of
        # the same type!
        LPINT = POINTER(c_int)
        LPINT.from_param((c_int*3)())
        self.assertRaises(TypeError, LPINT.from_param, c_short*3)
        self.assertRaises(TypeError, LPINT.from_param, c_long*3)
        self.assertRaises(TypeError, LPINT.from_param, c_uint*3)
test_parameters.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def test_byref_pointer(self):
        # The from_param class method of POINTER(typ) classes accepts what is
        # returned by byref(obj), it type(obj) == typ
        from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref
        LPINT = POINTER(c_int)

        LPINT.from_param(byref(c_int(42)))

        self.assertRaises(TypeError, LPINT.from_param, byref(c_short(22)))
        if c_int != c_long:
            self.assertRaises(TypeError, LPINT.from_param, byref(c_long(22)))
        self.assertRaises(TypeError, LPINT.from_param, byref(c_uint(22)))
test_parameters.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_byref_pointerpointer(self):
        # See above
        from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref

        LPLPINT = POINTER(POINTER(c_int))
        LPLPINT.from_param(byref(pointer(c_int(42))))

        self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_short(22))))
        if c_int != c_long:
            self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_long(22))))
        self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_uint(22))))
test_parameters.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_array_pointers(self):
        from ctypes import c_short, c_uint, c_int, c_long, POINTER
        INTARRAY = c_int * 3
        ia = INTARRAY()
        self.assertEqual(len(ia), 3)
        self.assertEqual([ia[i] for i in range(3)], [0, 0, 0])

        # Pointers are only compatible with arrays containing items of
        # the same type!
        LPINT = POINTER(c_int)
        LPINT.from_param((c_int*3)())
        self.assertRaises(TypeError, LPINT.from_param, c_short*3)
        self.assertRaises(TypeError, LPINT.from_param, c_long*3)
        self.assertRaises(TypeError, LPINT.from_param, c_uint*3)
test_parameters.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_byref_pointer(self):
        # The from_param class method of POINTER(typ) classes accepts what is
        # returned by byref(obj), it type(obj) == typ
        from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref
        LPINT = POINTER(c_int)

        LPINT.from_param(byref(c_int(42)))

        self.assertRaises(TypeError, LPINT.from_param, byref(c_short(22)))
        if c_int != c_long:
            self.assertRaises(TypeError, LPINT.from_param, byref(c_long(22)))
        self.assertRaises(TypeError, LPINT.from_param, byref(c_uint(22)))
test_parameters.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_byref_pointerpointer(self):
        # See above
        from ctypes import c_short, c_uint, c_int, c_long, pointer, POINTER, byref

        LPLPINT = POINTER(POINTER(c_int))
        LPLPINT.from_param(byref(pointer(c_int(42))))

        self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_short(22))))
        if c_int != c_long:
            self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_long(22))))
        self.assertRaises(TypeError, LPLPINT.from_param, byref(pointer(c_uint(22))))
test_parameters.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_array_pointers(self):
        from ctypes import c_short, c_uint, c_int, c_long, POINTER
        INTARRAY = c_int * 3
        ia = INTARRAY()
        self.assertEqual(len(ia), 3)
        self.assertEqual([ia[i] for i in range(3)], [0, 0, 0])

        # Pointers are only compatible with arrays containing items of
        # the same type!
        LPINT = POINTER(c_int)
        LPINT.from_param((c_int*3)())
        self.assertRaises(TypeError, LPINT.from_param, c_short*3)
        self.assertRaises(TypeError, LPINT.from_param, c_long*3)
        self.assertRaises(TypeError, LPINT.from_param, c_uint*3)
pypyodbc.py 文件源码 项目:rekall-agent-server 作者: rekall-innovations 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _NumOfCols(self):
        """Get the number of cols"""
        if not self.connection:
            self.close()

        NOC = c_short()
        ret = SQLNumResultCols(self.stmt_h, ADDR(NOC))
        if ret != SQL_SUCCESS:
            check_success(self, ret)
        return NOC.value


问题


面经


文章

微信
公众号

扫码关注公众号