diff -r f6f6d3093bea code/ryzom/client/src/interface_v3/lua_ihm.cpp --- a/code/ryzom/client/src/interface_v3/lua_ihm.cpp Sun May 09 08:11:26 2010 +0200 +++ b/code/ryzom/client/src/interface_v3/lua_ihm.cpp Sun May 09 15:48:54 2010 +0200 @@ -441,12 +441,12 @@ // *************************************************************************** #define LUA_REGISTER_BASIC(_type_) \ -yes_t is_user_defined(by_value<_type_>); \ -_type_ convert_lua_to_cpp(lua_State* L, by_value<_type_>, int index) \ +luabind::detail::yes_t is_user_defined(luabind::detail::by_value<_type_>); \ +_type_ convert_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \ { \ return (_type_)lua_tonumber(L, index); \ } \ -int match_lua_to_cpp(lua_State* L, by_value<_type_>, int index) \ +int match_lua_to_cpp(lua_State* L, luabind::detail::by_value<_type_>, int index) \ { \ if (lua_isnumber(L, index)) return 0; else return -1; \ } \ @@ -476,6 +476,8 @@ { //H_AUTO(Lua_CLuaIHM_registerBasics) using namespace luabind; + using namespace luabind::detail; + lua_State *L= ls.getStatePointer(); // RGBA @@ -1193,18 +1195,20 @@ } #define LUABIND_ENUM(__enum__, __name__, __num__, __toStringFunc__) \ - createLuaEnumTable(ls, __name__); \ for (uint e=0 ; e<__num__ ; e++) \ { \ - std::string str = __toStringFunc__((__enum__)e); \ - std::string temp = __name__ + toString(".") + __toStringFunc__((__enum__)e) + " = " + toString("%d;", e); \ - ls.executeScript(temp); \ - } \ + luabind::module(L) [ \ + luabind::class_<__enum__>(__name__).enum_("constants") [ \ + value(__toStringFunc__((__enum__)e), (__enum__)e), \ + ] \ + ]; \ + } // *************************************************************************** -#define LUABIND_FUNC(__func__) luabind::function(L, #__func__, &__func__); +#define LUABIND_FUNC(__func__) luabind::def(#__func__, &__func__) void CLuaIHM::registerIHM(CLuaState &ls) { + using namespace luabind; //H_AUTO(Lua_CLuaIHM_registerIHM) CLuaStackChecker lsc(&ls); @@ -1323,89 +1327,92 @@ ls.registerFunc("getUserRace", getUserRace); // Through LUABind API lua_State *L= ls.getStatePointer(); - LUABIND_FUNC(getDbProp); - LUABIND_FUNC(setDbProp); - LUABIND_FUNC(debugInfo); - LUABIND_FUNC(rawDebugInfo); - LUABIND_FUNC(dumpCallStack); - LUABIND_FUNC(getDefine); - LUABIND_FUNC(setContextHelpText); - luabind::function(L, "messageBox", (void(*)(const ucstring &)) &messageBox); - luabind::function(L, "messageBox", (void(*)(const ucstring &, const std::string &)) &messageBox); - luabind::function(L, "messageBox", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBox); - luabind::function(L, "messageBox", (void(*)(const std::string &)) &messageBox); - luabind::function(L, "messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp); - luabind::function(L, "messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp); - luabind::function(L, "messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp); - luabind::function(L, "messageBoxWithHelp", (void(*)(const std::string &)) &messageBoxWithHelp); - luabind::function(L, "findReplaceAll", (std::string(*)(const std::string &, const std::string &, const std::string &)) &findReplaceAll); - luabind::function(L, "findReplaceAll", (ucstring(*)(const ucstring &, const ucstring &, const ucstring &)) &findReplaceAll); - luabind::function(L, "findReplaceAll", (ucstring(*)(const ucstring &, const std::string &, const std::string &)) &findReplaceAll); - luabind::function(L, "findReplaceAll", (ucstring(*)(const ucstring &, const ucstring &, const std::string &)) &findReplaceAll); - luabind::function(L, "findReplaceAll", (ucstring(*)(const ucstring &, const std::string &, const ucstring &)) &findReplaceAll); - LUABIND_FUNC(getPlayerSelectedSlot) - LUABIND_FUNC(isInGame) - LUABIND_FUNC(pauseBGDownloader); - LUABIND_FUNC(unpauseBGDownloader); - LUABIND_FUNC(requestBGDownloaderPriority); - LUABIND_FUNC(getBGDownloaderPriority); - LUABIND_FUNC(getPatchLastErrorMessage); - LUABIND_FUNC(isPlayerSlotNewbieLand) - LUABIND_FUNC(getSkillIdFromName); - LUABIND_FUNC(getSkillLocalizedName); - LUABIND_FUNC(getMaxSkillValue); - LUABIND_FUNC(getBaseSkillValueMaxChildren); - LUABIND_FUNC(getMagicResistChance); - LUABIND_FUNC(getDodgeParryChance); - LUABIND_FUNC(browseNpcWebPage); - LUABIND_FUNC(clearHtmlUndoRedo); - LUABIND_FUNC(getDynString); - LUABIND_FUNC(isDynStringAvailable); - LUABIND_FUNC(isFullyPatched); - LUABIND_FUNC(getSheetType); - LUABIND_FUNC(getSheetName); - LUABIND_FUNC(getFameIndex); - LUABIND_FUNC(getFameName); - LUABIND_FUNC(getFameDBIndex); - LUABIND_FUNC(getFirstTribeFameIndex); - LUABIND_FUNC(getNbTribeFameIndex); - LUABIND_FUNC(getClientCfg); - LUABIND_FUNC(fileExists); - LUABIND_FUNC(sendMsgToServer); - LUABIND_FUNC(sendMsgToServerPvpTag); - LUABIND_FUNC(isGuildQuitAvailable); - LUABIND_FUNC(sortGuildMembers); - LUABIND_FUNC(getNbGuildMembers); - LUABIND_FUNC(getGuildMemberName); - LUABIND_FUNC(getGuildMemberGrade); - LUABIND_FUNC(isR2Player); - LUABIND_FUNC(getR2PlayerRace); - LUABIND_FUNC(isR2PlayerMale); - LUABIND_FUNC(getCharacterSheetSkel); - LUABIND_FUNC(getSheetId) - LUABIND_FUNC(getCharacterSheetRegionForce) - LUABIND_FUNC(getCharacterSheetRegionLevel) - LUABIND_FUNC(replacePvpEffectParam); - LUABIND_FUNC(getRegionByAlias); - LUABIND_FUNC(tell); - LUABIND_FUNC(isRingAccessPointInReach); - LUABIND_FUNC(updateTooltipCoords); - LUABIND_FUNC(secondsSince1970ToHour); - LUABIND_FUNC(isCtrlKeyDown); - LUABIND_FUNC(encodeURLUnicodeParam); - - LUABIND_ENUM(PVP_CLAN::TPVPClan, "game.TPVPClan", PVP_CLAN::NbClans, PVP_CLAN::toString) - LUABIND_ENUM(BONUS_MALUS::TBonusMalusSpecialTT, "game.TBonusMalusSpecialTT", BONUS_MALUS::NbSpecialTT, BONUS_MALUS::toString) - - LUABIND_FUNC(getPlayerLevel); - LUABIND_FUNC(getTargetLevel); - LUABIND_FUNC(getTargetForceRegion); - LUABIND_FUNC(getTargetLevelForce); - LUABIND_FUNC(isTargetNPC) - LUABIND_FUNC(isTargetPlayer) // return 'true' if the target is an npc - LUABIND_FUNC(isTargetUser) - LUABIND_FUNC(isPlayerInPVPMode) - LUABIND_FUNC(isTargetInPVPMode) + luabind::module(L) + [ + LUABIND_FUNC(getDbProp), + LUABIND_FUNC(setDbProp), + LUABIND_FUNC(debugInfo), + LUABIND_FUNC(rawDebugInfo), + LUABIND_FUNC(dumpCallStack), + LUABIND_FUNC(getDefine), + LUABIND_FUNC(setContextHelpText), + luabind::def("messageBox", (void(*)(const ucstring &)) &messageBox), + luabind::def("messageBox", (void(*)(const ucstring &, const std::string &)) &messageBox), + luabind::def("messageBox", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBox), + luabind::def("messageBox", (void(*)(const std::string &)) &messageBox), + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &)) &messageBoxWithHelp), + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp), + luabind::def("messageBoxWithHelp", (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp), + luabind::def("messageBoxWithHelp", (void(*)(const std::string &)) &messageBoxWithHelp), + luabind::def("findReplaceAll", (std::string(*)(const std::string &, const std::string &, const std::string &)) &findReplaceAll), + luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const ucstring &, const ucstring &)) &findReplaceAll), + luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const std::string &, const std::string &)) &findReplaceAll), + luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const ucstring &, const std::string &)) &findReplaceAll), + luabind::def("findReplaceAll", (ucstring(*)(const ucstring &, const std::string &, const ucstring &)) &findReplaceAll), + LUABIND_FUNC(getPlayerSelectedSlot), + LUABIND_FUNC(isInGame), + LUABIND_FUNC(pauseBGDownloader), + LUABIND_FUNC(unpauseBGDownloader), + LUABIND_FUNC(requestBGDownloaderPriority), + LUABIND_FUNC(getBGDownloaderPriority), + LUABIND_FUNC(getPatchLastErrorMessage), + LUABIND_FUNC(isPlayerSlotNewbieLand), + LUABIND_FUNC(getSkillIdFromName), + LUABIND_FUNC(getSkillLocalizedName), + LUABIND_FUNC(getMaxSkillValue), + LUABIND_FUNC(getBaseSkillValueMaxChildren), + LUABIND_FUNC(getMagicResistChance), + LUABIND_FUNC(getDodgeParryChance), + LUABIND_FUNC(browseNpcWebPage), + LUABIND_FUNC(clearHtmlUndoRedo), + LUABIND_FUNC(getDynString), + LUABIND_FUNC(isDynStringAvailable), + LUABIND_FUNC(isFullyPatched), + LUABIND_FUNC(getSheetType), + LUABIND_FUNC(getSheetName), + LUABIND_FUNC(getFameIndex), + LUABIND_FUNC(getFameName), + LUABIND_FUNC(getFameDBIndex), + LUABIND_FUNC(getFirstTribeFameIndex), + LUABIND_FUNC(getNbTribeFameIndex), + LUABIND_FUNC(getClientCfg), + LUABIND_FUNC(fileExists), + LUABIND_FUNC(sendMsgToServer), + LUABIND_FUNC(sendMsgToServerPvpTag), + LUABIND_FUNC(isGuildQuitAvailable), + LUABIND_FUNC(sortGuildMembers), + LUABIND_FUNC(getNbGuildMembers), + LUABIND_FUNC(getGuildMemberName), + LUABIND_FUNC(getGuildMemberGrade), + LUABIND_FUNC(isR2Player), + LUABIND_FUNC(getR2PlayerRace), + LUABIND_FUNC(isR2PlayerMale), + LUABIND_FUNC(getCharacterSheetSkel), + LUABIND_FUNC(getSheetId), + LUABIND_FUNC(getCharacterSheetRegionForce), + LUABIND_FUNC(getCharacterSheetRegionLevel), + LUABIND_FUNC(replacePvpEffectParam), + LUABIND_FUNC(getRegionByAlias), + LUABIND_FUNC(tell), + LUABIND_FUNC(isRingAccessPointInReach), + LUABIND_FUNC(updateTooltipCoords), + LUABIND_FUNC(secondsSince1970ToHour), + LUABIND_FUNC(isCtrlKeyDown), + LUABIND_FUNC(encodeURLUnicodeParam), + + LUABIND_FUNC(getPlayerLevel), + LUABIND_FUNC(getTargetLevel), + LUABIND_FUNC(getTargetForceRegion), + LUABIND_FUNC(getTargetLevelForce), + LUABIND_FUNC(isTargetNPC), + LUABIND_FUNC(isTargetPlayer), // return 'true' if the target is an npc + LUABIND_FUNC(isTargetUser), + LUABIND_FUNC(isPlayerInPVPMode), + LUABIND_FUNC(isTargetInPVPMode) + ]; + + LUABIND_ENUM(PVP_CLAN::TPVPClan, "TPVPClan", PVP_CLAN::NbClans, PVP_CLAN::toString) + LUABIND_ENUM(BONUS_MALUS::TBonusMalusSpecialTT, "TBonusMalusSpecialTT", BONUS_MALUS::NbSpecialTT, BONUS_MALUS::toString) // inside i18n table luabind::module(L, "i18n") @@ -1432,8 +1439,11 @@ #if !FINAL_VERSION - LUABIND_FUNC(openDoc) + luabind::module(L) + [ + LUABIND_FUNC(openDoc), LUABIND_FUNC(launchProgram) + ]; #endif #ifdef NL_OS_WINDOWS @@ -1450,8 +1460,11 @@ #endif } }; - luabind::function(L, "fileLookup", CMiscFunctions::fileLookup); - luabind::function(L, "shellExecute", CMiscFunctions::shellExecute); + luabind::module(L) + [ + luabind::def("fileLookup", CMiscFunctions::fileLookup), + luabind::def("shellExecute", CMiscFunctions::shellExecute) + ]; #endif }