From fc3fb39c90ab7fe5fccbe3f3bc0eb2645157bb96 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 13 Dec 2023 21:57:53 +0300 Subject: Switch to build2 --- common/inheritance/polymorphism/.gitignore | 76 ++++++++++++++ common/inheritance/polymorphism/buildfile | 52 ++++++++++ common/inheritance/polymorphism/driver.cxx | 159 ++++++----------------------- common/inheritance/polymorphism/makefile | 120 ---------------------- common/inheritance/polymorphism/test.std | 36 ------- common/inheritance/polymorphism/test5.hxx | 6 -- common/inheritance/polymorphism/test6.hxx | 10 -- common/inheritance/polymorphism/test7.hxx | 12 --- common/inheritance/polymorphism/testscript | 80 +++++++++++++++ common/inheritance/reuse/buildfile | 41 ++++++++ common/inheritance/reuse/driver.cxx | 24 +++-- common/inheritance/reuse/makefile | 117 --------------------- common/inheritance/reuse/test.hxx | 2 +- common/inheritance/reuse/test.std | 0 common/inheritance/reuse/testscript | 33 ++++++ common/inheritance/transient/buildfile | 41 ++++++++ common/inheritance/transient/driver.cxx | 12 ++- common/inheritance/transient/makefile | 117 --------------------- common/inheritance/transient/test.std | 0 common/inheritance/transient/testscript | 33 ++++++ 20 files changed, 409 insertions(+), 562 deletions(-) create mode 100644 common/inheritance/polymorphism/.gitignore create mode 100644 common/inheritance/polymorphism/buildfile delete mode 100644 common/inheritance/polymorphism/makefile delete mode 100644 common/inheritance/polymorphism/test.std create mode 100644 common/inheritance/polymorphism/testscript create mode 100644 common/inheritance/reuse/buildfile delete mode 100644 common/inheritance/reuse/makefile delete mode 100644 common/inheritance/reuse/test.std create mode 100644 common/inheritance/reuse/testscript create mode 100644 common/inheritance/transient/buildfile delete mode 100644 common/inheritance/transient/makefile delete mode 100644 common/inheritance/transient/test.std create mode 100644 common/inheritance/transient/testscript (limited to 'common/inheritance') diff --git a/common/inheritance/polymorphism/.gitignore b/common/inheritance/polymorphism/.gitignore new file mode 100644 index 0000000..f183a6f --- /dev/null +++ b/common/inheritance/polymorphism/.gitignore @@ -0,0 +1,76 @@ +# ODB-generated files. +# +test1-odb.?xx +test1-odb-*.?xx +test1.sql +test1-*.sql + +test2-odb.?xx +test2-odb-*.?xx +test2.sql +test2-*.sql + +test3-odb.?xx +test3-odb-*.?xx +test3.sql +test3-*.sql + +test4-odb.?xx +test4-odb-*.?xx +test4.sql +test4-*.sql + +test5-odb.?xx +test5-odb-*.?xx +test5.sql +test5-*.sql + +test6-odb.?xx +test6-odb-*.?xx +test6.sql +test6-*.sql + +test7-odb.?xx +test7-odb-*.?xx +test7.sql +test7-*.sql + +test8-odb.?xx +test8-odb-*.?xx +test8.sql +test8-*.sql + +test9-odb.?xx +test9-odb-*.?xx +test9.sql +test9-*.sql + +test10-odb.?xx +test10-odb-*.?xx +test10.sql +test10-*.sql + +test11-odb.?xx +test11-odb-*.?xx +test11.sql +test11-*.sql + +test12-odb.?xx +test12-odb-*.?xx +test12.sql +test12-*.sql + +test13-odb.?xx +test13-odb-*.?xx +test13.sql +test13-*.sql + +test14-odb.?xx +test14-odb-*.?xx +test14.sql +test14-*.sql + +test15-odb.?xx +test15-odb-*.?xx +test15.sql +test15-*.sql diff --git a/common/inheritance/polymorphism/buildfile b/common/inheritance/polymorphism/buildfile new file mode 100644 index 0000000..846eb12 --- /dev/null +++ b/common/inheritance/polymorphism/buildfile @@ -0,0 +1,52 @@ +# file : common/inheritance/polymorphism/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +hs = test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 \ + test12 test13 test14 test15 + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +for h: $hs +{ + exe{driver}: {hxx ixx cxx}{$h-odb} + + <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta} + + for db: $databases + { + exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi + <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} libue{test-meta} + } +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix inhrt_p_ \ + --generate-schema \ + --generate-query \ + --generate-prepared + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc + +testscript@./: schemas = $hs diff --git a/common/inheritance/polymorphism/driver.cxx b/common/inheritance/polymorphism/driver.cxx index 6d4e615..12f4666 100644 --- a/common/inheritance/polymorphism/driver.cxx +++ b/common/inheritance/polymorphism/driver.cxx @@ -4,15 +4,14 @@ // Test polymorphic object inheritance. // -#include // std::auto_ptr -#include +#include // std::unique_ptr #include #include #include #include -#include +#include #include "test1.hxx" #include "test2.hxx" @@ -46,6 +45,9 @@ #include "test14-odb.hxx" #include "test15-odb.hxx" +#undef NDEBUG +#include + using namespace std; using namespace odb::core; @@ -87,7 +89,7 @@ main (int argc, char* argv[]) { try { - auto_ptr db (create_database (argc, argv)); + unique_ptr db (create_database (argc, argv)); // Test 1: basic polymorphism functionality. // @@ -136,9 +138,9 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); - auto_ptr pr (db->load (r.id)); - auto_ptr pb (db->load (b.id)); - auto_ptr pd (db->load (d.id)); + unique_ptr pr (db->load (r.id)); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); t.commit (); assert (*pr == r); @@ -150,9 +152,9 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); - auto_ptr pb (db->load (b.id)); - auto_ptr pd1 (db->load (d.id)); - auto_ptr pd2 (db->load (d.id)); + unique_ptr pb (db->load (b.id)); + unique_ptr pd1 (db->load (d.id)); + unique_ptr pd2 (db->load (d.id)); t.commit (); assert (*pb == b); @@ -167,14 +169,14 @@ main (int argc, char* argv[]) try { - auto_ptr p (db->load (r.id)); + unique_ptr p (db->load (r.id)); assert (false); } catch (const object_not_persistent&) {} try { - auto_ptr p (db->load (b.id)); + unique_ptr p (db->load (b.id)); assert (false); } catch (const object_not_persistent&) {} @@ -452,14 +454,14 @@ main (int argc, char* argv[]) if (ds == "test1::base") { - auto_ptr d1 (db->load (d.id)); + unique_ptr d1 (db->load (d.id)); assert (*d1 == d); assert (*i == b); mask |= 1; } else if (ds == "test1::derived") { - auto_ptr b1 (db->load (b.id)); + unique_ptr b1 (db->load (b.id)); assert (*b1 == b); assert (*i == d); mask |= 2; @@ -562,9 +564,9 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); - auto_ptr pr (db->load (r.id)); - auto_ptr pb (db->load (b.id)); - auto_ptr pd (db->load (d.id)); + unique_ptr pr (db->load (r.id)); + unique_ptr pb (db->load (b.id)); + unique_ptr pd (db->load (d.id)); t.commit (); assert (*pr == r); @@ -661,9 +663,9 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); - auto_ptr pd (db->load (d.id)); - auto_ptr pb (db->load (d.id)); - auto_ptr pr (db->load (d.id)); + unique_ptr pd (db->load (d.id)); + unique_ptr pb (db->load (d.id)); + unique_ptr pr (db->load (d.id)); t.commit (); assert (pd->rp.object_id () == rp.id && @@ -791,18 +793,18 @@ main (int argc, char* argv[]) transaction t (db->begin ()); { - auto_ptr p1 (db->load (b1.id)); - auto_ptr p2 (db->load (b2.id)); - auto_ptr p3 (db->load (b3.id)); + unique_ptr p1 (db->load (b1.id)); + unique_ptr p2 (db->load (b2.id)); + unique_ptr p3 (db->load (b3.id)); assert (*p1 == b1); assert (*p2 == b2); assert (*p3 == b3); } { - auto_ptr p1 (db->load (d1.id)); - auto_ptr p2 (db->load (d2.id)); - auto_ptr p3 (db->load (d3.id)); + unique_ptr p1 (db->load (d1.id)); + unique_ptr p2 (db->load (d2.id)); + unique_ptr p3 (db->load (d3.id)); assert (*p1 == d1); assert (*p2 == d2); assert (*p3 == d3); @@ -1028,11 +1030,7 @@ main (int argc, char* argv[]) // Root. // { -#ifdef HAVE_CXX11 unique_ptr p (db->load (r.id)); -#else - auto_ptr p (db->load (r.id)); -#endif r.num++; r.strs.push_back ("aaaa"); @@ -1056,11 +1054,7 @@ main (int argc, char* argv[]) // Base. // { -#ifdef HAVE_CXX11 unique_ptr p (db->load (b.id)); -#else - auto_ptr p (db->load (b.id)); -#endif b.num++; b.str += "b"; @@ -1088,11 +1082,7 @@ main (int argc, char* argv[]) // Derived. // { -#ifdef HAVE_CXX11 unique_ptr p (db->load (d.id)); // Via root. -#else - auto_ptr p (db->load (d.id)); // Via root. -#endif d.num++; d.str += "d"; @@ -1156,11 +1146,7 @@ main (int argc, char* argv[]) // Root. // { -#ifdef HAVE_CXX11 unique_ptr p (db->load (r.id)); -#else - auto_ptr p (db->load (r.id)); -#endif r.num++; r.strs.push_back ("aaaaa"); @@ -1180,11 +1166,7 @@ main (int argc, char* argv[]) // Base. // { -#ifdef HAVE_CXX11 unique_ptr p (db->load (b.id)); -#else - auto_ptr p (db->load (b.id)); -#endif b.num++; b.str += "b"; @@ -1206,11 +1188,7 @@ main (int argc, char* argv[]) // Derived. // { -#ifdef HAVE_CXX11 unique_ptr p (db->load (d.id)); // Via root. -#else - auto_ptr p (db->load (d.id)); // Via root. -#endif d.num++; d.str += "d"; @@ -1264,11 +1242,7 @@ main (int argc, char* argv[]) base b (1, 1, "bbb"); -#ifdef HAVE_CXX11 unique_ptr d (new derived (2, 2, "ddd")); -#else - auto_ptr d (new derived (2, 2, "ddd")); -#endif // Persist. // @@ -1284,13 +1258,8 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); -#ifdef HAVE_CXX11 unique_ptr pb (db->load (b.id)); unique_ptr pd (db->load (d->id)); -#else - auto_ptr pb (db->load (b.id)); - auto_ptr pd (db->load (d->id)); -#endif db->load (b.id, *pb); db->load (d->id, *pd); @@ -1353,11 +1322,7 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); -#ifdef HAVE_CXX11 unique_ptr p (db->load (d.id)); -#else - auto_ptr p (db->load (d.id)); -#endif t.commit (); } } @@ -1365,7 +1330,6 @@ main (int argc, char* argv[]) // Test 7: polymorphism and object cache (session). // -#if defined(HAVE_CXX11) || defined(HAVE_TR1_MEMORY) { using namespace test7; @@ -1468,7 +1432,6 @@ main (int argc, char* argv[]) } } } -#endif // Test 8: polymorphism and abstract bases. // @@ -1517,15 +1480,9 @@ main (int argc, char* argv[]) // load (id) // -#ifdef HAVE_CXX11 unique_ptr pb (db->load (b.id)); unique_ptr pd1 (db->load (d1.id)); unique_ptr pd2 (db->load (d2.id)); -#else - auto_ptr pb (db->load (b.id)); - auto_ptr pd1 (db->load (d1.id)); - auto_ptr pd2 (db->load (d2.id)); -#endif assert (*pb == b); assert (*pd1 == d1); @@ -1608,15 +1565,9 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); -#ifdef HAVE_CXX11 unique_ptr pb (db->load (b.id)); unique_ptr pd1 (db->load (d1.id)); unique_ptr pd2 (db->load (d2.id)); -#else - auto_ptr pb (db->load (b.id)); - auto_ptr pd1 (db->load (d1.id)); - auto_ptr pd2 (db->load (d2.id)); -#endif t.commit (); @@ -1743,7 +1694,6 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); -#ifdef HAVE_CXX11 unique_ptr p_ro_r (db->load (ro_r.id)); unique_ptr p_rw_b (db->load (rw_b.id)); unique_ptr p_ro_d (db->load (ro_d.id)); @@ -1751,15 +1701,6 @@ main (int argc, char* argv[]) unique_ptr p_rw_r (db->load (rw_r.id)); unique_ptr p_ro_b (db->load (ro_b.id)); unique_ptr p_rw_d (db->load (rw_d.id)); -#else - auto_ptr p_ro_r (db->load (ro_r.id)); - auto_ptr p_rw_b (db->load (rw_b.id)); - auto_ptr p_ro_d (db->load (ro_d.id)); - - auto_ptr p_rw_r (db->load (rw_r.id)); - auto_ptr p_ro_b (db->load (ro_b.id)); - auto_ptr p_rw_d (db->load (rw_d.id)); -#endif t.commit (); @@ -1795,13 +1736,8 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); -#ifdef HAVE_CXX11 unique_ptr pb (db->load (b.id)); unique_ptr pd (db->load (d.id)); -#else - auto_ptr pb (db->load (b.id)); - auto_ptr pd (db->load (d.id)); -#endif t.commit (); assert (*pb == b); @@ -1825,13 +1761,8 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); -#ifdef HAVE_CXX11 unique_ptr pb (db->load (b.id)); unique_ptr pd (db->load (d.id)); -#else - auto_ptr pb (db->load (b.id)); - auto_ptr pd (db->load (d.id)); -#endif t.commit (); assert (*pb == b); @@ -1867,13 +1798,8 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); -#ifdef HAVE_CXX11 unique_ptr pb (db->load (b.id)); unique_ptr pd (db->load (d.id)); -#else - auto_ptr pb (db->load (b.id)); - auto_ptr pd (db->load (d.id)); -#endif t.commit (); assert (*pb == b); @@ -1906,13 +1832,8 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); -#ifdef HAVE_CXX11 unique_ptr pb (db->load (b.id)); unique_ptr pd (db->load (d.id)); -#else - auto_ptr pb (db->load (b.id)); - auto_ptr pd (db->load (d.id)); -#endif t.commit (); @@ -1975,13 +1896,8 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); -#ifdef HAVE_CXX11 unique_ptr pb (db->load (id1)); unique_ptr pd (db->load (id2)); -#else - auto_ptr pb (db->load (id1)); - auto_ptr pd (db->load (id2)); -#endif t.commit (); @@ -2019,17 +1935,10 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); -#ifdef HAVE_CXX11 unique_ptr pbr (db->load (b.id)); unique_ptr pdr (db->load (d.id)); unique_ptr pdb (db->load (d.id)); unique_ptr pb1r (db->load (b1.id)); -#else - auto_ptr pbr (db->load (b.id)); - auto_ptr pdr (db->load (d.id)); - auto_ptr pdb (db->load (d.id)); - auto_ptr pb1r (db->load (b1.id)); -#endif t.commit (); base& rb (static_cast (*pbr)); @@ -2083,10 +1992,10 @@ main (int argc, char* argv[]) object4* p4 (db->load (d.o4[0]->id)); t.commit (); - assert (p1->d->num = d.num); - assert (p2->d[0]->num = d.num); - assert (p3->d[0]->num = d.num); - assert (p4->d->num = d.num); + assert (p1->d->num == d.num); + assert (p2->d[0]->num == d.num); + assert (p3->d[0]->num == d.num); + assert (p4->d->num == d.num); delete p1->d; } @@ -2149,11 +2058,7 @@ main (int argc, char* argv[]) { transaction t (db->begin ()); -#ifdef HAVE_CXX11 unique_ptr pb (db->load (d.id)); -#else - auto_ptr pb (db->load (d.id)); -#endif t.commit (); derived* pd (dynamic_cast (pb.get ())); diff --git a/common/inheritance/polymorphism/makefile b/common/inheritance/polymorphism/makefile deleted file mode 100644 index 2b969f5..0000000 --- a/common/inheritance/polymorphism/makefile +++ /dev/null @@ -1,120 +0,0 @@ -# file : common/inheritance/polymorphism/makefile -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -cxx_tun := driver.cxx -odb_hdr := test1.hxx test2.hxx test3.hxx test4.hxx test5.hxx test6.hxx \ -test7.hxx test8.hxx test9.hxx test10.hxx test11.hxx test12.hxx test13.hxx \ -test14.hxx test15.hxx -genf := $(call odb-gen,$(odb_hdr)) -gen := $(addprefix $(out_base)/,$(genf)) -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) $(filter %.o,$(gen:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -common.l := $(out_root)/libcommon/common/common.l -common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options - -# Import. -# -$(call import,\ - $(scf_root)/import/odb/stub.make,\ - odb: odb,odb-rules: odb_rules) - -# Build. -# -$(driver): $(cxx_obj) $(common.l) -$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base) -$(cxx_obj) $(cxx_od): $(common.l.cpp-options) - -$(gen): $(odb) -$(gen): odb := $(odb) -$(gen) $(dist): export odb_options += --generate-schema --generate-query \ ---generate-prepared --table-prefix inhrt_p_ -$(gen): cpp_options := -I$(src_base) -$(gen): $(common.l.cpp-options) - -ifneq ($(db_id),common) -$(gen): odb_options += --database $(db_id) -else -$(gen): odb_options += --multi-database dynamic -endif - -$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) - -# Alias for default target. -# -$(out_base)/: $(driver) - -# Dist -# -name := $(subst /,-,$(subst $(src_root)/common/,,$(src_base))) - -$(dist): sources := $(cxx_tun) -$(dist): headers := $(odb_hdr) -$(dist): data_dist := test.std -$(dist): export name := $(name) -$(dist): export odb_header_stem := $(basename $(odb_hdr)) -$(dist): export extra_dist := $(data_dist) $(call vc8projs,$(name)) \ -$(call vc9projs,$(name)) $(call vc10projs,$(name)) $(call vc11projs,$(name)) \ -$(call vc12projs,$(name)) -$(dist): - $(call dist-data,$(sources) $(headers) $(data_dist)) - $(call meta-automake,../../template/Makefile.am) - $(call meta-vc8projs,../../template/template,$(name)) - $(call meta-vc9projs,../../template/template,$(name)) - $(call meta-vc10projs,../../template/template,$(name)) - $(call meta-vc11projs,../../template/template,$(name)) - $(call meta-vc12projs,../../template/template,$(name)) - -# Test. -# -ifneq ($(db_id),common) -$(eval $(call test-rule,,$(filter %.sql,$(gen)))) -else -$(foreach d,$(databases),$(eval $(call test-rule,$d,$(filter %.sql,$(gen))))) -endif - -# Clean. -# -$(clean): \ - $(driver).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) \ - $(addsuffix .hxx.clean,$(filter %.cxx,$(gen))) - $(call message,,rm -f $(out_base)/test.out) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver $(genf) -$(clean): $(out_base)/.gitignore.clean - -$(call include,$(bld_root)/git/gitignore.make) -endif - -# How to. -# -$(call include,$(bld_root)/dist.make) -$(call include,$(bld_root)/meta/vc8proj.make) -$(call include,$(bld_root)/meta/vc9proj.make) -$(call include,$(bld_root)/meta/vc10proj.make) -$(call include,$(bld_root)/meta/vc11proj.make) -$(call include,$(bld_root)/meta/vc12proj.make) -$(call include,$(bld_root)/meta/automake.make) - -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): odb_options += --std $(cxx_standard) -$(call include,$(odb_rules)) -endif - -$(call include,$(bld_root)/cxx/cxx-d.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/o-e.make) - -# Dependencies. -# -$(call import,$(src_root)/libcommon/makefile) diff --git a/common/inheritance/polymorphism/test.std b/common/inheritance/polymorphism/test.std deleted file mode 100644 index 5c18191..0000000 --- a/common/inheritance/polymorphism/test.std +++ /dev/null @@ -1,36 +0,0 @@ -base pre_persist 1 const -base post_persist 1 const -derived pre_persist 2 const -derived post_persist 2 const -base pre_load 0 -base post_load 1 -derived pre_load 0 const -derived post_load 2 const -base pre_load 1 -base post_load 1 -derived pre_load 2 const -derived post_load 2 const -base pre_load 1 -base post_load 1 -derived pre_load 2 const -derived post_load 2 const -base pre_update 1 const -base post_update 1 const -derived pre_update 2 const -derived post_update 2 const -base pre_load 0 -base post_load 1 -derived pre_load 0 const -derived post_load 2 const -base pre_erase 1 const -base post_erase 1 const -derived pre_erase 2 const -derived post_erase 2 const -derived pre_persist 3 const -derived post_persist 3 const -derived pre_persist 4 const -derived post_persist 4 const -derived pre_load 0 const -derived pre_load 0 const -derived post_load 4 const -derived post_load 3 const diff --git a/common/inheritance/polymorphism/test5.hxx b/common/inheritance/polymorphism/test5.hxx index e6dba8d..172e7e8 100644 --- a/common/inheritance/polymorphism/test5.hxx +++ b/common/inheritance/polymorphism/test5.hxx @@ -4,8 +4,6 @@ #ifndef TEST5_HXX #define TEST5_HXX -#include // HAVE_CXX11 - #include #include #include @@ -18,11 +16,7 @@ #pragma db namespace table("t5_") namespace test5 { -#ifdef HAVE_CXX11 #pragma db object polymorphic optimistic pointer(std::unique_ptr) -#else - #pragma db object polymorphic optimistic pointer(std::auto_ptr) -#endif struct root { virtual ~root () {} diff --git a/common/inheritance/polymorphism/test6.hxx b/common/inheritance/polymorphism/test6.hxx index 1e42400..b0f9a16 100644 --- a/common/inheritance/polymorphism/test6.hxx +++ b/common/inheritance/polymorphism/test6.hxx @@ -4,8 +4,6 @@ #ifndef TEST6_HXX #define TEST6_HXX -#include // HAVE_CXX11 - #include #include @@ -17,11 +15,7 @@ #pragma db namespace table("t6_") namespace test6 { -#ifdef HAVE_CXX11 #pragma db object polymorphic pointer(std::unique_ptr) -#else - #pragma db object polymorphic pointer(std::auto_ptr) -#endif struct root { virtual ~root () {} @@ -60,11 +54,7 @@ namespace test6 unsigned long dnum; std::string dstr; -#ifdef HAVE_CXX11 std::unique_ptr ptr; -#else - std::auto_ptr ptr; -#endif void db_callback (odb::callback_event, odb::database&) const; diff --git a/common/inheritance/polymorphism/test7.hxx b/common/inheritance/polymorphism/test7.hxx index 6edb834..60da98e 100644 --- a/common/inheritance/polymorphism/test7.hxx +++ b/common/inheritance/polymorphism/test7.hxx @@ -4,28 +4,17 @@ #ifndef TEST7_HXX #define TEST7_HXX -#include // HAVE_CXX11, HAVE_TR1_MEMORY - #include #include -#if !defined(HAVE_CXX11) && defined(HAVE_TR1_MEMORY) -# include -#endif - #include // Test polymorphism and object cache (session). // -#if defined(HAVE_CXX11) || defined(HAVE_TR1_MEMORY) #pragma db namespace table("t7_") namespace test7 { -#ifdef HAVE_CXX11 using std::shared_ptr; -#else - using std::tr1::shared_ptr; -#endif #pragma db object polymorphic pointer(shared_ptr) session struct root @@ -61,6 +50,5 @@ namespace test7 std::string dstr; }; } -#endif #endif // TEST7_HXX diff --git a/common/inheritance/polymorphism/testscript b/common/inheritance/polymorphism/testscript new file mode 100644 index 0000000..89e5726 --- /dev/null +++ b/common/inheritance/polymorphism/testscript @@ -0,0 +1,80 @@ +# file : common/inheritance/polymorphism/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + ++cat <=output + base pre_persist 1 const + base post_persist 1 const + derived pre_persist 2 const + derived post_persist 2 const + base pre_load 0 + base post_load 1 + derived pre_load 0 const + derived post_load 2 const + base pre_load 1 + base post_load 1 + derived pre_load 2 const + derived post_load 2 const + base pre_load 1 + base post_load 1 + derived pre_load 2 const + derived post_load 2 const + base pre_update 1 const + base post_update 1 const + derived pre_update 2 const + derived post_update 2 const + base pre_load 0 + base post_load 1 + derived pre_load 0 const + derived post_load 2 const + base pre_erase 1 const + base post_erase 1 const + derived pre_erase 2 const + derived post_erase 2 const + derived pre_persist 3 const + derived post_persist 3 const + derived pre_persist 4 const + derived post_persist 4 const + derived pre_load 0 const + derived pre_load 0 const + derived post_load 4 const + derived post_load 3 const + EOI + +test.redirects += >>>../output + +: mysql +: +if $mysql +{ + .include ../../../mysql-schema.testscript + + for s: $schemas + cat $out_base/"$s"($multi ? '-mysql' : '').sql | $create_schema_cmd + end; + + $* ($multi ? 'mysql' : ) $mysql_options +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql-schema.testscript + + for s: $schemas + $create_schema_cmd -f $out_base/"$s"($multi ? '-pgsql' : '').sql + end; + + $* ($multi ? 'pgsql' : ) $pgsql_options +} diff --git a/common/inheritance/reuse/buildfile b/common/inheritance/reuse/buildfile new file mode 100644 index 0000000..b82439a --- /dev/null +++ b/common/inheritance/reuse/buildfile @@ -0,0 +1,41 @@ +# file : common/inheritance/reuse/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix inhrt_r_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/inheritance/reuse/driver.cxx b/common/inheritance/reuse/driver.cxx index 616c6a4..e6122bb 100644 --- a/common/inheritance/reuse/driver.cxx +++ b/common/inheritance/reuse/driver.cxx @@ -4,18 +4,20 @@ // Test reuse object inheritance. // -#include // std::auto_ptr -#include +#include // std::unique_ptr #include #include #include -#include +#include #include "test.hxx" #include "test-odb.hxx" +#undef NDEBUG +#include + using namespace std; using namespace odb::core; @@ -24,7 +26,7 @@ main (int argc, char* argv[]) { try { - auto_ptr db (create_database (argc, argv)); + unique_ptr db (create_database (argc, argv)); base b; b.comp_.bools.push_back (true); @@ -99,7 +101,7 @@ main (int argc, char* argv[]) reference r; r.o1_ = &o1; - empty e; + empty_object e; e.comp_.bools.push_back (true); e.comp_.bools.push_back (true); e.comp_.obools.push_back (true); @@ -134,12 +136,12 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); - auto_ptr lb (db->load (b.id_)); - auto_ptr lo1 (db->load (o1.id_)); - auto_ptr lo2 (db->load (o2.id_)); - auto_ptr lo3 (db->load (o3.id_)); - auto_ptr le (db->load (e.id_)); - auto_ptr lr (db->load (r.id_)); + unique_ptr lb (db->load (b.id_)); + unique_ptr lo1 (db->load (o1.id_)); + unique_ptr lo2 (db->load (o2.id_)); + unique_ptr lo3 (db->load (o3.id_)); + unique_ptr le (db->load (e.id_)); + unique_ptr lr (db->load (r.id_)); t.commit (); assert (b == *lb); diff --git a/common/inheritance/reuse/makefile b/common/inheritance/reuse/makefile deleted file mode 100644 index 58222f3..0000000 --- a/common/inheritance/reuse/makefile +++ /dev/null @@ -1,117 +0,0 @@ -# file : common/inheritance/reuse/makefile -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -cxx_tun := driver.cxx -odb_hdr := test.hxx -genf := $(call odb-gen,$(odb_hdr)) -gen := $(addprefix $(out_base)/,$(genf)) -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) $(filter %.o,$(gen:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -common.l := $(out_root)/libcommon/common/common.l -common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options - -# Import. -# -$(call import,\ - $(scf_root)/import/odb/stub.make,\ - odb: odb,odb-rules: odb_rules) - -# Build. -# -$(driver): $(cxx_obj) $(common.l) -$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base) -$(cxx_obj) $(cxx_od): $(common.l.cpp-options) - -$(gen): $(odb) -$(gen): odb := $(odb) -$(gen) $(dist): export odb_options += --generate-schema --generate-query \ ---table-prefix inhrt_r_ -$(gen): cpp_options := -I$(src_base) -$(gen): $(common.l.cpp-options) - -ifneq ($(db_id),common) -$(gen): odb_options += --database $(db_id) -else -$(gen): odb_options += --multi-database dynamic -endif - -$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) - -# Alias for default target. -# -$(out_base)/: $(driver) - -# Dist -# -name := $(subst /,-,$(subst $(src_root)/common/,,$(src_base))) - -$(dist): sources := $(cxx_tun) -$(dist): headers := $(odb_hdr) -$(dist): data_dist := test.std -$(dist): export name := $(name) -$(dist): export extra_dist := $(data_dist) $(call vc8projs,$(name)) \ -$(call vc9projs,$(name)) $(call vc10projs,$(name)) $(call vc11projs,$(name)) \ -$(call vc12projs,$(name)) -$(dist): - $(call dist-data,$(sources) $(headers) $(data_dist)) - $(call meta-automake,../../template/Makefile.am) - $(call meta-vc8projs,../../template/template,$(name)) - $(call meta-vc9projs,../../template/template,$(name)) - $(call meta-vc10projs,../../template/template,$(name)) - $(call meta-vc11projs,../../template/template,$(name)) - $(call meta-vc12projs,../../template/template,$(name)) - -# Test. -# -ifneq ($(db_id),common) -$(eval $(call test-rule)) -else -$(foreach d,$(databases),$(eval $(call test-rule,$d))) -endif - -# Clean. -# -$(clean): \ - $(driver).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) \ - $(addsuffix .hxx.clean,$(filter %.cxx,$(gen))) - $(call message,,rm -f $(out_base)/test.out) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver $(genf) -$(clean): $(out_base)/.gitignore.clean - -$(call include,$(bld_root)/git/gitignore.make) -endif - -# How to. -# -$(call include,$(bld_root)/dist.make) -$(call include,$(bld_root)/meta/vc8proj.make) -$(call include,$(bld_root)/meta/vc9proj.make) -$(call include,$(bld_root)/meta/vc10proj.make) -$(call include,$(bld_root)/meta/vc11proj.make) -$(call include,$(bld_root)/meta/vc12proj.make) -$(call include,$(bld_root)/meta/automake.make) - -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): odb_options += --std $(cxx_standard) -$(call include,$(odb_rules)) -endif - -$(call include,$(bld_root)/cxx/cxx-d.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/o-e.make) - -# Dependencies. -# -$(call import,$(src_root)/libcommon/makefile) diff --git a/common/inheritance/reuse/test.hxx b/common/inheritance/reuse/test.hxx index 8124417..48f474f 100644 --- a/common/inheritance/reuse/test.hxx +++ b/common/inheritance/reuse/test.hxx @@ -146,7 +146,7 @@ struct object3: abstract_base, id_base // Empty derived object. // #pragma db object -struct empty: base +struct empty_object: base { }; diff --git a/common/inheritance/reuse/test.std b/common/inheritance/reuse/test.std deleted file mode 100644 index e69de29..0000000 diff --git a/common/inheritance/reuse/testscript b/common/inheritance/reuse/testscript new file mode 100644 index 0000000..995b3f5 --- /dev/null +++ b/common/inheritance/reuse/testscript @@ -0,0 +1,33 @@ +# file : common/inheritance/reuse/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} diff --git a/common/inheritance/transient/buildfile b/common/inheritance/transient/buildfile new file mode 100644 index 0000000..1961abc --- /dev/null +++ b/common/inheritance/transient/buildfile @@ -0,0 +1,41 @@ +# file : common/inheritance/transient/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix inhrt_t_ \ + --generate-schema \ + --generate-query + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/inheritance/transient/driver.cxx b/common/inheritance/transient/driver.cxx index fa6e05d..1caae6c 100644 --- a/common/inheritance/transient/driver.cxx +++ b/common/inheritance/transient/driver.cxx @@ -4,18 +4,20 @@ // Test transient inheritance of objects, composite value types, and views. // -#include // std::auto_ptr -#include +#include // std::unique_ptr #include #include #include -#include +#include #include "test.hxx" #include "test-odb.hxx" +#undef NDEBUG +#include + using namespace std; using namespace odb::core; @@ -24,7 +26,7 @@ main (int argc, char* argv[]) { try { - auto_ptr db (create_database (argc, argv)); + unique_ptr db (create_database (argc, argv)); object o; o.num = 1; @@ -48,7 +50,7 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); - auto_ptr p (db->load (o.id_)); + unique_ptr p (db->load (o.id_)); t.commit (); assert (*p == o); diff --git a/common/inheritance/transient/makefile b/common/inheritance/transient/makefile deleted file mode 100644 index 57e7909..0000000 --- a/common/inheritance/transient/makefile +++ /dev/null @@ -1,117 +0,0 @@ -# file : common/inheritance/transient/makefile -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -cxx_tun := driver.cxx -odb_hdr := test.hxx -genf := $(call odb-gen,$(odb_hdr)) -gen := $(addprefix $(out_base)/,$(genf)) -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) $(filter %.o,$(gen:.cxx=.o)) -cxx_od := $(cxx_obj:.o=.o.d) - -common.l := $(out_root)/libcommon/common/common.l -common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options - -# Import. -# -$(call import,\ - $(scf_root)/import/odb/stub.make,\ - odb: odb,odb-rules: odb_rules) - -# Build. -# -$(driver): $(cxx_obj) $(common.l) -$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base) -$(cxx_obj) $(cxx_od): $(common.l.cpp-options) - -$(gen): $(odb) -$(gen): odb := $(odb) -$(gen) $(dist): export odb_options += --generate-schema --generate-query \ ---table-prefix inhrt_t_ -$(gen): cpp_options := -I$(src_base) -$(gen): $(common.l.cpp-options) - -ifneq ($(db_id),common) -$(gen): odb_options += --database $(db_id) -else -$(gen): odb_options += --multi-database dynamic -endif - -$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) - -# Alias for default target. -# -$(out_base)/: $(driver) - -# Dist -# -name := $(subst /,-,$(subst $(src_root)/common/,,$(src_base))) - -$(dist): sources := $(cxx_tun) -$(dist): headers := $(odb_hdr) -$(dist): data_dist := test.std -$(dist): export name := $(name) -$(dist): export extra_dist := $(data_dist) $(call vc8projs,$(name)) \ -$(call vc9projs,$(name)) $(call vc10projs,$(name)) $(call vc11projs,$(name)) \ -$(call vc12projs,$(name)) -$(dist): - $(call dist-data,$(sources) $(headers) $(data_dist)) - $(call meta-automake,../../template/Makefile.am) - $(call meta-vc8projs,../../template/template,$(name)) - $(call meta-vc9projs,../../template/template,$(name)) - $(call meta-vc10projs,../../template/template,$(name)) - $(call meta-vc11projs,../../template/template,$(name)) - $(call meta-vc12projs,../../template/template,$(name)) - -# Test. -# -ifneq ($(db_id),common) -$(eval $(call test-rule)) -else -$(foreach d,$(databases),$(eval $(call test-rule,$d))) -endif - -# Clean. -# -$(clean): \ - $(driver).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) \ - $(addsuffix .hxx.clean,$(filter %.cxx,$(gen))) - $(call message,,rm -f $(out_base)/test.out) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver $(genf) -$(clean): $(out_base)/.gitignore.clean - -$(call include,$(bld_root)/git/gitignore.make) -endif - -# How to. -# -$(call include,$(bld_root)/dist.make) -$(call include,$(bld_root)/meta/vc8proj.make) -$(call include,$(bld_root)/meta/vc9proj.make) -$(call include,$(bld_root)/meta/vc10proj.make) -$(call include,$(bld_root)/meta/vc11proj.make) -$(call include,$(bld_root)/meta/vc12proj.make) -$(call include,$(bld_root)/meta/automake.make) - -$(call include,$(bld_root)/cxx/standard.make) # cxx_standard -ifdef cxx_standard -$(gen): odb_options += --std $(cxx_standard) -$(call include,$(odb_rules)) -endif - -$(call include,$(bld_root)/cxx/cxx-d.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/o-e.make) - -# Dependencies. -# -$(call import,$(src_root)/libcommon/makefile) diff --git a/common/inheritance/transient/test.std b/common/inheritance/transient/test.std deleted file mode 100644 index e69de29..0000000 diff --git a/common/inheritance/transient/testscript b/common/inheritance/transient/testscript new file mode 100644 index 0000000..bce91de --- /dev/null +++ b/common/inheritance/transient/testscript @@ -0,0 +1,33 @@ +# file : common/inheritance/transient/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} -- cgit v1.1