static int ps_get_levels (lua_State *L) { const cairo_ps_level_t *levels; int num_levels, i; cairo_ps_get_levels(&levels, &num_levels); lua_createtable(L, num_levels, 0); for (i = 0; i < num_levels; ++i) { lua_pushstring(L, cairo_ps_level_to_string(levels[i])); lua_rawseti(L, -2, i + 1); } return 1; }
static VALUE cr_ps_get_levels (VALUE self) { VALUE rb_levels; const cairo_ps_level_t *levels; int i, n_levels; cairo_ps_get_levels (&levels, &n_levels); rb_levels = rb_ary_new2 (n_levels); for (i = 0; i < n_levels; i++) { rb_ary_push (rb_levels, INT2NUM (levels[i])); } return rb_levels; }