Skip to content

Commit

Permalink
Remove remaining, unnecessary references to ctypes
Browse files Browse the repository at this point in the history
Since 5a87608 ctypes is only needed in inprocess.py. The remaining
references to it were unused.
  • Loading branch information
mrh1997 committed May 21, 2019
1 parent 27a0152 commit e8508ac
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 17 deletions.
1 change: 0 additions & 1 deletion headlock/address_space/inprocess.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import collections
from platform import architecture
from typing import Dict
import ctypes as ct
Expand Down
6 changes: 3 additions & 3 deletions headlock/c_data_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ class BuildInDefs:
signed_char = CIntType('signed char', 8, False, ENDIANESS)
unsigned_char = CIntType('unsigned char', 8, False, ENDIANESS)

float = CFloatType('float', 32, ctypes_type=ct.c_float)
float = CFloatType('float', 32)

double = CFloatType('double', 64, ctypes_type=ct.c_double)
double = CFloatType('double', 64)

long_double = CFloatType('long double', 80, ctypes_type=ct.c_longdouble)
long_double = CFloatType('long double', 80)

_Bool = CIntType('_Bool', 8, False, ENDIANESS)

Expand Down
4 changes: 2 additions & 2 deletions headlock/c_data_model/float.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
class CFloatType(CProxyType):
"""This is a dummy yet"""

def __init__(self, c_name, bits, ctypes_type):
super().__init__(None, ctypes_type)
def __init__(self, c_name, bits):
super().__init__(bits//8)
self.bits = bits
self.c_name = c_name

Expand Down
2 changes: 0 additions & 2 deletions tests/test_c_data_model/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import ctypes as ct
import pytest
import sys
import headlock.c_data_model as cdm
from headlock.address_space.virtual import VirtualAddressSpace

Expand Down
10 changes: 5 additions & 5 deletions tests/test_c_data_model/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,15 @@ class TestCProxy:

def test_init_setsAttributes(self, ctype, addrspace):
adr = addrspace.alloc_memory(10)
bound_ctypes = ctype.bind(addrspace)
cproxy = cdm.CProxy(bound_ctypes, adr)
assert cproxy.ctype is bound_ctypes
bound_ctype = ctype.bind(addrspace)
cproxy = cdm.CProxy(bound_ctype, adr)
assert cproxy.ctype is bound_ctype
assert cproxy.__address__ == adr

def test_init_onManagedMemoryBlocks(self, ctype, addrspace):
adr = addrspace.alloc_memory(10)
bound_ctypes = ctype.bind(addrspace)
cproxy = cdm.CProxy(bound_ctypes, adr)
bound_ctype = ctype.bind(addrspace)
cproxy = cdm.CProxy(bound_ctype, adr)

@pytest.fixture
def cobj(self, ctype, addrspace):
Expand Down
3 changes: 0 additions & 3 deletions tests/test_c_data_model/test_memory_access.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import pytest
import ctypes as ct
from unittest.mock import Mock

from headlock.address_space.virtual import VirtualAddressSpace
from headlock.c_data_model.memory_access import CMemory, WriteProtectError
import headlock.c_data_model as cdm


class TestCMemory:
Expand Down
1 change: 0 additions & 1 deletion tests/test_c_data_model/test_struct.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
import re
import ctypes as ct
from unittest.mock import patch

import headlock.c_data_model as cdm
Expand Down

0 comments on commit e8508ac

Please sign in to comment.