示例#1
0
static
int _event_handler (Xpost_Context *ctx,
                    Xpost_Object devdic)
{
    Xpost_Object privatestr;
    PrivateData private;
    xcb_generic_event_t *event;


    /* load private data struct from string */
    privatestr = xpost_dict_get(ctx, devdic, namePrivate);
    if (xpost_object_get_type(privatestr) == invalidtype)
        return undefined;
    xpost_memory_get(xpost_context_select_memory(ctx, privatestr),
            xpost_object_get_ent(privatestr), 0, sizeof private, &private);

    event = xcb_poll_for_event(private.c);
    if (event)
    {
        switch(event->response_type & ~0x80)
        {
        case XCB_EXPOSE:
            _flush(ctx, devdic);
            break;
        default:
            break;
        }
        free(event);
    }
    else if (xcb_connection_has_error(private.c))
        return unregistered;

    return 0;
}
示例#2
0
/* initialize the name special entities XPOST_MEMORY_TABLE_SPECIAL_NAME_STACK, NAME_TREE */
int xpost_name_init(Xpost_Context *ctx)
{
    Xpost_Memory_Table *tab;
    unsigned int ent;
    unsigned int t;
    unsigned int mode;
    unsigned int nstk;
    int ret;

    mode = ctx->vmmode;
    ctx->vmmode = GLOBAL;
    ret = xpost_memory_table_alloc(ctx->gl, 0, 0, &ent); //gl:NAMES
    if (!ret)
    {
        return 0;
    }
    //assert(ent == XPOST_MEMORY_TABLE_SPECIAL_NAME_STACK);
    if (ent != XPOST_MEMORY_TABLE_SPECIAL_NAME_STACK)
        XPOST_LOG_ERR("Warning: name stack is not in special position");
    ret = xpost_memory_table_alloc(ctx->gl, 0, 0, &ent); //gl:NAMET
    if (!ret)
    {
        return 0;
    }
    //assert(ent == XPOST_MEMORY_TABLE_SPECIAL_NAME_TREE);
    if (ent != XPOST_MEMORY_TABLE_SPECIAL_NAME_TREE)
        XPOST_LOG_ERR("Warning: name tree is not in special position");

    xpost_stack_init(ctx->gl, &t);
    tab = &ctx->gl->table; //recalc pointer
    tab->tab[XPOST_MEMORY_TABLE_SPECIAL_NAME_STACK].adr = t;
    tab->tab[XPOST_MEMORY_TABLE_SPECIAL_NAME_TREE].adr = 0;
    xpost_memory_table_get_addr(ctx->gl,
            XPOST_MEMORY_TABLE_SPECIAL_NAME_STACK, &nstk);
    xpost_stack_push(ctx->gl, nstk, xpost_string_cons(ctx, CNT_STR("_not_a_name_")));
    assert (xpost_object_get_ent(xpost_stack_topdown_fetch(ctx->gl, nstk, 0)) == XPOST_MEMORY_TABLE_SPECIAL_BOGUS_NAME);

    ctx->vmmode = LOCAL;
    ret = xpost_memory_table_alloc(ctx->lo, 0, 0, &ent); //lo:NAMES
    if (!ret)
    {
        return 0;
    }
    //assert(ent == XPOST_MEMORY_TABLE_SPECIAL_NAME_STACK);
    if (ent != XPOST_MEMORY_TABLE_SPECIAL_NAME_STACK)
        XPOST_LOG_ERR("Warning: name stack is not in special position");
    ret = xpost_memory_table_alloc(ctx->lo, 0, 0, &ent); //lo:NAMET
    if (!ret)
    {
        return 0;
    }
    //assert(ent == XPOST_MEMORY_TABLE_SPECIAL_NAME_TREE);
    if (ent != XPOST_MEMORY_TABLE_SPECIAL_NAME_TREE)
        XPOST_LOG_ERR("Warning: name tree is not in special position");

    xpost_stack_init(ctx->lo, &t);
    tab = &ctx->lo->table; //recalc pointer
    tab->tab[XPOST_MEMORY_TABLE_SPECIAL_NAME_STACK].adr = t;
    tab->tab[XPOST_MEMORY_TABLE_SPECIAL_NAME_TREE].adr = 0;
    xpost_memory_table_get_addr(ctx->lo,
            XPOST_MEMORY_TABLE_SPECIAL_NAME_STACK, &nstk);
    xpost_stack_push(ctx->lo, nstk, xpost_string_cons(ctx, CNT_STR("_not_a_name_")));
    //assert (xpost_object_get_ent(xpost_stack_topdown_fetch(ctx->lo, nstk, 0)) == XPOST_MEMORY_TABLE_SPECIAL_BOGUS_NAME);
    if (xpost_object_get_ent(xpost_stack_topdown_fetch(ctx->lo, nstk, 0)) != XPOST_MEMORY_TABLE_SPECIAL_BOGUS_NAME)
        XPOST_LOG_ERR("Warning: bogus name not in special position");

    ctx->vmmode = mode;

    return 1;
}
示例#3
0
/* traverse the contents of composite objects
   if markall is true, this is a collection of global vm,
   so we must mark objects and recurse
   even if it means switching memory files
 */
