zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <psprint@zdharma.org>
To: Bart Schaefer <schaefer@brasslantern.com>, zsh-workers@zsh.org
Subject: Re: Return value from execstring(), or construct Options for a builtin?
Date: Thu, 8 Jun 2017 12:04:06 +0200	[thread overview]
Message-ID: <etPan.59392116.2eb141f2.8e19@MacMini.local> (raw)
In-Reply-To: <170607091113.ZM17152@torch.brasslantern.com>

On 7 czerwca 2017 at 18:11:30, Bart Schaefer (schaefer@brasslantern.com) wrote:
> On Jun 7, 12:20pm, Sebastian Gniazdowski wrote:
> }
> } backend_cmd = "zrtie"; // (or "zgtie")
> } execstring(backend_cmd, 1, 0, "ztie");
>  
> I believe this is very much the wrong way to do this (even though I
> suggested it as a solution for a different specific problem).

I tried the parameter-way, to pass to backend via ZSH_DATABASE_SPEC. No problem with builtintab searching, it's fixed.

> The right thing would be to handle this the way that ZLE entry points
> are managed (see Src/init.c:zleentry), with one module to contain ztie
> and related functions which makes an entry point call back to the chosen
> backend module.

I depend on coffee, which has ended for today, worked for 6 hours on the zleentry-way, I think I got it. I declare the following in db.c:

/* For casts, as below mod_export variables are void-no-arguments */
typedef int (*DbBackendEntryPoint)(VA_ALIST1(int cmd));

/**/
mod_export void (*backend_gdbm_entry_ptr)();

/**/
mod_export void (*backend_redis_entry_ptr)();

/**/
mod_export void (*backend_custom1_entry_ptr)();

...

There are three custom "db/custom[0-9]" backends. This way a custom module can attach, or also, it can fully replace db.c and provide own above variables in its custom db.c. In backend I include db.epro, to have the declarations of above vars, but backend module can just define own externs. This is to not depend on zsh.h. For this I also used macros not enum, for command ids.

> The decisions about how to abstract bin_ztie et al. from gdbm should be
> made by discussion with this group, not by you racing ahead on your own.
> Proposed approaches are of course welcome (see for example the discussion
> about numeric sorting).

This goes on me, coffee+interesting topic+coding. Hope current method is OK, if not I can change.

I've commited zredis plugin using two modules:

https://github.com/zdharma/zredis/blob/master/module/Src/zdharma/db.c
https://github.com/zdharma/zredis/blob/master/module/Src/zdharma/zredis.c

From the last one, on-topic are functions redis_main_entry, zrtie_cmd and zruntie_cmd.

--
Sebastian Gniazdowski
psprint /at/ zdharma.org


  reply	other threads:[~2017-06-08 10:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-07 10:20 Sebastian Gniazdowski
2017-06-07 16:11 ` Bart Schaefer
2017-06-08 10:04   ` Sebastian Gniazdowski [this message]
2017-06-08 23:14     ` Bart Schaefer
2017-06-08 23:31       ` Bart Schaefer
2017-06-09  8:53       ` Sebastian Gniazdowski

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=etPan.59392116.2eb141f2.8e19@MacMini.local \
    --to=psprint@zdharma.org \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).