Przeglądaj źródła

ты гонишь?

Savtis 2 lat temu
rodzic
commit
67be421577
2 zmienionych plików z 13 dodań i 7 usunięć
  1. 2 3
      src/main.py
  2. 11 4
      src/ombs_src/py/cdll_class.py

+ 2 - 3
src/main.py

@@ -3,7 +3,7 @@
 def main():
     import sys
     import os
-    sys.path.append('ombs_src')
+    sys.path.append('ombs_src/py')
     import output
     import error_class
     import error_list
@@ -14,8 +14,7 @@ def main():
     sl.loader(sys.argv[1])
     import cdll_class
     import ctypes
-    a = cdll_class.C_Library('./lib.so', ctypes.c_int)
-    print(a.main())
+    # a = cdll_class.C_Library('./lib.so', ctypes.c_int)
 
 
 if __name__ == '__main__':

+ 11 - 4
src/ombs_src/py/cdll_class.py

@@ -1,10 +1,17 @@
 from ctypes import *
 
+
 class C_Library(object):
-    def __init__(self, path:str, retype:type(c_int)):
-        self.path:str = path
-        self.lib:_DLLT = cdll.LoadLibrary(path)
+    def __init__(self, path: str, retype: type):
+        self.path: str = path
+        self.lib: _DLLT = cdll.LoadLibrary(path)
         self.lib.main.restype = retype
-        self.func:CDLL = self.lib.main
+        self.func = self.lib.main
+
     def main(self, *args):
         return self.func(*args)
+
+    def other(self, name: str, retype: type, *args):
+        local_func = getattr(self.lib, name)
+        local_func.restype = retype
+        return local_func(*args)