Commit 4d4d29d8 authored by Robert Bradshaw's avatar Robert Bradshaw

merge

parents b054c8c4 6f060c90
......@@ -871,9 +871,22 @@ class CComplexType(CNumericType):
def attributes_known(self):
if self.scope is None:
import Symtab
self.scope = Symtab.StructOrUnionScope(self.specalization_name())
self.scope.declare_var("real", self.real_type, None, "real")
self.scope.declare_var("imag", self.real_type, None, "imag")
self.scope = scope = Symtab.CClassScope(
'',
None,
visibility="extern")
scope.parent_type = self
scope.declare_var("real", self.real_type, None, "real", is_cdef=True)
scope.declare_var("imag", self.real_type, None, "imag", is_cdef=True)
entry = scope.declare_cfunction(
"conjugate",
CFuncType(self, [CFuncTypeArg("self", self, None)]),
pos=None,
defining=1,
cname="__Pyx_c_conj%s" % self.real_type.math_h_modifier)
return True
def create_declaration_utility_code(self, env):
......
......@@ -10,6 +10,7 @@ from Nodes import Node
from ExprNodes import AtomicExprNode
class TempHandle(object):
# THIS IS DEPRECATED, USE LetRefNode instead
temp = None
needs_xdecref = False
def __init__(self, type):
......@@ -23,6 +24,7 @@ class TempHandle(object):
return CleanupTempRefNode(pos, handle=self, type=self.type)
class TempRefNode(AtomicExprNode):
# THIS IS DEPRECATED, USE LetRefNode instead
# handle TempHandle
def analyse_types(self, env):
......@@ -52,6 +54,7 @@ class TempRefNode(AtomicExprNode):
rhs.free_temps(code)
class CleanupTempRefNode(TempRefNode):
# THIS IS DEPRECATED, USE LetRefNode instead
# handle TempHandle
def generate_assignment_code(self, rhs, code):
......@@ -63,6 +66,8 @@ class CleanupTempRefNode(TempRefNode):
self.handle.needs_cleanup = False
class TempsBlockNode(Node):
# THIS IS DEPRECATED, USE LetNode instead
"""
Creates a block which allocates temporary variables.
This is used by transforms to output constructs that need
......
......@@ -469,6 +469,13 @@ cdef extern from "numpy/arrayobject.h":
object PyArray_Take(ndarray ap, object items, int axis)
object PyArray_Put(ndarray ap, object items, object values)
void PyArray_ITER_RESET(flatiter it) nogil
void PyArray_ITER_NEXT(flatiter it) nogil
void PyArray_ITER_GOTO(flatiter it, npy_intp* destination) nogil
void PyArray_ITER_GOTO1D(flatiter it, npy_intp ind) nogil
void* PyArray_ITER_DATA(flatiter it) nogil
bint PyArray_ITER_NOTDONE(flatiter it) nogil
void PyArray_MultiIter_RESET(broadcast multi) nogil
void PyArray_MultiIter_NEXT(broadcast multi) nogil
void PyArray_MultiIter_GOTO(broadcast multi, npy_intp dest) nogil
......
def f():
print assert sizeof(int) == sizof(short) == sizeof(long)
_ERRORS = u"""
3:10: Expected an identifier or literal
"""
def f():
"""
>>> f()
True
True
"""
cdef char a
a = 62
print (a == '>')
print (a == <char>'>')
......@@ -58,9 +58,11 @@ __doc__ = u"""
>>> test_real_imag_assignment(1.5, -3.5)
(1.5-3.5j)
## XXX not implemented yet!
## >>> test_conjugate(1+2j)
## (1-2j)
>>> test_conjugate(2+3j)
(2-3j)
>>> test_conjugate_double(2+3j)
(2-3j)
"""
#cdef extern from "complex.h":
......@@ -109,6 +111,8 @@ def test_real_imag_assignment(object a, double b):
z.imag = b
return z
## XXX not implemented yet!
## def test_conjugate(float complex z):
## return z.conjugate()
def test_conjugate(float complex z):
return z.conjugate()
def test_conjugate_double(double complex z):
return z.conjugate()
typedef struct {
int x
} MyStruct;
cimport crashT245_pxd
"""
>>> f()
{'x': 1}
"""
def f():
cdef crashT245_pxd.MyStruct s
s.x = 1
print s
cdef extern from "crashT245.h":
ctypedef struct MyStruct:
int x
import math
cdef class MyClass:
"""
>>> x=MyClass()
4
"""
def __cinit__(self, int arg=2*2):
print arg
cdef class MyOtherClass:
"""
>>> x=MyOtherClass()
8
"""
def __cinit__(self, int arg=4*int(math.sqrt(4))):
print arg
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