summaryrefslogtreecommitdiff
path: root/Src/Zle
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-05-28 22:57:39 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-05-28 22:57:39 +0000
commitb0c5f09169ac31855ebf0e93772bb57b9635b380 (patch)
tree410c43a9843b2c88166c2cb9acd531eaa36d036d /Src/Zle
parentbd7632079045b1b6d0dee498c40833b409cf757e (diff)
downloadzsh-b0c5f09169ac31855ebf0e93772bb57b9635b380.tar.gz
zsh-b0c5f09169ac31855ebf0e93772bb57b9635b380.zip
see 23479: add initial features support for modules
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/compctl.c28
-rw-r--r--Src/Zle/complete.c33
-rw-r--r--Src/Zle/complist.c27
-rw-r--r--Src/Zle/computil.c28
-rw-r--r--Src/Zle/deltochar.c29
-rw-r--r--Src/Zle/zle_main.c27
-rw-r--r--Src/Zle/zle_thingy.c2
-rw-r--r--Src/Zle/zle_tricky.c2
-rw-r--r--Src/Zle/zleparameter.c118
9 files changed, 182 insertions, 112 deletions
diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c
index 81f11b423..bafbb2f68 100644
--- a/Src/Zle/compctl.c
+++ b/Src/Zle/compctl.c
@@ -3942,6 +3942,14 @@ static struct builtin bintab[] = {
BUILTIN("compcall", 0, bin_compcall, 0, 0, 0, "TD", NULL),
};
+static struct features module_features = {
+ bintab, sizeof(bintab)/sizeof(*bintab),
+ NULL, 0,
+ NULL, 0,
+ NULL, 0,
+ 0
+};
+
/**/
int
setup_(UNUSED(Module m))
@@ -3964,11 +3972,26 @@ setup_(UNUSED(Module m))
/**/
int
+features_(Module m, char ***features)
+{
+ *features = featuresarray(m->nam, &module_features);
+ return 0;
+}
+
+/**/
+int
+enables_(Module m, int **enables)
+{
+ return handlefeatures(m->nam, &module_features, enables);
+}
+
+/**/
+int
boot_(Module m)
{
addhookfunc("compctl_make", (Hookfn) ccmakehookfn);
addhookfunc("compctl_cleanup", (Hookfn) cccleanuphookfn);
- return (addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab)) != 1);
+ return 0;
}
/**/
@@ -3977,8 +4000,7 @@ cleanup_(Module m)
{
deletehookfunc("compctl_make", (Hookfn) ccmakehookfn);
deletehookfunc("compctl_cleanup", (Hookfn) cccleanuphookfn);
- deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
- return 0;
+ return setfeatureenables(m->nam, &module_features, NULL);
}
/**/
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index a73d3cf14..aac760a92 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -1467,6 +1467,14 @@ struct hookdef comphooks[] = {
HOOKDEF("comp_list_matches", ilistmatches, 0),
};
+static struct features module_features = {
+ bintab, sizeof(bintab)/sizeof(*bintab),
+ cotab, sizeof(cotab)/sizeof(*cotab),
+ NULL, 0,
+ NULL, 0,
+ 0
+};
+
/**/
int
setup_(UNUSED(Module m))
@@ -1492,6 +1500,21 @@ setup_(UNUSED(Module m))
/**/
int
+features_(Module m, char ***features)
+{
+ *features = featuresarray(m->nam, &module_features);
+ return 0;
+}
+
+/**/
+int
+enables_(Module m, int **enables)
+{
+ return handlefeatures(m->nam, &module_features, enables);
+}
+
+/**/
+int
boot_(Module m)
{
addhookfunc("complete", (Hookfn) do_completion);
@@ -1502,11 +1525,7 @@ boot_(Module m)
addhookfunc("list_matches", (Hookfn) list_matches);
addhookfunc("invalidate_list", (Hookfn) invalidate_list);
addhookdefs(m->nam, comphooks, sizeof(comphooks)/sizeof(*comphooks));
- if (!(addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab)) |
- addconddefs(m->nam, cotab, sizeof(cotab)/sizeof(*cotab)) |
- !addwrapper(m, wrapper)))
- return 1;
- return 0;
+ return addwrapper(m, wrapper);
}
/**/
@@ -1521,10 +1540,8 @@ cleanup_(Module m)
deletehookfunc("list_matches", (Hookfn) list_matches);
deletehookfunc("invalidate_list", (Hookfn) invalidate_list);
deletehookdefs(m->nam, comphooks, sizeof(comphooks)/sizeof(*comphooks));
- deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
- deleteconddefs(m->nam, cotab, sizeof(cotab)/sizeof(*cotab));
deletewrapper(m, wrapper);
- return 0;
+ return seteatureenables(m->nam, &module_features, NULL);
}
/**/
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index cedccc254..787b7b25c 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -3219,6 +3219,14 @@ menuselect(char **args)
return 0;
}
+static struct features module_features = {
+ NULL, 0,
+ NULL, 0,
+ NULL, 0,
+ NULL, 0,
+ 0
+};
+
/**/
int
setup_(UNUSED(Module m))
@@ -3228,6 +3236,21 @@ setup_(UNUSED(Module m))
/**/
int
+features_(Module m, char ***features)
+{
+ *features = featuresarray(m->nam, &module_features);
+ return 0;
+}
+
+/**/
+int
+enables_(Module m, int **enables)
+{
+ return handlefeatures(m->nam, &module_features, enables);
+}
+
+/**/
+int
boot_(Module m)
{
mtab = NULL;
@@ -3269,7 +3292,7 @@ boot_(Module m)
/**/
int
-cleanup_(UNUSED(Module m))
+cleanup_(Module m)
{
free(mtab);
free(mgtab);
@@ -3279,7 +3302,7 @@ cleanup_(UNUSED(Module m))
deletehookfunc("menu_start", (Hookfn) domenuselect);
unlinkkeymap("menuselect", 1);
unlinkkeymap("listscroll", 1);
- return 0;
+ return setfeatureenables(m->nam, &module_features, NULL);
}
/**/
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index dbbaa61e2..0d8cf5364 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -4567,6 +4567,14 @@ static struct builtin bintab[] = {
BUILTIN("compgroups", 0, bin_compgroups, 1, -1, 0, NULL, NULL),
};
+static struct features module_features = {
+ bintab, sizeof(bintab)/sizeof(*bintab),
+ NULL, 0,
+ NULL, 0,
+ NULL, 0,
+ 0
+};
+
/**/
int
@@ -4584,17 +4592,31 @@ setup_(UNUSED(Module m))
/**/
int
+features_(Module m, char ***features)
+{
+ *features = featuresarray(m->nam, &module_features);
+ return 0;
+}
+
+/**/
+int
+enables_(Module m, int **enables)
+{
+ return handlefeatures(m->nam, &module_features, enables);
+}
+
+/**/
+int
boot_(Module m)
{
- return !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
+ return 0;
}
/**/
int
cleanup_(Module m)
{
- deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
- return 0;
+ return setfeatureenables(m->nam, &module_features, NULL);
}
/**/
diff --git a/Src/Zle/deltochar.c b/Src/Zle/deltochar.c
index e7bfabfd3..0c64cf18d 100644
--- a/Src/Zle/deltochar.c
+++ b/Src/Zle/deltochar.c
@@ -74,6 +74,16 @@ deltochar(UNUSED(char **args))
return !ok;
}
+
+static struct features module_features = {
+ NULL, 0,
+ NULL, 0,
+ NULL, 0,
+ NULL, 0,
+ 0
+};
+
+
/**/
int
setup_(UNUSED(Module m))
@@ -83,6 +93,21 @@ setup_(UNUSED(Module m))
/**/
int
+features_(Module m, char ***features)
+{
+ *features = featuresarray(m->nam, &module_features);
+ return 0;
+}
+
+/**/
+int
+enables_(Module m, int **enables)
+{
+ return handlefeatures(m->nam, &module_features, enables);
+}
+
+/**/
+int
boot_(Module m)
{
w_deletetochar = addzlefunction("delete-to-char", deltochar,
@@ -100,11 +125,11 @@ boot_(Module m)
/**/
int
-cleanup_(UNUSED(Module m))
+cleanup_(Module m)
{
deletezlefunction(w_deletetochar);
deletezlefunction(w_zaptochar);
- return 0;
+ return setfeatureenables(m->nam, &module_features, NULL);
}
/**/
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 9f71f692b..8ab10e5de 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1777,6 +1777,14 @@ mod_export struct hookdef zlehooks[] = {
HOOKDEF("invalidate_list", NULL, 0),
};
+static struct features module_features = {
+ bintab, sizeof(bintab)/sizeof(*bintab),
+ NULL, 0,
+ NULL, 0,
+ NULL, 0,
+ 0
+};
+
/**/
int
setup_(UNUSED(Module m))
@@ -1817,11 +1825,25 @@ setup_(UNUSED(Module m))
/**/
int
+features_(Module m, char ***features)
+{
+ *features = featuresarray(m->nam, &module_features);
+ return 0;
+}
+
+/**/
+int
+enables_(Module m, int **enables)
+{
+ return handlefeatures(m->nam, &module_features, enables);
+}
+
+/**/
+int
boot_(Module m)
{
addhookfunc("before_trap", (Hookfn) zlebeforetrap);
addhookfunc("after_trap", (Hookfn) zleaftertrap);
- addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
addhookdefs(m->nam, zlehooks, sizeof(zlehooks)/sizeof(*zlehooks));
return 0;
}
@@ -1836,9 +1858,8 @@ cleanup_(Module m)
}
deletehookfunc("before_trap", (Hookfn) zlebeforetrap);
deletehookfunc("after_trap", (Hookfn) zleaftertrap);
- deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
deletehookdefs(m->nam, zlehooks, sizeof(zlehooks)/sizeof(*zlehooks));
- return 0;
+ return setfeatureenables(m->nam, &module_features, NULL);
}
/**/
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index debd31a28..42e32f142 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -590,7 +590,7 @@ bin_zle_complete(char *name, char **args, UNUSED(Options ops), UNUSED(char func)
Thingy t;
Widget w, cw;
- if (!require_module(name, "zsh/complete", 0, 0)) {
+ if (require_module(name, "zsh/complete", NULL) == 1) {
zwarnnam(name, "can't load complete module");
return 1;
}
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 6aaf53e80..2b8e17c22 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -612,7 +612,7 @@ docomplete(int lst)
* no completion widgets are defined. */
if (!module_loaded("zsh/compctl") && !hascompwidgets)
- load_module("zsh/compctl");
+ (void)load_module("zsh/compctl", NULL);
if (runhookdef(BEFORECOMPLETEHOOK, (void *) &lst)) {
active = 0;
diff --git a/Src/Zle/zleparameter.c b/Src/Zle/zleparameter.c
index 3c7f1474f..1b84fdff7 100644
--- a/Src/Zle/zleparameter.c
+++ b/Src/Zle/zleparameter.c
@@ -30,45 +30,6 @@
#include "zleparameter.mdh"
#include "zleparameter.pro"
-/* Empty dummy function for special hash parameters. */
-
-/**/
-static void
-shempty(void)
-{
-}
-
-/* Create a simple special hash parameter. */
-
-/**/
-static Param
-createspecialhash(char *name, GetNodeFunc get, ScanTabFunc scan)
-{
- Param pm;
- HashTable ht;
-
- if (!(pm = createparam(name, PM_SPECIAL|PM_HIDE|PM_REMOVABLE|PM_HASHED)))
- return NULL;
-
- pm->level = pm->old ? locallevel : 0;
- pm->gsu.h = &stdhash_gsu;
- pm->u.hash = ht = newhashtable(0, name, NULL);
-
- ht->hash = hasher;
- ht->emptytable = (TableFunc) shempty;
- ht->filltable = NULL;
- ht->addnode = (AddNodeFunc) shempty;
- ht->getnode = ht->getnode2 = get;
- ht->removenode = (RemoveNodeFunc) shempty;
- ht->disablenode = NULL;
- ht->enablenode = NULL;
- ht->freenode = (FreeNodeFunc) shempty;
- ht->printnode = printparamnode;
- ht->scantab = scan;
-
- return pm;
-}
-
/* Functions for the zlewidgets special parameter. */
/**/
@@ -157,18 +118,6 @@ keymapsgetfn(UNUSED(Param pm))
return ret;
}
-/* Table for defined parameters. */
-
-struct pardef {
- char *name;
- int flags;
- GetNodeFunc getnfn;
- ScanTabFunc scantfn;
- GsuHash hash_gsu;
- GsuArray array_gsu;
- Param pm;
-};
-
/*
* This is a duplicate of stdhash_gsu. On some systems
* (such as Cygwin) we can't put a pointer to an imported variable
@@ -179,14 +128,18 @@ static const struct gsu_hash zlestdhash_gsu =
static const struct gsu_array keymaps_gsu =
{ keymapsgetfn, arrsetfn, stdunsetfn };
-static struct pardef partab[] = {
- { "widgets", PM_READONLY,
- getpmwidgets, scanpmwidgets, &zlestdhash_gsu,
- NULL, NULL },
- { "keymaps", PM_ARRAY|PM_SPECIAL|PM_READONLY,
- NULL, NULL, NULL,
- &keymaps_gsu, NULL },
- { NULL, 0, NULL, NULL, NULL, NULL, NULL }
+static struct paramdef partab[] = {
+ SPECIALPMDEF("widgets", PM_READONLY,
+ &zlestdhash_gsu, getpmwidgets, scanpmwidgets),
+ SPECIALPMDEF("keymaps", PM_ARRAY|PM_READONLY, &keymaps_gsu, NULL, NULL),
+};
+
+static struct features module_features = {
+ NULL, 0,
+ NULL, 0,
+ partab, sizeof(partab)/sizeof(*partab),
+ NULL, 0,
+ 0
};
/**/
@@ -198,48 +151,35 @@ setup_(UNUSED(Module m))
/**/
int
-boot_(UNUSED(Module m))
+features_(Module m, char ***features)
{
- struct pardef *def;
-
- for (def = partab; def->name; def++) {
- unsetparam(def->name);
-
- if (def->getnfn) {
- if (!(def->pm = createspecialhash(def->name, def->getnfn,
- def->scantfn)))
- return 1;
- def->pm->node.flags |= def->flags;
- if (def->hash_gsu)
- def->pm->gsu.h = def->hash_gsu;
- } else {
- if (!(def->pm = createparam(def->name, def->flags | PM_HIDE)))
- return 1;
- def->pm->gsu.a = def->array_gsu;
- }
- }
+ *features = featuresarray(m->nam, &module_features);
return 0;
}
/**/
int
-cleanup_(UNUSED(Module m))
+enables_(Module m, int **enables)
+{
+ return handlefeatures(m->nam, &module_features, enables);
+}
+
+/**/
+int
+boot_(UNUSED(Module m))
{
- Param pm;
- struct pardef *def;
-
- for (def = partab; def->name; def++) {
- if ((pm = (Param) paramtab->getnode(paramtab, def->name)) &&
- pm == def->pm) {
- pm->node.flags &= ~PM_READONLY;
- unsetparam_pm(pm, 0, 1);
- }
- }
return 0;
}
/**/
int
+cleanup_(Module m)
+{
+ return setfeatureenables(m->nam, &module_features, NULL);
+}
+
+/**/
+int
finish_(UNUSED(Module m))
{
return 0;