[PATCH wayland 2/3] Add version information to wl_message signatures.

Bill Spitzak spitzak at gmail.com
Thu Jun 27 11:19:15 PDT 2013



Jason Ekstrand wrote:
> This commit adds version information to wl_message signatures and a
> wl_message_get_since function to retrieve.  The since version comes in the
> form of a (possible) integer at the begining of the message.  If the
> message starts with an integer, then it specifies the "since" version of
> that message.  Messages present in version one do not get this "since"
> information.  In this way we can run-time detect the version information
> for a structure on a per-message basis.

Why can't it record the version when the client creates an object, and 
then assume all messages to that object are that version?

> -	if (*signature == '?') {
> -		details->nullable = 1;
> -		signature++;
> -	} else
> -		details->nullable = 0;
> -
> -	details->type = *signature;
> -	return signature + 1;
> +	details->nullable = 0;
> +	for(; *signature; ++signature) {
> +		switch(*signature) {
> +		case 'i':
> +		case 'u':
> +		case 'f':
> +		case 's':
> +		case 'o':
> +		case 'n':
> +		case 'a':
> +		case 'h':
> +			details->type = *signature;
> +			return signature + 1;
> +		case '?':
> +			details->nullable = 1;
> +		}
> +	}
> +	return signature;

To match your use of atoi it would be better to skip all the leading 
digits (possibly in other code where you know you are at the start of 
the signature), then use this old version of the code.


More information about the wayland-devel mailing list