code.put_xdecref(self.result(), self.ctype())
else:
code.put_decref(self.result(), self.ctype())
- if entry.is_cglobal or entry.in_closure:
- code.put_giveref(rhs.py_result())
+ if self.use_managed_ref:
- if entry.is_cglobal:
++ if entry.is_cglobal or entry.in_closure:
+ code.put_giveref(rhs.py_result())
code.putln('%s = %s;' % (self.result(), rhs.result_as(self.ctype())))
if debug_disposal_code:
print("NameNode.generate_assignment_code:")
# from a PyMethodDef struct.
#
# pymethdef_cname string PyMethodDef structure
+ # self_object ExprNode or None
+
+ subexprs = []
+ self_object = None
+ type = py_object_type
+ is_temp = 1
+
def analyse_types(self, env):
- self.type = py_object_type
- self.is_temp = 1
-
+ pass
+
gil_message = "Constructing Python function"
+ def self_result_code(self):
+ if self.self_object is None:
+ self_result = "NULL"
+ else:
+ self_result = self.self_object.py_result()
+ return self_result
+
def generate_result_code(self, code):
code.putln(
- "%s = PyCFunction_New(&%s, 0); %s" % (
+ "%s = PyCFunction_New(&%s, %s); %s" % (
self.result(),
self.pymethdef_cname,
+ self.self_result_code(),
code.error_goto_if_null(self.result(), self.pos)))
code.put_gotref(self.py_result())
WithTransform(self),
DecoratorTransform(self),
AnalyseDeclarationsTransform(self),
+ CreateClosureClasses(self),
AutoTestDictTransform(self),
EmbedSignature(self),
+ MarkAssignments(self),
TransformBuiltinMethods(self),
IntroduceBufferAuxiliaryVars(self),
_check_c_declarations,
import Naming
import PyrexTypes
import TypeSlots
-from PyrexTypes import py_object_type, error_type, CFuncType
-from Symtab import ModuleScope, LocalScope, GeneratorLocalScope, \
+from PyrexTypes import py_object_type, error_type, CTypedefType, CFuncType
- from Symtab import ModuleScope, LocalScope, ClosureScope, \
++from Symtab import ModuleScope, LocalScope, GeneratorLocalScope, ClosureScope, \
StructOrUnionScope, PyClassScope, CClassScope
from Cython.Utils import open_new_file, replace_suffix
from Code import UtilityCode
var_entry.is_cglobal = 1
var_entry.is_readonly = 1
entry.as_variable = var_entry
+
+ def infer_types(self):
+ from TypeInference import PyObjectTypeInferer
+ PyObjectTypeInferer().infer_types(self)
-class LocalScope(Scope):
+class LocalScope(Scope):
def __init__(self, name, outer_scope):
Scope.__init__(self, name, outer_scope, outer_scope)