@@ -99,32 +99,45 @@ def process_vmlinux_post_ast(
9999 local_module_name = getattr (elem_type , "__module__" , None )
100100 new_dep_node .add_field (elem_name , elem_type , ready = False )
101101 if local_module_name == ctypes .__name__ :
102- #TODO: need to process pointer to ctype and also CFUNCTYPES here recursively.
103- # for now, function pointers should give an error
102+ # TODO: need to process pointer to ctype and also CFUNCTYPES here recursively. Current processing is a single dereference
104103 new_dep_node .set_field_bitfield_size (elem_name , elem_bitfield_size )
105104
106105 # Process pointer to ctype
107- if isinstance (elem_type , type ) and issubclass (elem_type , ctypes ._Pointer ):
106+ if isinstance (elem_type , type ) and issubclass (
107+ elem_type , ctypes ._Pointer
108+ ):
108109 # Get the pointed-to type
109110 pointed_type = elem_type ._type_
110111 logger .debug (f"Found pointer to type: { pointed_type } " )
111112 new_dep_node .set_field_containing_type (elem_name , pointed_type )
112- new_dep_node .set_field_ctype_complex_type (elem_name , ctypes ._Pointer )
113+ new_dep_node .set_field_ctype_complex_type (
114+ elem_name , ctypes ._Pointer
115+ )
113116 new_dep_node .set_field_ready (elem_name , is_ready = True )
114117
115118 # Process function pointers (CFUNCTYPE)
116- elif hasattr (elem_type , '_restype_' ) and hasattr (elem_type , '_argtypes_' ):
119+ elif hasattr (elem_type , "_restype_" ) and hasattr (
120+ elem_type , "_argtypes_"
121+ ):
117122 # This is a CFUNCTYPE or similar
118- logger .info (f"Function pointer detected for { elem_name } with return type { elem_type ._restype_ } and arguments { elem_type ._argtypes_ } " )
123+ logger .info (
124+ f"Function pointer detected for { elem_name } with return type { elem_type ._restype_ } and arguments { elem_type ._argtypes_ } "
125+ )
119126 # Set the field as ready but mark it with special handling
120- new_dep_node .set_field_ctype_complex_type (elem_name , ctypes .CFUNCTYPE )
127+ new_dep_node .set_field_ctype_complex_type (
128+ elem_name , ctypes .CFUNCTYPE
129+ )
121130 new_dep_node .set_field_ready (elem_name , is_ready = True )
122- logger .warning ("Blindly processing CFUNCTYPE ctypes to ensure compilation. Unsupported" )
131+ logger .warning (
132+ "Blindly processing CFUNCTYPE ctypes to ensure compilation. Unsupported"
133+ )
123134
124135 else :
125136 # Regular ctype
126137 new_dep_node .set_field_ready (elem_name , is_ready = True )
127- logger .debug (f"Field { elem_name } is direct ctypes type: { elem_type } " )
138+ logger .debug (
139+ f"Field { elem_name } is direct ctypes type: { elem_type } "
140+ )
128141 elif local_module_name == "vmlinux" :
129142 new_dep_node .set_field_bitfield_size (elem_name , elem_bitfield_size )
130143 logger .debug (
@@ -149,7 +162,9 @@ def process_vmlinux_post_ast(
149162 elif issubclass (elem_type , ctypes ._Pointer ):
150163 ctype_complex_type = ctypes ._Pointer
151164 else :
152- raise ImportError ("Non Array and Pointer type ctype imports not supported in current version" )
165+ raise ImportError (
166+ "Non Array and Pointer type ctype imports not supported in current version"
167+ )
153168 else :
154169 raise TypeError ("Unsupported ctypes subclass" )
155170 else :
0 commit comments