lua/decimal: rework luaT_{new,push}decimal() API
`luaT_pushdecimal()` now accepts a decimal argument to copy into the Lua managed memory. `luaT_newdecimal()` now doing what `luaT_pushdecimal()` did before: just allocates a storage for decimal on the Lua stack. This naming looks much more friendly. It also seems that it follow Lua API names: `lua_push*()` accepts what to push, `lua_new*()` doesn't. A couple of notes around the change: * On the first glance it seems that `luaT_pushdecimal()` is redundant, because it can be written using `luaT_newdecimal()` + copying. That's truth in contexts, where we know size of the internal `decimal_t` structure. A user of the module API don't know it and should pass `box_decimal_t *` pointer to `luaT_pushdecimal()` to write the value. * I use `memcpy()` instead of just `*a = *b` in `luaT_pushdecimal()` to copy the padding byte content. Who knows, maybe this not-so-legal way to hold extra information may be crucial for some use case or will allow us to add one field into the structure. This is preparatory commit for exposing `luaT_*decimal()` functions into the module API. Next commits will change uuid, datetime, interval functions in the same way. Part of #7228 NO_DOC=refactoring, no user-visible changes NO_TEST=will be tested in a next commit, after exposing to the module API NO_CHANGELOG=refactoring, no user-visible changes
Loading
Please register or sign in to comment