[PATCH 7/7] scanner: dump interfaces in tex format and plug with main.tex

y y
Thu Feb 9 09:27:53 PST 2012


From: Tiago Vignatti <tiago.vignatti at intel.com>

Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
---
 spec/main.tex   |   17 +----------------
 src/Makefile.am |    3 ++-
 src/scanner.c   |   50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 src/scanner.mk  |    3 +++
 4 files changed, 55 insertions(+), 18 deletions(-)

diff --git a/spec/main.tex b/spec/main.tex
index 59d4fe0..32aa14e 100644
--- a/spec/main.tex
+++ b/spec/main.tex
@@ -192,22 +192,7 @@ interfaces provided as extensions, but there are several which are
 always expected to be present.
 
 Core interfaces:
-\begin{itemize}
-\item wl_display: provides global functionality like objecting binding and fatal error events
-\item wl_callback: callback interface for dnoe events
-\item wl_compositor: core compositor interface, allows surface creation
-\item wl_shm: buffer management interface with buffer creation and format handling
-\item wl_buffer: buffer handling interface for indicating damage and object destruction, also provides buffer release events from the server
-\item wl_data_offer: for accepting and receiving specific mime types
-\item wl_data_source: for offering specific mime types
-\item wl_data_Device: lets clients manage drag & drop, provides pointer enter/leave events and motion
-\item wl_data_device_manager: for managing data sources and devices
-\item wl_shell: shell surface handling
-\item wl_shell_surface: shell surface handling and desktop-like events (e.g. set a surface to fullscreen, display a popup, etc.)
-\item wl_surface: surface management (destruction, damage, buffer attach, frame handling)
-\item wl_input_device: cursor setting, motion, button, and key events, etc.
-\item wl_output: events describing an attached output (subpixel orientation, current mode & geometry, etc.)
-\end{itemize}
+\input{wayland-interfaces.tex}
 
 \subsection{Connect Time}
 
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/$@
-- 
1.7.5.4



More information about the wayland-devel mailing list