Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit cf68468

Browse files
committed
Merge pull request #319 from tcahuzax/clang_format
Using clang-format to format code
2 parents 124158d + ef6f701 commit cf68468

File tree

267 files changed

+5237
-4563
lines changed

Some content is hidden

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

267 files changed

+5237
-4563
lines changed

.clang-format

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Copyright (c) 2015, Intel Corporation
2+
# All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without modification,
5+
# are permitted provided that the following conditions are met:
6+
#
7+
# 1. Redistributions of source code must retain the above copyright notice, this
8+
# list of conditions and the following disclaimer.
9+
#
10+
# 2. Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation and/or
12+
# other materials provided with the distribution.
13+
#
14+
# 3. Neither the name of the copyright holder nor the names of its contributors
15+
# may be used to endorse or promote products derived from this software without
16+
# specific prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
29+
---
30+
# The extra indent or outdent of access modifiers
31+
AccessModifierOffset: -4
32+
33+
# Align parameters on the open bracket
34+
AlignAfterOpenBracket: Align
35+
36+
# Disallows contracting simple braced statements to a single line
37+
AllowShortBlocksOnASingleLine: 'false'
38+
39+
# Short case labels wont't be contracted to a single line
40+
AllowShortCaseLabelsOnASingleLine: 'false'
41+
42+
# Merge all inline functions fitting on a single line
43+
AllowShortFunctionsOnASingleLine: 'Inline'
44+
45+
# If (a) return; cannot be put on a single line
46+
AllowShortIfStatementsOnASingleLine: 'false'
47+
48+
# While (true) continue; cannot be put on a single line
49+
AllowShortLoopsOnASingleLine: 'false'
50+
51+
# Break after the template<...> of a template declaration.
52+
AlwaysBreakTemplateDeclarations: 'true'
53+
54+
# Configure each individual brace in BraceWrapping
55+
BreakBeforeBraces: 'Custom'
56+
57+
# Control of individual brace wrapping cases
58+
BraceWrapping: {
59+
AfterClass: 'true'
60+
AfterControlStatement: 'false'
61+
AfterEnum : 'true'
62+
AfterFunction : 'true'
63+
AfterNamespace : 'true'
64+
AfterStruct : 'true'
65+
AfterUnion : 'true'
66+
BeforeCatch : 'false'
67+
BeforeElse : 'false'
68+
IndentBraces : 'false'
69+
}
70+
71+
# The column limit
72+
ColumnLimit: '100'
73+
74+
# The number of columns to use for indentation.
75+
IndentWidth: '4'
76+
77+
# Targeted language
78+
Language: Cpp
79+
80+
# No indentation for namespaces.
81+
NamespaceIndentation: None
82+
83+
# Pointer is aligned to right side
84+
PointerAlignment: Right
85+
86+
# High penalty to avoid line break just after return type
87+
PenaltyReturnTypeOnItsOwnLine: 10000
88+
89+
# Treat 'catch' BDD macros as control instructions
90+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, GIVEN, WHEN, AND_WHEN, THEN, AND_THEN,
91+
SECTION ]
92+
93+
...

bindings/c/ParameterFramework.cpp

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ using std::string;
4747
/** Rename long pfw types to short ones in pfw namespace. */
4848
namespace pfw
4949
{
50-
typedef ISelectionCriterionInterface Criterion;
51-
typedef std::map<string, Criterion *> Criteria;
52-
typedef CParameterMgrPlatformConnector Pfw;
50+
typedef ISelectionCriterionInterface Criterion;
51+
typedef std::map<string, Criterion *> Criteria;
52+
typedef CParameterMgrPlatformConnector Pfw;
5353
}
5454

5555
/** Class to abstract the boolean+string status api. */
@@ -59,16 +59,27 @@ class Status
5959
/** Fail without an instance of status. */
6060
static bool failure() { return false; }
6161
/** Fail with the given error msg. */
62-
bool failure(const string &msg) { mMsg = msg; return false; }
62+
bool failure(const string &msg)
63+
{
64+
mMsg = msg;
65+
return false;
66+
}
6367
/** Success (no error message). */
64-
bool success() { mMsg.clear(); return true; }
68+
bool success()
69+
{
70+
mMsg.clear();
71+
return true;
72+
}
6573

