diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/scanner.c | 50 | ||||
-rw-r--r-- | src/scanner.mk | 3 |
3 files changed, 54 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index f356b54..4dd8964 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -58,6 +58,7 @@ endif BUILT_SOURCES = \ wayland-server-protocol.h \ wayland-client-protocol.h \ - wayland-protocol.c + wayland-protocol.c \ + $(top_srcdir)/spec/wayland-interfaces.tex CLEANFILES = $(BUILT_SOURCES) diff --git a/src/scanner.c b/src/scanner.c index 51c01af..5a7e466 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -32,7 +32,7 @@ static int usage(char *name, int ret) { - fprintf(stderr, "usage: %s [client-header|server-header|code]" + fprintf(stderr, "usage: %s [client-header|server-header|code|tex]" " < xmlfile\n", name); exit(ret); } @@ -975,6 +975,52 @@ emit_code(struct protocol *protocol) } } +static char * +get_latex(char *name) +{ + int i, j, lenght, new_lenght; + char *word = name; + + lenght = strlen(word); + new_lenght = lenght; + for (i = 0; i < lenght; i++) + if (word[i] == '_') + new_lenght++; + + if (lenght == new_lenght) + return word; + + word = realloc(word, new_lenght + 1); + + /* e.g. "wl_display" becomes "wl\_display" */ + for (i = 0; i < new_lenght; i++) { + if (word[i] == '_') { + for (j = lenght - 1; j >= i; j--) + word[j + 1] = word[j]; + word[i] = '\\'; + i++; + lenght++; + } + } + word[new_lenght] = '\0'; + + return word; +} + +static void +emit_tex(struct protocol *protocol) +{ + struct interface *i; + + printf("\\begin{itemize}\n"); + wl_list_for_each(i, &protocol->interface_list, link) { + printf("\\item %s: %s.\n", + i->name ? get_latex(i->name) : 0, + i->description ? get_latex(i->description->summary) : NULL); + } + printf("\\end{itemize}\n"); +} + int main(int argc, char *argv[]) { struct parse_context ctx; @@ -1021,6 +1067,8 @@ int main(int argc, char *argv[]) emit_header(&protocol, 1); } else if (strcmp(argv[1], "code") == 0) { emit_code(&protocol); + } else if (strcmp(argv[1], "tex") == 0) { + emit_tex(&protocol); } return 0; diff --git a/src/scanner.mk b/src/scanner.mk index 1b6963c..a7e5d4d 100644 --- a/src/scanner.mk +++ b/src/scanner.mk @@ -6,3 +6,6 @@ %-client-protocol.h : $(protocoldir)/%.xml $(AM_V_GEN)$(wayland_scanner) client-header < $< > $@ + +%-interfaces.tex : $(protocoldir)/%.xml + $(AM_V_GEN)$(wayland_scanner) tex < $< > $(top_srcdir)/spec/$@ |