is_temp = 1
def analyse_types(self, env):
- pass
+ if self.binding:
+ env.use_utility_code(binding_cfunc_utility_code)
+
+ def may_be_none(self):
+ return False
gil_message = "Constructing Python function"
code.putln("__pyx_refnanny = __Pyx_RefNanny->SetupContext(\"%s\", __LINE__, __FILE__);"% header3)
code.putln("#endif")
- self.generate_filename_init_call(code)
-
code.putln("%s = PyTuple_New(0); %s" % (Naming.empty_tuple, code.error_goto_if_null(Naming.empty_tuple, self.pos)));
- code.putln("%s = __Pyx_PyBytes_FromStringAndSize(\"\", 0); %s" % (Naming.empty_bytes, code.error_goto_if_null(Naming.empty_bytes, self.pos)));
-
+ code.putln("%s = PyBytes_FromStringAndSize(\"\", 0); %s" % (Naming.empty_bytes, code.error_goto_if_null(Naming.empty_bytes, self.pos)));
+
+ code.putln("#ifdef %s_USED" % Naming.binding_cfunc)
+ code.putln("if (%s_init() < 0) %s" % (Naming.binding_cfunc, code.error_goto(self.pos)))
+ code.putln("#endif")
+
code.putln("/*--- Library function declarations ---*/")
env.generate_library_function_declarations(code)
# base_type CBaseTypeNode
# declarator CDeclaratorNode
# not_none boolean Tagged with 'not None'
+ # or_none boolean Tagged with 'or None'
+ # accept_none boolean Resolved boolean for not_none/or_none
# default ExprNode or None
# default_value PyObjectConst constant for default value
+ # annotation ExprNode or None Py3 function arg annotation
# is_self_arg boolean Is the "self" arg of an extension type method
# is_type_arg boolean Is the "class" arg of an extension type classmethod
# is_kw_only boolean Is a keyword-only argument
cpdef p_name(PyrexScanner s, name)
cpdef p_cat_string_literal(PyrexScanner s)
cpdef p_opt_string_literal(PyrexScanner s)
- cpdef p_string_literal(PyrexScanner s)
+ cpdef p_string_literal(PyrexScanner s, kind_override=*)
cpdef p_list_maker(PyrexScanner s)
-cpdef p_list_iter(PyrexScanner s, body)
-cpdef p_list_for(PyrexScanner s, body)
-cpdef p_list_if(PyrexScanner s, body)
+cpdef p_comp_iter(PyrexScanner s, body)
+cpdef p_comp_for(PyrexScanner s, body)
+cpdef p_comp_if(PyrexScanner s, body)
cpdef p_dict_or_set_maker(PyrexScanner s)
cpdef p_backquote_expr(PyrexScanner s)
cpdef p_simple_expr_list(PyrexScanner s)
else:
return 0
-def p_c_arg_decl(s, ctx, in_pyfunc, cmethod_flag = 0, nonempty = 0, kw_only = 0):
+def p_c_arg_decl(s, ctx, in_pyfunc, cmethod_flag = 0, nonempty = 0,
+ kw_only = 0, annotated = 1):
pos = s.position()
- not_none = 0
+ not_none = or_none = 0
default = None
+ annotation = None
if s.in_python_file:
# empty type declaration
base_type = Nodes.CSimpleBaseTypeNode(pos,
else:
s.error("Expected 'None'")
if not in_pyfunc:
- error(pos, "'not None' only allowed in Python functions")
- not_none = 1
+ error(pos, "'%s None' only allowed in Python functions" % kind)
+ or_none = kind == 'or'
+ not_none = kind == 'not'
+ if annotated and s.sy == ':':
+ s.next()
+ annotation = p_simple_expr(s)
if s.sy == '=':
s.next()
if 'pxd' in s.level:
base_type = base_type,
declarator = declarator,
not_none = not_none,
+ or_none = or_none,
default = default,
+ annotation = annotation,
kw_only = kw_only)
def p_api(s):
# return_type PyrexType or None Return type of function owning scope
# is_py_class_scope boolean Is a Python class scope
# is_c_class_scope boolean Is an extension type scope
+ # is_closure_scope boolean
+ # is_cpp_class_scope boolean Is a C++ class scope
+ # is_property_scope boolean Is a extension type property scope
# scope_prefix string Disambiguator for C names
# in_cinclude boolean Suppress C declaration code
# qualified_name string "modname" or "modname.classname"
is_py_class_scope = 0
is_c_class_scope = 0
+ is_closure_scope = 0
is_cpp_class_scope = 0
+ is_property_scope = 0
is_module_scope = 0
+ is_internal = 0
scope_prefix = ""
in_cinclude = 0
nogil = 0