update luapkg2c to deal with "static" modules.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
AUTOMAKE_OPTIONS = foreign
EXTRA_PROGRAMS = madmutt_dotlock pgpringng pgpewrapng makedoc
+.cpkg.c: ; ./lib-lua/luapkg2c.pl -c $< > $@
+
if BUILD_NNTP
NNTP_SUBDIR = nntp
endif
bin_PROGRAMS = madmutt madmutt_dotlock pgpringng pgpewrapng smime_keysng
madmutt_SOURCES = $(BUILT_SOURCES) \
- alias.c attach.c base64.c browser.c buffy.c charset.c commands.c \
+ alias.cpkg attach.c base64.c browser.c buffy.c charset.c commands.c \
compose.c copy.c editmsg.c init.c keymap.c lib.c \
flags.c from.c handler.c headers.c help.c hook.c \
main.c muttlib.c mutt_idna.c pager.c pattern.c postpone.c recvattach.c recvcmd.c \
#include "mutt_idna.h"
#include "sort.h"
-char *AliasFmt;
+@type bool = {
+ .kind = 'b';
+ .ctype = unsigned : 1;
+};
+
+@type string_t = {
+ .kind = 's';
+ .ctype = char *;
+ .dtor = p_delete($$);
+ .ctor = m_strdup($$);
+};
+
+@type path_t = {
+ .push = luaM_path_post($$);
+ .kind = 's';
+ .ctype = char *;
+ .dtor = p_delete($$);
+ .ctor = m_strdup($$);
+};
+
+@type quadopt_t = {
+ .kind = 'i';
+ .check = luaM_checkquadopt($L, $$);
+ .ctype = unsigned : 2;
+};
+
+static @package MAlias {
+ path_t alias_format = m_strdup("%4n %2f %t %-10a %r");
+} MAlias;
+
char *AliasFile;
alias_t *Aliases;
rx_t GecosMask;
static void alias_entry(char *s, ssize_t slen, MUTTMENU *m, int num)
{
- m_strformat(s, slen, COLS - SW, AliasFmt, alias_format_str,
+ m_strformat(s, slen, COLS - SW, MAlias.alias_format, alias_format_str,
((alias_t **)m->data)[num],
option(OPTARROWCURSOR) ? M_FORMAT_ARROWCURSOR : 0);
}
mutt_menuDestroy (&menu);
p_delete(&AliasTable);
}
+
+/* vim:set ft=c: */
#define _MUTT_ALIAS_H
#include <lib-lib/lib-lib.h>
+#include <lib-lua/lib-lua.h>
+
#include <lib-mime/mime.h>
+int luaopen_MAlias(lua_State *L);
+
typedef struct alias_t {
struct alias_t *next;
char *name;
** \fBNote:\fP Madmutt will not automatically source this file; you must
** explicitly use the ``$source'' command for it to be executed.
*/
- {"alias_format", DT_STR, R_NONE, UL &AliasFmt, "%4n %2f %t %-10a %r"},
- /*
- ** .pp
- ** Specifies the format of the data displayed for the ``alias'' menu. The
- ** following \fTprintf(3)\fP-style sequences are available:
- ** .pp
- ** .dl
- ** .dt %a .dd alias name
- ** .dt %f .dd flags - currently, a "d" for an alias marked for deletion
- ** .dt %n .dd index number
- ** .dt %r .dd address which alias expands to
- ** .dt %t .dd character which indicates if the alias is tagged for inclusion
- ** .de
- */
{"allow_8bit", DT_BOOL, R_NONE, OPTALLOW8BIT, "yes" },
/*
** .pp
## tmpdir
## username
## version
+## alias_format
EOF
}
+sub dump_struct_static($) {
+ my ($pkg) = @_;
+
+ print "static struct {\n";
+ foreach (@{$pkg->{props}}) {
+ my $p = $pkg->{members}{$_};
+ my %t = find_type($p, $p->{type});
+ if ($t{const}) {
+ printf " const $t{type}->{ctypefmt};\n", $p->{name};
+ } else {
+ printf " $t{type}->{ctypefmt};\n", $p->{name};
+ }
+ }
+ put_line($pkg, 0);
+ print "} $pkg->{cname} = {\n";
+
+ foreach (@{$pkg->{props}}) {
+ my $p = $pkg->{members}{$_};
+ my %t = find_type($p, $p->{type});
+
+ if ($t{const}) {
+ put_line($p, 0);
+ print " $p->{init},\n";
+ } else {
+ print " 0,\n" if ($t{type}->{kind} eq 'b');
+ print " 0,\n" if ($t{type}->{kind} eq 'i');
+ print " NULL,\n" if ($t{type}->{kind} eq 's');
+ }
+ }
+
+ print <<EOF;
+};
+
+static void $pkg->{cname}_init(void)
+{
+EOF
+
+ foreach (@{$pkg->{props}}) {
+ my $p = $pkg->{members}{$_};
+ my %t = find_type($p, $p->{type});
+ my $var = $pkg->{cname}.".".$p->{name};
+
+ next if $t{const};
+
+ put_line($p, 0);
+ if ($t{type}->{dtor}) {
+ my $dtor = $t{type}->{dtor};
+ $dtor =~ s/\$L/L/;
+ $dtor =~ s/\$\$/\&$var/;
+ print " $dtor;\n";
+ }
+ print " $var = $p->{init};\n"
+ }
+ print "};\n";
+};
+
#}}}
#{{{ dump package
-sub dump_package_full($) {
- my $pkg = shift;
+sub dump_package_full($$) {
+ my ($pkg, $static) = @_;
- dump_struct_full($pkg);
+ if ($static) {
+ dump_struct_static($pkg);
+ } else {
+ dump_struct_full($pkg);
+ }
map { print "\n"; dump_fun($pkg->{name}, $pkg->{members}{$_}); } @{$pkg->{meths}};
print <<EOF;
if (/^\s*\@type\s+([a-zA-Z]\w*)\s*=\s*{\s*$/) {
parse_type(\%src, $1);
$resync = 1;
+ } elsif (/^\s*static\s+\@package\s+([a-zA-Z]\w*)\s+{\s*$/) {
+ dump_package_full(parse_package(\%src, $1), 1);
+ $resync = 1;
} elsif (/^\s*\@package\s+([a-zA-Z]\w*)\s+{\s*$/) {
- dump_package_full(parse_package(\%src, $1));
+ dump_package_full(parse_package(\%src, $1), 0);
$resync = 1;
} elsif (/^\s*(\@\w*)/) {
fatal(\%src, "syntax error: unknown directive `$1'");
#include <lib-lib/lib-lib.h>
#include <lib-lua/lib-lua.h>
+#include <alias.h>
+
static lua_State *L;
void luaM_initialize(void)
{LUA_DBLIBNAME, luaopen_debug},
{"MCore", luaopen_MCore},
{"MTransport", luaopen_MTransport},
+ {"MAlias", luaopen_MAlias},
};
int i;