Merge lp:~mir-team/mir/alternative-extension-naming into lp:mir
- alternative-extension-naming
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Cemil Azizoglu |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3890 |
Proposed branch: | lp:~mir-team/mir/alternative-extension-naming |
Merge into: | lp:mir |
Diff against target: |
721 lines (+147/-142) 20 files modified
include/client/mir_toolkit/extensions/mesa_drm_auth.h (+10/-4) include/client/mir_toolkit/extensions/set_gbm_device.h (+11/-3) include/client/mir_toolkit/mir_extension_core.h (+4/-1) include/test/mir_test_framework/stub_platform_extension.h (+27/-10) playground/mir_egl_platform_shim.c (+2/-3) src/client/mir_extension_core.cpp (+2/-2) src/client/symbols.map (+8/-8) src/include/client/mir_toolkit/extensions/android_buffer.h (+13/-8) src/include/client/mir_toolkit/extensions/android_egl.h (+13/-8) src/include/client/mir_toolkit/extensions/fenced_buffers.h (+9/-5) src/platforms/android/client/android_client_platform.cpp (+4/-6) src/platforms/android/client/android_client_platform.h (+3/-3) src/platforms/mesa/client/client_platform.cpp (+2/-8) src/platforms/mesa/client/client_platform.h (+1/-1) src/server/graphics/nested/mir_client_host_connection.cpp (+8/-14) tests/acceptance-tests/staging/test_presentation_chain.cpp (+1/-3) tests/acceptance-tests/test_client_extensions.cpp (+10/-19) tests/include/mir_test_framework/stub_client_platform_factory.h (+4/-4) tests/mir_test_framework/stub_client_platform_factory.cpp (+10/-25) tests/unit-tests/platforms/android/client/test_android_client_platform.cpp (+5/-7) |
To merge this branch: | bzr merge lp:~mir-team/mir/alternative-extension-naming |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir CI Bot | continuous-integration | Approve | |
Cemil Azizoglu (community) | Approve | ||
Alan Griffiths | Abstain | ||
Chris Halse Rogers | Approve | ||
Kevin DuBois | Pending | ||
Review via email: mp+313132@code.launchpad.net |
This proposal supersedes a proposal from 2016-11-30.
Commit message
client: propose an alternative standard naming scheme for mir extensions. The landed, but unreleased scheme has gotten some requests for modification. Should be in final form in time for 0.26.
The current scheme is:
void* mir_connection_
where name is a uuid-string.
but an alternative that might be more accepted is proposed here:
mir_connection_
where name is a readable, unique string for the extension.
Description of the change
client: propose an alternative standard naming scheme for mir extensions. The landed, but unreleased scheme has gotten some requests for modification. Should be in final form in time for 0.26.
The current scheme is:
void* mir_connection_
where name is a uuid-string.
but an alternative that might be more accepted is proposed here:
mir_connection_
where name is a readable, unique string for the extension.
Kevin DuBois (kdub) wrote : Posted in a previous version of this proposal | # |
Cemil Azizoglu (cemil-azizoglu) wrote : Posted in a previous version of this proposal | # |
I like the name, without the uuid, better.
Mir CI Bot (mir-ci-bot) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:3857
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal | # |
There are two unrelated changes here
1) Use a human-readable string rather than UUID to identify the extension, and
2) Drop extension versioning.
I'm ambivalent about the first change - the idea of using UUIDs is that it removes a coordination problem around extensions; anyone is free to independently develop and use one for their code (eg: drivers), safe in the knowledge it won't break anyone else.
That issue is mostly avoidable if everyone uses sensible prefixes - mir_* for core stuff, nv_*, amd_*, canonical_*, etc, so I won't block this change. (It'll also make extensions somewhat more verbose over the wire, as we'll need to send the whole string rather than 128 bits of UUID, but that's unlikely to be an important optimisation).
I also don't think it's a win to go from
#define MIR_EXTENSION_
to
#define MIR_EXTENSION_
If you're going to use human-readable strings as extension names, you should use those in the callsites. Otherwise you haven't meaningfully changed anything.
****************
I'm *against* removing the version field; that means we'll need to come up with a different name for each version of any extension we use, and this will make our code more verbose and obscures the useful invariant that you can use a v2 struct anywhere a v1 struct is required.
****************
So, if *I* were proposing something, all I'd do is drop the
MIR_EXTENSION_
a) version is just an integer, with 1 < 2 < 3 < ..., and
b) that version n+1 is a strict superset of version n
Kevin DuBois (kdub) wrote : Posted in a previous version of this proposal | # |
1) so it seems like between Chris & Cemil, and I, using a human-readable independently prefixed string (eg, mir_..., nv_..., etc) is something that's acceptable.
2) Re: versions, sure I don't mind keeping them around.
I do think its useful to give the extension maintainers latitude in their versioning.
(speaking in semver scheme) The "major" version seems roughly synonymous with the extension name, but we could make a distinction between minor and micro in the version field. OTOH, I don't mind other extensions using a strictly-ordered int scheme.
There's another topic though,
3) Is it beneficial to have #defines indicating versions and appropriate string names?
I like it documented in the extension header what sort of things to plug into mir_connection_
Andreas Pokorny (andreas-pokorny) wrote : Posted in a previous version of this proposal | # |
Having a define/constant for the string identifying the extension makes sense since you will have implementors and users passing in the very same thing..
For the version number I think it is not necessary - there is no sharing of the 'current' version, instead both implementors and users, provide and use a specific version.
So I would be ok with using a macro UUID, and no macro for the version number.
UUID vs name ... no real preference, the UUID does not hurt.
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
> There are two unrelated changes here
> 1) Use a human-readable string rather than UUID to identify the extension, and
> 2) Drop extension versioning.
>
> I'm ambivalent about the first change - the idea of using UUIDs is that it
> removes a coordination problem around extensions; anyone is free to
> independently develop and use one for their code (eg: drivers), safe in the
> knowledge it won't break anyone else.
>
> That issue is mostly avoidable if everyone uses sensible prefixes - mir_* for
> core stuff, nv_*, amd_*, canonical_*, etc, so I won't block this change.
> (It'll also make extensions somewhat more verbose over the wire, as we'll need
> to send the whole string rather than 128 bits of UUID, but that's unlikely to
> be an important optimisation).
I've also seen the UUID approach fall foul of cut&paste. It starts as shortcut "that will be changed before we ship" but somehow never is.
I'm weakly for using readable names, and don't love the macro.
> I'm *against* removing the version field; that means we'll need to come up
> with a different name for each version of any extension we use, and this will
> make our code more verbose and obscures the useful invariant that you can use
> a v2 struct anywhere a v1 struct is required.
I'm also against it, but I never assumed that we had that invariant is that enforceable? I had assumed that the implementation would decide whether to return the same structure or a different one.
> So, if *I* were proposing something, all I'd do is drop the
> MIR_EXTENSION_
+1
> and make it clearer in the
> mir_connection_
> a) version is just an integer, with 1 < 2 < 3 < ..., and
> b) that version n+1 is a strict superset of version n
I think that makes more sense with UUIDs than with meaningful names which are more resistant to change.
Kevin DuBois (kdub) wrote : Posted in a previous version of this proposal | # |
UUID seems prone to the copy-paste error, I almost made that error a few times in the few extensions in MP/landed.
Seems everyone likes the version field for the extension, so that's back in.
It also seems like human-readable unique names are preferred, so will keep that change.
The remaining question is how do we tell the users of the strings and the set of ints that they need to access the extension that they want? A macro in the header seems a straightforward way to me.
Cemil Azizoglu (cemil-azizoglu) wrote : Posted in a previous version of this proposal | # |
> The remaining question is how do we tell the users of the strings and the set
> of ints that they need to access the extension that they want? A macro in the
> header seems a straightforward way to me.
+1 on that from me. Otherwise, we'll need to keep some sort of registry somewhere.
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
> UUID seems prone to the copy-paste error, I almost made that error a few times
> in the few extensions in MP/landed.
>
> Seems everyone likes the version field for the extension, so that's back in.
> It also seems like human-readable unique names are preferred, so will keep
> that change.
>
> The remaining question is how do we tell the users of the strings and the set
> of ints that they need to access the extension that they want? A macro in the
> header seems a straightforward way to me.
What a shame this is C!
template<typename Extension>
auto constexpr interface_
template<typename Extension>
auto constexpr interface_
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
A client might want to try several versions of an interface:
extension_v1 x1;
extension_v3 x3;
extension_v5 x5;
if (load version 5)
plan_a(&x5)
else if (load version 3)
plan_b(&x3)
else if (load version 1)
...
Making that Murphy resistant is hard.
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
Actually, something like:
DEFINE_
load(&x1.
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal | # |
> UUID seems prone to the copy-paste error, I almost made that error a few times
> in the few extensions in MP/landed.
>
> Seems everyone likes the version field for the extension, so that's back in.
> It also seems like human-readable unique names are preferred, so will keep
> that change.
>
> The remaining question is how do we tell the users of the strings and the set
> of ints that they need to access the extension that they want? A macro in the
> header seems a straightforward way to me.
Alternately, this can be a combination of documentation and convention.
Given an extension struct
mir_extention_
... function pointers here ...
}
we have
mir_extension_
Since the user already needs to look up the extension struct to do anything with it, I don't think there's a lot of benefit to having macros in addition to the documentation above the struct definition.
Kevin DuBois (kdub) wrote : | # |
resubmitted, it was easier to just rename the strings from lp:mir than to fiddle with bzr.
Kevin DuBois (kdub) wrote : | # |
Alright, so there's human-readable strings now.
The remaining question (which seems slight) is how to give the user a connection between a struct containing the functions and the number to plug in as the version to get the appropriate struct.
The current contenders seem to be:
1) struct-
struct MirExtensionFooV1 (and then "1" is the int to plug in as the version)
2) existing, just have a #define
3) Alan's pseudocode (not quite clear to me how this would look in C code, so can't comment)
I don't mind 1) really, but it seems less advantageous to me because of the mental hop that is needed (mentally parse "V1", and then use it as a version).
Will wait to change the code until consensus, the differences are slight (or a matter of preference, perhaps).
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:3881
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
> Alright, so there's human-readable strings now.
>
> The remaining question (which seems slight) is how to give the user a
> connection between a struct containing the functions and the number to plug in
> as the version to get the appropriate struct.
>
> The current contenders seem to be:
>
> 1) struct-
> struct MirExtensionFooV1 (and then "1" is the int to plug in as the version)
> 2) existing, just have a #define
> 3) Alan's pseudocode (not quite clear to me how this would look in C code, so
> can't comment)
>
> I don't mind 1) really, but it seems less advantageous to me because of the
> mental hop that is needed (mentally parse "V1", and then use it as a version).
>
> Will wait to change the code until consensus, the differences are slight (or a
> matter of preference, perhaps).
I vote for (2). (2) is more explicit to me, whereas (1) is more implicit and could be confusing. People are used to khronos style extension strings already.
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
Meant to approve
Alan Griffiths (alan-griffiths) wrote : | # |
> 3) Alan's pseudocode (not quite clear to me how this would look in C code, so
> can't comment)
That comes from thinking about what client code looks like and how to keep it self-consistent.
I was thinking something along the lines of:
void load(void* data, char const* interface, unsigned version);
typedef struct { } foo_v1_extensions;
#define DEFINE_
struct { char const* const interface; unsigned const version; foo_v1_extensions extensions; } \
var = { "foo_v1_
int main()
{
DEFINE_
load(
return 0;
}
Alan Griffiths (alan-griffiths) wrote : | # |
*Needs discussion*
Another thought: We're a C99 project and that can do better...
#include <stdbool.h>
bool load(void* data, char const* interface, unsigned version);
typedef struct { } foo_v1_extensions;
static inline bool load_foo_
{
return load(extensions, "foo_v1_
}
int main()
{
foo_
load_
return 0;
}
Chris Halse Rogers (raof) wrote : | # |
Hm, I like the cut of your jib!
static inline foo_v1_extensions const* request_
{
return mir_connection_
}
Relevant changes: pass in the MirConnection, because that's the object that knows about extensions. Return a pointer-to-const rather than populating an input pointer so that the extension table can live in the RO .text section and we can have a single table for all versions of the extension.
Daniel van Vugt (vanvugt) wrote : | # |
It sounds like some of the above discussion doesn't need to happen here?... Doesn't need to block this branch?
Although along those lines:
If you had a load(name, version) and name contained version then the version parameter is not required... unless version is actually a minimum_version.
Kevin DuBois (kdub) wrote : | # |
I don't mind it blocking, point of the MP is to give a forum for complaints that didn't come up in the MP implementing extensions. I like Alan's suggestion as well (and Chris's tweaks), the users will know how to load an extension.
Alan Griffiths (alan-griffiths) wrote : | # |
> Hm, I like the cut of your jib!
>
> static inline foo_v1_extensions const* request_
> connection)
> {
> return mir_connection_
> }
>
> Relevant changes: pass in the MirConnection, because that's the object that
> knows about extensions. Return a pointer-to-const rather than populating an
> input pointer so that the extension table can live in the RO .text section and
> we can have a single table for all versions of the extension.
Fine by me
Alan Griffiths (alan-griffiths) wrote : | # |
> It sounds like some of the above discussion doesn't need to happen here?...
> Doesn't need to block this branch?
Well, we are discussing an alternative to what this branch proposes. That seems to be a good reason to block.
Alan Griffiths (alan-griffiths) wrote : | # |
> return mir_connection_
return (foo_v1_extensions const*)
I guess.
Chris Halse Rogers (raof) wrote : | # |
On Thu, Dec 15, 2016 at 4:53 AM, Alan Griffiths <email address hidden>
wrote:
>> return mir_connection_
>> 1);
>
> return (foo_v1_extensions
> const*)
>
> I guess.
Yeah, I mean, you *could* do that. If you wanted it to compile. ☺
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
Sounds good to me too.
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3883
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Chris Halse Rogers (raof) wrote : | # |
Yup, looks good to me.
Alan Griffiths (alan-griffiths) wrote : | # |
+__attribute__ ((deprecated))
void* mir_connection_
Deprecating an API we've not even released seems unnecessary. We should just delete it.
...
+//legacy compatibility
+typedef MirExtensionSet
What legacy?
Alan Griffiths (alan-griffiths) wrote : | # |
> +__attribute__ ((deprecated))
> void* mir_connection_
>
> Deprecating an API we've not even released seems unnecessary. We should just
> delete it.
>
> ...
>
> +//legacy compatibility
> +typedef MirExtensionSet
>
>
> What legacy?
I've contributed these changes, so abstaining.
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
Looks good
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:3886
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Cemil Azizoglu (cemil-azizoglu) wrote : | # |
^^ lp:1646558
Mir CI Bot (mir-ci-bot) : | # |
Preview Diff
1 | === modified file 'include/client/mir_toolkit/extensions/mesa_drm_auth.h' |
2 | --- include/client/mir_toolkit/extensions/mesa_drm_auth.h 2016-11-23 15:30:44 +0000 |
3 | +++ include/client/mir_toolkit/extensions/mesa_drm_auth.h 2016-12-19 16:28:18 +0000 |
4 | @@ -19,8 +19,7 @@ |
5 | #ifndef MIR_CLIENT_EXTENSIONS_MESA_DRM_AUTH_H_ |
6 | #define MIR_CLIENT_EXTENSIONS_MESA_DRM_AUTH_H_ |
7 | |
8 | -#define MIR_EXTENSION_MESA_DRM_AUTH "2782f477-bb9c-473b-a9ed-e4e85c61c0d1" |
9 | -#define MIR_EXTENSION_MESA_DRM_AUTH_VERSION_1 1 |
10 | +#include "mir_toolkit/mir_extension_core.h" |
11 | |
12 | #ifdef __cplusplus |
13 | extern "C" { |
14 | @@ -50,11 +49,18 @@ |
15 | typedef void (*mir_extension_mesa_drm_auth_magic)( |
16 | MirConnection* connection, int magic, mir_auth_magic_callback cb, void* context); |
17 | |
18 | -struct MirExtensionMesaDRMAuth |
19 | +typedef struct MirExtensionMesaDRMAuthV1 |
20 | { |
21 | mir_extension_mesa_drm_auth_fd drm_auth_fd; |
22 | mir_extension_mesa_drm_auth_magic drm_auth_magic; |
23 | -}; |
24 | +} MirExtensionMesaDRMAuthV1; |
25 | + |
26 | +static inline MirExtensionMesaDRMAuthV1 const* mir_extension_mesa_drm_auth_v1( |
27 | + MirConnection* connection) |
28 | +{ |
29 | + return (MirExtensionMesaDRMAuthV1 const*) mir_connection_request_extension( |
30 | + connection, "mir_extension_mesa_drm_auth", 1); |
31 | +} |
32 | |
33 | #ifdef __cplusplus |
34 | } |
35 | |
36 | === modified file 'include/client/mir_toolkit/extensions/set_gbm_device.h' |
37 | --- include/client/mir_toolkit/extensions/set_gbm_device.h 2016-12-09 02:54:31 +0000 |
38 | +++ include/client/mir_toolkit/extensions/set_gbm_device.h 2016-12-19 16:28:18 +0000 |
39 | @@ -19,8 +19,7 @@ |
40 | #ifndef MIR_CLIENT_EXTENSIONS_SET_GBM_DEVICE_H_ |
41 | #define MIR_CLIENT_EXTENSIONS_SET_GBM_DEVICE_H_ |
42 | |
43 | -#define MIR_EXTENSION_SET_GBM_DEVICE "6d38bfa6-1257-4b31-8e6d-910e7769093d" |
44 | -#define MIR_EXTENSION_SET_GBM_DEVICE_VERSION_1 1 |
45 | +#include "mir_toolkit/mir_extension_core.h" |
46 | |
47 | #ifdef __cplusplus |
48 | extern "C" { |
49 | @@ -32,11 +31,20 @@ |
50 | // \param [in] device The gbm_device. |
51 | // \param [in] context The context to set the gbm device. |
52 | typedef void (*set_gbm_dev)(struct gbm_device*, void* const context); |
53 | -struct MirExtensionSetGbmDevice |
54 | +struct MirExtensionSetGbmDeviceV1 |
55 | { |
56 | set_gbm_dev set_gbm_device; |
57 | void* const context; |
58 | }; |
59 | +//legacy compatibility |
60 | +typedef MirExtensionSetGbmDeviceV1 MirExtensionSetGbmDevice; |
61 | + |
62 | +static inline MirExtensionSetGbmDeviceV1 const* mir_extension_set_gbm_device_v1( |
63 | + MirConnection* connection) |
64 | +{ |
65 | + return (MirExtensionSetGbmDeviceV1 const*) mir_connection_request_extension( |
66 | + connection, "mir_extension_set_gbm_device", 1); |
67 | +} |
68 | |
69 | #ifdef __cplusplus |
70 | } |
71 | |
72 | === modified file 'include/client/mir_toolkit/mir_extension_core.h' |
73 | --- include/client/mir_toolkit/mir_extension_core.h 2016-11-01 18:47:14 +0000 |
74 | +++ include/client/mir_toolkit/mir_extension_core.h 2016-12-19 16:28:18 +0000 |
75 | @@ -27,6 +27,8 @@ |
76 | |
77 | /** |
78 | * Request a Mir extension |
79 | + * \note Extensions should provide an inline function to access |
80 | + * the extension that should be preferred to using this directly. |
81 | * |
82 | * \param [in] connection A connection |
83 | * \param [in] interface The name of the interface. |
84 | @@ -35,7 +37,8 @@ |
85 | * provided by the interface or NULL if the |
86 | * extension is not supported. |
87 | */ |
88 | -void* mir_connection_request_interface( |
89 | + |
90 | +void const* mir_connection_request_extension( |
91 | MirConnection* connection, |
92 | char const* interface, |
93 | int version); |
94 | |
95 | === modified file 'include/test/mir_test_framework/stub_platform_extension.h' |
96 | --- include/test/mir_test_framework/stub_platform_extension.h 2016-11-07 17:33:09 +0000 |
97 | +++ include/test/mir_test_framework/stub_platform_extension.h 2016-12-19 16:28:18 +0000 |
98 | @@ -19,28 +19,45 @@ |
99 | #ifndef MIR_TEST_FRAMEWORK_STUB_PLATFORM_EXTENSION_H_ |
100 | #define MIR_TEST_FRAMEWORK_STUB_PLATFORM_EXTENSION_H_ |
101 | |
102 | -#define MIR_EXTENSION_FAVORITE_FLAVOR "665f8be5-996f-4557-8404-f1c7ed94c04a" |
103 | -#define MIR_EXTENSION_ANIMAL_NAME "817e4327-bdd7-495a-9d3c-b5ac7a8a831f" |
104 | - |
105 | -#define MIR_EXTENSION_FAVORITE_FLAVOR_VERSION_1 1 |
106 | -#define MIR_EXTENSION_FAVORITE_FLAVOR_VERSION_2 2 |
107 | -#define MIR_EXTENSION_ANIMAL_NAME_VERSION_9 9 |
108 | +#include "mir_toolkit/mir_extension_core.h" |
109 | |
110 | #ifdef __cplusplus |
111 | extern "C" { |
112 | #endif |
113 | |
114 | typedef char const* (*mir_extension_favorite_flavor)(); |
115 | -struct MirExtensionFavoriteFlavor |
116 | +typedef struct MirExtensionFavoriteFlavorV1 |
117 | { |
118 | mir_extension_favorite_flavor favorite_flavor; |
119 | -}; |
120 | +} MirExtensionFavoriteFlavor; |
121 | +typedef MirExtensionFavoriteFlavorV1 MirExtensionFavoriteFlavorV9; |
122 | |
123 | typedef char const* (*mir_extension_animal_name)(); |
124 | -struct MirExtensionAnimalNames |
125 | +typedef struct MirExtensionAnimalNamesV1 |
126 | { |
127 | mir_extension_animal_name animal_name; |
128 | -}; |
129 | +} MirExtensionAnimalNames; |
130 | + |
131 | +static inline MirExtensionFavoriteFlavorV1 const* mir_extension_favorite_flavor_v1( |
132 | + MirConnection* connection) |
133 | +{ |
134 | + return (MirExtensionFavoriteFlavorV1 const*) mir_connection_request_extension( |
135 | + connection, "mir_extension_favorite_flavor", 1); |
136 | +} |
137 | + |
138 | +static inline MirExtensionFavoriteFlavorV9 const* mir_extension_favorite_flavor_v9( |
139 | + MirConnection* connection) |
140 | +{ |
141 | + return (MirExtensionFavoriteFlavorV9 const*) mir_connection_request_extension( |
142 | + connection, "mir_extension_favorite_flavor", 9); |
143 | +} |
144 | + |
145 | +static inline MirExtensionAnimalNamesV1 const* mir_extension_animal_names_v1( |
146 | + MirConnection* connection) |
147 | +{ |
148 | + return (MirExtensionAnimalNamesV1 const*) mir_connection_request_extension( |
149 | + connection, "mir_extension_animal_names", 1); |
150 | +} |
151 | |
152 | #ifdef __cplusplus |
153 | } |
154 | |
155 | === modified file 'playground/mir_egl_platform_shim.c' |
156 | --- playground/mir_egl_platform_shim.c 2016-11-23 04:37:50 +0000 |
157 | +++ playground/mir_egl_platform_shim.c 2016-12-19 16:28:18 +0000 |
158 | @@ -35,7 +35,7 @@ |
159 | int current_physical_width; //The driver is in charge of the physical width |
160 | int current_physical_height; //The driver is in charge of the physical height |
161 | |
162 | - struct MirExtensionAndroidEGL* ext; |
163 | + MirExtensionAndroidEGLV1 const* ext; |
164 | PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; |
165 | PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; |
166 | PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; |
167 | @@ -106,8 +106,7 @@ |
168 | memset(info, 0, sizeof(*info)); |
169 | info->connection = connection; |
170 | |
171 | - info->ext = (struct MirExtensionAndroidEGL*) mir_connection_request_interface( |
172 | - info->connection, MIR_EXTENSION_ANDROID_EGL, MIR_EXTENSION_ANDROID_EGL_VERSION_1); |
173 | + info->ext = mir_extension_android_egl_v1(info->connection); |
174 | info->eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC) eglGetProcAddress("eglCreateImageKHR"); |
175 | info->eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC) eglGetProcAddress("eglDestroyImageKHR"); |
176 | info->glEGLImageTargetTexture2DOES = |
177 | |
178 | === modified file 'src/client/mir_extension_core.cpp' |
179 | --- src/client/mir_extension_core.cpp 2016-12-13 06:00:32 +0000 |
180 | +++ src/client/mir_extension_core.cpp 2016-12-19 16:28:18 +0000 |
181 | @@ -22,14 +22,14 @@ |
182 | #include "mir/uncaught.h" |
183 | #include "mir/require.h" |
184 | |
185 | -void* mir_connection_request_interface( |
186 | +void const* mir_connection_request_extension( |
187 | MirConnection* connection, |
188 | char const* interface, |
189 | int version) |
190 | try |
191 | { |
192 | mir::require(connection); |
193 | - return connection->request_interface(interface, version); |
194 | + return const_cast<void const*>(connection->request_interface(interface, version)); |
195 | } |
196 | catch (std::exception const& ex) |
197 | { |
198 | |
199 | === modified file 'src/client/symbols.map' |
200 | --- src/client/symbols.map 2016-12-14 06:27:05 +0000 |
201 | +++ src/client/symbols.map 2016-12-19 16:28:18 +0000 |
202 | @@ -436,24 +436,23 @@ |
203 | |
204 | MIR_CLIENT_0.25 { # New functions in Mir 0.25 |
205 | global: |
206 | - mir_buffer_stream_set_swapinterval; |
207 | - mir_connection_cancel_base_display_configuration_preview; |
208 | mir_connection_create_spec_for_tip; |
209 | - mir_display_output_type_name; |
210 | mir_event_get_surface_placement_event; |
211 | - mir_input_device_state_event_device_pressed_keys_for_index; |
212 | mir_output_get_current_mode_index; |
213 | - mir_output_get_gamma; |
214 | - mir_output_get_gamma_size; |
215 | mir_output_get_preferred_mode_index; |
216 | mir_output_get_subpixel_arrangement; |
217 | + mir_output_get_gamma_size; |
218 | mir_output_is_gamma_supported; |
219 | + mir_output_get_gamma; |
220 | mir_output_set_gamma; |
221 | + mir_connection_cancel_base_display_configuration_preview; |
222 | + mir_surface_placement_get_relative_position; |
223 | + mir_display_output_type_name; |
224 | mir_output_type_name; |
225 | mir_surface_output_event_get_refresh_rate; |
226 | - mir_surface_placement_get_relative_position; |
227 | + mir_input_device_state_event_device_pressed_keys_for_index; |
228 | + mir_buffer_stream_set_swapinterval; |
229 | mir_buffer_stream_get_swapinterval; |
230 | - mir_connection_request_interface; |
231 | mir_buffer_stream_set_size; |
232 | mir_buffer_stream_get_size; |
233 | } MIR_CLIENT_0.24; |
234 | @@ -499,5 +498,6 @@ |
235 | mir_touchpad_configuration_set_middle_mouse_button_emulation; |
236 | mir_touchpad_configuration_set_scroll_modes; |
237 | mir_touchpad_configuration_set_tap_to_click; |
238 | + mir_connection_request_extension; |
239 | mir_output_get_model; |
240 | } MIR_CLIENT_0.25; |
241 | |
242 | === modified file 'src/include/client/mir_toolkit/extensions/android_buffer.h' |
243 | --- src/include/client/mir_toolkit/extensions/android_buffer.h 2016-11-30 18:00:03 +0000 |
244 | +++ src/include/client/mir_toolkit/extensions/android_buffer.h 2016-12-19 16:28:18 +0000 |
245 | @@ -16,15 +16,13 @@ |
246 | * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
247 | */ |
248 | |
249 | -#ifndef MIR_CLIENT_EXTENSIONS_ANDORID_BUFFER_H_ |
250 | -#define MIR_CLIENT_EXTENSIONS_ANDORID_BUFFER_H_ |
251 | - |
252 | -#define MIR_EXTENSION_ANDROID_BUFFER "149701d1-0c46-423f-a523-9cdc74d54860" |
253 | -#define MIR_EXTENSION_ANDROID_BUFFER_VERSION_1 1 |
254 | +#ifndef MIR_CLIENT_EXTENSIONS_ANDROID_BUFFER_H_ |
255 | +#define MIR_CLIENT_EXTENSIONS_ANDROID_BUFFER_H_ |
256 | |
257 | #include "mir_toolkit/mir_connection.h" |
258 | #include <mir_toolkit/client_types_nbs.h> |
259 | #include "mir_toolkit/mir_buffer.h" |
260 | +#include "mir_toolkit/mir_extension_core.h" |
261 | |
262 | #ifdef __cplusplus |
263 | extern "C" { |
264 | @@ -57,12 +55,19 @@ |
265 | unsigned int gralloc_usage_flags, |
266 | mir_buffer_callback available_callback, void* available_context); |
267 | |
268 | -struct MirExtensionAndroidBuffer |
269 | +typedef struct MirExtensionAndroidBufferV1 |
270 | { |
271 | mir_connection_allocate_buffer_android allocate_buffer_android; |
272 | -}; |
273 | +} MirExtensionAndroidBufferV1; |
274 | + |
275 | +static inline MirExtensionAndroidBufferV1 const* mir_extension_android_buffer_v1( |
276 | + MirConnection* connection) |
277 | +{ |
278 | + return (MirExtensionAndroidBufferV1 const*) mir_connection_request_extension( |
279 | + connection, "mir_extension_android_buffer", 1); |
280 | +} |
281 | |
282 | #ifdef __cplusplus |
283 | } |
284 | #endif |
285 | -#endif /* MIR_CLIENT_EXTENSIONS_ANDORID_BUFFER_H_ */ |
286 | +#endif /* MIR_CLIENT_EXTENSIONS_ANDROID_BUFFER_H_ */ |
287 | |
288 | === modified file 'src/include/client/mir_toolkit/extensions/android_egl.h' |
289 | --- src/include/client/mir_toolkit/extensions/android_egl.h 2016-11-22 03:42:44 +0000 |
290 | +++ src/include/client/mir_toolkit/extensions/android_egl.h 2016-12-19 16:28:18 +0000 |
291 | @@ -16,15 +16,13 @@ |
292 | * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
293 | */ |
294 | |
295 | -#ifndef MIR_CLIENT_EXTENSIONS_ANDORID_EGL_H_ |
296 | -#define MIR_CLIENT_EXTENSIONS_ANDORID_EGL_H_ |
297 | - |
298 | -#define MIR_EXTENSION_ANDROID_EGL "817e4327-bdd7-495a-9d3c-b5ac7a8a831f" |
299 | -#define MIR_EXTENSION_ANDROID_EGL_VERSION_1 1 |
300 | +#ifndef MIR_CLIENT_EXTENSIONS_ANDROID_EGL_H_ |
301 | +#define MIR_CLIENT_EXTENSIONS_ANDROID_EGL_H_ |
302 | |
303 | #include "mir_toolkit/mir_connection.h" |
304 | #include "mir_toolkit/mir_render_surface.h" |
305 | #include "mir_toolkit/mir_buffer.h" |
306 | +#include "mir_toolkit/mir_extension_core.h" |
307 | |
308 | #ifdef __cplusplus |
309 | extern "C" { |
310 | @@ -38,16 +36,23 @@ |
311 | typedef struct ANativeWindowBuffer* (*mir_extension_create_anwb)(MirBuffer*); |
312 | typedef void (*mir_extension_destroy_anwb)(struct ANativeWindowBuffer*); |
313 | |
314 | -struct MirExtensionAndroidEGL |
315 | +typedef struct MirExtensionAndroidEGLV1 |
316 | { |
317 | mir_extension_to_native_display_type to_display; |
318 | mir_extension_create_anw create_window; |
319 | mir_extension_destroy_anw destroy_window; |
320 | mir_extension_create_anwb create_buffer; |
321 | mir_extension_destroy_anwb destroy_buffer; |
322 | -}; |
323 | +} MirExtensionAndroidEGLV1; |
324 | + |
325 | +static inline MirExtensionAndroidEGLV1 const* mir_extension_android_egl_v1( |
326 | + MirConnection* connection) |
327 | +{ |
328 | + return (MirExtensionAndroidEGLV1 const*) mir_connection_request_extension( |
329 | + connection, "mir_extension_android_egl", 1); |
330 | +} |
331 | |
332 | #ifdef __cplusplus |
333 | } |
334 | #endif |
335 | -#endif /* MIR_CLIENT_EXTENSIONS_ANDORID_EGL_H_ */ |
336 | +#endif /* MIR_CLIENT_EXTENSIONS_ANDROID_EGL_H_ */ |
337 | |
338 | === modified file 'src/include/client/mir_toolkit/extensions/fenced_buffers.h' |
339 | --- src/include/client/mir_toolkit/extensions/fenced_buffers.h 2016-11-08 16:50:45 +0000 |
340 | +++ src/include/client/mir_toolkit/extensions/fenced_buffers.h 2016-12-19 16:28:18 +0000 |
341 | @@ -19,10 +19,8 @@ |
342 | #ifndef MIR_CLIENT_EXTENSIONS_FENCED_BUFFERS_H_ |
343 | #define MIR_CLIENT_EXTENSIONS_FENCED_BUFFERS_H_ |
344 | |
345 | -#define MIR_EXTENSION_FENCED_BUFFERS "d31d8ae9-dbd0-43b4-8d2d-30b8ff2f8586" |
346 | -#define MIR_EXTENSION_FENCED_BUFFERS_VERSION_1 1 |
347 | - |
348 | #include "mir_toolkit/client_types_nbs.h" |
349 | +#include "mir_toolkit/mir_extension_core.h" |
350 | |
351 | #ifdef __cplusplus |
352 | extern "C" { |
353 | @@ -88,13 +86,19 @@ |
354 | MirBufferAccess access, |
355 | int timeout); |
356 | |
357 | -struct MirExtensionFencedBuffers |
358 | +typedef struct MirExtensionFencedBuffersV1 |
359 | { |
360 | mir_buffer_get_fence get_fence; |
361 | mir_buffer_associate_fence associate_fence; |
362 | mir_buffer_wait_for_access wait_for_access; |
363 | -}; |
364 | +} MirExtensionFencedBuffersV1; |
365 | |
366 | +static inline MirExtensionFencedBuffersV1 const* mir_extension_fenced_buffers_v1( |
367 | + MirConnection* connection) |
368 | +{ |
369 | + return (MirExtensionFencedBuffersV1 const*) mir_connection_request_extension( |
370 | + connection, "mir_extension_fenced_buffers", 1); |
371 | +} |
372 | #ifdef __cplusplus |
373 | } |
374 | #endif |
375 | |
376 | === modified file 'src/platforms/android/client/android_client_platform.cpp' |
377 | --- src/platforms/android/client/android_client_platform.cpp 2016-12-14 06:27:05 +0000 |
378 | +++ src/platforms/android/client/android_client_platform.cpp 2016-12-19 16:28:18 +0000 |
379 | @@ -263,13 +263,11 @@ |
380 | |
381 | void* mcla::AndroidClientPlatform::request_interface(char const* name, int version) |
382 | { |
383 | - if (!strcmp(name, MIR_EXTENSION_FENCED_BUFFERS) && version == MIR_EXTENSION_FENCED_BUFFERS_VERSION_1) |
384 | - return &fence_extension; |
385 | - |
386 | - if (!strcmp(name, MIR_EXTENSION_ANDROID_EGL) && (version == MIR_EXTENSION_ANDROID_EGL_VERSION_1)) |
387 | + if (!strcmp(name, "mir_extension_android_egl") && (version == 1)) |
388 | return &android_types_extension; |
389 | - |
390 | - if (!strcmp(name, MIR_EXTENSION_ANDROID_BUFFER) && (version == MIR_EXTENSION_ANDROID_BUFFER_VERSION_1)) |
391 | + if (!strcmp(name, "mir_extension_android_buffer") && (version == 1)) |
392 | return &buffer_extension; |
393 | + if (!strcmp(name, "mir_extension_fenced_buffers") && version == 1) |
394 | + return &fence_extension; |
395 | return nullptr; |
396 | } |
397 | |
398 | === modified file 'src/platforms/android/client/android_client_platform.h' |
399 | --- src/platforms/android/client/android_client_platform.h 2016-12-14 06:27:05 +0000 |
400 | +++ src/platforms/android/client/android_client_platform.h 2016-12-19 16:28:18 +0000 |
401 | @@ -53,9 +53,9 @@ |
402 | std::shared_ptr<logging::Logger> const logger; |
403 | |
404 | std::shared_ptr<EGLNativeDisplayType> const native_display; |
405 | - MirExtensionAndroidEGL android_types_extension; |
406 | - MirExtensionFencedBuffers fence_extension; |
407 | - MirExtensionAndroidBuffer buffer_extension; |
408 | + MirExtensionAndroidEGLV1 android_types_extension; |
409 | + MirExtensionFencedBuffersV1 fence_extension; |
410 | + MirExtensionAndroidBufferV1 buffer_extension; |
411 | }; |
412 | |
413 | } |
414 | |
415 | === modified file 'src/platforms/mesa/client/client_platform.cpp' |
416 | --- src/platforms/mesa/client/client_platform.cpp 2016-12-09 02:54:31 +0000 |
417 | +++ src/platforms/mesa/client/client_platform.cpp 2016-12-19 16:28:18 +0000 |
418 | @@ -257,15 +257,9 @@ |
419 | |
420 | void* mclm::ClientPlatform::request_interface(char const* extension_name, int version) |
421 | { |
422 | - if (!strcmp(MIR_EXTENSION_MESA_DRM_AUTH, extension_name) && |
423 | - (MIR_EXTENSION_MESA_DRM_AUTH_VERSION_1 == version)) |
424 | - { |
425 | + if (!strcmp("mir_extension_mesa_drm_auth", extension_name) && (version == 1)) |
426 | return &drm_extensions; |
427 | - } |
428 | - if (!strcmp(extension_name, MIR_EXTENSION_SET_GBM_DEVICE) && |
429 | - (version == MIR_EXTENSION_SET_GBM_DEVICE_VERSION_1)) |
430 | - { |
431 | + if (!strcmp(extension_name, "mir_extension_set_gbm_device") && (version == 1)) |
432 | return &mesa_auth; |
433 | - } |
434 | return nullptr; |
435 | } |
436 | |
437 | === modified file 'src/platforms/mesa/client/client_platform.h' |
438 | --- src/platforms/mesa/client/client_platform.h 2016-12-09 02:54:31 +0000 |
439 | +++ src/platforms/mesa/client/client_platform.h 2016-12-19 16:28:18 +0000 |
440 | @@ -59,7 +59,7 @@ |
441 | std::shared_ptr<BufferFileOps> const buffer_file_ops; |
442 | EGLNativeDisplayContainer& display_container; |
443 | gbm_device* gbm_dev; |
444 | - MirExtensionMesaDRMAuth drm_extensions; |
445 | + MirExtensionMesaDRMAuthV1 drm_extensions; |
446 | MirExtensionSetGbmDevice mesa_auth; |
447 | }; |
448 | |
449 | |
450 | === modified file 'src/server/graphics/nested/mir_client_host_connection.cpp' |
451 | --- src/server/graphics/nested/mir_client_host_connection.cpp 2016-12-14 06:27:05 +0000 |
452 | +++ src/server/graphics/nested/mir_client_host_connection.cpp 2016-12-19 16:28:18 +0000 |
453 | @@ -551,9 +551,7 @@ |
454 | { |
455 | public: |
456 | HostBuffer(MirConnection* mir_connection, mg::BufferProperties const& properties) : |
457 | - fence_extensions(static_cast<MirExtensionFencedBuffers*>( |
458 | - mir_connection_request_interface(mir_connection, |
459 | - MIR_EXTENSION_FENCED_BUFFERS, MIR_EXTENSION_FENCED_BUFFERS_VERSION_1))) |
460 | + fence_extensions(mir_extension_fenced_buffers_v1(mir_connection)) |
461 | { |
462 | mir_connection_allocate_buffer( |
463 | mir_connection, |
464 | @@ -659,7 +657,7 @@ |
465 | } |
466 | |
467 | private: |
468 | - MirExtensionFencedBuffers* fence_extensions = nullptr; |
469 | + MirExtensionFencedBuffersV1 const* fence_extensions = nullptr; |
470 | |
471 | std::function<void()> f; |
472 | MirBuffer* handle = nullptr; |
473 | @@ -767,9 +765,7 @@ |
474 | mir::optional_value<std::shared_ptr<mir::graphics::MesaAuthExtension>> |
475 | mgn::MirClientHostConnection::auth_extension() |
476 | { |
477 | - auto ext = static_cast<MirExtensionMesaDRMAuth*>( |
478 | - mir_connection_request_interface(mir_connection, |
479 | - MIR_EXTENSION_MESA_DRM_AUTH, MIR_EXTENSION_MESA_DRM_AUTH_VERSION_1)); |
480 | + auto ext = mir_extension_mesa_drm_auth_v1(mir_connection); |
481 | if (!ext) |
482 | return {}; |
483 | |
484 | @@ -777,7 +773,7 @@ |
485 | { |
486 | AuthExtension( |
487 | MirConnection* connection, |
488 | - MirExtensionMesaDRMAuth* ext) : |
489 | + MirExtensionMesaDRMAuthV1 const* ext) : |
490 | connection(connection), |
491 | extensions(ext) |
492 | { |
493 | @@ -794,7 +790,7 @@ |
494 | } |
495 | private: |
496 | MirConnection* const connection; |
497 | - MirExtensionMesaDRMAuth* const extensions; |
498 | + MirExtensionMesaDRMAuthV1 const * const extensions; |
499 | }; |
500 | return { std::make_unique<AuthExtension>(mir_connection, ext) }; |
501 | } |
502 | @@ -802,15 +798,13 @@ |
503 | mir::optional_value<std::shared_ptr<mg::SetGbmExtension>> |
504 | mgn::MirClientHostConnection::set_gbm_extension() |
505 | { |
506 | - auto ext = static_cast<MirExtensionSetGbmDevice*>( |
507 | - mir_connection_request_interface(mir_connection, |
508 | - MIR_EXTENSION_SET_GBM_DEVICE, MIR_EXTENSION_SET_GBM_DEVICE_VERSION_1)); |
509 | + auto ext = mir_extension_set_gbm_device_v1(mir_connection); |
510 | if (!ext) |
511 | return {}; |
512 | |
513 | struct SetGbm : SetGbmExtension |
514 | { |
515 | - SetGbm(MirExtensionSetGbmDevice* ext) : |
516 | + SetGbm(MirExtensionSetGbmDevice const* ext) : |
517 | ext(ext) |
518 | { |
519 | } |
520 | @@ -818,7 +812,7 @@ |
521 | { |
522 | ext->set_gbm_device(dev, ext->context); |
523 | } |
524 | - MirExtensionSetGbmDevice* const ext; |
525 | + MirExtensionSetGbmDeviceV1 const* const ext; |
526 | }; |
527 | return { std::make_unique<SetGbm>(ext) }; |
528 | } |
529 | |
530 | === modified file 'tests/acceptance-tests/staging/test_presentation_chain.cpp' |
531 | --- tests/acceptance-tests/staging/test_presentation_chain.cpp 2016-12-14 06:27:05 +0000 |
532 | +++ tests/acceptance-tests/staging/test_presentation_chain.cpp 2016-12-19 16:28:18 +0000 |
533 | @@ -237,9 +237,7 @@ |
534 | { |
535 | SurfaceWithChainFromStart surface(connection, size, pf); |
536 | |
537 | - auto ext = static_cast<MirExtensionFencedBuffers*>( |
538 | - mir_connection_request_interface( |
539 | - connection, MIR_EXTENSION_FENCED_BUFFERS, MIR_EXTENSION_FENCED_BUFFERS_VERSION_1)); |
540 | + auto ext = mir_extension_fenced_buffers_v1(connection); |
541 | ASSERT_THAT(ext, Ne(nullptr)); |
542 | ASSERT_THAT(ext->get_fence, Ne(nullptr)); |
543 | |
544 | |
545 | === modified file 'tests/acceptance-tests/test_client_extensions.cpp' |
546 | --- tests/acceptance-tests/test_client_extensions.cpp 2016-11-17 06:04:51 +0000 |
547 | +++ tests/acceptance-tests/test_client_extensions.cpp 2016-12-19 16:28:18 +0000 |
548 | @@ -31,33 +31,24 @@ |
549 | |
550 | TEST_F(ClientExtensions, can_load_an_extension) |
551 | { |
552 | - auto ext_raw = mir_connection_request_interface( |
553 | - connection, MIR_EXTENSION_FAVORITE_FLAVOR, MIR_EXTENSION_FAVORITE_FLAVOR_VERSION_1); |
554 | - ASSERT_THAT(ext_raw, Ne(nullptr)); |
555 | - |
556 | - auto ext = static_cast<MirExtensionFavoriteFlavor*>(ext_raw); |
557 | + auto ext = mir_extension_favorite_flavor_v1(connection); |
558 | + ASSERT_THAT(ext, Ne(nullptr)); |
559 | ASSERT_THAT(ext->favorite_flavor, Ne(nullptr)); |
560 | EXPECT_THAT(ext->favorite_flavor(), StrEq("banana")); |
561 | } |
562 | |
563 | TEST_F(ClientExtensions, can_load_an_extension_with_a_different_version) |
564 | { |
565 | - auto ext_raw = mir_connection_request_interface( |
566 | - connection, MIR_EXTENSION_FAVORITE_FLAVOR, MIR_EXTENSION_FAVORITE_FLAVOR_VERSION_2); |
567 | - ASSERT_THAT(ext_raw, Ne(nullptr)); |
568 | - |
569 | - auto ext = static_cast<MirExtensionFavoriteFlavor*>(ext_raw); |
570 | + auto ext = mir_extension_favorite_flavor_v9(connection); |
571 | + ASSERT_THAT(ext, Ne(nullptr)); |
572 | ASSERT_THAT(ext->favorite_flavor, Ne(nullptr)); |
573 | EXPECT_THAT(ext->favorite_flavor(), StrEq("rhubarb")); |
574 | } |
575 | |
576 | TEST_F(ClientExtensions, can_load_different_extensions) |
577 | { |
578 | - auto ext_raw = mir_connection_request_interface( |
579 | - connection, MIR_EXTENSION_ANIMAL_NAME, MIR_EXTENSION_ANIMAL_NAME_VERSION_9); |
580 | - ASSERT_THAT(ext_raw, Ne(nullptr)); |
581 | - |
582 | - auto ext = static_cast<MirExtensionAnimalNames*>(ext_raw); |
583 | + auto ext = mir_extension_animal_names_v1(connection); |
584 | + ASSERT_THAT(ext, Ne(nullptr)); |
585 | ASSERT_THAT(ext->animal_name, Ne(nullptr)); |
586 | EXPECT_THAT(ext->animal_name(), Not(StrEq("mushroom"))); |
587 | } |
588 | @@ -65,8 +56,8 @@ |
589 | TEST_F(ClientExtensions, gives_nullptr_on_errors) |
590 | { |
591 | int made_up_version = 10101; |
592 | - EXPECT_THAT(mir_connection_request_interface( |
593 | - connection, MIR_EXTENSION_ANIMAL_NAME, made_up_version), Eq(nullptr)); |
594 | - EXPECT_THAT(mir_connection_request_interface( |
595 | - connection, "pancake", MIR_EXTENSION_ANIMAL_NAME_VERSION_9), Eq(nullptr)); |
596 | + EXPECT_THAT(mir_connection_request_extension( |
597 | + connection, "mir_extension_animal_names", made_up_version), Eq(nullptr)); |
598 | + EXPECT_THAT(mir_connection_request_extension( |
599 | + connection, "pancake", 8), Eq(nullptr)); |
600 | } |
601 | |
602 | === modified file 'tests/include/mir_test_framework/stub_client_platform_factory.h' |
603 | --- tests/include/mir_test_framework/stub_client_platform_factory.h 2016-11-08 16:50:45 +0000 |
604 | +++ tests/include/mir_test_framework/stub_client_platform_factory.h 2016-12-19 16:28:18 +0000 |
605 | @@ -44,10 +44,10 @@ |
606 | mir::client::ClientContext* const context; |
607 | MirBufferPackage mutable native_buffer; |
608 | |
609 | - MirExtensionFavoriteFlavor flavor_ext_0_1; |
610 | - MirExtensionFavoriteFlavor flavor_ext_2_2; |
611 | - MirExtensionAnimalNames animal_ext; |
612 | - MirExtensionFencedBuffers fence_ext; |
613 | + MirExtensionFavoriteFlavorV1 flavor_ext_1; |
614 | + MirExtensionFavoriteFlavorV9 flavor_ext_9; |
615 | + MirExtensionAnimalNamesV1 animal_ext; |
616 | + MirExtensionFencedBuffersV1 fence_ext; |
617 | }; |
618 | |
619 | struct StubClientPlatformFactory : public mir::client::ClientPlatformFactory |
620 | |
621 | === modified file 'tests/mir_test_framework/stub_client_platform_factory.cpp' |
622 | --- tests/mir_test_framework/stub_client_platform_factory.cpp 2016-11-22 14:49:28 +0000 |
623 | +++ tests/mir_test_framework/stub_client_platform_factory.cpp 2016-12-19 16:28:18 +0000 |
624 | @@ -35,12 +35,12 @@ |
625 | |
626 | namespace |
627 | { |
628 | -char const* favorite_flavor_0_1() |
629 | +char const* favorite_flavor_1() |
630 | { |
631 | static char const* favorite = "banana"; |
632 | return favorite; |
633 | } |
634 | -char const* favorite_flavor_2_2() |
635 | +char const* favorite_flavor_9() |
636 | { |
637 | static char const* favorite = "rhubarb"; |
638 | return favorite; |
639 | @@ -59,8 +59,8 @@ |
640 | |
641 | mtf::StubClientPlatform::StubClientPlatform(mir::client::ClientContext* context) : |
642 | context{context}, |
643 | - flavor_ext_0_1{favorite_flavor_0_1}, |
644 | - flavor_ext_2_2{favorite_flavor_2_2}, |
645 | + flavor_ext_1{favorite_flavor_1}, |
646 | + flavor_ext_9{favorite_flavor_9}, |
647 | animal_ext{animal_name}, |
648 | fence_ext{get_fence, nullptr, nullptr} |
649 | { |
650 | @@ -147,29 +147,14 @@ |
651 | |
652 | void* mtf::StubClientPlatform::request_interface(char const* name, int version) |
653 | { |
654 | - if (!strcmp(name, MIR_EXTENSION_FAVORITE_FLAVOR) && |
655 | - (version == MIR_EXTENSION_FAVORITE_FLAVOR_VERSION_1)) |
656 | - { |
657 | - return &flavor_ext_0_1; |
658 | - } |
659 | - |
660 | - if (!strcmp(name, MIR_EXTENSION_FAVORITE_FLAVOR) && |
661 | - (version == MIR_EXTENSION_FAVORITE_FLAVOR_VERSION_2)) |
662 | - { |
663 | - return &flavor_ext_2_2; |
664 | - } |
665 | - |
666 | - if (!strcmp(name, MIR_EXTENSION_ANIMAL_NAME) && |
667 | - (version == MIR_EXTENSION_ANIMAL_NAME_VERSION_9)) |
668 | - { |
669 | + if (!strcmp(name, "mir_extension_favorite_flavor") && (version == 1)) |
670 | + return &flavor_ext_1; |
671 | + if (!strcmp(name, "mir_extension_favorite_flavor") && (version == 9)) |
672 | + return &flavor_ext_9; |
673 | + if (!strcmp(name, "mir_extension_animal_names") && (version == 1)) |
674 | return &animal_ext; |
675 | - } |
676 | - |
677 | - if (!strcmp(name, MIR_EXTENSION_FENCED_BUFFERS) && |
678 | - (version == MIR_EXTENSION_FENCED_BUFFERS_VERSION_1)) |
679 | - { |
680 | + if (!strcmp(name, "mir_extension_fenced_buffers") && (version == 1)) |
681 | return &fence_ext; |
682 | - } |
683 | return nullptr; |
684 | } |
685 | |
686 | |
687 | === modified file 'tests/unit-tests/platforms/android/client/test_android_client_platform.cpp' |
688 | --- tests/unit-tests/platforms/android/client/test_android_client_platform.cpp 2016-12-14 06:27:05 +0000 |
689 | +++ tests/unit-tests/platforms/android/client/test_android_client_platform.cpp 2016-12-19 16:28:18 +0000 |
690 | @@ -133,9 +133,8 @@ |
691 | native_handle{std::make_shared<native_handle_t>()}, |
692 | mock_native_buffer{std::make_shared<NiceMock<mtd::MockAndroidNativeBuffer>>(geom::Size{1, 1})}, |
693 | mock_registrar{create_registrar()}, |
694 | - extension(static_cast<MirExtensionFencedBuffers*>( |
695 | - platform->request_interface( |
696 | - MIR_EXTENSION_FENCED_BUFFERS, MIR_EXTENSION_FENCED_BUFFERS_VERSION_1))) |
697 | + extension(static_cast<MirExtensionFencedBuffersV1*>( |
698 | + platform->request_interface("mir_extension_fenced_buffers", 1))) |
699 | { |
700 | } |
701 | |
702 | @@ -145,7 +144,7 @@ |
703 | std::shared_ptr<mtd::MockAndroidNativeBuffer> const mock_native_buffer; |
704 | std::shared_ptr<mtd::MockBufferRegistrar> const mock_registrar; |
705 | MirBufferPackage package; |
706 | - MirExtensionFencedBuffers* extension; |
707 | + MirExtensionFencedBuffersV1* extension; |
708 | int fake_fence = 8482; |
709 | mcl::Buffer buffer{ |
710 | nullptr, nullptr, 0, |
711 | @@ -264,9 +263,8 @@ |
712 | |
713 | int width = 32; |
714 | int height = 90; |
715 | - auto ext = static_cast<MirExtensionAndroidBuffer*>( |
716 | - platform->request_interface( |
717 | - MIR_EXTENSION_ANDROID_BUFFER,MIR_EXTENSION_ANDROID_BUFFER_VERSION_1)); |
718 | + auto ext = static_cast<MirExtensionAndroidBufferV1*>( |
719 | + platform->request_interface("mir_extension_android_buffer", 1)); |
720 | ASSERT_THAT(ext, Ne(nullptr)); |
721 | ASSERT_THAT(ext->allocate_buffer_android, Ne(nullptr)); |
722 |
fwiw, I'm alright with the current scheme, although the proposed scheme seems to be simpler, and resolve the comments about the current scheme that I can recollect.