示例#1
0
int gt_lua_open_feature_index(lua_State *L)
{
#ifndef NDEBUG
  int stack_size;
#endif
  gt_assert(L);
#ifndef NDEBUG
  stack_size = lua_gettop(L);
#endif
  luaL_newmetatable(L, FEATURE_INDEX_METATABLE);
  /* metatable.__index = metatable */
  lua_pushvalue(L, -1); /* duplicate the metatable */
  lua_setfield(L, -2, "__index");
  /* set its _gc field */
  lua_pushstring(L, "__gc");
  lua_pushcfunction(L, feature_index_lua_delete);
  lua_settable(L, -3);
  /* register functions */
  luaL_register(L, NULL, feature_index_lib_m);
  gt_lua_export_metatable(L, FEATURE_INDEX_METATABLE);
  luaL_register(L, "gt", feature_index_lib_f);
  lua_pop(L, 1);
  gt_assert(lua_gettop(L) == stack_size);
  return 1;
}
示例#2
0
int gt_lua_open_encseq(lua_State *L)
{
#ifndef NDEBUG
  int stack_size;
#endif
  gt_assert(L);
#ifndef NDEBUG
  stack_size = lua_gettop(L);
#endif
  luaL_newmetatable(L, ENCSEQ_METATABLE);
  lua_pushvalue(L, -1); /* duplicate the metatable */
  lua_setfield(L, -2, "__index");
  lua_pushstring(L, "__gc");
  lua_pushcfunction(L, encseq_lua_delete);
  lua_settable(L, -3);
  luaL_register(L, NULL, encseq_lib_m);
  gt_lua_export_metatable(L, ENCSEQ_METATABLE);

  luaL_newmetatable(L, ENCSEQ_BUFFER_METATABLE);
  lua_pushcfunction(L, encseq_lua_index_buffer);
  lua_setfield(L, -2, "__index");
  lua_pushstring(L, "__gc");
  lua_pushcfunction(L, encseq_lua_delete_buffer);
  lua_settable(L, -3);
  lua_pop(L, 1);

  luaL_newmetatable(L, ENCSEQ_READER_METATABLE);
  lua_pushvalue(L, -1); /* duplicate the metatable */
  lua_setfield(L, -2, "__index");
  lua_pushstring(L, "__gc");
  lua_pushcfunction(L, encseq_reader_lua_delete);
  lua_settable(L, -3);
  luaL_register(L, NULL, encseq_reader_lib_m);
  gt_lua_export_metatable(L, ENCSEQ_READER_METATABLE);

  luaL_newmetatable(L, ENCSEQ_ENCODER_METATABLE);
  lua_pushvalue(L, -1); /* duplicate the metatable */
  lua_setfield(L, -2, "__index");
  lua_pushstring(L, "__gc");
  lua_pushcfunction(L, encseq_encoder_lua_delete);
  lua_settable(L, -3);
  luaL_register(L, NULL, encseq_encoder_lib_m);
  gt_lua_export_metatable(L, ENCSEQ_ENCODER_METATABLE);

  luaL_newmetatable(L, ENCSEQ_LOADER_METATABLE);
  lua_pushvalue(L, -1); /* duplicate the metatable */
  lua_setfield(L, -2, "__index");
  lua_pushstring(L, "__gc");
  lua_pushcfunction(L, encseq_loader_lua_delete);
  lua_settable(L, -3);
  luaL_register(L, NULL, encseq_loader_lib_m);
  gt_lua_export_metatable(L, ENCSEQ_LOADER_METATABLE);

  luaL_newmetatable(L, ENCSEQ_BUILDER_METATABLE);
  lua_pushvalue(L, -1); /* duplicate the metatable */
  lua_setfield(L, -2, "__index");
  lua_pushstring(L, "__gc");
  lua_pushcfunction(L, encseq_builder_lua_delete);
  lua_settable(L, -3);
  luaL_register(L, NULL, encseq_builder_lib_m);
  gt_lua_export_metatable(L, ENCSEQ_BUILDER_METATABLE);

  luaL_register(L, "gt", encseq_lib_f);
  lua_pop(L, 1);
  gt_assert(lua_gettop(L) == stack_size);
  return 1;
}