Commit cf03fa62 authored by isotherm's avatar isotherm Committed by Stefan Behnel

FIX: Declare cimported ctuples (GH-1427) (GH-3271)

Closes #1427 
parent e3f413bf
......@@ -575,14 +575,16 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
for entry in vtabslot_list:
self.generate_objstruct_predeclaration(entry.type, code)
vtabslot_entries = set(vtabslot_list)
ctuple_names = set()
for module in modules:
definition = module is env
if definition:
type_entries = module.type_entries
else:
type_entries = []
for entry in module.type_entries:
if entry.defined_in_pxd:
if entry.type.is_ctuple:
if entry.name not in ctuple_names:
ctuple_names.add(entry.name)
type_entries.append(entry)
elif definition or entry.defined_in_pxd:
type_entries.append(entry)
type_entries = [t for t in type_entries if t not in vtabslot_entries]
self.generate_type_header_code(type_entries, code)
......
# Verify defined before function prototype
cdef (int, int) get_a_ctuple()
# Verify defined before typedef
ctypedef (int, double) int_double
# Verify typedef defined
cdef int_double tuple_global = (1, 2.)
# Verify defined before opt args
cdef void test_opt_args((double, int) x=*)
# Verify defined before class declaration
cdef class CTupleClass:
cdef void get_a_ctuple(self, (double, double) x)
# ticket: 1427
# mode: compile
cimport ctuple_cimport
# Verify same tuple defined in multiple pxd not redeclared
ctypedef (int, double) int_double
ctuple_cimport.get_a_ctuple()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment