/* * Baltisot * Copyright (C) 1999-2008 Nicolas "Pixel" Noble * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "LuaConfigFile.h" class LuaConfigSectionContents : public LuaObject { public: static void pushstatics(Lua *) throw (GeneralException); LuaConfigSectionContents(ConfigSectionContents *); protected: virtual void pushmembers(Lua *); ConfigSectionContents * c; }; LuaConfigFile::LuaConfigFile(ConfigFile * _c) : c(_c) { } enum ConfigFile_methods_t { CONFIGFILE_INDEX = 0, CONFIGFILE_NEWINDEX, }; enum ConfigFile_functions_t { CONFIGFILE_NEWCONFIGFILE = 0, }; struct lua_functypes_t ConfigFile_methods[] = { { CONFIGFILE_INDEX, "index", 1, 1, { BLUA_STRING } }, { CONFIGFILE_NEWINDEX, "newindex", 1, 1, { BLUA_ANY } }, { -1, 0, 0, 0, 0 } }; struct lua_functypes_t ConfigFile_functions[] = { { CONFIGFILE_NEWCONFIGFILE, "ConfigFile" , 1, 1, { BLUA_OBJECT } }, { -1, 0, 0, 0, 0 } }; class sLua_ConfigFile : public Base { public: DECLARE_METHOD(ConfigFile, CONFIGFILE_INDEX); DECLARE_METHOD(ConfigFile, CONFIGFILE_NEWINDEX); DECLARE_FUNCTION(ConfigFile, CONFIGFILE_NEWCONFIGFILE); private: static int ConfigFile_proceed(Lua * L, int n, ConfigFile * obj, int caller); static int ConfigFile_proceed_statics(Lua * L, int n, int caller); }; void LuaConfigFile::pushmembers(Lua * L) { pushme(L, c, "ConfigFile"); PUSH_METAMETHOD(ConfigFile, CONFIGFILE_INDEX); PUSH_METAMETHOD(ConfigFile, CONFIGFILE_NEWINDEX); } void LuaConfigFile::pushstatics(Lua * L) throw (GeneralException) { CHECK_METHODS(ConfigFile); CHECK_FUNCTIONS(ConfigFile); PUSH_FUNCTION(ConfigFile, CONFIGFILE_NEWCONFIGFILE); LuaConfigSectionContents::pushstatics(L); } int sLua_ConfigFile::ConfigFile_proceed(Lua * L, int n, ConfigFile * c, int caller) { String i; switch (caller) { case CONFIGFILE_INDEX: i = L->tostring(2); { LuaConfigSectionContents csc(&((*c)[i])); csc.push(L); } break; case CONFIGFILE_NEWINDEX: L->error("ConfigFile is read only."); break; } return 1; } int sLua_ConfigFile::ConfigFile_proceed_statics(Lua * L, int n, int caller) { Handle * h; switch (caller) { case CONFIGFILE_NEWCONFIGFILE: h = L->recast(1); { LuaConfigFile c(new ConfigFile(h)); c.pushdestruct(L); } break; } return 1; } LuaConfigSectionContents::LuaConfigSectionContents(ConfigSectionContents * _c) : c(_c) { } enum ConfigSectionContents_methods_t { CONFIGSECTIONCONTENTS_INDEX = 0, CONFIGSECTIONCONTENTS_NEWINDEX, }; struct lua_functypes_t ConfigSectionContents_methods[] = { { CONFIGSECTIONCONTENTS_INDEX, "index", 1, 1, { BLUA_STRING } }, { CONFIGSECTIONCONTENTS_NEWINDEX, "newindex", 1, 1, { BLUA_ANY } }, { -1, 0, 0, 0, 0 } }; class sLua_ConfigSectionContents : public Base { public: DECLARE_METHOD(ConfigSectionContents, CONFIGSECTIONCONTENTS_INDEX); DECLARE_METHOD(ConfigSectionContents, CONFIGSECTIONCONTENTS_NEWINDEX); private: static int ConfigSectionContents_proceed(Lua * L, int n, ConfigSectionContents * obj, int caller); static int ConfigSectionContents_proceed_statics(Lua * L, int n, int caller); }; void LuaConfigSectionContents::pushmembers(Lua * L) { pushme(L, c, "ConfigSectionContents"); PUSH_METAMETHOD(ConfigSectionContents, CONFIGSECTIONCONTENTS_INDEX); PUSH_METAMETHOD(ConfigSectionContents, CONFIGSECTIONCONTENTS_NEWINDEX); } void LuaConfigSectionContents::pushstatics(Lua * L) throw (GeneralException) { CHECK_METHODS(ConfigSectionContents); } int sLua_ConfigSectionContents::ConfigSectionContents_proceed(Lua * L, int n, ConfigSectionContents * c, int caller) { String i; switch (caller) { case CONFIGSECTIONCONTENTS_INDEX: i = L->tostring(2); L->push((*c)[i]); break; case CONFIGSECTIONCONTENTS_NEWINDEX: L->error("ConfigSectionContents is read only."); break; } return 1; }