1From 5486c8c85b9cfb92232518b2fadf6d8ed7b332d5 Mon Sep 17 00:00:00 2001 2From: Boris Kolpackov <boris@codesynthesis.com> 3Date: Wed, 3 Jun 2015 21:35:43 +0200 4Subject: [PATCH] Remove gratuitous classes 5 6In the process also get rid of global class processor which conflicts 7with enum processor on MIPS. 8 9[Upstream: bbc39ffe31c67506b4c03fc56fa3adcb925b6325] 10Signed-off-by: Kamel Bouhara <kamel.bouhara@bootlin.com> 11--- 12 odb/context.hxx | 3 ++- 13 odb/generator.cxx | 24 ++++++++++++------------ 14 odb/generator.hxx | 26 ++++++++------------------ 15 odb/plugin.cxx | 18 +++++++----------- 16 odb/processor.cxx | 4 ++-- 17 odb/processor.hxx | 22 ++++++---------------- 18 odb/relational/validator.cxx | 6 +++--- 19 odb/relational/validator.hxx | 29 +++++++++-------------------- 20 odb/validator.cxx | 13 ++++++------- 21 odb/validator.hxx | 28 +++++++++------------------- 22 10 files changed, 64 insertions(+), 109 deletions(-) 23 24diff --git a/odb/context.hxx b/odb/context.hxx 25index 1cf002a..351bc61 100644 26--- a/odb/context.hxx 27+++ b/odb/context.hxx 28@@ -41,7 +41,8 @@ typedef cutl::re::format regex_format; 29 30 typedef std::vector<regexsub> regex_mapping; 31 32-// 33+// Generic exception thrown to indicate a failure when diagnostics 34+// has already been issued (to stderr). 35 // 36 class operation_failed {}; 37 38diff --git a/odb/generator.cxx b/odb/generator.cxx 39index e165faf..6aa5151 100644 40--- a/odb/generator.cxx 41+++ b/odb/generator.cxx 42@@ -58,7 +58,7 @@ namespace 43 if (!ifs.is_open ()) 44 { 45 cerr << "error: unable to open '" << p << "' in read mode" << endl; 46- throw generator::failed (); 47+ throw generator_failed (); 48 } 49 } 50 51@@ -70,7 +70,7 @@ namespace 52 if (!ofs.is_open ()) 53 { 54 cerr << "error: unable to open '" << p << "' in write mode" << endl; 55- throw generator::failed (); 56+ throw generator_failed (); 57 } 58 } 59 60@@ -118,7 +118,7 @@ namespace 61 } 62 } 63 64-void generator:: 65+void 66 generate (options const& ops, 67 features& fts, 68 semantics::unit& unit, 69@@ -259,7 +259,7 @@ generate (options const& ops, 70 cerr << in_log_path << ": error: wrong database '" << 71 old_changelog->database () << "', expected '" << db << 72 "'" << endl; 73- throw generator::failed (); 74+ throw generator_failed (); 75 } 76 77 string sn (ops.schema_name ()[db]); 78@@ -268,18 +268,18 @@ generate (options const& ops, 79 cerr << in_log_path << ": error: wrong schema name '" << 80 old_changelog->schema_name () << "', expected '" << sn << 81 "'" << endl; 82- throw generator::failed (); 83+ throw generator_failed (); 84 } 85 } 86 catch (const ios_base::failure& e) 87 { 88 cerr << in_log_path << ": read failure" << endl; 89- throw failed (); 90+ throw generator_failed (); 91 } 92 catch (const xml::parsing& e) 93 { 94 cerr << e.what () << endl; 95- throw failed (); 96+ throw generator_failed (); 97 } 98 } 99 100@@ -976,12 +976,12 @@ generate (options const& ops, 101 catch (const ios_base::failure& e) 102 { 103 cerr << out_log_path << ": write failure" << endl; 104- throw failed (); 105+ throw generator_failed (); 106 } 107 catch (const xml::serialization& e) 108 { 109 cerr << e.what () << endl; 110- throw failed (); 111+ throw generator_failed (); 112 } 113 } 114 115@@ -998,18 +998,18 @@ generate (options const& ops, 116 { 117 // Code generation failed. Diagnostics has already been issued. 118 // 119- throw failed (); 120+ throw generator_failed (); 121 } 122 catch (semantics::invalid_path const& e) 123 { 124 cerr << "error: '" << e.path () << "' is not a valid filesystem path" 125 << endl; 126- throw failed (); 127+ throw generator_failed (); 128 } 129 catch (fs::error const&) 130 { 131 // Auto-removal of generated files failed. Ignore it. 132 // 133- throw failed (); 134+ throw generator_failed (); 135 } 136 } 137diff --git a/odb/generator.hxx b/odb/generator.hxx 138index ce49295..e83d94d 100644 139--- a/odb/generator.hxx 140+++ b/odb/generator.hxx 141@@ -11,23 +11,13 @@ 142 #include <odb/features.hxx> 143 #include <odb/semantics/unit.hxx> 144 145-class generator 146-{ 147-public: 148- class failed {}; 149- 150- void 151- generate (options const&, 152- features&, 153- semantics::unit&, 154- semantics::path const& file, 155- std::vector<semantics::path> const& inputs); 156- 157- generator () {} 158- 159-private: 160- generator (generator const&); 161- generator& operator= (generator const&); 162-}; 163+class generator_failed {}; 164+ 165+void 166+generate (options const&, 167+ features&, 168+ semantics::unit&, 169+ semantics::path const& file, 170+ std::vector<semantics::path> const& inputs); 171 172 #endif // ODB_GENERATOR_HXX 173diff --git a/odb/plugin.cxx b/odb/plugin.cxx 174index e32f225..51f0cb1 100644 175--- a/odb/plugin.cxx 176+++ b/odb/plugin.cxx 177@@ -199,27 +199,23 @@ gate_callback (void*, void*) 178 parser p (*options_, loc_pragmas_, ns_loc_pragmas_, decl_pragmas_); 179 auto_ptr<unit> u (p.parse (global_namespace, file_)); 180 181- 182 features f; 183 184 // Validate, pass 1. 185 // 186- validator v; 187- v.validate (*options_, f, *u, file_, 1); 188+ validate (*options_, f, *u, file_, 1); 189 190 // Process. 191 // 192- processor pr; 193- pr.process (*options_, f, *u, file_); 194+ process (*options_, f, *u, file_); 195 196 // Validate, pass 2. 197 // 198- v.validate (*options_, f, *u, file_, 2); 199+ validate (*options_, f, *u, file_, 2); 200 201 // Generate. 202 // 203- generator g; 204- g.generate (*options_, f, *u, file_, inputs_); 205+ generate (*options_, f, *u, file_, inputs_); 206 } 207 catch (cutl::re::format const& e) 208 { 209@@ -239,19 +235,19 @@ gate_callback (void*, void*) 210 // 211 r = 1; 212 } 213- catch (validator::failed const&) 214+ catch (validator_failed const&) 215 { 216 // Diagnostics has aready been issued. 217 // 218 r = 1; 219 } 220- catch (processor::failed const&) 221+ catch (processor_failed const&) 222 { 223 // Diagnostics has aready been issued. 224 // 225 r = 1; 226 } 227- catch (generator::failed const&) 228+ catch (generator_failed const&) 229 { 230 // Diagnostics has aready been issued. 231 // 232diff --git a/odb/processor.cxx b/odb/processor.cxx 233index a808a52..3a2cb1d 100644 234--- a/odb/processor.cxx 235+++ b/odb/processor.cxx 236@@ -3064,7 +3064,7 @@ namespace 237 }; 238 } 239 240-void processor:: 241+void 242 process (options const& ops, 243 features& f, 244 semantics::unit& unit, 245@@ -3120,6 +3120,6 @@ process (options const& ops, 246 { 247 // Processing failed. Diagnostics has already been issued. 248 // 249- throw failed (); 250+ throw processor_failed (); 251 } 252 } 253diff --git a/odb/processor.hxx b/odb/processor.hxx 254index 602b999..e62dd25 100644 255--- a/odb/processor.hxx 256+++ b/odb/processor.hxx 257@@ -9,22 +9,12 @@ 258 #include <odb/features.hxx> 259 #include <odb/semantics/unit.hxx> 260 261-class processor 262-{ 263-public: 264- class failed {}; 265+class processor_failed {}; 266 267- void 268- process (options const&, 269- features&, 270- semantics::unit&, 271- semantics::path const&); 272- 273- processor () {} 274- 275-private: 276- processor (processor const&); 277- processor& operator= (processor const&); 278-}; 279+void 280+process (options const&, 281+ features&, 282+ semantics::unit&, 283+ semantics::path const&); 284 285 #endif // ODB_PROCESSOR_HXX 286diff --git a/odb/relational/validator.cxx b/odb/relational/validator.cxx 287index 1d51c9a..47f089c 100644 288--- a/odb/relational/validator.cxx 289+++ b/odb/relational/validator.cxx 290@@ -528,7 +528,7 @@ namespace relational 291 }; 292 } 293 294- void validator:: 295+ void 296 validate (options const&, 297 features&, 298 semantics::unit& u, 299@@ -608,7 +608,7 @@ namespace relational 300 } 301 302 if (!valid) 303- throw failed (); 304+ throw operation_failed (); 305 306 if (pass == 1) 307 { 308@@ -636,6 +636,6 @@ namespace relational 309 } 310 311 if (!valid) 312- throw failed (); 313+ throw operation_failed (); 314 } 315 } 316diff --git a/odb/relational/validator.hxx b/odb/relational/validator.hxx 317index f0ede53..93360c3 100644 318--- a/odb/relational/validator.hxx 319+++ b/odb/relational/validator.hxx 320@@ -11,26 +11,15 @@ 321 322 namespace relational 323 { 324- class validator 325- { 326- public: 327- struct failed {}; 328- 329- // The first pass is performed before processing. The second -- after. 330- // 331- void 332- validate (options const&, 333- features&, 334- semantics::unit&, 335- semantics::path const&, 336- unsigned short pass); 337- 338- validator () {} 339- 340- private: 341- validator (validator const&); 342- validator& operator= (validator const&); 343- }; 344+ // The first pass is performed before processing. The second -- after. 345+ // Throws operation_failed to signal a failure. 346+ // 347+ void 348+ validate (options const&, 349+ features&, 350+ semantics::unit&, 351+ semantics::path const&, 352+ unsigned short pass); 353 } 354 355 #endif // ODB_RELATIONAL_VALIDATOR_HXX 356diff --git a/odb/validator.cxx b/odb/validator.cxx 357index e80f4d8..91d91e5 100644 358--- a/odb/validator.cxx 359+++ b/odb/validator.cxx 360@@ -1457,7 +1457,7 @@ namespace 361 }; 362 } 363 364-void validator:: 365+void 366 validate (options const& ops, 367 features& f, 368 semantics::unit& u, 369@@ -1506,7 +1506,7 @@ validate (options const& ops, 370 } 371 372 if (!valid) 373- throw failed (); 374+ throw validator_failed (); 375 376 auto_ptr<context> ctx (create_context (cerr, u, ops, f, 0)); 377 378@@ -1559,7 +1559,7 @@ validate (options const& ops, 379 } 380 381 if (!valid) 382- throw failed (); 383+ throw validator_failed (); 384 385 switch (db) 386 { 387@@ -1575,12 +1575,11 @@ validate (options const& ops, 388 { 389 try 390 { 391- relational::validator v; 392- v.validate (ops, f, u, p, pass); 393+ relational::validate (ops, f, u, p, pass); 394 } 395- catch (relational::validator::failed const&) 396+ catch (operation_failed const&) 397 { 398- throw failed (); 399+ throw validator_failed (); 400 } 401 402 break; 403diff --git a/odb/validator.hxx b/odb/validator.hxx 404index f913049..3ffa470 100644 405--- a/odb/validator.hxx 406+++ b/odb/validator.hxx 407@@ -9,25 +9,15 @@ 408 #include <odb/features.hxx> 409 #include <odb/semantics/unit.hxx> 410 411-class validator 412-{ 413-public: 414- struct failed {}; 415+class validator_failed {}; 416 417- // The first pass is performed before processing. The second -- after. 418- // 419- void 420- validate (options const&, 421- features&, 422- semantics::unit&, 423- semantics::path const&, 424- unsigned short pass); 425- 426- validator () {} 427- 428-private: 429- validator (validator const&); 430- validator& operator= (validator const&); 431-}; 432+// The first pass is performed before processing. The second -- after. 433+// 434+void 435+validate (options const&, 436+ features&, 437+ semantics::unit&, 438+ semantics::path const&, 439+ unsigned short pass); 440 441 #endif // ODB_VALIDATOR_HXX 442-- 4432.25.0 444 445