Skip to content

Commit cd91c2c

Browse files
committed
some patches
1 parent 5027d6e commit cd91c2c

17 files changed

+193
-133
lines changed

docs/getting_started.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,16 @@ $ pip install .
2424
```
2525

2626
**Python 3.6+ is required**
27+
28+
Now, to ensure everything is working properly we can run this simple program:
29+
30+
```py
31+
from pointers import to_ptr
32+
33+
ptr = to_ptr("hello world")
34+
print(*ptr)
35+
```
36+
37+
Running this should print `hello world` into the console.
38+
39+
Congratulations, you have written a program with the worst library every created!

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ fclose(file)
4141
- Reworked documentation
4242
- Several bug fixes
4343
- Optimized internal API
44-
- Better type safety
44+
- Better and fixed type safety
45+
- New memory safety features
4546

4647
### Features
4748

docs/pointers.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Using Pointers

src/pointers/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
from .base_pointers import (
2+
BaseAllocatedPointer, BaseCPointer, BaseObjectPointer, BasePointer,
3+
BasicPointer, Dereferencable, IterDereferencable, Sized, Typed
4+
)
15
from .bindings import *
26
from .c_pointer import (
37
StructPointer, TypedCPointer, VoidPointer, array, cast, to_c_ptr,

src/pointers/_cstd.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,44 +144,44 @@ class lconv(ctypes.Structure):
144144
dll.calloc.argtypes = (ctypes.c_size_t, ctypes.c_size_t)
145145
dll.calloc.restype = ctypes.c_void_p
146146
# int isalnum(int c)
147-
dll.isalnum.argtypes = (ctypes.c_int,)
147+
dll.isalnum.argtypes = (ctypes.c_char,)
148148
dll.isalnum.restype = ctypes.c_int
149149
# int isalpha(int c)
150-
dll.isalpha.argtypes = (ctypes.c_int,)
150+
dll.isalpha.argtypes = (ctypes.c_char,)
151151
dll.isalpha.restype = ctypes.c_int
152152
# int iscntrl(int c)
153-
dll.iscntrl.argtypes = (ctypes.c_int,)
153+
dll.iscntrl.argtypes = (ctypes.c_char,)
154154
dll.iscntrl.restype = ctypes.c_int
155155
# int isdigit(int c)
156-
dll.isdigit.argtypes = (ctypes.c_int,)
156+
dll.isdigit.argtypes = (ctypes.c_char,)
157157
dll.isdigit.restype = ctypes.c_int
158158
# int isgraph(int c)
159-
dll.isgraph.argtypes = (ctypes.c_int,)
159+
dll.isgraph.argtypes = (ctypes.c_char,)
160160
dll.isgraph.restype = ctypes.c_int
161161
# int islower(int c)
162-
dll.islower.argtypes = (ctypes.c_int,)
162+
dll.islower.argtypes = (ctypes.c_char,)
163163
dll.islower.restype = ctypes.c_int
164164
# int isprint(int c)
165-
dll.isprint.argtypes = (ctypes.c_int,)
165+
dll.isprint.argtypes = (ctypes.c_char,)
166166
dll.isprint.restype = ctypes.c_int
167167
# int ispunct(int c)
168-
dll.ispunct.argtypes = (ctypes.c_int,)
168+
dll.ispunct.argtypes = (ctypes.c_char,)
169169
dll.ispunct.restype = ctypes.c_int
170170
# int isspace(int c)
171-
dll.isspace.argtypes = (ctypes.c_int,)
171+
dll.isspace.argtypes = (ctypes.c_char,)
172172
dll.isspace.restype = ctypes.c_int
173173
# int isupper(int c)
174-
dll.isupper.argtypes = (ctypes.c_int,)
174+
dll.isupper.argtypes = (ctypes.c_char,)
175175
dll.isupper.restype = ctypes.c_int
176176
# int isxdigit(int c)
177-
dll.isxdigit.argtypes = (ctypes.c_int,)
177+
dll.isxdigit.argtypes = (ctypes.c_char,)
178178
dll.isxdigit.restype = ctypes.c_int
179179
# int tolower(int c)
180-
dll.tolower.argtypes = (ctypes.c_int,)
181-
dll.tolower.restype = ctypes.c_int
180+
dll.tolower.argtypes = (ctypes.c_char,)
181+
dll.tolower.restype = ctypes.c_char
182182
# int toupper(int c)
183-
dll.toupper.argtypes = (ctypes.c_int,)
184-
dll.toupper.restype = ctypes.c_int
183+
dll.toupper.argtypes = (ctypes.c_char,)
184+
dll.toupper.restype = ctypes.c_char
185185
# char* setlocale(int category, const char* locale)
186186
dll.setlocale.argtypes = (ctypes.c_int, ctypes.c_char_p)
187187
dll.setlocale.restype = ctypes.c_char_p

src/pointers/_pointer.py renamed to src/pointers/base_pointers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def _make_stream_and_ptr(
173173
self,
174174
size: int,
175175
address: int,
176-
) -> Tuple[ctypes.pointer, bytes]:
176+
) -> Tuple[ctypes._PointerLike, bytes]:
177177
...
178178

179179

@@ -279,7 +279,7 @@ def _make_stream_and_ptr(
279279
self,
280280
size: int,
281281
address: int,
282-
) -> Tuple[ctypes.pointer, bytes]:
282+
) -> Tuple[ctypes._PointerLike, bytes]:
283283
bytes_a = (ctypes.c_ubyte * size).from_address(address)
284284
return self.make_ct_pointer(), bytes(bytes_a)
285285

@@ -394,7 +394,7 @@ def _make_stream_and_ptr(
394394
self,
395395
size: int,
396396
address: int,
397-
) -> Tuple[ctypes.pointer, bytes]:
397+
) -> Tuple[ctypes._PointerLike, bytes]:
398398
if self.freed:
399399
raise FreedMemoryError("memory has been freed")
400400

0 commit comments

Comments
 (0)