From 8a23835baa00f0079dbcd259c04ffeb87a764568 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 13 Feb 2024 11:40:12 +0200 Subject: Make target_type non-copyable --- libbuild2/scope.cxx | 28 ++++++++++++++++++++++------ libbuild2/target-type.hxx | 3 +++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/libbuild2/scope.cxx b/libbuild2/scope.cxx index 2b47dd0..6ed7bab 100644 --- a/libbuild2/scope.cxx +++ b/libbuild2/scope.cxx @@ -985,10 +985,17 @@ namespace build2 // Note: copies flags. // - unique_ptr dt (new target_type (base)); - dt->base = &base; - dt->factory = &derived_tt_factory; - dt->flags |= flags; + unique_ptr dt ( + new target_type { + nullptr, // Will be patched in by insert() below. + &base, + &derived_tt_factory, + base.fixed_extension, + base.default_extension, + base.pattern, + base.print, + base.search, + base.flags | flags}); #if 0 // @@ We should probably inherit the fixed extension unless overriden with @@ -1067,8 +1074,17 @@ namespace build2 derive_target_type (const target_type& et) { assert (root_scope () == this); - unique_ptr dt (new target_type (et)); - dt->factory = &derived_tt_factory; + unique_ptr dt ( + new target_type { + nullptr, // Will be patched in by insert() below. + et.base, + &derived_tt_factory, + et.fixed_extension, + et.default_extension, + et.pattern, + et.print, + et.search, + et.flags}); return root_extra->target_types.insert (et.name, move (dt)).first; } diff --git a/libbuild2/target-type.hxx b/libbuild2/target-type.hxx index fcf867a..93c5744 100644 --- a/libbuild2/target-type.hxx +++ b/libbuild2/target-type.hxx @@ -141,6 +141,9 @@ namespace build2 bool is_a (const char*) const; // Defined in target.cxx + + target_type& operator= (target_type&&) = delete; + target_type& operator= (const target_type&) = delete; }; inline bool -- cgit v1.1