Sha256: 53aed0e7b3d6b629f2f8160712931080b39f0cb7cac80f829369ce23ddf79e19

Contents?: true

Size: 573 Bytes

Versions: 11

Compression:

Stored size: 573 Bytes

Contents

static bool is_userdata(lua_State *L, int index, const char *tname) {
  void *p = lua_touserdata(L, index);
  if (p != NULL) {  /* value is a userdata? */
    if (lua_getmetatable(L, index)) {  /* does it have a metatable? */
      lua_getfield(L, LUA_REGISTRYINDEX, tname);  /* get correct metatable */
      if (lua_rawequal(L, -1, -2)) {  /* does it have the correct mt? */
        lua_pop(L, 2);  /* remove both metatables */
        // type match
        return true;
      }
    }
  }
  // type does not match
  return false;
}

<%= @bindings %>

<%= @init_code %>

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dub-1.0.0 lib/dub/templates/lua_template.erb
dub-0.7.0 lib/dub/templates/lua_template.erb
dub-0.6.6 lib/dub/templates/lua_template.erb
dub-0.6.5 lib/dub/templates/lua_template.erb
dub-0.6.4 lib/dub/templates/lua_template.erb
dub-0.6.3 lib/dub/templates/lua_template.erb
dub-0.6.2 lib/dub/templates/lua_template.erb
dub-0.6.1 lib/dub/templates/lua_template.erb
dub-0.6.0 lib/dub/templates/lua_template.erb
dub-0.5.1 lib/dub/templates/lua_template.erb
dub-0.5.0 lib/dub/templates/lua_template.erb