@@ -39,7 +39,7 @@ def visit_Struct(self, node):
3939 self .ret += "\n "
4040 if not node .decls :
4141 self .forward_declared [node .name ] = True
42- self .ret += "class {}(Structure):\n " .format (node .name )
42+ self .ret += "class {}(ctypes. Structure):\n " .format (node .name )
4343 self .ret += " pass\n "
4444 return
4545
@@ -55,7 +55,7 @@ def visit_Struct(self, node):
5555 if node .name in self .forward_declared :
5656 self .ret += "{}._fields = [ # type: ignore\n " .format (node .name )
5757 else :
58- self .ret += "class {}(Structure):\n " .format (node .name )
58+ self .ret += "class {}(ctypes. Structure):\n " .format (node .name )
5959 self .ret += " _fields_ = [\n "
6060
6161 for decl in node .decls :
@@ -72,7 +72,7 @@ def visit_Union(self, node):
7272 assert (node .decls )
7373
7474 self .ret += "\n "
75- self .ret += "class {}(Union):\n " .format (node .name )
75+ self .ret += "class {}(ctypes. Union):\n " .format (node .name )
7676 self .ret += " _fields_ = [\n "
7777 for decl in node .decls :
7878 self .ret += " (\" {}\" , {}),\n " .format (name (decl .name ), type_name (decl .type ))
@@ -184,44 +184,44 @@ def type_name(ty, ptr=False, typing=False):
184184 if typing :
185185 return "ctypes._Pointer"
186186 if isinstance (ty , c_ast .IdentifierType ) and ty .names [0 ] == "void" :
187- return "c_void_p"
187+ return "ctypes. c_void_p"
188188 elif not isinstance (ty , c_ast .FuncDecl ):
189- return "POINTER({})" .format (type_name (ty , False , typing ))
189+ return "ctypes. POINTER({})" .format (type_name (ty , False , typing ))
190190
191191 if isinstance (ty , c_ast .IdentifierType ):
192192 assert (len (ty .names ) == 1 )
193193 if ty .names [0 ] == "void" :
194194 return "None"
195195 elif ty .names [0 ] == "_Bool" :
196- return "bool" if typing else "c_bool"
196+ return "bool" if typing else "ctypes. c_bool"
197197 elif ty .names [0 ] == "byte_t" :
198- return "c_ubyte"
198+ return "ctypes. c_ubyte"
199199 elif ty .names [0 ] == "int8_t" :
200- return "c_int8"
200+ return "ctypes. c_int8"
201201 elif ty .names [0 ] == "uint8_t" :
202- return "c_uint8"
202+ return "ctypes. c_uint8"
203203 elif ty .names [0 ] == "int16_t" :
204- return "c_int16"
204+ return "ctypes. c_int16"
205205 elif ty .names [0 ] == "uint16_t" :
206- return "c_uint16"
206+ return "ctypes. c_uint16"
207207 elif ty .names [0 ] == "int32_t" :
208- return "int" if typing else "c_int32"
208+ return "int" if typing else "ctypes. c_int32"
209209 elif ty .names [0 ] == "uint32_t" :
210- return "int" if typing else "c_uint32"
210+ return "int" if typing else "ctypes. c_uint32"
211211 elif ty .names [0 ] == "uint64_t" :
212- return "int" if typing else "c_uint64"
212+ return "int" if typing else "ctypes. c_uint64"
213213 elif ty .names [0 ] == "int64_t" :
214- return "int" if typing else "c_int64"
214+ return "int" if typing else "ctypes. c_int64"
215215 elif ty .names [0 ] == "float32_t" :
216- return "float" if typing else "c_float"
216+ return "float" if typing else "ctypes. c_float"
217217 elif ty .names [0 ] == "float64_t" :
218- return "float" if typing else "c_double"
218+ return "float" if typing else "ctypes. c_double"
219219 elif ty .names [0 ] == "size_t" :
220- return "int" if typing else "c_size_t"
220+ return "int" if typing else "ctypes. c_size_t"
221221 elif ty .names [0 ] == "char" :
222- return "c_char"
222+ return "ctypes. c_char"
223223 elif ty .names [0 ] == "int" :
224- return "int" if typing else "c_int"
224+ return "int" if typing else "ctypes. c_int"
225225 # ctypes values can't stand as typedefs, so just use the pointer type here
226226 elif typing and 'callback_t' in ty .names [0 ]:
227227 return "ctypes._Pointer"
@@ -239,13 +239,13 @@ def type_name(ty, ptr=False, typing=False):
239239 # TODO: apparently errors are thrown if we faithfully represent the
240240 # pointer type here, seems odd?
241241 if isinstance (ty .type , c_ast .PtrDecl ):
242- tys .append ("c_size_t" )
242+ tys .append ("ctypes. c_size_t" )
243243 else :
244244 tys .append (type_name (ty .type ))
245245 if ty .args and ty .args .params :
246246 for param in ty .args .params :
247247 tys .append (type_name (param .type ))
248- return "CFUNCTYPE({})" .format (', ' .join (tys ))
248+ return "ctypes. CFUNCTYPE({})" .format (', ' .join (tys ))
249249 elif isinstance (ty , c_ast .PtrDecl ) or isinstance (ty , c_ast .ArrayDecl ):
250250 return type_name (ty .type , True , typing )
251251 else :
0 commit comments