Tarantool development patches archive
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tml <tarantool-patches@dev.tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH v10 2/4] module_cache: move module handling into own subsystem
Date: Mon, 16 Nov 2020 17:41:57 +0300	[thread overview]
Message-ID: <20201116144157.GP2021@grain> (raw)
In-Reply-To: <4b185545-84c6-86d4-b89c-5059344d55c4@tarantool.org>

On Thu, Nov 12, 2020 at 11:54:01PM +0100, Vladislav Shpilevoy wrote:
> > +
> > +/**
> > + * Find a path to a module using Lua's package.cpath.
> > + */
> > +static int
> > +module_find(struct module_find_ctx *ctx)
> > +{
> 
> 2. In the original code the function took package name and
> path, which was way more clear than a ctx. Which in the
> old code was constructed inside of this function.
> 
> But you somewhy moved it to the caller code, to module_load(),
> which creates the ctx just to call module_find(), and never
> uses it again. So what was the point? I honestly do not
> understand.

Some more details on this function. Previously we have

static int
module_find(const char *package, const char *package_end, char *path,
	    size_t path_len)
{
	struct module_find_ctx ctx = { package, package_end, path, path_len };
	lua_State *L = tarantool_L;
	int top = lua_gettop(L);
	if (luaT_cpcall(L, luaT_module_find, &ctx) != 0) {
	...
}

The caller provides *all* 4 parameters which are then packed into
module_find_ctx and sent to luaT_cpcall. The luaT_cpcall extracts
them and fills the @path inside.

Thus instead of passing module_find_ctx right from the point where
path[] and path_len are allocated (ie just one argument) we pass
4 instead, for absolutely no reason. So bloody ugly :( I simply
fixed it since I'm reworking this code.

If you prefer I can do such transition as a separate patch before
moving code into new place.

  parent reply	other threads:[~2020-11-16 14:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 15:18 [Tarantool-patches] [PATCH v10 0/4] box/cbox: implement cfunc Lua module Cyrill Gorcunov
2020-11-05 15:18 ` [Tarantool-patches] [PATCH v10 1/4] box/func: factor out c function entry structure Cyrill Gorcunov
2020-11-12 22:53   ` Vladislav Shpilevoy
2020-11-13 17:56     ` Cyrill Gorcunov
2020-11-05 15:18 ` [Tarantool-patches] [PATCH v10 2/4] module_cache: move module handling into own subsystem Cyrill Gorcunov
2020-11-12 22:54   ` Vladislav Shpilevoy
2020-11-16  9:54     ` Cyrill Gorcunov
2020-11-16 14:41     ` Cyrill Gorcunov [this message]
2020-11-05 15:18 ` [Tarantool-patches] [PATCH v10 3/4] box/cbox: implement cbox Lua module Cyrill Gorcunov
2020-11-12 22:53   ` Vladislav Shpilevoy
2020-11-16 20:26     ` Cyrill Gorcunov
2020-11-05 15:18 ` [Tarantool-patches] [PATCH v10 4/4] test: box/cfunc -- add simple module test Cyrill Gorcunov
2020-11-12 22:53 ` [Tarantool-patches] [PATCH v10 0/4] box/cbox: implement cfunc Lua module Vladislav Shpilevoy
2020-11-13 17:54   ` Cyrill Gorcunov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201116144157.GP2021@grain \
    --to=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v10 2/4] module_cache: move module handling into own subsystem' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox