Add C funcs ret value specification 94/171694/4 submit/tizen/20180307.132902
authorAlexander Aksenov <a.aksenov@samsung.com>
Tue, 6 Mar 2018 11:31:54 +0000 (14:31 +0300)
committerAlexander Aksenov <a.aksenov@samsung.com>
Wed, 7 Mar 2018 11:43:26 +0000 (14:43 +0300)
Change-Id: I65c4e805dcb59fe50f8554a59c10bc5cde4a9321
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
scripts/gen_headers.py

index fa096d1..f196b4c 100755 (executable)
@@ -15,6 +15,34 @@ class ParseElf:
     IFUNC = 10
     FUNC = 2
 
+    @staticmethod
+    def __set_func_ret_types(lib):
+        lib.elfp_init.restype = c_void_p
+        lib.elfp_is_64bit.restype = c_bool
+        lib.elfp_syms_count.restype = c_uint
+        lib.elfp_syms_fill.restype = c_uint
+
+    @staticmethod
+    def __elfp_init(lib, filename):
+        return c_void_p(lib.elfp_init(filename))
+
+    @staticmethod
+    def __elfp_is_64bit(lib, elfp):
+        return c_bool(lib.elfp_is_64bit(elfp)).value
+
+    @staticmethod
+    def __elfp_uninit(lib, elfp):
+        lib.elfp_uninit(elfp)
+
+    @staticmethod
+    def __elfp_syms_count(lib, elfp):
+        return c_uint(lib.elfp_syms_count(elfp)).value
+
+    @staticmethod
+    def __elfp_syms_fill(lib, elfp, addr, name, type):
+        return c_uint(lib.elfp_syms_fill(elfp, addr, name, type)).value
+
+
     def init_library(self):
         parse_lib_list = [
             "./elf_parsing/libparserelf.so",
@@ -26,6 +54,7 @@ class ParseElf:
             try:
                 dbg_log("LOAD %s" % lib)
                 self.lib = cdll.LoadLibrary(lib)
+                self.__set_func_ret_types(self.lib)
                 return 0
             except:
                 dbg_log("Cannot load %s" % lib)
@@ -33,24 +62,24 @@ class ParseElf:
         return -1
 
     def init(self, filename):
-        self.elfp = self.lib.elfp_init(filename);
+        self.elfp = self.__elfp_init(self.lib, filename)
         if bool(self.elfp):
-            is64 = self.lib.elfp_is_64bit(self.elfp)
+            is64 = self.__elfp_is_64bit(self.lib, self.elfp)
             self.prefix64 = 1 << 63 if is64 else 0
             return 0
         return -1
 
     def uninit(self):
-        self.lib.elfp_uninit(self.elfp)
+        self.__elfp_uninit(self.lib, self.elfp)
 
     def get_all_symbols(self):
-        count = self.lib.elfp_syms_count(self.elfp)
+        count = self.__elfp_syms_count(self.lib, self.elfp)
         addr = (c_ulonglong * count)()
         name = (c_char_p * count)()
         type = (c_byte * count)()
 
         ret = {}
-        n = self.lib.elfp_syms_fill(self.elfp, addr, name, type)
+        n = self.__elfp_syms_fill(self.lib, self.elfp, addr, name, type)
         for i in range(n):
             # We never need undefined functions in headers generation
             if addr[i] == 0: