Mir

Merge lp:~kuchtam/mir/mir into lp:mir

Proposed by Michał Kuchta
Status: Rejected
Rejected by: Daniel van Vugt
Proposed branch: lp:~kuchtam/mir/mir
Merge into: lp:mir
Diff against target: 87 lines (+38/-0)
5 files modified
include/client/mir_toolkit/mir_connection.h (+7/-0)
include/core/mir_toolkit/mir_version_number.h (+13/-0)
src/client/mir_connection_api.cpp (+5/-0)
src/client/symbols.map (+1/-0)
tests/acceptance-tests/test_client_header_version.cpp (+12/-0)
To merge this branch: bzr merge lp:~kuchtam/mir/mir
Reviewer Review Type Date Requested Status
Daniel van Vugt Needs Fixing
Brandon Schaefer (community) Abstain
Review via email: mp+315950@code.launchpad.net

Commit message

Implementation of bug#1195540 - "[enhancement] Make able to get version information from client / server APIs"

Description of the change

Implementation of bug#1195540 - "[enhancement] Make able to get version information from client / server APIs"

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Thanks for doing this.

I believe it's actually the version of libmirclient that we want to return. Not the version of libmirserver. So you can do that just by returning:
  MIR_CLIENT_API_VERSION
or:
  MIR_VERSION_NUMBER(MIR_VERSION_MAJOR, MIR_VERSION_MINOR, MIR_VERSION_PATCH)

review: Needs Fixing
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Also if you're doing c++ calls that can possibly throw we need to surround that with try/catch to avoid leaking a throw to the C API.

+unsigned mir_connection_get_server_version(const MirConnection* connection)

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I think you can safely skip Brandon's comment because it's not relevant to the final solution. All we need is:

unsigned mir_get_client_api_version()
{
    return MIR_CLIENT_API_VERSION;
}

And yes, those are different things. One describes the version of the headers you are using and the other describes the version of the libmirclient binary that you are using. Usually they will be equal, but the point of bug 1195540 is to cover cases where you want to dynamically bind to new API functions at runtime.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Very true

review: Abstain
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

You need to add a commit message to the merge request so that CI will run with the branch and allow autolanding.

lp:~kuchtam/mir/mir updated
3973. By Michal Kuchta <email address hidden>

Fix after review

3974. By Michal Kuchta <email address hidden>

Fix after review - merge

Revision history for this message
Michał Kuchta (kuchtam) wrote :

Thank you for your comments.

I’ve made corrections according your comments: -r 3974.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Thanks. But MIR_CLIENT_API_VERSION is already defined (starting in Mir v0.26.0 released a few hours ago). Get it from mir_toolkit/version.h

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

That also means the new function is part of Mir 0.27 (or 1.0 or whatever), so this needs moving:

63 mir_window_request_persistent_id_sync;
64 + mir_get_client_api_version;
65 } MIR_CLIENT_0.25;

Revision history for this message
Michał Kuchta (kuchtam) wrote :

I have committed correction and it is available on separate branch: https://code.launchpad.net/~kuchtam/mir/bug_1195540_after_review/+merge/316287

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

OK, I'll reject this branch and look at the other one instead.

Unmerged revisions

3974. By Michal Kuchta <email address hidden>

Fix after review - merge

3973. By Michal Kuchta <email address hidden>

Fix after review

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/client/mir_toolkit/mir_connection.h'
2--- include/client/mir_toolkit/mir_connection.h 2017-01-31 19:33:32 +0000
3+++ include/client/mir_toolkit/mir_connection.h 2017-02-02 00:05:14 +0000
4@@ -473,6 +473,13 @@
5 MirErrorCallback callback,
6 void* context);
7
8+/**
9+ * Returns client API version
10+ *
11+ * \return The client API version
12+ */
13+unsigned mir_get_client_api_version();
14+
15 #ifdef __cplusplus
16 }
17 /**@}*/
18
19=== modified file 'include/core/mir_toolkit/mir_version_number.h'
20--- include/core/mir_toolkit/mir_version_number.h 2017-01-18 02:29:37 +0000
21+++ include/core/mir_toolkit/mir_version_number.h 2017-02-02 00:05:14 +0000
22@@ -34,4 +34,17 @@
23 #define MIR_VERSION_NUMBER(major,minor,micro) \
24 (((major) << 22) + ((minor) << 12) + (micro))
25
26+/**
27+ * MIR_CLIENT_API_VERSION
28+ * \param major [in] The major version (eg: 0 for version 0.26)
29+ * \param minor [in] The minor version (eg: 26 for version 0.26)
30+ *
31+ * Returns the combined version information as a single 32-bit value.
32+ *
33+ * Can be use to write a client that is not dependent on the newer
34+ * functionality but can utilize it.
35+ */
36+#define MIR_CLIENT_API_VERSION(major,minor) \
37+ ((major << 16) + minor)
38+
39 #endif /* MIR_VERSION_NUMBER_H_ */
40
41=== modified file 'src/client/mir_connection_api.cpp'
42--- src/client/mir_connection_api.cpp 2017-01-24 19:42:48 +0000
43+++ src/client/mir_connection_api.cpp 2017-02-02 00:05:14 +0000
44@@ -414,6 +414,11 @@
45 }
46 }
47
48+unsigned mir_get_client_api_version()
49+{
50+ return MIR_CLIENT_API_VERSION(MIR_VERSION_MAJOR, MIR_VERSION_MINOR);
51+}
52+
53 void mir_connection_apply_session_display_config(MirConnection* connection, MirDisplayConfig const* display_config)
54 try
55 {
56
57=== modified file 'src/client/symbols.map'
58--- src/client/symbols.map 2017-02-01 18:29:26 +0000
59+++ src/client/symbols.map 2017-02-02 00:05:14 +0000
60@@ -583,6 +583,7 @@
61 mir_window_get_preferred_orientation;
62 mir_window_request_persistent_id;
63 mir_window_request_persistent_id_sync;
64+ mir_get_client_api_version;
65 } MIR_CLIENT_0.25;
66
67 MIR_CLIENT_0.27 { # New functions in Mir 0.27 or 1.0
68
69=== modified file 'tests/acceptance-tests/test_client_header_version.cpp'
70--- tests/acceptance-tests/test_client_header_version.cpp 2017-01-17 05:58:36 +0000
71+++ tests/acceptance-tests/test_client_header_version.cpp 2017-02-02 00:05:14 +0000
72@@ -80,3 +80,15 @@
73 MIR_VERSION_MINOR,
74 MIR_VERSION_MICRO), MIR_CLIENT_API_VERSION);
75 }
76+
77+TEST(ClientApiVersion, mir_client_api_version_is_sane)
78+{
79+
80+ EXPECT_TRUE(0x00010000 >= MIR_CLIENT_API_VERSION(1, 0));
81+
82+ EXPECT_TRUE(0x00000001 >= MIR_CLIENT_API_VERSION(0, 1));
83+
84+ EXPECT_TRUE(0x00010001 >= MIR_CLIENT_API_VERSION(1, 1));
85+
86+ EXPECT_TRUE(0x0002ffff >= MIR_CLIENT_API_VERSION(1, 65536));
87+}

Subscribers

People subscribed via source and target branches