Skip to content

Commit df1ea47

Browse files
committed
Bug#26036912 COMPONENT MACRO DO CONFUSE CODE FORMATTERS
Before this fix, all code involving macros used to define or implement components and services is extremely poorly formatted by clang-format. The root cause is that the macro themselves are very opaque, and obfuscate completely the code structure, so that clang-format can not even find basic expressions or statements while just reading the calling code. The fix is as follows. When a macro generates a list item, ending by a column: - remove the column from the macro - require the calling code to explicitly add the column When a macro generates a statement, ending by a semicolumn: - remove the semicolumn from the macro - require the calling code to explicitly add the semicolumn With this change, code formatted by clang-format, while not beeing perfect, is at least workable. Details of the change: - END_DECLARE_COMPONENT() is now followed by ';' - PROVIDES_SERVICE() is now followed by ',' - END_COMPONENT_PROVIDES() is now followed by ';' - REQUIRES_SERVICE() is now followed by ',' - END_COMPONENT_REQUIRES() is now followed by ';' - METADATA() is now followed by ',' - END_COMPONENT_METADATA() is now followed by ';' - END_SERVICE_IMPLEMENTATION() is now followed by ';'
1 parent d2a6f82 commit df1ea47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+826
-970
lines changed

components/example/example_component1.cc

+32-36
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -50,38 +50,34 @@ mysql_service_status_t example_deinit() { return 0; }
5050

5151
/* This component provides an implementation for all example Services. */
5252
BEGIN_SERVICE_IMPLEMENTATION(example_component1, greetings)
53-
english_greeting_service_imp::say_hello,
54-
END_SERVICE_IMPLEMENTATION()
55-
56-
BEGIN_SERVICE_IMPLEMENTATION(example_component1, greetings_localization)
57-
english_greeting_service_imp::get_language,
58-
END_SERVICE_IMPLEMENTATION()
59-
60-
BEGIN_SERVICE_IMPLEMENTATION(example_component1, example_math)
61-
simple_example_math_imp::calculate_gcd,
62-
END_SERVICE_IMPLEMENTATION()
63-
64-
BEGIN_COMPONENT_PROVIDES(example_component1)
65-
PROVIDES_SERVICE(example_component1, greetings)
66-
PROVIDES_SERVICE(example_component1, greetings_localization)
67-
PROVIDES_SERVICE(example_component1, example_math)
68-
END_COMPONENT_PROVIDES()
69-
70-
/* An empty list of dependencies. */
71-
BEGIN_COMPONENT_REQUIRES(example_component1) END_COMPONENT_REQUIRES()
72-
73-
/* A list of metadata to describe the Component. */
74-
BEGIN_COMPONENT_METADATA(example_component1)
75-
METADATA("mysql.author", "Oracle Corporation")
76-
METADATA("mysql.license", "GPL") METADATA("test_property", "1")
77-
END_COMPONENT_METADATA()
78-
79-
/* Declaration of the Component. */
80-
DECLARE_COMPONENT(example_component1,
81-
"mysql:example_component1") example_init,
82-
example_deinit END_DECLARE_COMPONENT()
83-
84-
/* Defines list of Components contained in this library. Note that for now
85-
we assume that library will have exactly one Component. */
86-
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(example_component1)
87-
END_DECLARE_LIBRARY_COMPONENTS
53+
english_greeting_service_imp::say_hello, END_SERVICE_IMPLEMENTATION();
54+
55+
BEGIN_SERVICE_IMPLEMENTATION(example_component1, greetings_localization)
56+
english_greeting_service_imp::get_language, END_SERVICE_IMPLEMENTATION();
57+
58+
BEGIN_SERVICE_IMPLEMENTATION(example_component1, example_math)
59+
simple_example_math_imp::calculate_gcd, END_SERVICE_IMPLEMENTATION();
60+
61+
BEGIN_COMPONENT_PROVIDES(example_component1)
62+
PROVIDES_SERVICE(example_component1, greetings),
63+
PROVIDES_SERVICE(example_component1, greetings_localization),
64+
PROVIDES_SERVICE(example_component1, example_math),
65+
END_COMPONENT_PROVIDES();
66+
67+
/* An empty list of dependencies. */
68+
BEGIN_COMPONENT_REQUIRES(example_component1) END_COMPONENT_REQUIRES();
69+
70+
/* A list of metadata to describe the Component. */
71+
BEGIN_COMPONENT_METADATA(example_component1)
72+
METADATA("mysql.author", "Oracle Corporation"),
73+
METADATA("mysql.license", "GPL"), METADATA("test_property", "1"),
74+
END_COMPONENT_METADATA();
75+
76+
/* Declaration of the Component. */
77+
DECLARE_COMPONENT(example_component1, "mysql:example_component1")
78+
example_init, example_deinit END_DECLARE_COMPONENT();
79+
80+
/* Defines list of Components contained in this library. Note that for now
81+
we assume that library will have exactly one Component. */
82+
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(example_component1)
83+
END_DECLARE_LIBRARY_COMPONENTS
+30-32
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -32,34 +32,32 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
3232
Services. */
3333

