Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kodebach committed Oct 2, 2020
1 parent 0486d04 commit 33c2c53
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 299 deletions.
1 change: 1 addition & 0 deletions doc/news/_preparation_next_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The following section lists news about the [modules](https://www.libelektra.org/
- <<TODO>>

### TOML

### Quickdump

- Support for the old quickdump v1 and v2 formats has been removed. _(Klemens Böswirth)_
Expand Down
13 changes: 5 additions & 8 deletions src/tools/pythongen/tests/editor_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,21 @@
#include <iostream>


int main()
int main ()
{
using namespace kdb;

KDB kdb;
KeySet ks;
Context c;
// some predefined values (for convenience):
ks.append(Key("user:/kate/quit",
KEY_VALUE,
"Ctrl+k",
KEY_END));
ks.append (Key ("user:/kate/quit", KEY_VALUE, "Ctrl+k", KEY_END));
KeySet ks2;
kdb.get(ks2, "/myapp");
kdb.get (ks2, "/myapp");
// overwrite them if something is available in config files:
ks.append(ks2);
ks.append (ks2);

Parameters par(ks,c);
Parameters par (ks, c);

std::cout << par.myapp.shortcut.quitMyapp << std::endl;

Expand Down
82 changes: 40 additions & 42 deletions src/tools/pythongen/tests/lift.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,66 @@
#include <stdio.h>

// The application (just print out some config values in this case)
int lift(KeySet *conf)
int lift (KeySet * conf)
{
kdb_boolean_t stops = get_test_lift_emergency_action_stops(conf);
enum algorithm a = get_test_lift_algorithm(conf);
kdb_boolean_t write = get_test_lift_write(conf);
kdb_boolean_t stops = get_test_lift_emergency_action_stops (conf);
enum algorithm a = get_test_lift_algorithm (conf);
kdb_boolean_t write = get_test_lift_write (conf);

printf("delay: "ELEKTRA_LONG_F"\n", get_test_lift_emergency_delay(conf));
printf("stops: %s\n", bool_to_string(stops));
printf("algorithm: %s\n", algorithm_to_string(a));
printf("height #3: %f\n", get_test_lift_floor_3_height(conf));
printf("write: %s\n", bool_to_string(write));
printf("limit: "ELEKTRA_LONG_F"\n", get_test_lift_limit(conf));
printf("number: %s\n", get_test_lift_emergency_action_calls_number(conf));
printf ("delay: " ELEKTRA_LONG_F "\n", get_test_lift_emergency_delay (conf));
printf ("stops: %s\n", bool_to_string (stops));
printf ("algorithm: %s\n", algorithm_to_string (a));
printf ("height #3: %f\n", get_test_lift_floor_3_height (conf));
printf ("write: %s\n", bool_to_string (write));
printf ("limit: " ELEKTRA_LONG_F "\n", get_test_lift_limit (conf));
printf ("number: %s\n", get_test_lift_emergency_action_calls_number (conf));

// rewrite the same (does not change anything)
set_test_lift_algorithm(conf, a);
set_test_lift_emergency_action_stops(conf, stops);
set_test_lift_algorithm (conf, a);
set_test_lift_emergency_action_stops (conf, stops);

// set option to write out false
set_test_lift_write(conf, 0);
set_test_lift_write (conf, 0);

return write;
}

void kdbGetByName(KDB *kdb, KeySet *conf, Key *parentKey, char *where)
void kdbGetByName (KDB * kdb, KeySet * conf, Key * parentKey, char * where)
{
keySetName(parentKey, "system");
keyAddName(parentKey, where);
kdbGet(kdb, conf, parentKey);
keySetName (parentKey, "system");
keyAddName (parentKey, where);
kdbGet (kdb, conf, parentKey);

keySetName(parentKey, "user");
keyAddName(parentKey, where);
kdbGet(kdb, conf, parentKey);
keySetName (parentKey, "user");
keyAddName (parentKey, where);
kdbGet (kdb, conf, parentKey);
}

int main(int argc, char**argv)
int main (int argc, char ** argv)
{
Key *parentKey = keyNew("", KEY_END);
KDB *kdb = kdbOpen(parentKey);
KeySet *conf = ksNew(0, KS_END);
Key * parentKey = keyNew ("", KEY_END);
KDB * kdb = kdbOpen (parentKey);
KeySet * conf = ksNew (0, KS_END);

// get all config files
kdbGetByName(kdb, conf, parentKey, "/test/lift");
kdbGetByName(kdb, conf, parentKey, "/test/material_lift");
kdbGetByName(kdb, conf, parentKey, "/test/heavy_material_lift");
kdbGetByName(kdb, conf, parentKey, "/test/person_lift");
kdbGetByName (kdb, conf, parentKey, "/test/lift");
kdbGetByName (kdb, conf, parentKey, "/test/material_lift");
kdbGetByName (kdb, conf, parentKey, "/test/heavy_material_lift");
kdbGetByName (kdb, conf, parentKey, "/test/person_lift");

// get by params
int retval = ksGetOpt(argc, argv, conf);
int retval = ksGetOpt (argc, argv, conf);
if (retval & 1)
{
printf("%s Version 0.1\n",
argv[0]);
printf ("%s Version 0.1\n", argv[0]);
return 0;
}
else if (retval & 2)
{
printf("Usage: %s [OPTIONS]\n"
printf ("Usage: %s [OPTIONS]\n"
"%s\n"
"Example that demonstrates elektra gen parameters\n",
argv[0],
elektraGenHelpText());
argv[0], elektraGenHelpText ());
return 0;
}
else if (retval != 0)
Expand All @@ -84,15 +82,15 @@ int main(int argc, char**argv)
// write back to user:/test/lift what we got by commandline
// that means overrides in *_lift are still active, but
// fallbacks will be overriden.
if (lift(conf))
if (lift (conf))
{
printf("Write out config\n");
keySetName(parentKey, "user:/test/lift");
kdbSet(kdb, conf, parentKey);
printf ("Write out config\n");
keySetName (parentKey, "user:/test/lift");
kdbSet (kdb, conf, parentKey);
}

ksDel(conf);
kdbClose(kdb, parentKey);
keyDel(parentKey);
ksDel (conf);
kdbClose (kdb, parentKey);
keyDel (parentKey);
return retval;
}
26 changes: 13 additions & 13 deletions src/tools/pythongen/tests/lift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@

#include <iostream>

int main(int argc, char**argv)
int main (int argc, char ** argv)
{
using namespace kdb;

KDB kdb;
KeySet ks;
kdb.get(ks, "/test/lift");
kdb.get(ks, "/test/material_lift");
kdb.get(ks, "/test/heavy_material_lift");
kdb.get(ks, "/test/person_lift");
kdb.get (ks, "/test/lift");
kdb.get (ks, "/test/material_lift");
kdb.get (ks, "/test/heavy_material_lift");
kdb.get (ks, "/test/person_lift");

Parameters par(ks);
Parameters par (ks);

std::cout << std::boolalpha;
std::cout << "delay: " << par.getTestLiftEmergencyDelay() << std::endl;
std::cout << "stops: " << par.getTestLiftEmergencyActionStops() << std::endl;
std::cout << "delay: " << par.getTestLiftEmergencyDelay () << std::endl;
std::cout << "stops: " << par.getTestLiftEmergencyActionStops () << std::endl;
// std::cout << "algorithm: " << par.getTestLiftAlgorithm() << std::endl;
std::cout << "height #3: " << par.getTestLiftFloor3Height() << std::endl;
std::cout << "limit: " << par.getTestLiftLimit() << std::endl;
std::cout << "height #3: " << par.getTestLiftFloor3Height () << std::endl;
std::cout << "limit: " << par.getTestLiftLimit () << std::endl;

bool write = par.getTestLiftWrite();
par.setTestLiftWrite(false);
bool write = par.getTestLiftWrite ();
par.setTestLiftWrite (false);

// write back to user:/test/lift, see comments in lift.c
if (write)
{
kdb.set(ks, "user:/test/lift");
kdb.set (ks, "user:/test/lift");
}

return 0;
Expand Down
18 changes: 9 additions & 9 deletions src/tools/pythongen/tests/lift_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@

#include <iostream>

int main()
int main ()
{
using namespace kdb;

KDB kdb;
KeySet ks;
Coordinator c;
ThreadContext tc(c);
kdb.get(ks, "/test/lift");
kdb.get(ks, "/test/material_lift");
kdb.get(ks, "/test/heavy_material_lift");
kdb.get(ks, "/test/person_lift");
ThreadContext tc (c);
kdb.get (ks, "/test/lift");
kdb.get (ks, "/test/material_lift");
kdb.get (ks, "/test/heavy_material_lift");
kdb.get (ks, "/test/person_lift");

Environment <ContextPolicyIs<ThreadContext>> env(ks,tc);
Environment<ContextPolicyIs<ThreadContext>> env (ks, tc);
// Environment <ContextPolicyIs<ThreadContext>, WritePolicyIs<ReadOnlyPolicy>> env(ks,tc);
std::cout << std::boolalpha;
std::cout << "delay: " << env.test.lift.emergency.delay << std::endl;
std::cout << "stops: " << env.test.lift.emergency.action.stops << std::endl;
// kdb::test::Lift <ContextPolicyIs<ThreadContext>, WritePolicyIs<ReadOnlyPolicy>> const & lift = env.test.lift;
kdb::test::Lift <ContextPolicyIs<ThreadContext>> const & lift = env.test.lift;
kdb::test::Lift<ContextPolicyIs<ThreadContext>> const & lift = env.test.lift;
std::cout << "height #3: " << lift.floor.n3.height << std::endl;
std::cout << "limit: " << env.test.lift.limit << std::endl;

Expand All @@ -43,7 +43,7 @@ int main()
// write back to user:/test/lift, see comments in lift.c
if (write)
{
kdb.set(ks, "user:/test/lift");
kdb.set (ks, "user:/test/lift");
}

return 0;
Expand Down
28 changes: 14 additions & 14 deletions src/tools/pythongen/tests/lift_nested.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@

#include <iostream>

int main()
int main ()
{
using namespace kdb;

KDB kdb;
KeySet ks;
kdb.get(ks, "/test/lift");
kdb.get(ks, "/test/material_lift");
kdb.get(ks, "/test/heavy_material_lift");
kdb.get(ks, "/test/person_lift");
kdb.get (ks, "/test/lift");
kdb.get (ks, "/test/material_lift");
kdb.get (ks, "/test/heavy_material_lift");
kdb.get (ks, "/test/person_lift");

Parameters par(ks);
Parameters par (ks);

std::cout << std::boolalpha;
std::cout << "delay: " << par.test().lift().emergency().getDelay() << std::endl;
std::cout << "stops: " << par.test().lift().emergency().action().getStops() << std::endl;
std::cout << "delay: " << par.test ().lift ().emergency ().getDelay () << std::endl;
std::cout << "stops: " << par.test ().lift ().emergency ().action ().getStops () << std::endl;
// std::cout << "algorithm: " << par.getTestLiftAlgorithm() << std::endl;
kdb::test::Lift const & lift = par.test().lift();
std::cout << "height #3: " << lift.floor().n3().getHeight() << std::endl;
std::cout << "limit: " << par.test().lift().getLimit() << std::endl;
kdb::test::Lift const & lift = par.test ().lift ();
std::cout << "height #3: " << lift.floor ().n3 ().getHeight () << std::endl;
std::cout << "limit: " << par.test ().lift ().getLimit () << std::endl;

bool write = lift.getWrite();
par.test().lift().setWrite(false);
bool write = lift.getWrite ();
par.test ().lift ().setWrite (false);

// write back to user:/test/lift, see comments in lift.c
if (write)
{
kdb.set(ks, "user:/test/lift");
kdb.set (ks, "user:/test/lift");
}

return 0;
Expand Down
34 changes: 13 additions & 21 deletions src/tools/pythongen/tests/location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,28 @@ using namespace std;
using namespace kdb;
using namespace kdb::test;

void greet (Person <ContextPolicyIs<ThreadContext>> & p, Country <ContextPolicyIs<ThreadContext>> & country, Location <ContextPolicyIs<ThreadContext>> & location)
void greet (Person<ContextPolicyIs<ThreadContext>> & p, Country<ContextPolicyIs<ThreadContext>> & country,
Location<ContextPolicyIs<ThreadContext>> & location)
{
cout << p.context ().evaluate (p.greeting.getSpec (). getName ()) << endl;
p.context().activate(country);
p.context().activate(location);
cout << p.context ().evaluate (p.greeting.getSpec (). getName ()) << endl;
cout << p.context ().evaluate (country.getSpec (). getName ()) << endl;
cout << p.context ().evaluate (location.getSpec (). getName ()) << endl;
cout << p.context ().evaluate (p.greeting.getSpec ().getName ()) << endl;
p.context ().activate (country);
p.context ().activate (location);
cout << p.context ().evaluate (p.greeting.getSpec ().getName ()) << endl;
cout << p.context ().evaluate (country.getSpec ().getName ()) << endl;
cout << p.context ().evaluate (location.getSpec ().getName ()) << endl;
cout << p.greeting << endl;
}

int main()
int main ()
{
Coordinator c;
ThreadContext tc (c);
KeySet ks;
// some predefined values (for convenience):
ks.append(Key("user:/test/location",
KEY_VALUE,
"48N16O",
KEY_END));
ks.append(Key("user:/test/48N16O/country",
KEY_VALUE,
"austria",
KEY_END));
ks.append(Key("user:/test/person/austria/greeting",
KEY_VALUE,
"Griaz Enk!",
KEY_END));
Environment <ContextPolicyIs<ThreadContext>> env (ks,tc);
ks.append (Key ("user:/test/location", KEY_VALUE, "48N16O", KEY_END));
ks.append (Key ("user:/test/48N16O/country", KEY_VALUE, "austria", KEY_END));
ks.append (Key ("user:/test/person/austria/greeting", KEY_VALUE, "Griaz Enk!", KEY_END));
Environment<ContextPolicyIs<ThreadContext>> env (ks, tc);

greet (env.test.person, env.country, env.location);
}
Loading

0 comments on commit 33c2c53

Please sign in to comment.