Commit 49d90c94 authored by Robert Bradshaw's avatar Robert Bradshaw

Merge branch 'master' into static

Conflicts:
	CHANGES.rst
	Cython/Compiler/Nodes.py
parents 96416479 9610ed34
...@@ -45,6 +45,8 @@ Features added ...@@ -45,6 +45,8 @@ Features added
* New directive ``use_switch`` (defaults to True) to optionally disable * New directive ``use_switch`` (defaults to True) to optionally disable
the optimization of chained if statement to C switch statements. the optimization of chained if statement to C switch statements.
* Defines dynamic_cast et al. in `libcpp.cast`.
Optimizations Optimizations
------------- -------------
......
...@@ -5322,7 +5322,7 @@ class AttributeNode(ExprNode): ...@@ -5322,7 +5322,7 @@ class AttributeNode(ExprNode):
else: else:
# Create a temporary entry describing the C method # Create a temporary entry describing the C method
# as an ordinary function. # as an ordinary function.
if entry.func_cname: if entry.func_cname and not hasattr(entry.type, 'op_arg_struct'):
cname = entry.func_cname cname = entry.func_cname
if entry.type.is_static_method: if entry.type.is_static_method:
ctype = entry.type ctype = entry.type
......
...@@ -2145,6 +2145,7 @@ class CFuncDefNode(FuncDefNode): ...@@ -2145,6 +2145,7 @@ class CFuncDefNode(FuncDefNode):
# template_declaration String or None Used for c++ class methods # template_declaration String or None Used for c++ class methods
# is_const_method whether this is a const method # is_const_method whether this is a const method
# is_static_method whether this is a static method # is_static_method whether this is a static method
# is_c_class_method whether this is a cclass method
child_attrs = ["base_type", "declarator", "body", "py_func_stat"] child_attrs = ["base_type", "declarator", "body", "py_func_stat"]
...@@ -2161,6 +2162,7 @@ class CFuncDefNode(FuncDefNode): ...@@ -2161,6 +2162,7 @@ class CFuncDefNode(FuncDefNode):
return self.entry.name return self.entry.name
def analyse_declarations(self, env): def analyse_declarations(self, env):
self.is_c_class_method = env.is_c_class_scope
if self.directive_locals is None: if self.directive_locals is None:
self.directive_locals = {} self.directive_locals = {}
self.directive_locals.update(env.directives['locals']) self.directive_locals.update(env.directives['locals'])
...@@ -2401,8 +2403,13 @@ class CFuncDefNode(FuncDefNode): ...@@ -2401,8 +2403,13 @@ class CFuncDefNode(FuncDefNode):
header = self.return_type.declaration_code(entity, dll_linkage=dll_linkage) header = self.return_type.declaration_code(entity, dll_linkage=dll_linkage)
#print (storage_class, modifiers, header) #print (storage_class, modifiers, header)
needs_proto = self.is_c_class_method
if self.template_declaration: if self.template_declaration:
if needs_proto:
code.globalstate.parts['module_declarations'].putln(self.template_declaration)
code.putln(self.template_declaration) code.putln(self.template_declaration)
if needs_proto:
code.globalstate.parts['module_declarations'].putln("%s%s%s; /* proto*/" % (storage_class, modifiers, header))
code.putln("%s%s%s {" % (storage_class, modifiers, header)) code.putln("%s%s%s {" % (storage_class, modifiers, header))
def generate_argument_declarations(self, env, code): def generate_argument_declarations(self, env, code):
......
# empty file
cdef extern from *: cdef extern from *:
ctypedef bint bool ctypedef bint bool
# Defines the standard C++ cast operators.
#
# Due to type restrictions, these are only defined for pointer parameters,
# however that is the only case where they are significantly more interesting
# than the standard C cast operator which can be written "<T>(expression)" in
# Cython.
cdef extern from *:
cdef T dynamic_cast[T](void *) except + # nullptr may also indicate failure
cdef T static_cast[T](void *)
cdef T reinterpret_cast[T](void *)
cdef T const_cast[T](void *)
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