def set_initial_string_attribute(self, name: str, s: str): if s is not None: ps = PyStringLL(None, self.v) ps.declare_tmp() ps.new(s) else: ps = PyObjectLL(None, self.v) ps.declare_tmp() ps.assign_none() self.set_attr_string(name, ps) ps.decref()
def intro(self, docstring, module_name): self.v.ctx.add_variable(c.Decl('__return_value__', PyObjectLL.typedecl('__return_value__')), False) # set the docstring ds = PyStringLL(None, self.v) ds.declare_tmp() if docstring: ds.new(docstring) else: ds.assign_none() self.c_namespace_dict.set_item_string('__doc__', ds) ds.decref() # set the module name ds = PyStringLL(None, self.v) ds.declare_tmp() if module_name: ds.new(module_name) self.c_namespace_dict.set_item_string('__module__', ds) ds.decref()