summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-05-11 14:28:54 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-05-11 14:35:24 +0200
commit905c592e28d839a84480bdd4de22a828dfa2cefc (patch)
treed4be3e692708a5b4bf3aa54259d0ed107cea3f67
parent3d69272f9cb0f5c37ac7855ceafe6a27bbf9b1b3 (diff)
scanner: Split interface names into prefix and nameprefix
Prefixes can be inherited from the protocol element.
-rw-r--r--TODO3
-rw-r--r--protocol/wayland.xml72
-rw-r--r--wayland/scanner.c39
3 files changed, 71 insertions, 43 deletions
diff --git a/TODO b/TODO
index dabfb93..31e47fe 100644
--- a/TODO
+++ b/TODO
@@ -15,9 +15,6 @@ Core wayland protocol
Handle window title, icons, lower window, needs attention,
minimize, maximize, move to desktop?
- - scanner: wl_* prefix removal: split it out into a namespace part so
- we can call variables "surface" instead of "wl_surface"?
-
- Framebased input event delivery.
- Protocol for arbitrating access to scanout buffers (physically
diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index cf52439..aa1fcd7 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
-<protocol name="wayland">
+<protocol name="wayland" prefix="wl">
<!-- The core global object. This is a special singleton object.
It is used for internal wayland protocol features. -->
- <interface name="wl_display" version="1">
+ <interface name="display" version="1">
<request name="bind">
<arg name="id" type="uint"/>
<arg name="interface" type="string"/>
@@ -24,7 +24,7 @@
animations. The notification will only be posted for one
frame unless requested again. -->
<request name="frame">
- <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="surface" type="object" interface="surface"/>
<arg name="key" type="uint"/>
</request>
@@ -51,7 +51,7 @@
server will always announce an object before the object sends
out events. -->
<event name="global">
- <arg name="id" type="new_id" interface="wl_object"/>
+ <arg name="id" type="new_id" interface="object"/>
<arg name="name" type="string"/>
<arg name="version" type="uint"/>
</event>
@@ -80,17 +80,17 @@
<!-- A compositor. This object is a global. The compositor is in
charge of combining the contents of multiple surfaces into one
displayable output. -->
- <interface name="wl_compositor" version="1">
+ <interface name="compositor" version="1">
<!-- Factory request for a surface objects. A surface is akin to a
window. -->
<request name="create_surface">
- <arg name="id" type="new_id" interface="wl_surface"/>
+ <arg name="id" type="new_id" interface="surface"/>
</request>
</interface>
<!-- Shared memory support -->
- <interface name="wl_shm" version="1">
+ <interface name="shm" version="1">
<!-- Transfer a shm buffer to the server. The allocated buffer
would include at least stride * height bytes starting at the
beginning of fd. The file descriptor is transferred over the
@@ -98,12 +98,12 @@
and visual describe the respective properties of the pixel
data contained in the buffer. -->
<request name="create_buffer">
- <arg name="id" type="new_id" interface="wl_buffer"/>
+ <arg name="id" type="new_id" interface="buffer"/>
<arg name="fd" type="fd"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
<arg name="stride" type="uint"/>
- <arg name="visual" type="object" interface="wl_visual"/>
+ <arg name="visual" type="object" interface="visual"/>
</request>
</interface>
@@ -111,7 +111,7 @@
<!-- A pixel buffer. Created using the drm, shm or similar objects.
It has a size, visual and contents, but not a location on the
screen. -->
- <interface name="wl_buffer" version="1">
+ <interface name="buffer" version="1">
<!-- Notify the server that the specified area of the buffers
contents have changed. To describe a more complicated area
of damage, break down the region into rectangles and use this
@@ -128,10 +128,10 @@
<request name="destroy" type="destructor"/>
</interface>
- <interface name="wl_shell" version="1">
+ <interface name="shell" version="1">
<request name="move">
- <arg name="surface" type="object" interface="wl_surface"/>
- <arg name="input_device" type="object" interface="wl_input_device"/>
+ <arg name="surface" type="object" interface="surface"/>
+ <arg name="input_device" type="object" interface="input_device"/>
<arg name="time" type="uint"/>
</request>
@@ -148,18 +148,18 @@
</enum>
<request name="resize">
- <arg name="surface" type="object" interface="wl_surface"/>
- <arg name="input_device" type="object" interface="wl_input_device"/>
+ <arg name="surface" type="object" interface="surface"/>
+ <arg name="input_device" type="object" interface="input_device"/>
<arg name="time" type="uint"/>
<arg name="edges" type="enum" enum_name="resize"/>
</request>
<request name="create_drag">
- <arg name="id" type="new_id" interface="wl_drag"/>
+ <arg name="id" type="new_id" interface="drag"/>
</request>
<request name="create_selection">
- <arg name="id" type="new_id" interface="wl_selection"/>
+ <arg name="id" type="new_id" interface="selection"/>
</request>
<!-- The configure event asks the client to resize its surface.
@@ -171,13 +171,13 @@
<event name="configure">
<arg name="time" type="uint"/>
<arg name="edges" type="enum" enum_name="resize"/>
- <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="surface" type="object" interface="surface"/>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
</event>
</interface>
- <interface name="wl_selection" version="1">
+ <interface name="selection" version="1">
<!-- Add an offered mime type. Can be called several times to
offer multiple types, but must be called before 'activate'. -->
<request name="offer">
@@ -186,7 +186,7 @@
<!-- Can the selection be activated for multiple devices? -->
<request name="activate">
- <arg name="input_device" type="object" interface="wl_input_device"/>
+ <arg name="input_device" type="object" interface="input_device"/>
<arg name="time" type="uint"/>
</request>
@@ -204,7 +204,7 @@
<event name="cancelled"/>
</interface>
- <interface name="wl_selection_offer" version="1">
+ <interface name="selection_offer" version="1">
<!-- Called to receive the selection data as the specified type.
Sends the pipe fd to the compositor, which forwards it to the
source in the 'send' event -->
@@ -221,11 +221,11 @@
</event>
<event name="keyboard_focus">
- <arg name="input_device" type="object" interface="wl_input_device"/>
+ <arg name="input_device" type="object" interface="input_device"/>
</event>
</interface>
- <interface name="wl_drag" version="1">
+ <interface name="drag" version="1">
<!-- Add an offered mime type. Can be called several times to
offer multiple types, but must be called before 'activate'. -->
<request name="offer">
@@ -233,8 +233,8 @@
</request>
<request name="activate">
- <arg name="surface" type="object" interface="wl_surface"/>
- <arg name="input_device" type="object" interface="wl_input_device"/>
+ <arg name="surface" type="object" interface="surface"/>
+ <arg name="input_device" type="object" interface="input_device"/>
<arg name="time" type="uint"/>
</request>
@@ -262,7 +262,7 @@
</interface>
- <interface name="wl_drag_offer" version="1">
+ <interface name="drag_offer" version="1">
<!-- Call to accept the offer of the given type -->
<request name="accept">
<arg name="time" type="uint"/>
@@ -292,7 +292,7 @@
drag object may no longer be valid. -->
<event name="pointer_focus">
<arg name="time" type="uint"/>
- <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="surface" type="object" interface="surface"/>
<arg name="x" type="int"/>
<arg name="y" type="int"/>
<arg name="surface_x" type="int"/>
@@ -319,7 +319,7 @@
<!-- A surface. This is an image that is displayed on the screen.
It has a location, size and pixel contents. Similar to a window. -->
- <interface name="wl_surface" version="1">
+ <interface name="surface" version="1">
<!-- Deletes the surface and invalidates its object id. -->
<request name="destroy" type="destructor"/>
@@ -327,7 +327,7 @@
arguments specify the location of the new buffers upper left
corner, relative to the old buffers upper left corner. -->
<request name="attach">
- <arg name="buffer" type="object" interface="wl_buffer"/>
+ <arg name="buffer" type="object" interface="buffer"/>
<arg name="x" type="int"/>
<arg name="y" type="int"/>
</request>
@@ -344,7 +344,7 @@
determines the initial position or if the surface is locked
to that relative position during moves. -->
<request name="map_transient">
- <arg name="parent" type="object" interface="wl_surface"/>
+ <arg name="parent" type="object" interface="surface"/>
<arg name="x" type="int"/>
<arg name="y" type="int"/>
<arg name="flags" type="uint"/>
@@ -378,13 +378,13 @@
or when such a device is hot plugged. A input_device group
typically has a pointer and maintains a keyboard_focus and a
pointer_focus. -->
- <interface name="wl_input_device" version="1">
+ <interface name="input_device" version="1">
<!-- Set the pointer's image. This request only takes effect if
the pointer focus for this device is one of the requesting
clients surfaces. -->
<request name="attach">
<arg name="time" type="uint"/>
- <arg name="buffer" type="object" interface="wl_buffer"/>
+ <arg name="buffer" type="object" interface="buffer"/>
<arg name="hotspot_x" type="int"/>
<arg name="hotspot_y" type="int"/>
</request>
@@ -422,7 +422,7 @@
this event by setting an apropriate pointer image. -->
<event name="pointer_focus">
<arg name="time" type="uint"/>
- <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="surface" type="object" interface="surface"/>
<arg name="x" type="int"/>
<arg name="y" type="int"/>
<arg name="surface_x" type="int"/>
@@ -431,7 +431,7 @@
<event name="keyboard_focus">
<arg name="time" type="uint"/>
- <arg name="surface" type="object" interface="wl_surface"/>
+ <arg name="surface" type="object" interface="surface"/>
<arg name="keys" type="array"/>
</event>
</interface>
@@ -444,7 +444,7 @@
displays part of the compositor space. This object is
published as global during start up, or when a screen is hot
plugged. -->
- <interface name="wl_output" version="1">
+ <interface name="output" version="1">
<!-- Notification about the screen size. -->
<event name="geometry">
<arg name="x" type="int"/>
@@ -457,7 +457,7 @@
<!-- A visual is the pixel format. The different visuals are
currently only identified by the order they are advertised by
the 'global' events. We need something better. -->
- <interface name="wl_visual" version="1">
+ <interface name="visual" version="1">
<event name="type">
<arg name="type" type="enum" enum_name="type" />
</event>
diff --git a/wayland/scanner.c b/wayland/scanner.c
index 32bd62d..0e0fdf8 100644
--- a/wayland/scanner.c
+++ b/wayland/scanner.c
@@ -16,6 +16,8 @@
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#define _GNU_SOURCE
+
#include <stdio.h>
#include <string.h>
#include <errno.h>
@@ -58,6 +60,7 @@ usage(int ret)
struct protocol {
char *name;
+ char *prefix;
char *uppercase_name;
struct wl_list interface_list;
};
@@ -136,6 +139,16 @@ uppercase_dup(const char *src)
return u;
}
+static char *
+prefix_dup(const char *prefix, const char *name)
+{
+ char *s;
+
+ asprintf(&s, "%s%s%s", prefix, strlen(prefix) == 0 ? "": "_", name);
+
+ return s;
+}
+
static void
fail(struct parse_context *ctx, const char *msg)
{
@@ -153,18 +166,23 @@ start_element(void *data, const char *element_name, const char **atts)
struct arg *arg;
struct enumeration *enumeration;
struct entry *entry;
- const char *name, *type, *interface_name, *enum_name, *value;
+ const char *name, *prefix, *type, *_interface_name, *enum_name, *value;
+ char *interface_name;
int i, version;
name = NULL;
+ prefix = NULL;
type = NULL;
version = 0;
+ _interface_name = NULL;
interface_name = NULL;
enum_name = NULL;
value = NULL;
for (i = 0; atts[i]; i += 2) {
if (strcmp(atts[i], "name") == 0)
name = atts[i + 1];
+ if (strcmp(atts[i], "prefix") == 0)
+ prefix = atts[i + 1];
if (strcmp(atts[i], "version") == 0)
version = atoi(atts[i + 1]);
if (strcmp(atts[i], "type") == 0)
@@ -172,16 +190,25 @@ start_element(void *data, const char *element_name, const char **atts)
if (strcmp(atts[i], "value") == 0)
value = atts[i + 1];
if (strcmp(atts[i], "interface") == 0)
- interface_name = atts[i + 1];
+ _interface_name = atts[i + 1];
if (strcmp(atts[i], "enum_name") == 0)
enum_name = atts[i + 1];
}
+ if (prefix == NULL)
+ prefix = ctx->protocol->prefix;
+
+ if (_interface_name)
+ interface_name = prefix_dup(prefix, _interface_name);
+
if (strcmp(element_name, "protocol") == 0) {
if (name == NULL)
fail(ctx, "no protocol name given");
+ if (prefix == NULL)
+ fail(ctx, "no protocol prefix given");
ctx->protocol->name = strdup(name);
+ ctx->protocol->prefix = strdup(prefix);
ctx->protocol->uppercase_name = uppercase_dup(name);
} else if (strcmp(element_name, "interface") == 0) {
if (name == NULL)
@@ -191,8 +218,8 @@ start_element(void *data, const char *element_name, const char **atts)
fail(ctx, "no interface version given");
interface = malloc(sizeof *interface);
- interface->name = strdup(name);
- interface->uppercase_name = uppercase_dup(name);
+ interface->name = prefix_dup(prefix, name);
+ interface->uppercase_name = uppercase_dup(interface->name);
interface->version = version;
wl_list_init(&interface->request_list);
wl_list_init(&interface->event_list);
@@ -286,6 +313,9 @@ start_element(void *data, const char *element_name, const char **atts)
wl_list_insert(ctx->enumeration->entry_list.prev,
&entry->link);
}
+
+ if (interface_name)
+ free(interface_name);
}
static void
@@ -713,6 +743,7 @@ int main(int argc, char *argv[])
usage(EXIT_FAILURE);
wl_list_init(&protocol.interface_list);
+ protocol.prefix = NULL;
ctx.protocol = &protocol;
ctx.filename = "<stdin>";