def __init__(self, f): CCodeWriter.__init__(self, self) self.buffer = StringIO() self.real_f = f self.annotations = [] self.last_pos = None self.code = {}
def mark_pos(self, pos): if pos is not None: CCodeWriter.mark_pos(self, pos) if self.last_pos: code = self.code.get(self.last_pos[1], "") self.code[self.last_pos[1]] = code + self.annotation_buffer.getvalue() self.annotation_buffer = StringIO() self.last_pos = pos
def mark_pos(self, pos): if pos is not None: CCodeWriter.mark_pos(self, pos) if self.last_pos: code = self.code.get(self.last_pos[1], "") self.code[ self.last_pos[1]] = code + self.annotation_buffer.getvalue() self.annotation_buffer = StringIO() self.last_pos = pos
def mark_pos(self, pos): if pos is not None: CCodeWriter.mark_pos(self, pos) if self.last_pos: pos_code = self.code.setdefault(self.last_pos[0].filename,{}) code = pos_code.get(self.last_pos[1], "") pos_code[self.last_pos[1]] = code + self.annotation_buffer.getvalue() self.annotation_buffer = StringIO() self.last_pos = pos
def mark_pos(self, pos): if pos is not None: CCodeWriter.mark_pos(self, pos) if self.last_pos: pos_code = self.code.setdefault(self.last_pos[0].filename, {}) code = pos_code.get(self.last_pos[1], "") pos_code[ self.last_pos[1]] = code + self.annotation_buffer.getvalue() self.annotation_buffer = StringIO() self.last_pos = pos
def __init__(self, create_from=None, buffer=None, copy_formatting=True): CCodeWriter.__init__(self, create_from, buffer, copy_formatting=True) if create_from is None: self.annotation_buffer = StringIO() self.annotations = [] self.last_pos = None self.code = {} else: # When creating an insertion point, keep references to the same database self.annotation_buffer = create_from.annotation_buffer self.annotations = create_from.annotations self.code = create_from.code self.last_pos = create_from.last_pos
def write(self, s): CCodeWriter.write(self, s) self.annotation_buffer.write(s)