-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpycall.py
More file actions
52 lines (39 loc) · 1020 Bytes
/
Copy pathpycall.py
File metadata and controls
52 lines (39 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import ctypes
from ctypes import *
class Student(Structure):
_fields_ = [("name",c_char * 30),
("fScore", c_float * 3),
("age",c_int)
]
su = Student()
su.name = b"test-sdk"
su.fScore = (18,2,3)
su.age = 16
def test_Display_Student():
ll = ctypes.cdll.LoadLibrary
lib = ll("./libpycall.so")
# lib.Display.restype = c_float
# lib.Display.argtypes = [Student]
lib.Display_Student(su)
print('----- finish -----\n')
class Books(Structure):
_fields_ = [("title",c_char * 50),
("author", c_char * 50),
("subject",c_char *100),
("book_id",c_int)
]
book = Books()
book.title = b"C Programming"
book.author = b"Nuha Ali"
book.subject = b"C Programming Tutorial"
book.book_id = 6495407
def test_Display_Books():
ll = ctypes.cdll.LoadLibrary
lib = ll("./libpycall.so")
# lib.Display.restype = c_float
# lib.Display.argtypes = [Student]
lib.Display_Books(book)
print('----- finish -----')
if __name__ == '__main__':
test_Display_Student()
test_Display_Books()