0002-Remove-gratuitous-classes.patch 11 KB

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