From 5e527213a2430bb3018e5eebd909aef294edf9b5 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 18 Dec 2020 18:48:46 +0300 Subject: Switch to build2 --- .../cxx/parser/polymorphism/recursive/buildfile | 24 ++++ .../cxx/parser/polymorphism/recursive/driver.cxx | 68 ++++++++++ xsd-tests/cxx/parser/polymorphism/recursive/output | 22 +++ .../parser/polymorphism/recursive/test-pimpl.cxx | 147 +++++++++++++++++++++ .../parser/polymorphism/recursive/test-pimpl.hxx | 94 +++++++++++++ .../cxx/parser/polymorphism/recursive/test.xml | 15 +++ .../cxx/parser/polymorphism/recursive/test.xsd | 53 ++++++++ .../cxx/parser/polymorphism/same-type/buildfile | 24 ++++ .../cxx/parser/polymorphism/same-type/driver.cxx | 62 +++++++++ xsd-tests/cxx/parser/polymorphism/same-type/output | 4 + .../cxx/parser/polymorphism/same-type/test.xml | 10 ++ .../cxx/parser/polymorphism/same-type/test.xsd | 21 +++ 12 files changed, 544 insertions(+) create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/buildfile create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/driver.cxx create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/output create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/test.xml create mode 100644 xsd-tests/cxx/parser/polymorphism/recursive/test.xsd create mode 100644 xsd-tests/cxx/parser/polymorphism/same-type/buildfile create mode 100644 xsd-tests/cxx/parser/polymorphism/same-type/driver.cxx create mode 100644 xsd-tests/cxx/parser/polymorphism/same-type/output create mode 100644 xsd-tests/cxx/parser/polymorphism/same-type/test.xml create mode 100644 xsd-tests/cxx/parser/polymorphism/same-type/test.xsd (limited to 'xsd-tests/cxx/parser/polymorphism') diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/buildfile b/xsd-tests/cxx/parser/polymorphism/recursive/buildfile new file mode 100644 index 0000000..629645b --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/polymorphism/recursive/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-polymorphic \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/driver.cxx b/xsd-tests/cxx/parser/polymorphism/recursive/driver.cxx new file mode 100644 index 0000000..26793a0 --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/driver.cxx @@ -0,0 +1,68 @@ +// file : cxx/parser/polymorphism/recursive/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test polymorphic recursive parsing. +// + +#include +#include + +#include "test-pskel.hxx" +#include "test-pimpl.hxx" + +using namespace std; +using namespace test; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::int_pimpl int_p; + + root_pimpl root_p; + expression_pimpl expression_p; + recursive_pimpl recursive_p; + value_a_pimpl value_a_p; + value_b_pimpl value_b_p; + + xml_schema::parser_map_impl expression_map; + + // Connect the parsers together. + // + root_p.parsers (expression_p); + expression_map.insert(value_a_p); + expression_map.insert(value_b_p); + expression_map.insert(recursive_p); + + root_p.expression_parser(expression_map); + + recursive_p.parsers(expression_p); + recursive_p.expression_parser(expression_map); + + value_a_p.parsers(int_p); + value_b_p.parsers(int_p); + + xml_schema::document doc_p (root_p, "test", "root", true); + + root_p.pre (); + doc_p.parse (argv[1]); + root_p.post_root (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/output b/xsd-tests/cxx/parser/polymorphism/recursive/output new file mode 100644 index 0000000..28a835f --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/output @@ -0,0 +1,22 @@ +root start +recursive start +value_a begin +value->constant +value: post_expression override +value_a: post_value override +value_a end +recursive->expression event +recursive start +value_b begin +value->constant +value: post_expression override +value_b: post_value override +value_b end +recursive->expression event +recursive: post_expression override +recursive end +recursive->expression event +recursive: post_expression override +recursive end +root->expression +root end diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx b/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx new file mode 100644 index 0000000..7c7f410 --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.cxx @@ -0,0 +1,147 @@ +// file : cxx/parser/polymorphism/recursive/pimpl.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include + +#include "test-pimpl.hxx" + +using namespace std; + +namespace test +{ + // root_pimpl + // + + void root_pimpl:: + pre () + { + cout << "root start" << endl; + } + + void root_pimpl:: + expression () + { + cout << "root->expression" << endl; + } + + void root_pimpl:: + post_root () + { + cout << "root end" << endl; + } + + // expression_pimpl + // + + void expression_pimpl:: + pre () + { + cout << "expression begin" << endl; + } + + void expression_pimpl:: + post_expression () + { + cout << "expression end" << endl; + } + + // recursive_pimpl + // + + void recursive_pimpl:: + pre () + { + cout << "recursive start" << endl; + } + + void recursive_pimpl:: + expression () + { + cout << "recursive->expression event" << endl; + } + + void recursive_pimpl:: + post_expression () + { + cout << "recursive: post_expression override" << endl; + post_recursive (); + } + + void recursive_pimpl:: + post_recursive () + { + cout << "recursive end" << endl; + } + + // value_pimpl + // + + void value_pimpl:: + pre () + { + cout << "value begin" << endl; + } + + void value_pimpl:: + constant (int) + { + cout << "value->constant" << endl; + } + + void value_pimpl:: + post_expression () + { + cout << "value: post_expression override" << endl; + post_value (); + } + + void value_pimpl:: + post_value () + { + cout << "value end" << endl; + } + + // value_a_pimpl + // + + void value_a_pimpl:: + pre () + { + cout << "value_a begin" << endl; + } + + void value_a_pimpl:: + post_value () + { + cout << "value_a: post_value override" << endl; + post_value_a (); + } + + void value_a_pimpl:: + post_value_a () + { + cout << "value_a end" << endl; + } + + // value_b_pimpl + // + + void value_b_pimpl:: + pre () + { + cout << "value_b begin" << endl; + } + + void value_b_pimpl:: + post_value () + { + cout << "value_b: post_value override" << endl; + post_value_b (); + } + + void value_b_pimpl:: + post_value_b () + { + cout << "value_b end" << endl; + } +} diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx b/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx new file mode 100644 index 0000000..928b880 --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/test-pimpl.hxx @@ -0,0 +1,94 @@ +// file : cxx/parser/polymorphism/recursive/pimpl.hxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef TEST_PIMPL_HXX +#define TEST_PIMPL_HXX + +#include "test-pskel.hxx" + +namespace test +{ + class root_pimpl: public virtual root_pskel + { + public: + virtual void + pre (); + + virtual void + expression (); + + virtual void + post_root (); + }; + + class expression_pimpl: public virtual expression_pskel + { + public: + virtual void + pre (); + + virtual void + post_expression (); + }; + + class recursive_pimpl: public virtual recursive_pskel, + public expression_pimpl + { + public: + virtual void + pre (); + + virtual void + expression (); + + virtual void + post_expression (); + + virtual void + post_recursive (); + }; + + class value_pimpl: public virtual value_pskel, public expression_pimpl + { + public: + virtual void + pre (); + + virtual void + constant (int); + + virtual void + post_expression (); + + virtual void + post_value (); + }; + + class value_a_pimpl: public virtual value_a_pskel, public value_pimpl + { + public: + virtual void + pre (); + + virtual void + post_value (); + + virtual void + post_value_a (); + }; + + class value_b_pimpl: public virtual value_b_pskel, public value_pimpl + { + public: + virtual void + pre (); + + virtual void + post_value (); + + virtual void + post_value_b (); + }; +} + +#endif // TEST_PIMPL_HXX diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/test.xml b/xsd-tests/cxx/parser/polymorphism/recursive/test.xml new file mode 100644 index 0000000..42035ba --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/test.xml @@ -0,0 +1,15 @@ + + + + + 1 + + + + 2 + + + + diff --git a/xsd-tests/cxx/parser/polymorphism/recursive/test.xsd b/xsd-tests/cxx/parser/polymorphism/recursive/test.xsd new file mode 100644 index 0000000..affcc8a --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/recursive/test.xsd @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/buildfile b/xsd-tests/cxx/parser/polymorphism/same-type/buildfile new file mode 100644 index 0000000..d98e917 --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/same-type/buildfile @@ -0,0 +1,24 @@ +# file : cxx/parser/polymorphism/same-type/buildfile +# license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +import libs = libxsd%lib{xsd} +import libs += libxerces-c%lib{xerces-c} + +exe{driver}: {hxx cxx}{* -test-pskel} {hxx ixx cxx}{test-pskel} $libs + +exe{driver}: xml{test}: test.input = true +exe{driver}: file{output}: test.stdout = true + +<{hxx ixx cxx}{test-pskel}>: xsd{test} $xsd +{{ + diag xsd ($<[0]) # @@ TMP + + $xsd cxx-parser --std c++11 \ + --generate-inline \ + --skel-file-suffix -pskel \ + --output-dir $out_base \ + --generate-polymorphic \ + $path($<[0]) +}} + +cxx.poptions =+ "-I$out_base" diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/driver.cxx b/xsd-tests/cxx/parser/polymorphism/same-type/driver.cxx new file mode 100644 index 0000000..6da4a0a --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/same-type/driver.cxx @@ -0,0 +1,62 @@ +// file : cxx/parser/polymorphism/same-type/driver.cxx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +// Test substitution group and xsi:type that don't change the type. +// + +#include +#include + +#include "test-pskel.hxx" + +using namespace std; +using namespace test; + +struct base_pimpl: base_pskel +{ + virtual void + a (string const& v) + { + cout << v << endl; + } +}; + +struct type_pimpl: type_pskel +{ +}; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " test.xml" << endl; + return 1; + } + + try + { + xml_schema::string_pimpl string_p; + base_pimpl base_p; + type_pimpl type_p; + + base_p.parsers (string_p); + type_p.parsers (base_p); + + xml_schema::document doc_p (type_p, "test", "root", true); + + type_p.pre (); + doc_p.parse (argv[1]); + type_p.post_type (); + } + catch (xml_schema::exception const& e) + { + cerr << e << endl; + return 1; + } + catch (std::ios_base::failure const&) + { + cerr << "io failure" << endl; + return 1; + } +} diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/output b/xsd-tests/cxx/parser/polymorphism/same-type/output new file mode 100644 index 0000000..d418277 --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/same-type/output @@ -0,0 +1,4 @@ +a1 +a2 +a3 +a4 diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/test.xml b/xsd-tests/cxx/parser/polymorphism/same-type/test.xml new file mode 100644 index 0000000..f8b6d1e --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/same-type/test.xml @@ -0,0 +1,10 @@ + + + a1 + a2 + a3 + a4 + + diff --git a/xsd-tests/cxx/parser/polymorphism/same-type/test.xsd b/xsd-tests/cxx/parser/polymorphism/same-type/test.xsd new file mode 100644 index 0000000..a4157d3 --- /dev/null +++ b/xsd-tests/cxx/parser/polymorphism/same-type/test.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1