3434
BEGIN_SERVICE_IMPLEMENTATION(example_component2, greetings)
35-
polish_greeting_service_imp::say_hello,
36-
END_SERVICE_IMPLEMENTATION()
37-
38-
BEGIN_SERVICE_IMPLEMENTATION(example_component2, greetings_localization)
39-
polish_greeting_service_imp::get_language,
40-
END_SERVICE_IMPLEMENTATION()
41-
42-
BEGIN_COMPONENT_PROVIDES(example_component2)
43-
PROVIDES_SERVICE(example_component2, greetings)
44-
PROVIDES_SERVICE(example_component2, greetings_localization)
45-
END_COMPONENT_PROVIDES()
46-
47-
/* An empty list of dependencies. */
48-
BEGIN_COMPONENT_REQUIRES(example_component2) END_COMPONENT_REQUIRES()
49-
50-
/* A list of metadata to describe the Component. */
51-
BEGIN_COMPONENT_METADATA(example_component2)
52-
METADATA("mysql.author", "Oracle Corporation")
53-
METADATA("mysql.license", "GPL") METADATA("test_property", "2")
54-
END_COMPONENT_METADATA()
55-
56-
/* Declaration of the Component, this is the case when we don't need
57-
initialization/de-initialization methods, so we are fine to just use NULL
58-
values here. */
59-
DECLARE_COMPONENT(example_component2, "mysql:example_component2") NULL,
60-
NULL END_DECLARE_COMPONENT()
61-
62-
/* Defines list of Components contained in this library. Note that for now
63-
we assume that library will have exactly one Component. */
64-
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(example_component2)
65-
END_DECLARE_LIBRARY_COMPONENTS
35+
polish_greeting_service_imp::say_hello, END_SERVICE_IMPLEMENTATION();
36+
37+
BEGIN_SERVICE_IMPLEMENTATION(example_component2, greetings_localization)
38+
polish_greeting_service_imp::get_language, END_SERVICE_IMPLEMENTATION();
39+
40+
BEGIN_COMPONENT_PROVIDES(example_component2)
41+
PROVIDES_SERVICE(example_component2, greetings),
42+
PROVIDES_SERVICE(example_component2, greetings_localization),
43+
END_COMPONENT_PROVIDES();
44+
45+
/* An empty list of dependencies. */
46+
BEGIN_COMPONENT_REQUIRES(example_component2) END_COMPONENT_REQUIRES();
47+
48+
/* A list of metadata to describe the Component. */
49+
BEGIN_COMPONENT_METADATA(example_component2)
50+
METADATA("mysql.author", "Oracle Corporation"),
51+
METADATA("mysql.license", "GPL"), METADATA("test_property", "2"),
52+
END_COMPONENT_METADATA();
53+
54+
/* Declaration of the Component, this is the case when we don't need
55+
initialization/de-initialization methods, so we are fine to just use NULL
56+
values here. */
57+
DECLARE_COMPONENT(example_component2, "mysql:example_component2")
58+
NULL, NULL END_DECLARE_COMPONENT();
59+
60+
/* Defines list of Components contained in this library. Note that for now
61+
we assume that library will have exactly one Component. */
62+
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(example_component2)
63+
END_DECLARE_LIBRARY_COMPONENTS

