Skip to content

Commit

Permalink
Style: Reformat C & C++ code with ClangFormat 9
Browse files Browse the repository at this point in the history
  • Loading branch information
sanssecours committed May 22, 2020
1 parent af294ce commit 02d55f4
Show file tree
Hide file tree
Showing 83 changed files with 286 additions and 308 deletions.
2 changes: 1 addition & 1 deletion benchmarks/benchmarks.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct _KsTreeVertex
struct hsearch_data * htab; /*!< stores the Hash Map, containing the children names */
#endif
size_t numberofChildren; /*!< number of the stored children */
size_t mallocSize; /*!< size malloced for the children */
size_t mallocSize; /*!< size malloced for the children */
};

/**
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/benchmarks.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ typedef struct
{
unsigned int minWordLength; /*!< min Length of a string between two '/' */
unsigned int maxWordLength; /*!< max Length of a string between two '/' */
unsigned int parent; /*!< defines the parent behaviour */
unsigned int special; /*!< defines the special char behaviour */
KsShapeFunction shapef; /*!< function pointer for the KeySet shape */
KsShapeInit shapeInit; /*!< function pointer for the KeySet shape data initialization */
KsShapeDel shapeDel; /*!< function pointer for the KeySet shape data deletion */
unsigned int parent; /*!< defines the parent behaviour */
unsigned int special; /*!< defines the special char behaviour */
KsShapeFunction shapef; /*!< function pointer for the KeySet shape */
KsShapeInit shapeInit; /*!< function pointer for the KeySet shape data initialization */
KsShapeDel shapeDel; /*!< function pointer for the KeySet shape data deletion */
} KeySetShape;

KeySet * generateKeySet (const size_t size, int32_t * seed, KeySetShape * shape);
Expand Down
2 changes: 1 addition & 1 deletion examples/kdbintro.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ int main (void)
ksDel (myConfig); // delete the in-memory configuration

kdbClose (handle, parentKey); // no more affairs with the key database.
keyDel (parentKey); // working with key/ks does not need kdb
keyDel (parentKey); // working with key/ks does not need kdb
}
6 changes: 3 additions & 3 deletions examples/keyNewExample.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ int main (void)
KEY_END)); /* end of args */

ksAppendKey (ks, keyNew ("user/env/alias/ls", /* a key we know we have */
KEY_END)); /* do nothing more */
KEY_END)); /* do nothing more */

