Random Chitchat 2017 - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Off Topic (https://forum.cuberite.org/forum-9.html) +--- Forum: Off Topic Discussion (https://forum.cuberite.org/forum-10.html) +--- Thread: Random Chitchat 2017 (/thread-2727.html) |
RE: Random Chitchat 2017 - LogicParrot - 08-05-2017 Ping! RE: Random Chitchat 2017 - Mathias - 08-05-2017 Pong! RE: Random Chitchat 2017 - xoft - 08-07-2017 Ufff, I go away for a few days and get like 150 notifications on GitHub and the forum. Well better get used to it, I'm leaving again for a vacation. RE: Random Chitchat 2017 - NiLSPACE - 08-07-2017 Enjoy your holiday! RE: Random Chitchat 2017 - tigerw - 08-08-2017 I gave up trying. RE: Random Chitchat 2017 - xoft - 08-09-2017 So now instead of writing Cuberite code, or at least reviewing Cuberite code, I'm stuck babysitting my year-old niece. While the rest of the family are in a chateau for the tour, I'm walking the gardens with the stroller. Apparently, my dance-influenced gait has the perfect rhythm for making her fall asleep. Well, at least I don't have to endure one of those super-boring lectures about the owners of the chateau, who: a, lost it in drinking, or b, lost it in a bet, or c, lost it in a war, or d, lost it in a marriage; god I hate those even worse than reviewing the entity-ownership PR RE: Random Chitchat 2017 - xoft - 08-14-2017 I think I have a great new revolutionary way of writing API bindings. I'll polish things up and try to rewrite a few manual bindings to verify it works, but then it should be a breeze to add new bindings. Possibly even the ToLua++-generated bindings could be rewritten to use the new way. Basically, you can now do this: int someBindingFunction(lua_State * a_LuaState) { cLuaState L(a_LuaState); int overloadUsed; cPlayer * self; int paramI1, paramI2, paramI3; AString paramS1, paramS2; L.ReadParams(overloadUsed, std::tie(self, paramI1, paramS1), std::tie(self, paramI1, paramI2, paramS1), std::tie(self, paramI1, paramS1, paramI2), std::tie(self, paramI1, paramI2, paramS1, paramS2, paramI3) ); // Reads all params, chooses the right overload, reports any errors if none matches switch (overloadUsed) { case 0: { // paramI1, paramS1 are valid break; } case 1: { // paramI1, paramI2, paramS1 are valid break; } case 2: { // paramI1, paramS1, paramI2 are valid break; } case 3: { // paramI1, paramI2, paramS1, paramS2, paramI3 are valid break; } } } RE: Random Chitchat 2017 - NiLSPACE - 08-14-2017 That looks great! I assume it returns something like -1 when it doesn't match anything? What would we gain when using this in the ToLua++-generated bindings though? Except readability of course. RE: Random Chitchat 2017 - xoft - 08-15-2017 If there's no match, it doesn't return; it raises a Lua error instead, which basically throws an exception that is caught by the code that called into Lua and prints the plugin error message. Internally, it uses cLuaState::ApiParamError() to do all that. In the long run, I'd like to get rid of the ToLua++ parser and replace it with bindings description (something like APIDesc is now), from which a Lua script would generate the C++ bindings and the documentation simultaneously. And the CuberitePluginChecker could use it to simulate plugins, too. That way, we'd have guaranteed documentation for all API symbols, less manual exports and we'll get rid of the hacks we currently need in order for ToLua++ to parse the code. RE: Random Chitchat 2017 - xoft - 08-15-2017 Fuuuu, template meta-programming is hard. I just cannot seem to get it right. I'm trying to use std::enable_if<std::is_integral<...>> and the compiler still complains. Worst thing, MSVC2013 complains by "unknown compiler error" most of the time |