components/example/example_component3.cc

+18-22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -32,39 +32,35 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
3232

3333
/* This component provides an implementation for 'example_math' Service only. */
3434
BEGIN_SERVICE_IMPLEMENTATION(example_component3, example_math)
35-
example_math_wrapping_imp::calculate_gcd,
36-
END_SERVICE_IMPLEMENTATION()
35+
example_math_wrapping_imp::calculate_gcd, END_SERVICE_IMPLEMENTATION();
3736

38-
BEGIN_COMPONENT_PROVIDES(example_component3)
39-
PROVIDES_SERVICE(example_component3, example_math)
40-
END_COMPONENT_PROVIDES()
37+
BEGIN_COMPONENT_PROVIDES(example_component3)
38+
PROVIDES_SERVICE(example_component3, example_math), END_COMPONENT_PROVIDES();
4139

42-
/* A block for specifying dependencies of this Component. Note that for each
43-
dependency we need to have a placeholder, a extern to placeholder in
44-
header file of the Component, and an entry on requires list below. */
45-
REQUIRES_SERVICE_PLACEHOLDER(greetings);
40+
/* A block for specifying dependencies of this Component. Note that for each
41+
dependency we need to have a placeholder, a extern to placeholder in
42+
header file of the Component, and an entry on requires list below. */
43+
REQUIRES_SERVICE_PLACEHOLDER(greetings);
4644
REQUIRES_SERVICE_PLACEHOLDER(greetings_localization);
4745

4846
/* A list of dependencies. */
4947
BEGIN_COMPONENT_REQUIRES(example_component3)
50-
REQUIRES_SERVICE(greetings)
51-
REQUIRES_SERVICE(greetings_localization)
52-
END_COMPONENT_REQUIRES()
48+
REQUIRES_SERVICE(greetings), REQUIRES_SERVICE(greetings_localization),
49+
END_COMPONENT_REQUIRES();
5350

5451
/* A list of metadata to describe the Component. */
5552
BEGIN_COMPONENT_METADATA(example_component3)
56-
METADATA("mysql.author", "Oracle Corporation")
57-
METADATA("mysql.license", "GPL")
58-
METADATA("test_property", "3")
59-
END_COMPONENT_METADATA()
53+
METADATA("mysql.author", "Oracle Corporation"),
54+
METADATA("mysql.license", "GPL"), METADATA("test_property", "3"),
55+
END_COMPONENT_METADATA();
6056

6157
/* Declaration of the Component, this is the case when we don't need
6258
initialization/de-initialization methods, so we are fine to just use NULL
6359
values here. */
6460
DECLARE_COMPONENT(example_component3, "mysql:example_component3")
65-
NULL, NULL END_DECLARE_COMPONENT()
61+
NULL, NULL END_DECLARE_COMPONENT();
6662

67-
/* Defines list of Components contained in this library. Note that for now
68-
we assume that library will have exactly one Component. */
69-
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(example_component3)
70-
END_DECLARE_LIBRARY_COMPONENTS
63+
/* Defines list of Components contained in this library. Note that for now
64+
we assume that library will have exactly one Component. */
65+
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(example_component3)
66+
END_DECLARE_LIBRARY_COMPONENTS