ksAppendKey (ks, keyNew ("user/env/alias/ls", /* same key, to compare in output */
KEY_OWNER, "root", /* set new owner (not uid) as root */
ksAppendKey (ks, keyNew ("user/env/alias/ls", /* same key, to compare in output */
KEY_OWNER, "root", /* set new owner (not uid) as root */
KEY_COMMENT, "new comment", /* set new comment */
KEY_END)); /* end of args */

Expand Down
6 changes: 3 additions & 3 deletions examples/notificationAsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/

#include <kdb.h>
#include <kdbhelper.h> // elektraFree
#include <kdbio.h> // I/O binding functions (elektraIo*)
#include <kdbio/uv.h> // I/O binding constructor for uv (elektraIoUvNew)
#include <kdbhelper.h> // elektraFree
#include <kdbio.h> // I/O binding functions (elektraIo*)
#include <kdbio/uv.h> // I/O binding constructor for uv (elektraIoUvNew)
#include <kdbnotification.h> // notification functions

#include <uv.h> // uv functions
Expand Down
6 changes: 3 additions & 3 deletions examples/notificationReload.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
*/

#include <kdb.h>
#include <kdbhelper.h> // elektraFree
#include <kdbio.h> // I/O binding functions (elektraIo*)
#include <kdbio/glib.h> // I/O binding constructor for glib (elektraIoGlibNew)
#include <kdbhelper.h> // elektraFree
#include <kdbio.h> // I/O binding functions (elektraIo*)
#include <kdbio/glib.h> // I/O binding constructor for glib (elektraIoGlibNew)
#include <kdbnotification.h> // notification functions

#include <glib-unix.h> // g_unix_signal_add()
Expand Down
2 changes: 1 addition & 1 deletion examples/set_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int main (void)
Key * key = keyNew (0);
keySetName (key, "user/sw/MyApp/Tests/TestKey1"); // == 31
keySetString (key, "NULLTestValue"); // == 14
keySetMeta (key, "comment", "NULLTestComment"); // == 16
keySetMeta (key, "comment", "NULLTestComment"); // == 16
ksAppendKey (ks, key); // == 1
keyNeedSync (key);
kdbSet (kdb_handle, ks, top); // == -1
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/cpp/benchmarks/benchmark_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ __attribute__ ((noinline)) void benchmark_layer_withnoalloc9 (kdb::Environment &
for (long long i = 0; i < iterations1; ++i)
{
s.context ().withl (l1).withl (l2).withl (l3).withl (l4).withl (l5).withl (l6).withl (l7).withl (l8).withl (
l9, [&]() { x ^= add_contextual (s.bm, s.bm); });
l9, [&] () { x ^= add_contextual (s.bm, s.bm); });
x ^= add_contextual (s.bm, s.bm);
}
t.stop ();
Expand Down
12 changes: 6 additions & 6 deletions src/bindings/cpp/include/kdbcontext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class Context : public Subject
void attachByName (std::string const & key_name, ValueObserver & observer)
{
this->attachObserver (observer);
evaluate (key_name, [&](std::string const & current_id, std::string &, bool) {
evaluate (key_name, [&] (std::string const & current_id, std::string &, bool) {
this->attachObserverByEvent (current_id, observer);
return false;
});
Expand All @@ -221,7 +221,7 @@ class Context : public Subject
*/
std::string evaluate (std::string const & key_name) const
{
return evaluate (key_name, [&](std::string const & current_id, std::string & ret, bool in_group) {
return evaluate (key_name, [&] (std::string const & current_id, std::string & ret, bool in_group) {
auto f = m_active_layers.find (current_id);
bool left_group = true;
if (f != m_active_layers.end ())
Expand Down Expand Up @@ -262,7 +262,7 @@ class Context : public Subject
* @return the evaluated string
*/
std::string evaluate (std::string const & key_name,
std::function<bool(std::string const &, std::string &, bool in_group)> const & on_layer) const
std::function<bool (std::string const &, std::string &, bool in_group)> const & on_layer) const
{
size_t const & s = key_name.size ();
std::string ret;
Expand Down Expand Up @@ -492,14 +492,14 @@ class Context : public Subject
return *this;
}

Context & operator() (std::function<void()> const & f)
Context & operator() (std::function<void ()> const & f)
{
execHelper (f);

return *this;
}

Context & withl (std::shared_ptr<Layer> & l, std::function<void()> const & f)
Context & withl (std::shared_ptr<Layer> & l, std::function<void ()> const & f)
{
lazyActivateLayer (l);
execHelper (f);
Expand All @@ -510,7 +510,7 @@ class Context : public Subject
private:
typedef std::vector<std::pair<std::string, std::shared_ptr<Layer>>> WithStack;

void execHelper (std::function<void()> const & f)
void execHelper (std::function<void ()> const & f)
{
WithStack with_stack = m_with_stack;
m_with_stack.clear (); // allow with to be called recursively
Expand Down
12 changes: 6 additions & 6 deletions src/bindings/cpp/include/kdbthread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct LayerAction

/// A vector of layers
typedef std::unordered_map<std::string, LayerAction> LayerMap;
typedef std::unordered_map<std::string, std::vector<std::function<void()>>> FunctionMap;
typedef std::unordered_map<std::string, std::vector<std::function<void ()>>> FunctionMap;

/// A data structure that is stored by context inside the Coordinator
struct PerContext
Expand Down Expand Up @@ -75,7 +75,7 @@ class ThreadNoContext
}

std::string evaluate (std::string const & key_name,
std::function<bool(std::string const &, std::string &, bool in_group)> const &) const
std::function<bool (std::string const &, std::string &, bool in_group)> const &) const
{
return key_name;
}
Expand Down Expand Up @@ -106,28 +106,28 @@ class Coordinator
{
public:
template <typename T>
void onLayerActivation (std::function<void()> f)
void onLayerActivation (std::function<void ()> f)
{
std::lock_guard<std::mutex> lock (m_mutexOnActivate);
std::shared_ptr<Layer> layer = std::make_shared<T> ();
m_onActivate[layer->id ()].push_back (f);
}

template <typename T>
void onLayerDeactivation (std::function<void()> f)
void onLayerDeactivation (std::function<void ()> f)
{
std::lock_guard<std::mutex> lock (m_mutexOnDeactivate);
std::shared_ptr<Layer> layer = std::make_shared<T> ();
m_onDeactivate[layer->id ()].push_back (f);
}

void onLayerActivation (std::string layerid, std::function<void()> f)
void onLayerActivation (std::string layerid, std::function<void ()> f)
{
std::lock_guard<std::mutex> lock (m_mutexOnActivate);
m_onActivate[layerid].push_back (f);
}

void onLayerDeactivation (std::string layerid, std::function<void()> f)
void onLayerDeactivation (std::string layerid, std::function<void ()> f)
{
std::lock_guard<std::mutex> lock (m_mutexOnDeactivate);
m_onDeactivate[layerid].push_back (f);
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/cpp/include/kdbtimer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Timer
{
raw_data_cerr, ///< print name,data\n (default!)
median_cerr, ///< print name,median\n
quiet, ///< print nothing
quiet, ///< print nothing
};

// functions
Expand Down
16 changes: 8 additions & 8 deletions src/bindings/cpp/include/kdbvalue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ struct Command
}

ValueSubject & v; // this pointer
Func & execute; // to be executed within lock
Func & execute; // to be executed within lock
bool hasChanged; // if the value (m_cache) has changed and value propagation is needed
std::string oldKey; // old name before assignment
std::string newKey; // new name after assignment
Expand Down Expand Up @@ -234,7 +234,7 @@ class NoContext
}

std::string evaluate (std::string const & key_name,
std::function<bool(std::string const &, std::string &, bool in_group)> const &) const
std::function<bool (std::string const &, std::string &, bool in_group)> const &) const
{
return key_name;
}
Expand Down Expand Up @@ -448,7 +448,7 @@ class Value : public ValueObserver, public ValueSubject, public Wrapped
{
assert (m_spec.getName ()[0] == '/' && "spec keys are not yet supported");
m_context.attachByName (m_spec.getName (), *this);
Command::Func fun = [this]() -> Command::Pair {
Command::Func fun = [this] () -> Command::Pair {
this->unsafeUpdateKeyUsingContext (m_context.evaluate (m_spec.getName ()));
this->unsafeSyncCache (); // set m_cache
return std::make_pair ("", m_key.getName ());
Expand All @@ -459,7 +459,7 @@ class Value : public ValueObserver, public ValueSubject, public Wrapped

~Value<T, PolicySetter1, PolicySetter2, PolicySetter3, PolicySetter4, PolicySetter5, PolicySetter6> ()
{
Command::Func fun = [this]() -> Command::Pair {
Command::Func fun = [this] () -> Command::Pair {
std::string oldName = m_key.getName ();
m_key = static_cast<ckdb::Key *> (nullptr);
// after destructor we do not need to care about
Expand Down Expand Up @@ -629,7 +629,7 @@ class Value : public ValueObserver, public ValueSubject, public Wrapped
*/
void syncCache () const
{
Command::Func fun = [this]() -> Command::Pair {
Command::Func fun = [this] () -> Command::Pair {
std::string const & oldKey = m_key.getName ();
this->unsafeLookupKey ();
this->unsafeSyncCache ();
Expand All @@ -644,7 +644,7 @@ class Value : public ValueObserver, public ValueSubject, public Wrapped
*/
void syncKeySet () const
{
Command::Func fun = [this]() -> Command::Pair {
Command::Func fun = [this] () -> Command::Pair {
std::string const & oldKey = m_key.getName ();
this->unsafeSyncKeySet ();
return std::make_pair (oldKey, m_key.getName ());
Expand Down Expand Up @@ -721,7 +721,7 @@ class Value : public ValueObserver, public ValueSubject, public Wrapped
std::cout << "update context " << evaluatedName << " from " << m_spec.getName () << " with write " << write << std::endl;
#endif

Command::Func fun = [this, &evaluatedName, write]() -> Command::Pair {
Command::Func fun = [this, &evaluatedName, write] () -> Command::Pair {
std::string oldKey = m_key.getName ();
if (write && evaluatedName == oldKey)
{
Expand Down Expand Up @@ -752,7 +752,7 @@ class Value : public ValueObserver, public ValueSubject, public Wrapped
{
dep.setMeta ("order", meta.getString ());
}
m_context.evaluate (m_spec.getName (), [&](std::string const & current_id, std::string &, bool) {
m_context.evaluate (m_spec.getName (), [&] (std::string const & current_id, std::string &, bool) {
#if DEBUG && VERBOSE
std::cout << "add dep " << current_id << " to " << dep.getName () << std::endl;
#endif
Expand Down
Loading

0 comments on commit 02d55f4

Please sign in to comment.