Ejemplo n.º 1
0
/*
    Pop and deallocate the top token stack/context/textbuffer.
*/
void Tokenizer_delete_top_of_stack(Tokenizer* self)
{
    Stack* top = self->topstack;

    Py_DECREF(top->stack);
    Textbuffer_dealloc(top->textbuffer);
    self->topstack = top->next;
    free(top);
    self->depth--;
}
Ejemplo n.º 2
0
static void
Tokenizer_dealloc(Tokenizer* self)
{
    Py_XDECREF(self->text);
    struct Stack *this = self->topstack, *next;
    while (this) {
        Py_DECREF(this->stack);
        Textbuffer_dealloc(this->textbuffer);
        next = this->next;
        free(this);
        this = next;
    }
    self->ob_type->tp_free((PyObject*) self);
}
Ejemplo n.º 3
0
/*
    Write the contents of another textbuffer to the current textbuffer,
    deallocating it in the process.
*/
int Tokenizer_emit_textbuffer(Tokenizer* self, Textbuffer* buffer)
{
    int retval = Textbuffer_concat(self->topstack->textbuffer, buffer);
    Textbuffer_dealloc(buffer);
    return retval;
}