components/example/test_backup_lock_service.cc

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -56,28 +56,26 @@ mysql_service_status_t test_backup_lock_service_deinit() {
5656

5757
/* An empty list as no service is provided. */
5858
BEGIN_COMPONENT_PROVIDES(test_backup_lock_service)
59-
END_COMPONENT_PROVIDES()
59+
END_COMPONENT_PROVIDES();
6060

6161
REQUIRES_SERVICE_PLACEHOLDER(mysql_backup_lock);
6262

6363
/* A list of required services. */
6464
BEGIN_COMPONENT_REQUIRES(test_backup_lock_service)
65-
REQUIRES_SERVICE(mysql_backup_lock)
66-
END_COMPONENT_REQUIRES()
65+
REQUIRES_SERVICE(mysql_backup_lock), END_COMPONENT_REQUIRES();
6766

6867
/* A list of metadata to describe the Component. */
6968
BEGIN_COMPONENT_METADATA(test_backup_lock_service)
70-
METADATA("mysql.author", "Oracle Corporation")
71-
METADATA("mysql.license", "GPL")
72-
METADATA("test_backup_lock_service", "1")
73-
END_COMPONENT_METADATA()
69+
METADATA("mysql.author", "Oracle Corporation"),
70+
METADATA("mysql.license", "GPL"), METADATA("test_backup_lock_service", "1"),
71+
END_COMPONENT_METADATA();
7472

7573
/* Declaration of the Component. */
7674
DECLARE_COMPONENT(test_backup_lock_service, "mysql:test_backup_lock_service")
7775
test_backup_lock_service_init,
78-
test_backup_lock_service_deinit END_DECLARE_COMPONENT()
76+
test_backup_lock_service_deinit END_DECLARE_COMPONENT();
7977

80-
/* Defines list of Components contained in this library. Note that for now
81-
we assume that library will have exactly one Component. */
82-
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(test_backup_lock_service)
83-
END_DECLARE_LIBRARY_COMPONENTS
78+
/* Defines list of Components contained in this library. Note that for now
79+
we assume that library will have exactly one Component. */
80+
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(test_backup_lock_service)
81+
END_DECLARE_LIBRARY_COMPONENTS

components/example/test_string_service.cc

+17-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -313,7 +313,7 @@ mysql_service_status_t test_string_service_deinit() { return false; }
313313

314314
/* An empty list as no service is provided. */
315315
BEGIN_COMPONENT_PROVIDES(test_string_service)
316-
END_COMPONENT_PROVIDES()
316+
END_COMPONENT_PROVIDES();
317317

318318
REQUIRES_SERVICE_PLACEHOLDER(mysql_string_factory);
319319
REQUIRES_SERVICE_PLACEHOLDER(mysql_string_converter);
@@ -325,27 +325,25 @@ REQUIRES_SERVICE_PLACEHOLDER(mysql_string_ctype);
325325

326326
/* A list of required services. */
327327
BEGIN_COMPONENT_REQUIRES(test_string_service)
328-
REQUIRES_SERVICE(mysql_string_factory)
329-
REQUIRES_SERVICE(mysql_string_converter)
330-
REQUIRES_SERVICE(mysql_string_character_access)
331-
REQUIRES_SERVICE(mysql_string_byte_access)
332-
REQUIRES_SERVICE(mysql_string_case)
333-
REQUIRES_SERVICE(mysql_string_iterator)
334-
REQUIRES_SERVICE(mysql_string_ctype)
335-
END_COMPONENT_REQUIRES()
328+
REQUIRES_SERVICE(mysql_string_factory),
329+
REQUIRES_SERVICE(mysql_string_converter),
330+
REQUIRES_SERVICE(mysql_string_character_access),
331+
REQUIRES_SERVICE(mysql_string_byte_access),
332+
REQUIRES_SERVICE(mysql_string_case),
333+
REQUIRES_SERVICE(mysql_string_iterator),
334+
REQUIRES_SERVICE(mysql_string_ctype), END_COMPONENT_REQUIRES();
336335

337336
/* A list of metadata to describe the Component. */
338337
BEGIN_COMPONENT_METADATA(test_string_service)
339-
METADATA("mysql.author", "Oracle Corporation")
340-
METADATA("mysql.license", "GPL")
341-
METADATA("test_string_service", "1")
342-
END_COMPONENT_METADATA()
338+
METADATA("mysql.author", "Oracle Corporation"),
339+
METADATA("mysql.license", "GPL"), METADATA("test_string_service", "1"),
340+
END_COMPONENT_METADATA();
343341

344342
/* Declaration of the Component. */
345343
DECLARE_COMPONENT(test_string_service, "mysql:test_string_service")
346-
test_string_service_init, test_string_service_deinit END_DECLARE_COMPONENT()
344+
test_string_service_init, test_string_service_deinit END_DECLARE_COMPONENT();
347345

348-
/* Defines list of Components contained in this library. Note that for now
349-
we assume that library will have exactly one Component. */
350-
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(test_string_service)
351-
END_DECLARE_LIBRARY_COMPONENTS
346+
/* Defines list of Components contained in this library. Note that for now
347+
we assume that library will have exactly one Component. */
348+
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(test_string_service)
349+
END_DECLARE_LIBRARY_COMPONENTS

components/example/test_string_service_charset.cc

+17-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -196,7 +196,7 @@ mysql_service_status_t test_string_service_deinit() { return false; }
196196

197197
/* An empty list as no service is provided. */
198198
BEGIN_COMPONENT_PROVIDES(test_string_service_charset)
199-
END_COMPONENT_PROVIDES()
199+
END_COMPONENT_PROVIDES();
200200

201201
REQUIRES_SERVICE_PLACEHOLDER(mysql_string_factory);
202202
REQUIRES_SERVICE_PLACEHOLDER(mysql_string_converter);
@@ -208,28 +208,26 @@ REQUIRES_SERVICE_PLACEHOLDER(mysql_string_ctype);
208208

209209
/* A list of required services. */
210210
BEGIN_COMPONENT_REQUIRES(test_string_service_charset)
211-
REQUIRES_SERVICE(mysql_string_factory)
212-
REQUIRES_SERVICE(mysql_string_converter)
213-
REQUIRES_SERVICE(mysql_string_character_access)
214-
REQUIRES_SERVICE(mysql_string_byte_access)
215-
REQUIRES_SERVICE(mysql_string_case)
216-
REQUIRES_SERVICE(mysql_string_iterator)
217-
REQUIRES_SERVICE(mysql_string_ctype)
218-
END_COMPONENT_REQUIRES()
211+
REQUIRES_SERVICE(mysql_string_factory),
212+
REQUIRES_SERVICE(mysql_string_converter),
213+
REQUIRES_SERVICE(mysql_string_character_access),
214+
REQUIRES_SERVICE(mysql_string_byte_access),
215+
REQUIRES_SERVICE(mysql_string_case),
216+
REQUIRES_SERVICE(mysql_string_iterator),
217+
REQUIRES_SERVICE(mysql_string_ctype), END_COMPONENT_REQUIRES();
219218

220219
/* A list of metadata to describe the Component. */
221220
BEGIN_COMPONENT_METADATA(test_string_service_charset)
222-
METADATA("mysql.author", "Oracle Corporation")
223-
METADATA("mysql.license", "GPL")
224-
METADATA("test_string_charset_service", "1")
225-
END_COMPONENT_METADATA()
221+
METADATA("mysql.author", "Oracle Corporation"),
222+
METADATA("mysql.license", "GPL"),
223+
METADATA("test_string_charset_service", "1"), END_COMPONENT_METADATA();
226224

227225
/* Declaration of the Component. */
228226
DECLARE_COMPONENT(test_string_service_charset,
229227
"mysql:test_string_service_charset")
230-
test_string_service_init, test_string_service_deinit END_DECLARE_COMPONENT()
228+
test_string_service_init, test_string_service_deinit END_DECLARE_COMPONENT();
231229

232-
/* Defines list of Components contained in this library. Note that for now
233-
we assume that library will have exactly one Component. */
234-
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(test_string_service_charset)
235-
END_DECLARE_LIBRARY_COMPONENTS
230+
/* Defines list of Components contained in this library. Note that for now
231+
we assume that library will have exactly one Component. */
232+
DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(test_string_service_charset)
233+
END_DECLARE_LIBRARY_COMPONENTS

0 commit comments

Comments
 (0)