static
int _xpost_garbage_mark_object(Xpost_Context *ctx,
        Xpost_Memory_File *mem,
        Xpost_Object o,
        int markall)
{
    unsigned int ad;
    int ret;

    if (!mem) return 0;

    switch(xpost_object_get_type(o)) {
    default: break;

    case arraytype:
#ifdef DEBUG_GC
    printf("markobject: %d, %s (size %d)\n",
            xpost_object_get_ent(o),
            xpost_object_type_names[xpost_object_get_type(o)],
            o.comp_.sz);
#endif
        if (xpost_context_select_memory(ctx, o) != mem) {
            if (markall)
                mem = xpost_context_select_memory(ctx, o);
            else
                break;
        }
        if (!mem) return 0;
        if (!_xpost_garbage_ent_is_marked(mem, xpost_object_get_ent(o), &ret))
            return 0;
        if (!ret) {
            ret = _xpost_garbage_mark_ent(mem, xpost_object_get_ent(o));
            if (!ret)
            {
                XPOST_LOG_ERR("cannot mark array");
                return 0;
            }
            ret = xpost_memory_table_get_addr(mem, xpost_object_get_ent(o), &ad);
            if (!ret)
            {
                XPOST_LOG_ERR("cannot retrieve address for array ent %u", xpost_object_get_ent(o));
                return 0;
            }
            if (!_xpost_garbage_mark_array(ctx, mem, ad, o.comp_.sz, markall))
                return 0;
        }
        break;

    case dicttype:
#ifdef DEBUG_GC
    printf("markobject: %d, %s (size %d)\n",
            xpost_object_get_ent(o),
            xpost_object_type_names[xpost_object_get_type(o)],
            o.comp_.sz);
#endif
        if (xpost_context_select_memory(ctx, o) != mem) {
            if (markall)
                mem = xpost_context_select_memory(ctx, o);
            else
                break;
        }
        if (!_xpost_garbage_ent_is_marked(mem, xpost_object_get_ent(o), &ret))
            return 0;
        if (!ret) {
            ret = _xpost_garbage_mark_ent(mem, xpost_object_get_ent(o));
            if (!ret)
            {
                XPOST_LOG_ERR("cannot mark dict");
                return 0;
            }
            ret = xpost_memory_table_get_addr(mem, xpost_object_get_ent(o), &ad);
            if (!ret)
            {
                XPOST_LOG_ERR("cannot retrieve address for dict ent %u", xpost_object_get_ent(o));
                return 0;
            }
            if (!_xpost_garbage_mark_dict(ctx, mem, ad, markall))
                return 0;
        }
        break;

    case stringtype:
#ifdef DEBUG_GC
    printf("markobject: %d, %s (size %d)\n",
            xpost_object_get_ent(o),
            xpost_object_type_names[xpost_object_get_type(o)],
            o.comp_.sz);
#endif
        if (xpost_context_select_memory(ctx, o) != mem) {
            if (markall)
                mem = xpost_context_select_memory(ctx, o);
            else
                break;
        }
        ret = _xpost_garbage_mark_ent(mem, xpost_object_get_ent(o));
        if (!ret)
        {
            XPOST_LOG_ERR("cannot mark string");
            return 0;
        }
        break;

    case filetype:
        if (mem == ctx->gl) {
            printf("file found in global vm\n");
        } else {
            ret = _xpost_garbage_mark_ent(mem, o.mark_.padw);
            if (!ret)
            {
                XPOST_LOG_ERR("cannot mark file");
                return 0;
            }
        }
        break;
    }
    return 1;
}