diff -r 37d40646533e Cython/Compiler/ExprNodes.py
|
a
|
b
|
|
| 575 | 575 | return src |
| 576 | 576 | |
| 577 | 577 | def fail_assignment(self, dst_type): |
| | 578 | print '...' |
| | 579 | assert(0) |
| 578 | 580 | error(self.pos, "Cannot assign type '%s' to '%s'" % (self.type, dst_type)) |
| 579 | 581 | |
| 580 | 582 | def check_for_coercion_error(self, dst_type, fail=False, default=None): |
| … |
… |
|
| 5905 | 5907 | func_type = entry.type |
| 5906 | 5908 | if func_type.is_ptr: |
| 5907 | 5909 | func_type = func_type.base_type |
| 5908 | | if len(func_type.args) == 1: |
| 5909 | | self.operand2 = self.operand2.coerce_to(func_type.args[0].type, env) |
| 5910 | | else: |
| 5911 | | self.operand1 = self.operand1.coerce_to(func_type.args[0].type, env) |
| 5912 | | self.operand2 = self.operand2.coerce_to(func_type.args[1].type, env) |
| | 5910 | #if len(func_type.args) == 1: |
| | 5911 | #self.operand2 = self.operand2.coerce_to(func_type.args[0].type, env) |
| | 5912 | #else: |
| | 5913 | #self.operand1 = self.operand1.coerce_to(func_type.args[0].type, env) |
| | 5914 | #self.operand2 = self.operand2.coerce_to(func_type.args[1].type, env) |
| 5913 | 5915 | self.type = func_type.return_type |
| 5914 | 5916 | |
| 5915 | 5917 | def has_python_operands(self): |
diff -r 37d40646533e Cython/Compiler/Nodes.py
|
a
|
b
|
|
| 1027 | 1027 | if self.attributes is not None: |
| 1028 | 1028 | scope = CppClassScope(self.name, env) |
| 1029 | 1029 | base_class_types = [] |
| 1030 | | for base_class_name in self.base_classes: |
| 1031 | | base_class_entry = env.lookup(base_class_name) |
| 1032 | | if base_class_entry is None: |
| 1033 | | error(self.pos, "'%s' not found" % base_class_name) |
| 1034 | | elif not base_class_entry.is_type or not base_class_entry.type.is_cpp_class: |
| | 1030 | for base_class in self.base_classes: |
| | 1031 | base_class_type = base_class.analyse_as_type(env) |
| | 1032 | if not base_class_type.is_cpp_class: |
| 1035 | 1033 | error(self.pos, "'%s' is not a cpp class type" % base_class_name) |
| 1036 | 1034 | else: |
| 1037 | | base_class_types.append(base_class_entry.type) |
| | 1035 | base_class_types.append(base_class_type) |
| 1038 | 1036 | if self.templates is None: |
| 1039 | 1037 | template_types = None |
| 1040 | 1038 | else: |
diff -r 37d40646533e Cython/Compiler/Parsing.py
|
a
|
b
|
|
| 2627 | 2627 | templates = None |
| 2628 | 2628 | if s.sy == '(': |
| 2629 | 2629 | s.next() |
| 2630 | | base_classes = [p_dotted_name(s, False)[2]] |
| | 2630 | #base_classes = [p_dotted_name(s, False)[2]] |
| | 2631 | base_classes = [p_c_base_type(s, templates = templates)] |
| 2631 | 2632 | while s.sy == ',': |
| 2632 | 2633 | s.next() |
| 2633 | | base_classes.append(p_dotted_name(s, False)[2]) |
| | 2634 | base_classes.append(p_c_base_type(s, templates=templates)) |
| 2634 | 2635 | s.expect(')') |
| 2635 | 2636 | else: |
| 2636 | 2637 | base_classes = [] |
diff -r 37d40646533e Cython/Compiler/Symtab.py
|
a
|
b
|
|
| 1555 | 1555 | break |
| 1556 | 1556 | if not found: |
| 1557 | 1557 | self.default_constructor = temp_entry.scope.name |
| | 1558 | #assert(0) |
| 1558 | 1559 | error(pos, "no matching function for call to " \ |
| 1559 | 1560 | "%s::%s()" % (temp_entry.scope.name, temp_entry.scope.name)) |
| 1560 | 1561 | elif not self.default_constructor: |
| … |
… |
|
| 1565 | 1566 | cname = None, visibility = 'extern', defining = 0, |
| 1566 | 1567 | api = 0, in_pxd = 0, modifiers = ()): |
| 1567 | 1568 | if name == self.name.split('::')[-1] and cname is None: |
| 1568 | | self.check_base_default_constructor(pos) |
| | 1569 | #self.check_base_default_constructor(pos) |
| 1569 | 1570 | name = '<init>' |
| 1570 | 1571 | type.return_type = self.lookup(self.name).type |
| 1571 | 1572 | prev_entry = self.lookup_here(name) |
diff -r 37d40646533e tests/run/cpp_templates.pyx
|
a
|
b
|
|
| 14 | 14 | bint operator==(Pair[T1,T2]) |
| 15 | 15 | bint operator!=(Pair[T1,T2]) |
| 16 | 16 | |
| | 17 | cdef cppclass InheritedWrap(Wrap[int]): |
| | 18 | InheritedWrap(int) |
| | 19 | |
| 17 | 20 | def test_int(int x, int y): |
| 18 | 21 | """ |
| 19 | 22 | >>> test_int(3, 4) |
| … |
… |
|
| 29 | 32 | finally: |
| 30 | 33 | del a, b |
| 31 | 34 | |
| | 35 | def test_inherit(int x, int y): |
| | 36 | """ |
| | 37 | >>> test_inherit(3, 4) |
| | 38 | (3, 4, False) |
| | 39 | >>> test_inherit(100, 100) |
| | 40 | (100, 100, True) |
| | 41 | """ |
| | 42 | try: |
| | 43 | a = new InheritedWrap(x) |
| | 44 | b = new InheritedWrap(0) |
| | 45 | b.set(y) |
| | 46 | return a.get(), b.get() , a[0] == b[0] # |
| | 47 | finally: |
| | 48 | del a, b |
| 32 | 49 | |
| 33 | 50 | def test_double(double x, double y): |
| 34 | 51 | """ |
diff -r 37d40646533e tests/run/cpp_templates_helper.h
|
a
|
b
|
|
| 20 | 20 | bool operator==(Pair<T1,T2> other) { return _first == other._first && _second == other._second; } |
| 21 | 21 | bool operator!=(Pair<T1,T2> other) { return _first != other._first || _second != other._second; } |
| 22 | 22 | }; |
| | 23 | |
| | 24 | class InheritedWrap : public Wrap<int> { |
| | 25 | public: |
| | 26 | InheritedWrap(int v) : Wrap<int>(v) {} |
| | 27 | }; |
| | 28 | |