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