6674
/** Forward a status operation.
6775
* @param success[in] the operaton status to forward
6876
* or forward a previous failure if omitted
6977
*/
70-
bool forward(bool success = false) {
71-
if (success) { mMsg.clear(); }
78+
bool forward(bool success = false)
79+
{
80+
if (success) {
81+
mMsg.clear();
82+
}
7283
return success;
7384
}
7485
/** Error message accessors.
@@ -87,7 +98,8 @@ class Status
8798
///////////////////////////////
8899

89100
/** Default log callback. Log to cout or cerr depending on level. */
90-
static void defaultLogCb(void *, PfwLogLevel level, const char *logLine) {
101+
static void defaultLogCb(void *, PfwLogLevel level, const char *logLine)
102+
{
91103
switch (level) {
92104
case pfwLogInfo:
93105
std::cout << logLine << std::endl;
@@ -98,7 +110,7 @@ static void defaultLogCb(void *, PfwLogLevel level, const char *logLine) {
98110
};
99111
}
100112

101-
static PfwLogger defaultLogger = { NULL, &defaultLogCb };
113+
static PfwLogger defaultLogger = {NULL, &defaultLogCb};
102114

103115
class LogWrapper : public CParameterMgrPlatformConnector::ILogger
104116
{
@@ -109,7 +121,7 @@ class LogWrapper : public CParameterMgrPlatformConnector::ILogger
109121
private:
110122
void info(const string &msg) override { log(pfwLogInfo, msg); }
111123

112-
void warning(const string &msg) override { log(pfwLogWarning, msg); }
124+
void warning(const string &msg) override { log(pfwLogWarning, msg); }
113125

114126
void log(PfwLogLevel level, const string &strLog)
115127
{
@@ -137,6 +149,7 @@ struct PfwHandler_ : private utility::NonCopyable
137149
* Is mutable because even a const function can fail.
138150
*/
139151
mutable Status lastStatus;
152+
140153
private:
141154
LogWrapper mLogger;
142155
};
@@ -161,7 +174,6 @@ void PfwHandler::setLogger(const PfwLogger *logger)
161174
pfw->setLogger(&mLogger);
162175
}
163176

164-
165177
bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t criterionNb)
166178
{
167179
Status &status = lastStatus;
@@ -176,8 +188,7 @@ bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t crite
176188
}
177189
// Check that the criterion does not exist
178190
if (criteria.find(criterion.name) != criteria.end()) {
179-
return status.failure("Criterion \"" + string(criterion.name) +
180-
"\" already exist");
191+
return status.failure("Criterion \"" + string(criterion.name) + "\" already exist");
181192
}
182193

183194
// Create criterion type
@@ -189,15 +200,15 @@ bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t crite
189200
int value;
190201
if (criterion.inclusive) {
191202
// Check that (int)1 << valueIndex would not overflow (UB)
192-
if(std::numeric_limits<int>::max() >> valueIndex == 0) {
203+
if (std::numeric_limits<int>::max() >> valueIndex == 0) {
193204
return status.failure("Too many values for criterion " +
194205
string(criterion.name));
195206
}
196207
value = 1 << valueIndex;
197208
} else {
198209
value = static_cast<int>(valueIndex);
199210
}
200-
const char * valueName = criterion.values[valueIndex];
211+
const char *valueName = criterion.values[valueIndex];
201212
string error;
202213
if (not type->addValuePair(value, valueName, error)) {
203214
return status.failure("Could not add value " + string(valueName) +
@@ -210,10 +221,8 @@ bool PfwHandler::createCriteria(const PfwCriterion criteriaArray[], size_t crite
210221
return status.success();
211222
}
212223

213-
214-
bool pfwStart(PfwHandler *handle, const char *configPath,
215-
const PfwCriterion criteria[], size_t criterionNb,
216-
const PfwLogger *logger)
224+
bool pfwStart(PfwHandler *handle, const char *configPath, const PfwCriterion criteria[],
225+
size_t criterionNb, const PfwLogger *logger)
217226
{
218227
// Check that the api is correctly used
219228
Status &status = handle->lastStatus;
@@ -238,8 +247,7 @@ const char *pfwGetLastError(const PfwHandler *handle)
238247
return handle->lastStatus.msg().c_str();
239248
}
240249

241-
static pfw::Criterion *getCriterion(const pfw::Criteria &criteria,
242-
const string &name)
250+
static pfw::Criterion *getCriterion(const pfw::Criteria &criteria, const string &name)
243251
{
244252
pfw::Criteria::const_iterator it = criteria.find(name);
245253
return it == criteria.end() ? NULL : it->second;
@@ -300,7 +308,8 @@ PfwParameterHandler *pfwBindParameter(PfwHandler *handle, const char path[])
300308
Status &status = handle->lastStatus;
301309
if (handle->pfw == NULL) {
302310
status.failure("The parameter framework is not started, "
303-
"while trying to bind parameter \"" + string(path) + "\")");
311+
"while trying to bind parameter \"" +
312+
string(path) + "\")");
304313
return NULL;
305314
}
306315

@@ -321,7 +330,6 @@ void pfwUnbindParameter(PfwParameterHandler *handle)
321330
delete handle;
322331
}
323332

324-
325333
bool pfwGetIntParameter(const PfwParameterHandler *handle, int32_t *value)
326334
{
327335
Status &status = handle->pfw.lastStatus;
@@ -339,7 +347,9 @@ bool pfwGetStringParameter(const PfwParameterHandler *handle, char *value[])
339347
*value = NULL;
340348
string retValue;
341349
bool success = handle->parameter.getAsString(retValue, status.msg());
342-
if (not success) { return status.forward(); }
350+
if (not success) {
351+
return status.forward();
352+
}
343353

344354
*value = strdup(retValue.c_str());
345355
return status.success();
@@ -351,5 +361,7 @@ bool pfwSetStringParameter(PfwParameterHandler *handle, const char value[])
351361
return status.forward(handle->parameter.setAsString(value, status.msg()));
352362
}
353363

354-
void pfwFree(void *ptr) { std::free(ptr); }
355-
364+
void pfwFree(void *ptr)
365+
{
366+
std::free(ptr);
367+
}

bindings/c/ParameterFramework.h

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
#pragma once
4040

41-
4241
#ifdef __cplusplus
4342
extern "C" {
4443
#endif
@@ -53,17 +52,17 @@ extern "C" {
5352
* Such arguments are marked NONNULL.
5453
*/
5554
#if defined(__clang__) || defined(__GNUC__)
56-
# define NONNULL __attribute__((nonnull))
57-
# define NONNULL_(...) __attribute__((nonnull (__VA_ARGS__)))
58-
# define USERESULT __attribute__((warn_unused_result))
55+
#define NONNULL __attribute__((nonnull))
56+
#define NONNULL_(...) __attribute__((nonnull(__VA_ARGS__)))
57+
#define USERESULT __attribute__((warn_unused_result))
5958
#elif defined(_MSC_VER)
60-
// In visual studio's cl there is no
61-
// equivalent of nonnull
62-
# define NONNULL
63-
# define NONNULL_(...)
64-
# define USERESULT _Check_return_
59+
// In visual studio's cl there is no
60+
// equivalent of nonnull
61+
#define NONNULL
62+
#define NONNULL_(...)
63+
#define USERESULT _Check_return_
6564
#else
66-
# error "Unknown compilator"
65+
#error "Unknown compilator"
6766
#endif
6867

6968
/** Private handle to a parameter framework.
@@ -99,7 +98,8 @@ typedef enum {
9998
typedef void PfwLogCb(void *userCtx, PfwLogLevel level, const char *logLine);
10099

101100
/** Logger containing a callback method and its context. */
102-
typedef struct {
101+
typedef struct
102+
{
103103
/** User defined arbitrary value that will be provided to all logCb call. */
104104
void *userCtx;
105105
/** Callback that will be called.
@@ -113,10 +113,12 @@ typedef struct {
113113
///////////////////////////////
114114

115115
/** Structure of a parameter framework criterion. */
116-
typedef struct {
116+
typedef struct
117+
{
117118
/** Name of the criterion in the pfw configuration rules. */
118119
const char *name; //< Must not be null.
119-
bool inclusive; //< True if the criterion is inclusive, false if exclusive.
120+
bool inclusive; //< True if the criterion is inclusive, false if exclusive.
121+
120122
/** Null terminated list of criterion value names.
121123
* @example { "Red", "Green", "Blue", NULL }
122124
*
@@ -131,7 +133,6 @@ typedef struct {
131133
const char **values; //< Must not be null.
132134
} PfwCriterion;
133135

134-
135136
/** Create a parameter framework instance.
136137
* Can not fail except for memory allocation.
137138
*/
@@ -153,9 +154,8 @@ void pfwDestroy(PfwHandler *handle) NONNULL;
153154
* @return true on success, false on failure.
154155
*/
155156
CPARAMETER_EXPORT
156-
bool pfwStart(PfwHandler *handle, const char *configPath,
157-
const PfwCriterion criteria[], size_t criterionNb,
158-
const PfwLogger *loggger) NONNULL_(1, 2, 3) USERESULT;
157+
bool pfwStart(PfwHandler *handle, const char *configPath, const PfwCriterion criteria[],
158+
size_t criterionNb, const PfwLogger *loggger) NONNULL_(1, 2, 3) USERESULT;
159159

160160
/** @return a string describing the last call result.
161161
* If the last pfw function call succeeded, return an empty string.
@@ -190,7 +190,8 @@ CPARAMETER_EXPORT
190190
bool pfwSetCriterion(PfwHandler *handle, const char name[], int value) NONNULL USERESULT;
191191
/** Get a criterion value given its name.
192192
* Same usage as pfwSetCriterion except that value is an out param.
193-
* Get criterion will return the last value setted with pfwSetCriterion independantly of pfwCommitCritenio.
193+
* Get criterion will return the last value setted with pfwSetCriterion independantly of
194+
* pfwCommitCritenio.
194195
*/
195196
CPARAMETER_EXPORT
196197
bool pfwGetCriterion(const PfwHandler *handle, const char name[], int *value) NONNULL USERESULT;
@@ -244,7 +245,7 @@ void pfwUnbindParameter(PfwParameterHandler *handle) NONNULL;
244245
* return true of success, false on failure.
245246
*/
246247
CPARAMETER_EXPORT
247-
bool pfwGetIntParameter(const PfwParameterHandler *handle, int32_t *value ) NONNULL USERESULT;
248+
bool pfwGetIntParameter(const PfwParameterHandler *handle, int32_t *value) NONNULL USERESULT;
248249

249250
/** Set the value of a previously bind int parameter.
250251
* @param handle[in] Handler to a valid parameter.

0 commit comments

Comments
 (0)