Random Chitchat 2017
Ping!
Thanks given by:
Pong!
Thanks given by:
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.
Thanks given by:
Enjoy your holiday! Smile
Thanks given by:
[Image: attachment.php?aid=753]

I gave up trying.


Attached Files
.png   I've given up already.PNG (Size: 689 bytes / Downloads: 430)
Thanks given by:
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 PRBig Grin
Thanks given by:
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;
   }
 }
}
Thanks given by:
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 courseTongue.
Thanks given by:
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.
Thanks given by: NiLSPACE
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 Sad
Thanks given by:




Users browsing this thread: 2 Guest(s)