def assignable_from_resolved_type(self, other_type):
if other_type is error_type:
return 1
- elif other_type.is_null_ptr:
+ if other_type.is_null_ptr:
return 1
- elif self.base_type.is_cfunction and other_type.is_cfunction:
- return self.base_type.same_as(other_type)
- elif other_type.is_array or other_type.is_ptr:
+ if self.base_type.is_cfunction:
+ if other_type.is_ptr:
+ other_type = other_type.base_type.resolve()
+ if other_type.is_cfunction:
+ return self.base_type.pointer_assignable_from_resolved_type(other_type)
+ else:
+ return 0
+ if other_type.is_array or other_type.is_ptr:
return self.base_type.is_void or self.base_type.same_as(other_type.base_type)
- else:
- return 0
+ return 0
class CNullPtrType(CPtrType):
return self.same_c_signature_as_resolved_type(
other_type.resolve(), as_cmethod)
- def same_c_signature_as_resolved_type(self, other_type, as_cmethod):
+ def same_c_signature_as_resolved_type(self, other_type, as_cmethod = 0):
#print "CFuncType.same_c_signature_as_resolved_type:", \
# self, other_type, "as_cmethod =", as_cmethod ###
if other_type is error_type:
def same_as_resolved_type(self, other_type, as_cmethod = 0):
return self.same_c_signature_as_resolved_type(other_type, as_cmethod) \
- and self.same_exception_signature_as_resolved_type(other_type)
+ and self.same_exception_signature_as_resolved_type(other_type) \
+ and self.nogil == other_type.nogil
+
+ def pointer_assignable_from_resolved_type(self, other_type):
+ return self.same_c_signature_as_resolved_type(other_type) \
+ and self.same_exception_signature_as_resolved_type(other_type) \
+ and not (self.nogil and not other_type.nogil)
def declaration_code(self, entity_code,
for_display = 0, dll_linkage = None, pyrex = 0):
if (not entity_code and cc) or entity_code.startswith("*"):
entity_code = "(%s%s)" % (cc, entity_code)
cc = ""
+ if not entity_code:
+ entity_code = "()"
return self.return_type.declaration_code(
"%s%s(%s)%s" % (cc, entity_code, arg_decl_code, trailer),
for_display, dll_linkage, pyrex)