- Use lua 5.1
- Compress *_register() functions svn path=/trunk/; revision=17354
This commit is contained in:
parent
97d857e20b
commit
c3c7f8a0c3
|
@ -111,13 +111,8 @@ static int PseudoHeader_nettl(lua_State* L) { luaL_error(L,"not implemented"); r
|
||||||
static int PseudoHeader_k12(lua_State* L) { luaL_error(L,"not implemented"); return 0; }
|
static int PseudoHeader_k12(lua_State* L) { luaL_error(L,"not implemented"); return 0; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static luaL_reg PseudoHeader_meta[] = {
|
|
||||||
{0,0}
|
|
||||||
};
|
|
||||||
|
|
||||||
int PseudoHeader_register(lua_State* L) {
|
int PseudoHeader_register(lua_State* L) {
|
||||||
luaL_newmetatable(L, PSEUDOHEADER);
|
luaL_newmetatable(L, PSEUDOHEADER);
|
||||||
luaL_openlib(L, NULL, PseudoHeader_meta, 0);
|
|
||||||
|
|
||||||
lua_pushstring(L, "PH_MTP2");
|
lua_pushstring(L, "PH_MTP2");
|
||||||
lua_pushcfunction(L, PseudoHeader_mtp2);
|
lua_pushcfunction(L, PseudoHeader_mtp2);
|
||||||
|
@ -321,24 +316,11 @@ static const luaL_reg Dumper_methods[] =
|
||||||
|
|
||||||
static const luaL_reg Dumper_meta[] =
|
static const luaL_reg Dumper_meta[] =
|
||||||
{
|
{
|
||||||
{"__index", Dumper_new},
|
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
int Dumper_register(lua_State* L) {
|
int Dumper_register(lua_State* L) {
|
||||||
|
|
||||||
dumper_encaps = g_hash_table_new(g_direct_hash,g_direct_equal);
|
dumper_encaps = g_hash_table_new(g_direct_hash,g_direct_equal);
|
||||||
|
REGISTER_FULL_CLASS(DUMPER, Dumper_methods, Dumper_meta)
|
||||||
luaL_openlib(L, DUMPER, Dumper_methods, 0);
|
|
||||||
luaL_newmetatable(L, DUMPER);
|
|
||||||
luaL_openlib(L, 0, Dumper_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,16 +362,7 @@ int TextWindow_register(lua_State* L) {
|
||||||
|
|
||||||
ops = funnel_get_funnel_ops();
|
ops = funnel_get_funnel_ops();
|
||||||
|
|
||||||
luaL_openlib(L, TEXT_WINDOW, TextWindow_methods, 0);
|
REGISTER_FULL_CLASS(TEXT_WINDOW, TextWindow_methods, TextWindow_meta);
|
||||||
luaL_newmetatable(L, TEXT_WINDOW);
|
|
||||||
luaL_openlib(L, 0, TextWindow_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,17 +300,7 @@ static const luaL_reg Address_meta[] = {
|
||||||
|
|
||||||
|
|
||||||
int Address_register(lua_State *L) {
|
int Address_register(lua_State *L) {
|
||||||
luaL_openlib(L, ADDRESS, Address_methods, 0);
|
REGISTER_FULL_CLASS(ADDRESS, Address_methods, Address_meta);
|
||||||
luaL_newmetatable(L, ADDRESS);
|
|
||||||
luaL_openlib(L, 0, Address_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,17 +459,7 @@ static const luaL_reg Column_meta[] = {
|
||||||
|
|
||||||
|
|
||||||
int Column_register(lua_State *L) {
|
int Column_register(lua_State *L) {
|
||||||
luaL_openlib(L, COLUMN, Column_methods, 0);
|
REGISTER_FULL_CLASS(COLUMN, Column_methods, Column_methods);
|
||||||
luaL_newmetatable(L, COLUMN);
|
|
||||||
luaL_openlib(L, 0, Column_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,9 +540,7 @@ static const luaL_reg Columns_meta[] = {
|
||||||
|
|
||||||
|
|
||||||
int Columns_register(lua_State *L) {
|
int Columns_register(lua_State *L) {
|
||||||
luaL_newmetatable(L, COLUMNS);
|
REGISTER_META(COLUMNS,Columns_meta);
|
||||||
luaL_openlib(L, NULL, Columns_meta, 0);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,11 +801,8 @@ static const luaL_reg Pinfo_meta[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int Pinfo_register(lua_State* L) {
|
int Pinfo_register(lua_State* L) {
|
||||||
luaL_newmetatable(L, PINFO);
|
REGISTER_META(PINFO,Pinfo_meta);
|
||||||
luaL_openlib(L, NULL, Pinfo_meta, 0);
|
|
||||||
|
|
||||||
outstanding_stuff = g_ptr_array_new();
|
outstanding_stuff = g_ptr_array_new();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,17 +119,7 @@ static const luaL_reg Pref_meta[] = {
|
||||||
|
|
||||||
|
|
||||||
static int Pref_register(lua_State* L) {
|
static int Pref_register(lua_State* L) {
|
||||||
luaL_openlib(L, PREF, Pref_methods, 0);
|
REGISTER_FULL_CLASS(PREF, Pref_methods, Pref_meta);
|
||||||
luaL_newmetatable(L, PREF);
|
|
||||||
luaL_openlib(L, 0, Pref_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,9 +228,7 @@ static const luaL_reg Prefs_meta[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int Prefs_register(lua_State* L) {
|
static int Prefs_register(lua_State* L) {
|
||||||
luaL_newmetatable(L, PREFS);
|
REGISTER_META(PREFS, Prefs_meta);
|
||||||
luaL_openlib(L, NULL, Prefs_meta, 0);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,16 +567,7 @@ int ProtoField_register(lua_State* L) {
|
||||||
const eth_ft_types_t* ts;
|
const eth_ft_types_t* ts;
|
||||||
const struct base_display_string_t* b;
|
const struct base_display_string_t* b;
|
||||||
|
|
||||||
luaL_openlib(L, PROTO_FIELD, ProtoField_methods, 0);
|
REGISTER_FULL_CLASS(PROTO_FIELD, ProtoField_methods, ProtoField_meta);
|
||||||
luaL_newmetatable(L, PROTO_FIELD);
|
|
||||||
luaL_openlib(L, 0, ProtoField_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
/* add a global FT_* variable for each FT_ type */
|
/* add a global FT_* variable for each FT_ type */
|
||||||
for (ts = ftenums; ts->str; ts++) {
|
for (ts = ftenums; ts->str; ts++) {
|
||||||
|
@ -711,17 +690,7 @@ static const luaL_reg ProtoFieldArray_meta[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int ProtoFieldArray_register(lua_State* L) {
|
int ProtoFieldArray_register(lua_State* L) {
|
||||||
luaL_openlib(L, PROTO_FIELD_ARRAY, ProtoFieldArray_methods, 0);
|
REGISTER_FULL_CLASS(PROTO_FIELD_ARRAY, ProtoFieldArray_methods, ProtoFieldArray_meta);
|
||||||
luaL_newmetatable(L, PROTO_FIELD_ARRAY);
|
|
||||||
luaL_openlib(L, 0, ProtoFieldArray_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -968,8 +937,8 @@ static const luaL_reg Proto_meta[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int Proto_register(lua_State* L) {
|
int Proto_register(lua_State* L) {
|
||||||
luaL_newmetatable(L, PROTO);
|
|
||||||
luaL_openlib(L, NULL, Proto_meta, 0);
|
REGISTER_META(PROTO, Proto_meta);
|
||||||
|
|
||||||
lua_pushstring(L, "register_postdissector");
|
lua_pushstring(L, "register_postdissector");
|
||||||
lua_pushcfunction(L, Proto_register_postdissector);
|
lua_pushcfunction(L, Proto_register_postdissector);
|
||||||
|
@ -1046,17 +1015,7 @@ static const luaL_reg Dissector_meta[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int Dissector_register(lua_State* L) {
|
int Dissector_register(lua_State* L) {
|
||||||
luaL_openlib(L, DISSECTOR, Dissector_methods, 0);
|
REGISTER_FULL_CLASS(DISSECTOR, Dissector_methods, Dissector_meta);
|
||||||
luaL_newmetatable(L, DISSECTOR);
|
|
||||||
luaL_openlib(L, 0, Dissector_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,17 +1269,7 @@ static const luaL_reg DissectorTable_meta[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int DissectorTable_register(lua_State* L) {
|
int DissectorTable_register(lua_State* L) {
|
||||||
luaL_openlib(L, DISSECTOR_TABLE, DissectorTable_methods, 0);
|
REGISTER_FULL_CLASS(DISSECTOR_TABLE, DissectorTable_methods, DissectorTable_meta);
|
||||||
luaL_newmetatable(L, DISSECTOR_TABLE);
|
|
||||||
luaL_openlib(L, 0, DissectorTable_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,8 +201,7 @@ int Field_register(lua_State* L) {
|
||||||
|
|
||||||
wanted_fields = g_ptr_array_new();
|
wanted_fields = g_ptr_array_new();
|
||||||
|
|
||||||
luaL_newmetatable(L, FIELD);
|
REGISTER_META(FIELD, Field_meta);
|
||||||
luaL_openlib(L, 0, Field_meta, 0);
|
|
||||||
|
|
||||||
lua_pushstring(L, "Field");
|
lua_pushstring(L, "Field");
|
||||||
lua_pushcfunction(L, Field_get);
|
lua_pushcfunction(L, Field_get);
|
||||||
|
@ -476,18 +475,12 @@ static const luaL_reg Tap_meta[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int Tap_register(lua_State* L) {
|
int Tap_register(lua_State* L) {
|
||||||
luaL_newmetatable(L, TAP);
|
REGISTER_META(TAP, Tap_meta);
|
||||||
luaL_openlib(L, 0, Tap_meta, 0);
|
|
||||||
|
|
||||||
|
lua_pushstring(L, "Tap");
|
||||||
lua_pushstring(L, "new_tap");
|
|
||||||
lua_pushcfunction(L, Tap_new);
|
lua_pushcfunction(L, Tap_new);
|
||||||
lua_settable(L, LUA_GLOBALSINDEX);
|
lua_settable(L, LUA_GLOBALSINDEX);
|
||||||
|
|
||||||
lua_pushstring(L, "remove_tap");
|
|
||||||
lua_pushcfunction(L, Tap_remove);
|
|
||||||
lua_settable(L, LUA_GLOBALSINDEX);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,17 +110,7 @@ static const luaL_reg SubTree_meta[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int SubTree_register(lua_State* L) {
|
int SubTree_register(lua_State* L) {
|
||||||
luaL_openlib(L, SUBTREE, SubTree_methods, 0);
|
REGISTER_FULL_CLASS(SUBTREE, SubTree_methods, SubTree_meta);
|
||||||
luaL_newmetatable(L, SUBTREE);
|
|
||||||
luaL_openlib(L, 0, SubTree_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,17 +279,7 @@ static const luaL_reg ProtoTree_meta[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int ProtoTree_register(lua_State* L) {
|
int ProtoTree_register(lua_State* L) {
|
||||||
luaL_openlib(L, PROTO_TREE, ProtoTree_methods, 0);
|
REGISTER_FULL_CLASS(PROTO_TREE, ProtoTree_methods, ProtoTree_meta);
|
||||||
luaL_newmetatable(L, PROTO_TREE);
|
|
||||||
luaL_openlib(L, 0, ProtoTree_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,17 +461,7 @@ static const luaL_reg ProtoItem_meta[] = {
|
||||||
int ProtoItem_register(lua_State *L) {
|
int ProtoItem_register(lua_State *L) {
|
||||||
const struct _expert_severity* s;
|
const struct _expert_severity* s;
|
||||||
|
|
||||||
luaL_openlib(L, ITEM, ProtoItem_methods, 0);
|
REGISTER_FULL_CLASS(ITEM, ProtoItem_methods, ProtoItem_meta);
|
||||||
luaL_newmetatable(L, ITEM);
|
|
||||||
luaL_openlib(L, 0, ProtoItem_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
outstanding_stuff = g_ptr_array_new();
|
outstanding_stuff = g_ptr_array_new();
|
||||||
|
|
||||||
for(s = severities; s->str; s++) {
|
for(s = severities; s->str; s++) {
|
||||||
|
|
|
@ -253,17 +253,7 @@ static const luaL_reg ByteArray_meta[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int ByteArray_register(lua_State* L) {
|
int ByteArray_register(lua_State* L) {
|
||||||
luaL_openlib(L, BYTE_ARRAY, ByteArray_methods, 0);
|
REGISTER_FULL_CLASS(BYTE_ARRAY, ByteArray_methods, ByteArray_methods);
|
||||||
luaL_newmetatable(L, BYTE_ARRAY);
|
|
||||||
luaL_openlib(L, 0, ByteArray_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,17 +401,7 @@ static const luaL_reg Tvb_meta[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int Tvb_register(lua_State* L) {
|
int Tvb_register(lua_State* L) {
|
||||||
luaL_openlib(L, TVB, Tvb_methods, 0);
|
REGISTER_FULL_CLASS(TVB, Tvb_methods, Tvb_meta);
|
||||||
luaL_newmetatable(L, TVB);
|
|
||||||
luaL_openlib(L, 0, Tvb_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,19 +707,7 @@ static const luaL_reg TvbRange_meta[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int TvbRange_register(lua_State* L) {
|
int TvbRange_register(lua_State* L) {
|
||||||
|
|
||||||
outstanding_stuff = g_ptr_array_new();
|
outstanding_stuff = g_ptr_array_new();
|
||||||
|
REGISTER_FULL_CLASS(TVB_RANGE, TvbRange_methods, TvbRange_meta);
|
||||||
luaL_openlib(L, TVB_RANGE, TvbRange_methods, 0);
|
|
||||||
luaL_newmetatable(L, TVB_RANGE);
|
|
||||||
luaL_openlib(L, 0, TvbRange_meta, 0);
|
|
||||||
lua_pushliteral(L, "__index");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pushliteral(L, "__metatable");
|
|
||||||
lua_pushvalue(L, -3);
|
|
||||||
lua_rawset(L, -3);
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,15 +307,7 @@ void register_lua(void) {
|
||||||
G_LOG_LEVEL_DEBUG,
|
G_LOG_LEVEL_DEBUG,
|
||||||
ops ? ops->logger : basic_logger, NULL);
|
ops ? ops->logger : basic_logger, NULL);
|
||||||
|
|
||||||
/* initialize the lua machine */
|
INIT_LUA(L);
|
||||||
|
|
||||||
L = lua_open();
|
|
||||||
|
|
||||||
/* load lua's standard library */
|
|
||||||
luaopen_base(L);
|
|
||||||
luaopen_table(L);
|
|
||||||
luaopen_io(L);
|
|
||||||
luaopen_string(L);
|
|
||||||
|
|
||||||
/* load ethereal's API */
|
/* load ethereal's API */
|
||||||
ProtoField_register(L);
|
ProtoField_register(L);
|
||||||
|
|
|
@ -211,6 +211,48 @@ C shift##C(lua_State* L,int i) { \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_LUA_5_1
|
||||||
|
|
||||||
|
#define REGISTER_FULL_CLASS(CN,methods,meta) { \
|
||||||
|
luaL_register (L, CN, methods); \
|
||||||
|
luaL_newmetatable (L, CN); \
|
||||||
|
luaL_register (L, NULL, meta); \
|
||||||
|
lua_pushliteral(L, "__index"); \
|
||||||
|
lua_pushvalue(L, -3); \
|
||||||
|
lua_rawset(L, -3); \
|
||||||
|
lua_pushliteral(L, "__metatable"); \
|
||||||
|
lua_pushvalue(L, -3); \
|
||||||
|
lua_rawset(L, -3); \
|
||||||
|
lua_pop(L, 1); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define REGISTER_META(CN,meta) luaL_newmetatable (L, CN); luaL_register (L, NULL, meta);
|
||||||
|
|
||||||
|
#define INIT_LUA(L) L = luaL_newstate(); luaL_openlibs(L);
|
||||||
|
|
||||||
|
#else /* Lua 5.0 */
|
||||||
|
|
||||||
|
#define REGISTER_FULL_CLASS(CN,methods,meta) { \
|
||||||
|
luaL_openlib(L, CN, methods, 0); \
|
||||||
|
luaL_newmetatable(L, CN); \
|
||||||
|
luaL_openlib(L, 0, meta, 0); \
|
||||||
|
lua_pushliteral(L, "__index"); \
|
||||||
|
lua_pushvalue(L, -3); \
|
||||||
|
lua_rawset(L, -3); \
|
||||||
|
lua_pushliteral(L, "__metatable"); \
|
||||||
|
lua_pushvalue(L, -3); \
|
||||||
|
lua_rawset(L, -3); \
|
||||||
|
lua_pop(L, 1); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define REGISTER_META(CN,meta) luaL_newmetatable (L, CN); luaL_openlib (L, NULL, meta, 0);
|
||||||
|
|
||||||
|
#define INIT_LUA(L) L = lua_open(); luaopen_base(L); luaopen_table(L); luaopen_io(L); luaopen_string(L);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern packet_info* lua_pinfo;
|
extern packet_info* lua_pinfo;
|
||||||
extern proto_tree* lua_tree;
|
extern proto_tree* lua_tree;
|
||||||
extern tvbuff_t* lua_tvb;
|
extern tvbuff_t* lua_tvb;
|
||||||
|
|
Loading…
Reference in New Issue