Mir

Merge lp:~afrantzis/mir/introduce-c++14 into lp:mir

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Cemil Azizoglu
Approved revision: no longer in the source branch.
Merged at revision: 2328
Proposed branch: lp:~afrantzis/mir/introduce-c++14
Merge into: lp:mir
Diff against target: 285 lines (+37/-46)
17 files modified
CMakeLists.txt (+1/-1)
src/client/lttng/rpc_report.cpp (+1/-1)
src/client/mir_connection_api.cpp (+1/-1)
src/client/rpc/make_socket_rpc_channel.cpp (+2/-2)
src/server/compositor/compositing_screencast.cpp (+1/-2)
src/server/compositor/default_display_buffer_compositor_factory.cpp (+2/-2)
src/server/compositor/gl_renderer_factory.cpp (+2/-3)
src/server/compositor/multi_threaded_compositor.cpp (+2/-2)
src/server/compositor/timeout_frame_dropping_policy_factory.cpp (+1/-1)
src/server/glib_main_loop.cpp (+2/-2)
src/server/graphics/nested/nested_display.cpp (+3/-6)
src/server/graphics/offscreen/display.cpp (+3/-5)
src/server/graphics/program_factory.cpp (+3/-4)
src/server/report/default_server_configuration.cpp (+3/-3)
src/server/scene/basic_surface.cpp (+8/-9)
src/server/server.cpp (+1/-1)
src/server/thread/basic_thread_pool.cpp (+1/-1)
To merge this branch: bzr merge lp:~afrantzis/mir/introduce-c++14
Reviewer Review Type Date Requested Status
Cemil Azizoglu (community) Approve
Alan Griffiths Approve
Daniel van Vugt Disapprove
Chris Halse Rogers Approve
Robert Carr (community) Abstain
Alberto Aguirre (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Andreas Pokorny (community) Approve
Review via email: mp+249988@code.launchpad.net

Commit message

Introduce C++14 by using std::make_unique<> in our core code

Description of the change

Introduce C++14 by using std::make_unique<> in our core code

To post a comment you must log in.
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

Should I write needs fixing because you did not replace optional_value with std::optional?

looks good.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

*Needs Discussion*

We need to agree whether using language features that are not available in the LTS is acceptable before landing this. (See related discussion on mir-devel mailing list.)

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> *Needs Discussion*
>
> We need to agree whether using language features that are not available in the
> LTS is acceptable before landing this. (See related discussion on mir-devel
> mailing list.)

review: Needs Information
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

"Should I write needs fixing because you did not replace optional_value with std::optional?"

Currently mir::optional is part of SurfaceCreationParameters which is public.

std::optional is not in C++14, so I would not want to expose std::experimental::optional in a public interface.

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

LGTM.

review: Approve
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Let's give everybody a chance to comment, if they feel like it, on supporting C++14 before TAing.

review: Approve
Revision history for this message
Robert Carr (robertcarr) wrote :

I have no concerns beyond the outstanding decision on Trusty.

review: Abstain
Revision history for this message
Chris Halse Rogers (raof) wrote :
review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

As discussed yesterday, I think this is a bad idea.

Here we've gone out of our way to make helping trusty users impossible. Just as soon as I mentioned in the meeting that I was going out of my way to help them.

review: Disapprove
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Given the existence of:
> https://launchpad.net/~ubuntu-
> toolchain-r/+archive/ubuntu/test?field.series_filter=trusty
>
> I'm very much in favour.

Works for me

review: Approve
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Compiler is one aspect of supporting Trusty and with the PPA Chris pointed out, we seem to be fairly okay in that aspect. I don't see any reason not to move to C++14.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-02-13 06:12:34 +0000
3+++ CMakeLists.txt 2015-02-17 12:25:13 +0000
4@@ -59,7 +59,7 @@
5 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${build_types}")
6
7 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -g -Werror -Wall -pedantic -Wextra -fPIC")
8-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -g -std=c++0x -Werror -Wall -fno-strict-aliasing -pedantic -Wnon-virtual-dtor -Wextra -fPIC")
9+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -g -std=c++14 -Werror -Wall -fno-strict-aliasing -pedantic -Wnon-virtual-dtor -Wextra -fPIC")
10
11 if ("${CMAKE_CXX_COMPILER}" MATCHES "clang")
12 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage -Wno-mismatched-tags")
13
14=== modified file 'src/client/lttng/rpc_report.cpp'
15--- src/client/lttng/rpc_report.cpp 2015-01-21 07:34:50 +0000
16+++ src/client/lttng/rpc_report.cpp 2015-02-17 12:25:13 +0000
17@@ -96,7 +96,7 @@
18 google::protobuf::Message const& /*response*/,
19 std::vector<Fd> const& fds)
20 {
21- std::unique_ptr<int[]> handles{new int[fds.size()]};
22+ auto handles = std::make_unique<int[]>(fds.size());
23 for (unsigned i = 0 ; i < fds.size() ; ++i)
24 {
25 handles[i] = fds[i];
26
27=== modified file 'src/client/mir_connection_api.cpp'
28--- src/client/mir_connection_api.cpp 2015-02-13 06:12:34 +0000
29+++ src/client/mir_connection_api.cpp 2015-02-17 12:25:13 +0000
30@@ -77,7 +77,7 @@
31
32 auto const conf = configuration(sock);
33
34- std::unique_ptr<MirConnection> connection{new MirConnection(*conf)};
35+ auto connection = std::make_unique<MirConnection>(*conf);
36 auto const result = connection->connect(name, callback, context);
37 connection.release();
38 return result;
39
40=== modified file 'src/client/rpc/make_socket_rpc_channel.cpp'
41--- src/client/rpc/make_socket_rpc_channel.cpp 2015-01-21 07:34:50 +0000
42+++ src/client/rpc/make_socket_rpc_channel.cpp 2015-02-17 12:25:13 +0000
43@@ -52,11 +52,11 @@
44 if (fd_prefix.is_start_of(name))
45 {
46 auto const fd = atoi(name.c_str()+fd_prefix.size);
47- transport = std::unique_ptr<mclr::StreamTransport>{new mclr::StreamSocketTransport{mir::Fd{fd}}};
48+ transport = std::make_unique<mclr::StreamSocketTransport>(mir::Fd{fd});
49 }
50 else
51 {
52- transport = std::unique_ptr<mclr::StreamTransport>{new mclr::StreamSocketTransport{name}};
53+ transport = std::make_unique<mclr::StreamSocketTransport>(name);
54 }
55 return std::make_shared<MirProtobufRpcChannel>(std::move(transport), map, disp_conf, rpc_report, lifecycle_control, event_sink);
56 }
57
58=== modified file 'src/server/compositor/compositing_screencast.cpp'
59--- src/server/compositor/compositing_screencast.cpp 2014-10-21 12:40:38 +0000
60+++ src/server/compositor/compositing_screencast.cpp 2015-02-17 12:25:13 +0000
61@@ -163,8 +163,7 @@
62 [&] { gl_context_raw->release_current(); });
63
64 auto buffer = buffer_allocator->alloc_buffer(buffer_properties);
65- auto display_buffer = std::unique_ptr<ScreencastDisplayBuffer>(
66- new ScreencastDisplayBuffer{rect, *buffer});
67+ auto display_buffer = std::make_unique<ScreencastDisplayBuffer>(rect, *buffer);
68 auto db_compositor = db_compositor_factory->create_compositor_for(*display_buffer);
69
70 return std::shared_ptr<detail::ScreencastSessionContext>(
71
72=== modified file 'src/server/compositor/default_display_buffer_compositor_factory.cpp'
73--- src/server/compositor/default_display_buffer_compositor_factory.cpp 2015-01-21 07:34:50 +0000
74+++ src/server/compositor/default_display_buffer_compositor_factory.cpp 2015-02-17 12:25:13 +0000
75@@ -42,6 +42,6 @@
76 auto dest_alpha = display_buffer.uses_alpha() ?
77 DestinationAlpha::generate_from_source : DestinationAlpha::opaque;
78 auto renderer = renderer_factory->create_renderer_for(display_buffer.view_area(), dest_alpha);
79- return std::unique_ptr<DisplayBufferCompositor>(
80- new DefaultDisplayBufferCompositor{display_buffer, std::move(renderer), report});
81+ return std::make_unique<DefaultDisplayBufferCompositor>(
82+ display_buffer, std::move(renderer), report);
83 }
84
85=== modified file 'src/server/compositor/gl_renderer_factory.cpp'
86--- src/server/compositor/gl_renderer_factory.cpp 2015-01-21 07:34:50 +0000
87+++ src/server/compositor/gl_renderer_factory.cpp 2015-02-17 12:25:13 +0000
88@@ -30,8 +30,7 @@
89 mc::GLRendererFactory::create_renderer_for(geom::Rectangle const& rect,
90 DestinationAlpha dest_alpha)
91 {
92- auto raw = new GLRenderer(
93- std::unique_ptr<mg::GLTextureCache>(new RecentlyUsedCache()),
94+ return std::make_unique<GLRenderer>(
95+ std::make_unique<RecentlyUsedCache>(),
96 rect, dest_alpha);
97- return std::unique_ptr<mc::Renderer>(raw);
98 }
99
100=== modified file 'src/server/compositor/multi_threaded_compositor.cpp'
101--- src/server/compositor/multi_threaded_compositor.cpp 2015-01-21 11:20:14 +0000
102+++ src/server/compositor/multi_threaded_compositor.cpp 2015-02-17 12:25:13 +0000
103@@ -307,8 +307,8 @@
104 /* Start the display buffer compositing threads */
105 display->for_each_display_buffer([this](mg::DisplayBuffer& buffer)
106 {
107- auto thread_functor_raw = new mc::CompositingFunctor{display_buffer_compositor_factory, buffer, scene, report};
108- auto thread_functor = std::unique_ptr<mc::CompositingFunctor>(thread_functor_raw);
109+ auto thread_functor = std::make_unique<mc::CompositingFunctor>(
110+ display_buffer_compositor_factory, buffer, scene, report);
111
112 futures.push_back(thread_pool.run(std::ref(*thread_functor), &buffer));
113 thread_functors.push_back(std::move(thread_functor));
114
115=== modified file 'src/server/compositor/timeout_frame_dropping_policy_factory.cpp'
116--- src/server/compositor/timeout_frame_dropping_policy_factory.cpp 2015-01-21 07:34:50 +0000
117+++ src/server/compositor/timeout_frame_dropping_policy_factory.cpp 2015-02-17 12:25:13 +0000
118@@ -91,5 +91,5 @@
119
120 std::unique_ptr<mc::FrameDroppingPolicy> mc::TimeoutFrameDroppingPolicyFactory::create_policy(std::function<void ()> drop_frame) const
121 {
122- return std::unique_ptr<mc::FrameDroppingPolicy>{new TimeoutFrameDroppingPolicy{timer, timeout, drop_frame}};
123+ return std::make_unique<TimeoutFrameDroppingPolicy>(timer, timeout, drop_frame);
124 }
125
126=== modified file 'src/server/glib_main_loop.cpp'
127--- src/server/glib_main_loop.cpp 2015-01-21 07:34:50 +0000
128+++ src/server/glib_main_loop.cpp 2015-02-17 12:25:13 +0000
129@@ -253,8 +253,8 @@
130 catch (...) { handle_exception(std::current_exception()); }
131 };
132
133- return std::unique_ptr<mir::time::Alarm>{
134- new AlarmImpl(main_context, clock, callback_with_exception_handling)};
135+ return std::make_unique<AlarmImpl>(
136+ main_context, clock, callback_with_exception_handling);
137 }
138
139 void mir::GLibMainLoop::reprocess_all_sources()
140
141=== modified file 'src/server/graphics/nested/nested_display.cpp'
142--- src/server/graphics/nested/nested_display.cpp 2015-02-13 06:12:34 +0000
143+++ src/server/graphics/nested/nested_display.cpp 2015-02-17 12:25:13 +0000
144@@ -153,11 +153,8 @@
145
146 std::unique_ptr<mg::DisplayConfiguration> mgn::NestedDisplay::configuration() const
147 {
148- return std::unique_ptr<mg::DisplayConfiguration>(
149- new NestedDisplayConfiguration(
150- connection->create_display_config()
151- )
152- );
153+ return std::make_unique<NestedDisplayConfiguration>(
154+ connection->create_display_config());
155 }
156
157 void mgn::NestedDisplay::complete_display_initialization(MirPixelFormat format)
158@@ -267,5 +264,5 @@
159
160 std::unique_ptr<mg::GLContext> mgn::NestedDisplay::create_gl_context()
161 {
162- return std::unique_ptr<mg::GLContext>{new SurfacelessEGLContext(egl_display, EGL_NO_CONTEXT)};
163+ return std::make_unique<SurfacelessEGLContext>(egl_display, EGL_NO_CONTEXT);
164 }
165
166=== modified file 'src/server/graphics/offscreen/display.cpp'
167--- src/server/graphics/offscreen/display.cpp 2015-01-21 07:34:50 +0000
168+++ src/server/graphics/offscreen/display.cpp 2015-02-17 12:25:13 +0000
169@@ -106,9 +106,8 @@
170 std::unique_ptr<mg::DisplayConfiguration> mgo::Display::configuration() const
171 {
172 std::lock_guard<std::mutex> lock{configuration_mutex};
173- return std::unique_ptr<mg::DisplayConfiguration>(
174- new mgo::DisplayConfiguration(current_display_configuration)
175- );
176+ return std::make_unique<mgo::DisplayConfiguration>(
177+ current_display_configuration);
178 }
179
180 void mgo::Display::configure(mg::DisplayConfiguration const& conf)
181@@ -165,6 +164,5 @@
182
183 std::unique_ptr<mg::GLContext> mgo::Display::create_gl_context()
184 {
185- return std::unique_ptr<GLContext>{
186- new SurfacelessEGLContext{egl_display, egl_context_shared}};
187+ return std::make_unique<SurfacelessEGLContext>(egl_display, egl_context_shared);
188 }
189
190=== modified file 'src/server/graphics/program_factory.cpp'
191--- src/server/graphics/program_factory.cpp 2015-01-21 07:34:50 +0000
192+++ src/server/graphics/program_factory.cpp 2015-02-17 12:25:13 +0000
193@@ -29,12 +29,11 @@
194 std::string const& fragment_shader) const
195 {
196 std::lock_guard<decltype(mutex)> lock(mutex);
197- return std::unique_ptr<mg::GLProgram>(
198- new SimpleGLProgram(vertex_shader.c_str(), fragment_shader.c_str()));
199+ return std::make_unique<SimpleGLProgram>(
200+ vertex_shader.c_str(), fragment_shader.c_str());
201 }
202
203 std::unique_ptr<mg::GLTextureCache> mg::ProgramFactory::create_texture_cache() const
204 {
205- return std::unique_ptr<mg::GLTextureCache>(
206- new mir::compositor::RecentlyUsedCache());
207+ return std::make_unique<mir::compositor::RecentlyUsedCache>();
208 }
209
210=== modified file 'src/server/report/default_server_configuration.cpp'
211--- src/server/report/default_server_configuration.cpp 2015-02-13 06:12:34 +0000
212+++ src/server/report/default_server_configuration.cpp 2015-02-17 12:25:13 +0000
213@@ -37,15 +37,15 @@
214
215 if (opt == options::log_opt_value)
216 {
217- return std::unique_ptr<mir::report::ReportFactory>(new report::LoggingReportFactory(the_logger(), the_clock()));
218+ return std::make_unique<report::LoggingReportFactory>(the_logger(), the_clock());
219 }
220 else if (opt == options::lttng_opt_value)
221 {
222- return std::unique_ptr<mir::report::ReportFactory>(new report::LttngReportFactory());
223+ return std::make_unique<report::LttngReportFactory>();
224 }
225 else if (opt == options::off_opt_value)
226 {
227- return std::unique_ptr<mir::report::ReportFactory>(new report::NullReportFactory());
228+ return std::make_unique<report::NullReportFactory>();
229 }
230 else
231 {
232
233=== modified file 'src/server/scene/basic_surface.cpp'
234--- src/server/scene/basic_surface.cpp 2015-02-03 15:07:44 +0000
235+++ src/server/scene/basic_surface.cpp 2015-02-17 12:25:13 +0000
236@@ -722,15 +722,14 @@
237 {
238 std::unique_lock<std::mutex> lk(guard);
239
240- return std::unique_ptr<mg::Renderable>(
241- new SurfaceSnapshot(
242- surface_buffer_stream,
243- compositor_id,
244- surface_rect,
245- transformation_matrix,
246- surface_alpha,
247- nonrectangular,
248- this));
249+ return std::make_unique<SurfaceSnapshot>(
250+ surface_buffer_stream,
251+ compositor_id,
252+ surface_rect,
253+ transformation_matrix,
254+ surface_alpha,
255+ nonrectangular,
256+ this);
257 }
258
259 int ms::BasicSurface::buffers_ready_for_compositor(void const* id) const
260
261=== modified file 'src/server/server.cpp'
262--- src/server/server.cpp 2015-02-13 06:12:34 +0000
263+++ src/server/server.cpp 2015-02-17 12:25:13 +0000
264@@ -173,7 +173,7 @@
265 auto create_renderer_for(mir::geometry::Rectangle const&, mir::compositor::DestinationAlpha)
266 -> std::unique_ptr<mir::compositor::Renderer>
267 {
268- return std::unique_ptr<mir::compositor::Renderer>(new StubRenderer());
269+ return std::make_unique<StubRenderer>();
270 }
271 };
272 }
273
274=== modified file 'src/server/thread/basic_thread_pool.cpp'
275--- src/server/thread/basic_thread_pool.cpp 2015-01-21 07:34:50 +0000
276+++ src/server/thread/basic_thread_pool.cpp 2015-02-17 12:25:13 +0000
277@@ -204,7 +204,7 @@
278 if (worker_thread == nullptr)
279 {
280 // No idle threads available so create a new one
281- std::unique_ptr<WorkerThread> new_worker_thread{new WorkerThread{id}};
282+ auto new_worker_thread = std::make_unique<WorkerThread>(id);
283 threads.push_back(std::move(new_worker_thread));
284 worker_thread = threads.back().get();
285 }

Subscribers

People subscribed via source and target branches