예제 #1
0
파일: lua-resource.c 프로젝트: 01org/murphy
static void resource_lua_destroy(void *data)
{
    resource_lua_t *res = (resource_lua_t *) data;

    mrp_debug("lua destructor for resource %p (%s)", res, res->resource_name);

    mrp_free(res->resource_name);

    /* TODO: unref res->real_attributes ? */

    mrp_lua_destroy_object(res->L, NULL, 0, res->real_attributes);

    return;
}
예제 #2
0
파일: lua-resource.c 프로젝트: 01org/murphy
static void htbl_free_resource(void *key, void *object)
{
    resource_lua_t *res = (resource_lua_t *) object;
    MRP_UNUSED(key);

    mrp_lua_destroy_object(res->L, NULL, 0, res);
#if 0

    mrp_debug("lua-resource: htbl_free_resource %p, res: '%s'", res,
            res->resource_name);

    MRP_UNUSED(key);
#endif
}
예제 #3
0
파일: lua-timer.c 프로젝트: e8johan/murphy
static int timer_lua_create(lua_State *L)
{

    mrp_context_t *ctx    = mrp_lua_get_murphy_context();
    char           e[128] = "";
    timer_lua_t   *t;
    int            narg;

    if (ctx == NULL)
        luaL_error(L, "failed to get murphy context");

    narg = lua_gettop(L);

    t = (timer_lua_t *)mrp_lua_create_object(L, TIMER_LUA_CLASS, NULL, 0);

    t->L        = L;
    t->ctx      = ctx;
    t->callback = LUA_NOREF;
    t->data     = LUA_NOREF;

    switch (narg) {
    case 1:
        break;
    case 2:
        if (mrp_lua_init_members(t, L, -2, e, sizeof(e)) != 1)
            return luaL_error(L, "failed to initialize timer members (%s)", e);
        break;
    default:
        return luaL_error(L, "expecting 0 or 1 constructor arguments, "
                          "got %d", narg);
    }

    if (t->callback != LUA_NOREF && t->t == NULL) {
        t->t = mrp_add_timer(t->ctx->ml, t->msecs, timer_lua_cb, t);

        if (t->t == NULL) {
            mrp_lua_destroy_object(L, NULL, 0, t);
            return luaL_error(L, "failed to create Murphy timer");
        }
    }

    mrp_lua_push_object(L, t);

    return 1;
}