def put_acquire_arg_buffer(entry, code, pos):
code.globalstate.use_utility_code(acquire_utility_code)
buffer_aux = entry.buffer_aux
- getbuffer = get_getbuffer_call(
- code, entry.cname, buffer_aux, entry.type)
+ getbuffer = get_getbuffer_call(code, entry.cname, buffer_aux, entry.type)
# Acquire any new buffer
code.putln("{")
def put_release_buffer_code(code, entry):
code.globalstate.use_utility_code(acquire_utility_code)
- code.putln("__Pyx_SafeReleaseBuffer(&%s);" %
- entry.buffer_aux.buffer_info_var.cname)
+ code.putln("__Pyx_SafeReleaseBuffer(&%s);" % entry.buffer_aux.buffer_info_var.cname)
def get_getbuffer_call(code, obj_cname, buffer_aux, buffer_type):
ndim = buffer_type.ndim
else:
cast = "(size_t)"
code.putln("if (%s) %s = %d;" % (
- code.unlikely("%s >= %s%s" % (
- cname, cast, shape.cname)),
+ code.unlikely("%s >= %s%s" % (cname, cast, shape.cname)),
tmp_cname, dim))
code.globalstate.use_utility_code(raise_indexerror_code)
code.putln("if (%s) {" % code.unlikely("%s != -1" % tmp_cname))
for signed, cname, shape in zip(index_signeds, index_cnames,
bufaux.shapevars):
if signed != 0:
- code.putln("if (%s < 0) %s += %s;" % (
- cname, cname, shape.cname))
+ code.putln("if (%s < 0) %s += %s;" % (cname, cname, shape.cname))
# Create buffer lookup and return it
# This is done via utility macros/inline functions, which vary
if t.is_extension_type:
release = get = None
for x in t.scope.pyfunc_entries:
- if x.name == u"__getbuffer__":
- get = x.func_cname
- elif x.name == u"__releasebuffer__":
- release = x.func_cname
+ if x.name == u"__getbuffer__": get = x.func_cname
+ elif x.name == u"__releasebuffer__": release = x.func_cname
if get:
types.append((t.typeptr_cname, get, release))
typecode.putln("static __Pyx_StructField %s[] = {" % structinfo_name, safe=True)
for f, typeinfo in zip(fields, types):
typecode.putln(' {&%s, "%s", offsetof(%s, %s)},' %
- (typeinfo, f.name,
- dtype.declaration_code(""), f.cname),
- safe=True)
+ (typeinfo, f.name, dtype.declaration_code(""), f.cname), safe=True)
typecode.putln(' {NULL, NULL, 0}', safe=True)
typecode.putln("};", safe=True)
else:
prefix,
(is_str and 's') or (is_unicode and 'u') or 'b',
self.cname[len(Naming.const_prefix):])
+
py_string = PyStringConst(
pystring_cname, encoding, is_unicode, is_str, intern)
self.py_strings[key] = py_string
entry.cname)
w.putln('#else')
self.put_cached_builtin_init(
- entry.pos,
- StringEncoding.EncodedString(entry.name),
+ entry.pos, StringEncoding.EncodedString(entry.name),
entry.cname)
if entry.name == 'xrange':
w.putln('#endif')
storage_class = "static"
if storage_class:
self.put("%s " % storage_class)
- if (entry.extern or
- entry.c_visibility != 'public'):
+ if (entry.extern or entry.c_visibility != 'public'):
dll_linkage = None
self.put(entry.type.declaration_code(entry.cname,
dll_linkage = dll_linkage))
def put_pymethoddef(self, entry, term, allow_skip=True):
if entry.is_special or entry.name == '__getattribute__':
- if entry.name not in [
- '__cinit__', '__dealloc__', '__richcmp__', '__next__',
- '__getreadbuffer__', '__getwritebuffer__', '__getsegcount__',
- '__getcharbuffer__', '__getbuffer__', '__releasebuffer__']:
- if (entry.name == '__getattr__' and
- not self.globalstate.directives['fast_getattr']):
+ if entry.name not in ['__cinit__', '__dealloc__', '__richcmp__', '__next__', '__getreadbuffer__', '__getwritebuffer__', '__getsegcount__', '__getcharbuffer__', '__getbuffer__', '__releasebuffer__']:
+ if entry.name == '__getattr__' and not self.globalstate.directives['fast_getattr']:
pass
# Python's typeobject.c will automatically fill in our slot
# in add_operators() (called by PyType_Ready) with a value
var_entry = entry.as_variable
if var_entry:
if var_entry.is_builtin and Options.cache_builtins:
- var_entry = env.declare_builtin(
- var_entry.name, self.pos)
+ var_entry = env.declare_builtin(var_entry.name, self.pos)
node = NameNode(self.pos, name = self.name)
node.entry = var_entry
node.analyse_rvalue_entry(env)
return # Lookup already cached
elif entry.is_pyclass_attr:
assert entry.type.is_pyobject, "Python global or builtin not a Python object"
- interned_cname = code.intern_identifier(
- self.entry.name)
+ interned_cname = code.intern_identifier(self.entry.name)
if entry.is_builtin:
namespace = Naming.builtins_cname
else: # entry.is_pyglobal
elif entry.is_pyglobal or entry.is_builtin:
assert entry.type.is_pyobject, "Python global or builtin not a Python object"
- interned_cname = code.intern_identifier(
- self.entry.name)
+ interned_cname = code.intern_identifier(self.entry.name)
if entry.is_builtin:
namespace = Naming.builtins_cname
else: # entry.is_pyglobal
elif entry.is_local and False:
# control flow not good enough yet
- assigned = entry.scope.control_flow.get_state(
- (entry.name, 'initialized'), self.pos)
+ assigned = entry.scope.control_flow.get_state((entry.name, 'initialized'), self.pos)
if assigned is False:
- error(
- self.pos,
- "local variable '%s' referenced before assignment" %
- entry.name)
+ error(self.pos, "local variable '%s' referenced before assignment" % entry.name)
elif not Options.init_local_none and assigned is None:
- code.putln(
- 'if (%s == 0) { PyErr_SetString(PyExc_UnboundLocalError, "%s"); %s }' %
- (entry.cname, entry.name,
- code.error_goto(self.pos)))
- entry.scope.control_flow.set_state(
- self.pos, (entry.name, 'initialized'), True)
+ code.putln('if (%s == 0) { PyErr_SetString(PyExc_UnboundLocalError, "%s"); %s }' %
+ (entry.cname, entry.name, code.error_goto(self.pos)))
+ entry.scope.control_flow.set_state(self.pos, (entry.name, 'initialized'), True)
def generate_assignment_code(self, rhs, code):
#print "NameNode.generate_assignment_code:", self.name ###
# We use this to access class->tp_dict if necessary.
if entry.is_pyglobal:
assert entry.type.is_pyobject, "Python global or builtin not a Python object"
- interned_cname = code.intern_identifier(
- self.entry.name)
+ interned_cname = code.intern_identifier(self.entry.name)
namespace = self.entry.scope.namespace_cname
if entry.is_member:
# if the entry is a member we have to cheat: SetAttr does not work
code.put_gotref(self.py_result())
if not self.lhs_of_first_assignment:
if entry.is_local and not Options.init_local_none:
- initialized = entry.scope.control_flow.get_state(
- (entry.name, 'initialized'),
- self.pos)
+ initialized = entry.scope.control_flow.get_state((entry.name, 'initialized'), self.pos)
if initialized is True:
code.put_decref(self.result(), self.ctype())
elif initialized is None:
args, kwds = self.explicit_args_kwds()
items = []
for arg, member in zip(args, type.scope.var_entries):
- items.append(DictItemNode(
- pos=arg.pos, key=StringNode(
- pos=arg.pos, value=member.name),
- value=arg))
+ items.append(DictItemNode(pos=arg.pos, key=StringNode(pos=arg.pos, value=member.name), value=arg))
if kwds:
items += kwds.key_value_pairs
self.key_value_pairs = items
elif result_type.is_builtin_type:
if function.entry.name == 'float':
return PyrexTypes.c_double_type
- elif (function.entry.name
- in Builtin.types_that_construct_their_instance):
+ elif function.entry.name in Builtin.types_that_construct_their_instance:
return result_type
return py_object_type
self.arg_tuple = TupleNode(self.pos, args = self.args)
self.arg_tuple.analyse_types(env)
self.args = None
- if (func_type is Builtin.type_type and function.is_name and
- function.entry and
- function.entry.is_builtin and
- (function.entry.name
- in Builtin.types_that_construct_their_instance)):
+ if func_type is Builtin.type_type and function.is_name and \
+ function.entry and \
+ function.entry.is_builtin and \
+ function.entry.name in Builtin.types_that_construct_their_instance:
# calling a builtin type that returns a specific object type
if function.entry.name == 'float':
# the following will come true later on in a transform
self.type = PyrexTypes.c_double_type
self.result_ctype = PyrexTypes.c_double_type
else:
- self.type = Builtin.builtin_types[
- function.entry.name]
+ self.type = Builtin.builtin_types[function.entry.name]
self.result_ctype = py_object_type
self.may_return_none = False
elif function.is_name and function.type_entry:
self_arg = func_type.args[0]
if self_arg.not_none: # C methods must do the None test for self at *call* time
self.self = self.self.as_none_safe_node(
- "'NoneType' object has no attribute '%s'" %
- self.function.entry.name,
+ "'NoneType' object has no attribute '%s'" % self.function.entry.name,
'PyExc_AttributeError')
expected_type = self_arg.type
self.coerced_self = CloneNode(self.self).coerce_to(
func_type.exception_value.entry.cname,
func_type.exception_value.entry.cname)
else:
- raise_py_exception = '%s(); if (!PyErr_Occurred()) PyErr_SetString(PyExc_RuntimeError , "Error converting c++ exception.")' % (
- func_type.exception_value.entry.cname)
+ raise_py_exception = '%s(); if (!PyErr_Occurred()) PyErr_SetString(PyExc_RuntimeError , "Error converting c++ exception.")' % func_type.exception_value.entry.cname
if self.nogil:
raise_py_exception = 'Py_BLOCK_THREADS; %s; Py_UNBLOCK_THREADS' % raise_py_exception
code.putln(
return
self.entry = entry
if entry:
- if (obj_type.is_extension_type and
- entry.name == "__weakref__"):
+ if obj_type.is_extension_type and entry.name == "__weakref__":
error(self.pos, "Illegal use of special attribute __weakref__")
# methods need the normal attribute lookup
# because they do not have struct entries
h_code.putln("")
for entry in api_funcs:
type = CPtrType(entry.type)
- h_code.putln("static %s;" % type.declaration_code(
- entry.cname))
+ h_code.putln("static %s;" % type.declaration_code(entry.cname))
h_code.putln("")
h_code.put_h_guard(Naming.api_func_guard + "import_module")
h_code.put(import_module_utility_code.impl)
var_entries = type.scope.var_entries
if var_entries:
for entry in var_entries:
- i_code.putln("cdef %s" % entry.type.declaration_code(
- entry.cname, pyrex = 1))
+ i_code.putln("cdef %s" %
+ entry.type.declaration_code(entry.cname, pyrex = 1))
else:
i_code.putln("pass")
i_code.dedent()
else:
writer = code
writer.putln("")
- writer.putln("typedef %s;" % base_type.declaration_code(
- entry.cname))
+ writer.putln("typedef %s;" % base_type.declaration_code(entry.cname))
def sue_header_footer(self, type, kind, name):
if type.typedef_flag:
for method_entry in scope.cfunc_entries:
if not method_entry.is_inherited:
code.putln(
- "%s;" % method_entry.type.declaration_code(
- "(*%s)" % method_entry.name))
+ "%s;" % method_entry.type.declaration_code("(*%s)" % method_entry.name))
code.putln(
"};")
for entry in env.cfunc_entries:
if entry.inline_func_in_pxd or (not entry.in_cinclude and (definition
or entry.defined_in_pxd or entry.extern)):
- if (entry.extern or
- entry.c_visibility == 'public'):
+ if entry.extern or entry.c_visibility == 'public':
dll_linkage = "DL_EXPORT"
else:
dll_linkage = None
dll_linkage = dll_linkage)
if entry.c_visibility == 'private':
storage_class = "static "
- elif (entry.c_visibility == 'public' and
- not entry.extern):
+ elif (entry.c_visibility == 'public' and not entry.extern):
storage_class = ""
else:
storage_class = "%s " % Naming.extern_c_macro
if weakref_slot in scope.var_entries:
code.putln("if (p->__weakref__) PyObject_ClearWeakRefs(o);")
for entry in py_attrs:
- code.put_xdecref(
- "p->%s" % entry.cname, entry.type, nanny=False)
+ code.put_xdecref("p->%s" % entry.cname, entry.type, nanny=False)
if base_type:
tp_dealloc = TypeSlots.get_base_slot_function(scope, tp_slot)
if tp_dealloc is None:
% slot_func)
py_attrs = []
for entry in scope.var_entries:
- if (entry.type.is_pyobject and
- entry.name != "__weakref__"):
+ if entry.type.is_pyobject and entry.name != "__weakref__":
py_attrs.append(entry)
if base_type or py_attrs:
code.putln("int e;")
code.putln("static int %s(PyObject *o) {" % slot_func)
py_attrs = []
for entry in scope.var_entries:
- if (entry.type.is_pyobject and
- entry.name != "__weakref__"):
+ if entry.type.is_pyobject and entry.name != "__weakref__":
py_attrs.append(entry)
if py_attrs:
self.generate_self_cast(scope, code)
entry.type.type_test_code("o"),
code.error_goto(entry.pos)))
code.putln("Py_INCREF(o);")
- code.put_decref(
- entry.cname, entry.type, nanny=False)
+ code.put_decref(entry.cname, entry.type, nanny=False)
code.putln("%s = %s;" % (
entry.cname,
PyrexTypes.typecast(entry.type, py_object_type, "o")))
if not entry.extern:
if entry.type.is_pyobject and entry.used:
code.putln("Py_DECREF(%s); %s = 0;" % (
- code.entry_as_pyobject(entry),
- entry.cname))
+ code.entry_as_pyobject(entry), entry.cname))
code.putln("__Pyx_CleanupGlobals();")
if Options.generate_cleanup_code >= 3:
code.putln("/*--- Type import cleanup code ---*/")
cname = self.cname, visibility='ignore')
struct_entry.type.typedef_flag = False
# FIXME: this might be considered a hack ;-)
- struct_entry.cname = struct_entry.type.cname = (
- '_' + self.entry.type.typedef_cname)
+ struct_entry.cname = struct_entry.type.cname = \
+ '_' + self.entry.type.typedef_cname
def analyse_expressions(self, env):
pass
# generate lambda function definitions
self.generate_lambda_definitions(lenv, code)
- is_getbuffer_slot = (
- self.entry.name == "__getbuffer__" and
- self.entry.scope.is_c_class_scope)
- is_releasebuffer_slot = (
- self.entry.name == "__releasebuffer__" and
- self.entry.scope.is_c_class_scope)
+ is_getbuffer_slot = (self.entry.name == "__getbuffer__" and
+ self.entry.scope.is_c_class_scope)
+ is_releasebuffer_slot = (self.entry.name == "__releasebuffer__" and
+ self.entry.scope.is_c_class_scope)
is_buffer_slot = is_getbuffer_slot or is_releasebuffer_slot
if is_buffer_slot:
if 'cython_unused' not in self.modifiers:
preprocessor_guard = None
if self.entry.is_special and not is_buffer_slot:
- slot = TypeSlots.method_name_to_slot.get(
- self.entry.name)
+ slot = TypeSlots.method_name_to_slot.get(self.entry.name)
if slot:
preprocessor_guard = slot.preprocessor_guard_code()
if (self.entry.name == '__long__' and
code.put_label(code.return_from_error_cleanup_label)
if not Options.init_local_none:
for entry in lenv.var_entries:
- if lenv.control_flow.get_state(
- (entry.name, 'initialized')
- ) is not True:
+ if lenv.control_flow.get_state((entry.name, 'initialized')) is not True:
entry.xdecref_cleanup = 1
for entry in lenv.var_entries:
if self.return_type.is_pyobject:
code.put_xgiveref(self.return_type.as_pyobject(Naming.retval_cname))
- if (self.entry.is_special and
- self.entry.name == "__hash__"):
+ if self.entry.is_special and self.entry.name == "__hash__":
# Returning -1 for __hash__ is supposed to signal an error
# We do as Python instances and coerce -1 into -2.
code.putln("if (unlikely(%s == -1) && !PyErr_Occurred()) %s = -2;" % (
def generate_arg_none_check(self, arg, code):
# Generate None check for one argument.
- code.putln('if (unlikely(((PyObject *)%s) == Py_None)) {' %
- arg.entry.cname)
+ code.putln('if (unlikely(((PyObject *)%s) == Py_None)) {' % arg.entry.cname)
code.putln('''PyErr_Format(PyExc_TypeError, "Argument '%s' must not be None"); %s''' % (
arg.name,
code.error_goto(arg.pos)))
args = args[:len(args) - self.type.optional_arg_count]
arg_names = [arg.name for arg in args]
if is_module_scope:
- cfunc = ExprNodes.NameNode(
- self.pos, name=self.entry.name)
+ cfunc = ExprNodes.NameNode(self.pos, name=self.entry.name)
else:
self_arg = ExprNodes.NameNode(self.pos, name=arg_names[0])
- cfunc = ExprNodes.AttributeNode(
- self.pos, obj=self_arg,
- attribute=self.entry.name)
+ cfunc = ExprNodes.AttributeNode(self.pos, obj=self_arg, attribute=self.entry.name)
skip_dispatch = not is_module_scope or Options.lookup_module_cpdef
c_call = ExprNodes.SimpleCallNode(self.pos, function=cfunc, args=[ExprNodes.NameNode(self.pos, name=n) for n in arg_names[1-is_module_scope:]], wrapper_call=skip_dispatch)
return ReturnStatNode(pos=self.pos, return_type=PyrexTypes.py_object_type, value=c_call)
declarator = arg.declarator
while not hasattr(declarator, 'name'):
declarator = declarator.base
- code.putln('%s = %s->%s;' % (
- arg.cname, Naming.optional_args_cname,
- self.type.opt_arg_cname(declarator.name)))
+ code.putln('%s = %s->%s;' % (arg.cname, Naming.optional_args_cname, self.type.opt_arg_cname(declarator.name)))
i += 1
for _ in range(self.type.optional_arg_count):
code.putln('}')
entry.doc_cname = \
Naming.funcdoc_prefix + prefix + name
if entry.is_special:
- if (entry.name in TypeSlots.invisible or
- not entry.doc or
- (entry.name in '__getattr__' and
- env.directives['fast_getattr'])):
+ if entry.name in TypeSlots.invisible or not entry.doc or (entry.name in '__getattr__' and env.directives['fast_getattr']):
entry.wrapperbase_cname = None
else:
entry.wrapperbase_cname = Naming.wrapperbase_prefix + prefix + name
arg.entry.cname,
func,
item,
- code.error_goto_if(
- arg.type.error_condition(
- arg.entry.cname),
- arg.pos)))
+ code.error_goto_if(arg.type.error_condition(arg.entry.cname), arg.pos)))
else:
error(arg.pos, "Cannot convert Python object argument to type '%s'" % arg.type)
Naming.kwds_cname,
Naming.kwds_cname))
code.putln("if (unlikely(!%s)) return %s;" % (
- self.starstar_arg.entry.cname,
- self.error_value()))
+ self.starstar_arg.entry.cname, self.error_value()))
self.starstar_arg.entry.xdecref_cleanup = 0
code.put_gotref(self.starstar_arg.entry.cname)
self.star_arg.entry.cname))
if self.starstar_arg:
code.putln("{")
- code.put_decref_clear(
- self.starstar_arg.entry.cname, py_object_type)
+ code.put_decref_clear(self.starstar_arg.entry.cname, py_object_type)
code.putln("return %s;" % self.error_value())
code.putln("}")
else:
code.put_gotref(self.star_arg.entry.cname)
if self.starstar_arg:
code.putln("")
- code.putln("if (unlikely(!%s)) {" %
- self.star_arg.entry.cname)
- code.put_decref_clear(
- self.starstar_arg.entry.cname, py_object_type)
+ code.putln("if (unlikely(!%s)) {" % self.star_arg.entry.cname)
+ code.put_decref_clear(self.starstar_arg.entry.cname, py_object_type)
code.putln('return %s;' % self.error_value())
code.putln('}')
else:
code.putln("if (unlikely(!%s)) return %s;" % (
- self.star_arg.entry.cname,
- self.error_value()))
+ self.star_arg.entry.cname, self.error_value()))
code.putln('} else {')
- code.put("%s = %s; " % (
- self.star_arg.entry.cname, Naming.empty_tuple))
+ code.put("%s = %s; " % (self.star_arg.entry.cname, Naming.empty_tuple))
code.put_incref(Naming.empty_tuple, py_object_type)
code.putln('}')
'if (unlikely(__Pyx_ParseOptionalKeywords(%s, %s, %s, values, %s, "%s") < 0)) ' % (
Naming.kwds_cname,
Naming.pykwdlist_cname,
- (self.starstar_arg and
- self.starstar_arg.entry.cname or
- '0'),
+ self.starstar_arg and self.starstar_arg.entry.cname or '0',
pos_arg_count,
self.name))
code.putln(code.error_goto(self.pos))
if arg.needs_conversion:
self.generate_arg_conversion(arg, code)
elif arg.entry.in_closure:
- code.putln('%s = %s;' % (
- arg.entry.cname, arg.hdr_cname))
+ code.putln('%s = %s;' % (arg.entry.cname, arg.hdr_cname))
if arg.type.is_pyobject:
code.put_var_incref(arg.entry)
code.putln("%s = %s; %s" % (
lhs,
rhs,
- code.error_goto_if(
- new_type.error_condition(arg.entry.cname),
- arg.pos)))
+ code.error_goto_if(new_type.error_condition(arg.entry.cname), arg.pos)))
else:
error(arg.pos,
"Cannot convert Python object argument to type '%s'"
first_arg = 1
import ExprNodes
self.func_node = ExprNodes.RawCNameExprNode(self.pos, py_object_type)
- call_tuple = ExprNodes.TupleNode(
- self.pos,
- args=[ExprNodes.NameNode(self.pos, name=arg.name)
- for arg in self.args[first_arg:]])
- call_node = ExprNodes.SimpleCallNode(
- self.pos,
- function=self.func_node,
- args=[ExprNodes.NameNode(self.pos, name=arg.name)
- for arg in self.args[first_arg:]])
+ call_tuple = ExprNodes.TupleNode(self.pos, args=[ExprNodes.NameNode(self.pos, name=arg.name) for arg in self.args[first_arg:]])
+ call_node = ExprNodes.SimpleCallNode(self.pos,
+ function=self.func_node,
+ args=[ExprNodes.NameNode(self.pos, name=arg.name) for arg in self.args[first_arg:]])
self.body = ReturnStatNode(self.pos, value=call_node)
self.body.analyse_expressions(env)
def generate_execution_code(self, code):
- interned_attr_cname = code.intern_identifier(
- self.py_func.entry.name)
+ interned_attr_cname = code.intern_identifier(self.py_func.entry.name)
# Check to see if we are an extension type
if self.py_func.is_module_scope:
self_arg = "((PyObject *)%s)" % Naming.module_cname
# We know target is a NameNode, this is the only ugly case.
target_node = ExprNodes.PyTempNode(self.target.pos, None)
target_node.allocate(code)
- interned_cname = code.intern_identifier(
- self.target.entry.name)
+ interned_cname = code.intern_identifier(self.target.entry.name)
code.globalstate.use_utility_code(ExprNodes.get_name_interned_utility_code)
code.putln("%s = __Pyx_GetName(%s, %s); %s" % (
target_node.result(),
else:
raise NotImplementedError('private python methods')
property = template.substitute({
- u"ATTR": ExprNodes.AttributeNode(
- pos=entry.pos,
- obj=ExprNodes.NameNode(pos=entry.pos, name="self"),
- attribute=entry.name),
+ u"ATTR": ExprNodes.AttributeNode(pos=entry.pos,
+ obj=ExprNodes.NameNode(pos=entry.pos, name="self"),
+ attribute=entry.name),
}, pos=entry.pos).stats[0]
property.name = entry.name
# ---------------------------------------
node.needs_outer_scope = True
return
- as_name = '%s_%s' % (
- target_module_scope.next_id(Naming.closure_class_prefix),
- node.entry.cname)
+ as_name = '%s_%s' % (target_module_scope.next_id(Naming.closure_class_prefix), node.entry.cname)
entry = target_module_scope.declare_c_class(name = as_name,
pos = node.pos, defining = True, implementing = True)
self.nested_funcdefs.append(node)
return node
- # node.entry.extern
+ # node.entry.extern = 1
+ # node.entry.c_visibility = 'public'
if node.py_func is None:
pf_cname = ''
else:
templates = new_templates)
def opt_arg_cname(self, arg_name):
- return self.op_arg_struct.base_type.scope.lookup(
- arg_name).cname
+ return self.op_arg_struct.base_type.scope.lookup(arg_name).cname
class CFuncTypeArg(object):
code.putln("PyObject* member;")
code.putln("res = PyDict_New(); if (res == NULL) return NULL;")
for member in self.type.scope.var_entries:
- nameconst_cname = code.get_py_string_const(
- member.name, identifier=True)
+ nameconst_cname = code.get_py_string_const(member.name, identifier=True)
code.putln("member = %s(s.%s); if (member == NULL) goto bad;" % (
member.type.to_py_function, member.cname))
code.putln("if (PyDict_SetItem(res, %s, member) < 0) goto bad;" % nameconst_cname)