Commit 2e94c118 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'unique'

9ecb3f8d Ninja,Makefile: use `unique_ptr` for memory management
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !3230
parents a000ec7a 9ecb3f8d
Pipeline #135028 passed with stage
in 0 seconds
......@@ -9,6 +9,7 @@
#include <utility>
#include <vector>
#include "cmAlgorithms.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalUnixMakefileGenerator3.h"
......@@ -35,14 +36,12 @@ cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator(
this->GeneratorTarget->GetExecutableNames(this->ConfigName);
this->OSXBundleGenerator =
new cmOSXBundleGenerator(target, this->ConfigName);
cm::make_unique<cmOSXBundleGenerator>(target, this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
}
cmMakefileExecutableTargetGenerator::~cmMakefileExecutableTargetGenerator()
{
delete this->OSXBundleGenerator;
}
cmMakefileExecutableTargetGenerator::~cmMakefileExecutableTargetGenerator() =
default;
void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
{
......
......@@ -9,6 +9,7 @@
#include <utility>
#include <vector>
#include "cmAlgorithms.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalUnixMakefileGenerator3.h"
......@@ -37,14 +38,12 @@ cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator(
}
this->OSXBundleGenerator =
new cmOSXBundleGenerator(target, this->ConfigName);
cm::make_unique<cmOSXBundleGenerator>(target, this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
}
cmMakefileLibraryTargetGenerator::~cmMakefileLibraryTargetGenerator()
{
delete this->OSXBundleGenerator;
}
cmMakefileLibraryTargetGenerator::~cmMakefileLibraryTargetGenerator() =
default;
void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
{
......
......@@ -235,7 +235,7 @@ protected:
// macOS content info.
std::set<std::string> MacContentFolders;
cmOSXBundleGenerator* OSXBundleGenerator;
std::unique_ptr<cmOSXBundleGenerator> OSXBundleGenerator;
MacOSXContentGeneratorType* MacOSXContentGenerator;
};
......
......@@ -7,6 +7,7 @@
#include <utility>
#include <vector>
#include "cmAlgorithms.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalUnixMakefileGenerator3.h"
......@@ -21,14 +22,12 @@ cmMakefileUtilityTargetGenerator::cmMakefileUtilityTargetGenerator(
{
this->CustomCommandDriver = OnUtility;
this->OSXBundleGenerator =
new cmOSXBundleGenerator(target, this->ConfigName);
cm::make_unique<cmOSXBundleGenerator>(target, this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
}
cmMakefileUtilityTargetGenerator::~cmMakefileUtilityTargetGenerator()
{
delete this->OSXBundleGenerator;
}
cmMakefileUtilityTargetGenerator::~cmMakefileUtilityTargetGenerator() =
default;
void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
{
......
......@@ -54,14 +54,11 @@ cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator(
}
this->OSXBundleGenerator =
new cmOSXBundleGenerator(target, this->GetConfigName());
cm::make_unique<cmOSXBundleGenerator>(target, this->GetConfigName());
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
}
cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
{
delete this->OSXBundleGenerator;
}
cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() = default;
void cmNinjaNormalTargetGenerator::Generate()
{
......
......@@ -59,13 +59,10 @@ cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target)
, LocalGenerator(
static_cast<cmLocalNinjaGenerator*>(target->GetLocalGenerator()))
{
MacOSXContentGenerator = new MacOSXContentGeneratorType(this);
MacOSXContentGenerator = cm::make_unique<MacOSXContentGeneratorType>(this);
}
cmNinjaTargetGenerator::~cmNinjaTargetGenerator()
{
delete this->MacOSXContentGenerator;
}
cmNinjaTargetGenerator::~cmNinjaTargetGenerator() = default;
cmGeneratedFileStream& cmNinjaTargetGenerator::GetBuildFileStream() const
{
......@@ -813,11 +810,11 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
std::vector<cmSourceFile const*> headerSources;
this->GeneratorTarget->GetHeaderSources(headerSources, config);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
headerSources, this->MacOSXContentGenerator);
headerSources, this->MacOSXContentGenerator.get());
std::vector<cmSourceFile const*> extraSources;
this->GeneratorTarget->GetExtraSources(extraSources, config);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
extraSources, this->MacOSXContentGenerator);
extraSources, this->MacOSXContentGenerator.get());
std::vector<cmSourceFile const*> externalObjects;
this->GeneratorTarget->GetExternalObjects(externalObjects, config);
for (cmSourceFile const* sf : externalObjects) {
......
......@@ -153,9 +153,9 @@ protected:
};
friend struct MacOSXContentGeneratorType;
MacOSXContentGeneratorType* MacOSXContentGenerator;
std::unique_ptr<MacOSXContentGeneratorType> MacOSXContentGenerator;
// Properly initialized by sub-classes.
cmOSXBundleGenerator* OSXBundleGenerator;
std::unique_ptr<cmOSXBundleGenerator> OSXBundleGenerator;
std::set<std::string> MacContentFolders;
void addPoolNinjaVariable(const std::string& pool_property,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment