Move make_unique to its own header file

Rebuilding the entire project after touching util.h gets old fast.
This commit is contained in:
Thomas Goyne 2014-04-23 13:53:24 -07:00
parent c248dc56da
commit 6fc4c8da14
101 changed files with 506 additions and 474 deletions

View file

@ -65,6 +65,7 @@
<ClInclude Include="$(SrcDir)include\libaegisub\line_iterator.h" />
<ClInclude Include="$(SrcDir)include\libaegisub\line_wrap.h" />
<ClInclude Include="$(SrcDir)include\libaegisub\log.h" />
<ClInclude Include="$(SrcDir)include\libaegisub\make_unique.h" />
<ClInclude Include="$(SrcDir)include\libaegisub\mru.h" />
<ClInclude Include="$(SrcDir)include\libaegisub\of_type_adaptor.h" />
<ClInclude Include="$(SrcDir)include\libaegisub\option.h" />

View file

@ -170,6 +170,9 @@
<ClInclude Include="$(SrcDir)include\libaegisub\character_count.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="$(SrcDir)include\libaegisub\make_unique.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(SrcDir)windows\lagi_pre.cpp">

View file

@ -17,6 +17,7 @@
#include "libaegisub/file_mapping.h"
#include "libaegisub/fs.h"
#include "libaegisub/make_unique.h"
#include "libaegisub/util.h"
#include <boost/filesystem.hpp>
@ -58,7 +59,7 @@ char *map(int64_t s_offset, uint64_t length, boost::interprocess::mode_t mode,
throw std::bad_alloc();
try {
region = agi::util::make_unique<mapped_region>(file, mode, mapping_start, static_cast<size_t>(length));
region = agi::make_unique<mapped_region>(file, mode, mapping_start, static_cast<size_t>(length));
}
catch (interprocess_exception const&) {
throw agi::fs::FileSystemUnknownError("Failed mapping a view of the file");

View file

@ -21,6 +21,7 @@
#include <libaegisub/access.h>
#include "libaegisub/fs.h"
#include "libaegisub/log.h"
#include "libaegisub/make_unique.h"
#include "libaegisub/path.h"
#include "libaegisub/util.h"
@ -34,7 +35,7 @@ std::unique_ptr<std::istream> Open(fs::path const& file, bool binary) {
LOG_D("agi/io/open/file") << file;
acs::CheckFileRead(file);
auto stream = util::make_unique<boost::filesystem::ifstream>(file, (binary ? std::ios::binary : std::ios::in));
auto stream = agi::make_unique<boost::filesystem::ifstream>(file, (binary ? std::ios::binary : std::ios::in));
if (stream->fail())
throw IOFatal("Unknown fatal error as occurred");
@ -56,7 +57,7 @@ Save::Save(fs::path const& file, bool binary)
// Not an error
}
fp = util::make_unique<boost::filesystem::ofstream>(tmp_name, binary ? std::ios::binary : std::ios::out);
fp = agi::make_unique<boost::filesystem::ofstream>(tmp_name, binary ? std::ios::binary : std::ios::out);
if (!fp->good())
throw fs::WriteDenied(tmp_name);
}

View file

@ -21,7 +21,7 @@
#include "libaegisub/fs.h"
#include "libaegisub/io.h"
#include "libaegisub/log.h"
#include "libaegisub/util.h"
#include "libaegisub/make_unique.h"
#include <boost/interprocess/streams/bufferstream.hpp>

View file

@ -25,7 +25,7 @@
#include <libaegisub/color.h>
#include <libaegisub/log.h>
#include <libaegisub/option_value.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <boost/algorithm/string/predicate.hpp>
@ -75,7 +75,7 @@ std::unique_ptr<OptionValue> ConfigVisitor::ReadArray(json::Array const& src, st
arr.push_back((typename OptionValueType::value_type::value_type)(obj.begin()->second));
}
return util::make_unique<OptionValueType>(name, std::move(arr));
return agi::make_unique<OptionValueType>(name, std::move(arr));
}
void ConfigVisitor::Visit(const json::Array& array) {
@ -107,11 +107,11 @@ void ConfigVisitor::Visit(const json::Array& array) {
}
void ConfigVisitor::Visit(const json::Integer& number) {
AddOptionValue(util::make_unique<OptionValueInt>(name, number));
AddOptionValue(agi::make_unique<OptionValueInt>(name, number));
}
void ConfigVisitor::Visit(const json::Double& number) {
AddOptionValue(util::make_unique<OptionValueDouble>(name, number));
AddOptionValue(agi::make_unique<OptionValueDouble>(name, number));
}
void ConfigVisitor::Visit(const json::String& string) {
@ -121,14 +121,14 @@ void ConfigVisitor::Visit(const json::String& string) {
(size >= 10 && boost::starts_with(string, "rgb(")) ||
((size == 9 || size == 10) && boost::starts_with(string, "&H")))
{
AddOptionValue(util::make_unique<OptionValueColor>(name, string));
AddOptionValue(agi::make_unique<OptionValueColor>(name, string));
} else {
AddOptionValue(util::make_unique<OptionValueString>(name, string));
AddOptionValue(agi::make_unique<OptionValueString>(name, string));
}
}
void ConfigVisitor::Visit(const json::Boolean& boolean) {
AddOptionValue(util::make_unique<OptionValueBool>(name, boolean));
AddOptionValue(agi::make_unique<OptionValueBool>(name, boolean));
}
void ConfigVisitor::Visit(const json::Null& null) {

View file

@ -21,7 +21,7 @@
#include "libaegisub/path.h"
#include "libaegisub/fs.h"
#include "libaegisub/util.h"
#include "libaegisub/make_unique.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>

View file

@ -21,7 +21,7 @@
#include "libaegisub/charset_conv.h"
#include "libaegisub/file_mapping.h"
#include "libaegisub/line_iterator.h"
#include "libaegisub/util.h"
#include "libaegisub/make_unique.h"
#include <boost/algorithm/string.hpp>
#include <boost/interprocess/streams/bufferstream.hpp>
@ -33,7 +33,7 @@ using boost::phoenix::placeholders::_1;
namespace agi {
Thesaurus::Thesaurus(agi::fs::path const& dat_path, agi::fs::path const& idx_path)
: dat(util::make_unique<read_file_mapping>(dat_path))
: dat(make_unique<read_file_mapping>(dat_path))
{
read_file_mapping idx_file(idx_path);
boost::interprocess::ibufferstream idx(idx_file.read(), static_cast<size_t>(idx_file.size()));

View file

@ -0,0 +1,24 @@
// Copyright (c) 2014, Thomas Goyne <plorkyeran@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
// Aegisub Project http://www.aegisub.org/
#include <memory>
namespace agi {
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
}

View file

@ -57,11 +57,6 @@ namespace agi {
/// @param name New name for the thread
void SetThreadName(const char *name);
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
/// A thin wrapper around this_thread::sleep_for that uses std::thread on
/// Windows (to avoid having to compile boost.thread) and boost::thread
/// elsewhere (because libstcc++ 4.7 is missing it).

View file

@ -23,7 +23,7 @@
#include <unistd.h>
#include "libaegisub/log.h"
#include "libaegisub/util.h"
#include "libaegisub/make_unique.h"
namespace agi {
namespace log {

View file

@ -16,7 +16,7 @@
/// @brief Unix utility methods.
/// @ingroup libaegisub unix
#include "libaegisub/util.h"
#include "libaegisub/make_unique.h"
#include <boost/thread.hpp>

View file

@ -23,7 +23,7 @@
#include "libaegisub/log.h"
#include "libaegisub/charset_conv_win.h"
#include "libaegisub/util.h"
#include "libaegisub/make_unique.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

View file

@ -20,7 +20,7 @@
#include <libaegisub/path.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <boost/filesystem.hpp>

View file

@ -37,7 +37,7 @@
#include <libaegisub/of_type_adaptor.h>
#include <libaegisub/split.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/join.hpp>
@ -171,7 +171,7 @@ std::vector<std::unique_ptr<AssDialogueBlock>> AssDialogue::ParseTags() const {
// Empty line, make an empty block
if (Text.get().empty()) {
Blocks.push_back(agi::util::make_unique<AssDialogueBlockPlain>());
Blocks.push_back(agi::make_unique<AssDialogueBlockPlain>());
return Blocks;
}
@ -196,11 +196,11 @@ std::vector<std::unique_ptr<AssDialogueBlock>> AssDialogue::ParseTags() const {
if (work.size() && work.find('\\') == std::string::npos) {
//We've found an override block with no backslashes
//We're going to assume it's a comment and not consider it an override block
Blocks.push_back(agi::util::make_unique<AssDialogueBlockComment>(work));
Blocks.push_back(agi::make_unique<AssDialogueBlockComment>(work));
}
else {
// Create block
auto block = agi::util::make_unique<AssDialogueBlockOverride>(work);
auto block = agi::make_unique<AssDialogueBlockOverride>(work);
block->ParseTags();
// Look for \p in block
@ -228,9 +228,9 @@ plain:
}
if (drawingLevel == 0)
Blocks.push_back(agi::util::make_unique<AssDialogueBlockPlain>(work));
Blocks.push_back(agi::make_unique<AssDialogueBlockPlain>(work));
else
Blocks.push_back(agi::util::make_unique<AssDialogueBlockDrawing>(work, drawingLevel));
Blocks.push_back(agi::make_unique<AssDialogueBlockDrawing>(work, drawingLevel));
}
return Blocks;

View file

@ -38,7 +38,7 @@
#include "utils.h"
#include <libaegisub/color.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/predicate.hpp>
@ -114,7 +114,7 @@ template<> agi::Color AssOverrideParameter::Get<agi::Color>() const {
template<> AssDialogueBlockOverride *AssOverrideParameter::Get<AssDialogueBlockOverride*>() const {
if (!block.get()) {
block = agi::util::make_unique<AssDialogueBlockOverride>(Get<std::string>());
block = agi::make_unique<AssDialogueBlockOverride>(Get<std::string>());
block->ParseTags();
}
return block.get();

View file

@ -21,7 +21,7 @@
#include "ass_style.h"
#include "subtitle_format.h"
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <algorithm>
#include <boost/algorithm/string/case_conv.hpp>
@ -105,12 +105,12 @@ void AssParser::ParseStyleLine(std::string const& data) {
void AssParser::ParseFontLine(std::string const& data) {
if (boost::starts_with(data, "fontname: "))
attach = agi::util::make_unique<AssAttachment>(data, AssEntryGroup::FONT);
attach = agi::make_unique<AssAttachment>(data, AssEntryGroup::FONT);
}
void AssParser::ParseGraphicsLine(std::string const& data) {
if (boost::starts_with(data, "filename: "))
attach = agi::util::make_unique<AssAttachment>(data, AssEntryGroup::GRAPHIC);
attach = agi::make_unique<AssAttachment>(data, AssEntryGroup::GRAPHIC);
}
void AssParser::AddLine(std::string const& data) {

View file

@ -39,7 +39,7 @@
#include <libaegisub/fs.h>
#include <libaegisub/io.h>
#include <libaegisub/line_iterator.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <boost/algorithm/string/predicate.hpp>
@ -67,7 +67,7 @@ void AssStyleStorage::Load(agi::fs::path const& filename) {
auto in = agi::io::Open(file);
for (auto const& line : agi::line_iterator<std::string>(*in)) {
try {
style.emplace_back(agi::util::make_unique<AssStyle>(line));
style.emplace_back(agi::make_unique<AssStyle>(line));
} catch(...) {
/* just ignore invalid lines for now */
}

View file

@ -52,7 +52,7 @@
#include "utils.h"
#include "video_context.h"
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <algorithm>
@ -551,10 +551,10 @@ AudioDisplay::AudioDisplay(wxWindow *parent, AudioController *controller, agi::C
: wxWindow(parent, -1, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS|wxBORDER_SIMPLE)
, audio_open_connection(controller->AddAudioOpenListener(&AudioDisplay::OnAudioOpen, this))
, context(context)
, audio_renderer(agi::util::make_unique<AudioRenderer>())
, audio_renderer(agi::make_unique<AudioRenderer>())
, controller(controller)
, scrollbar(agi::util::make_unique<AudioDisplayScrollbar>(this))
, timeline(agi::util::make_unique<AudioDisplayTimeline>(this))
, scrollbar(agi::make_unique<AudioDisplayScrollbar>(this))
, timeline(agi::make_unique<AudioDisplayTimeline>(this))
{
style_ranges[0] = AudioStyle_Normal;
@ -722,7 +722,7 @@ void AudioDisplay::ReloadRenderingSettings()
if (OPT_GET("Audio/Spectrum")->GetBool())
{
colour_scheme_name = OPT_GET("Colour/Audio Display/Spectrum")->GetString();
auto audio_spectrum_renderer = agi::util::make_unique<AudioSpectrumRenderer>(colour_scheme_name);
auto audio_spectrum_renderer = agi::make_unique<AudioSpectrumRenderer>(colour_scheme_name);
int64_t spectrum_quality = OPT_GET("Audio/Renderer/Spectrum/Quality")->GetInt();
#ifdef WITH_FFTW3
@ -744,7 +744,7 @@ void AudioDisplay::ReloadRenderingSettings()
else
{
colour_scheme_name = OPT_GET("Colour/Audio Display/Waveform")->GetString();
audio_renderer_provider = agi::util::make_unique<AudioWaveformRenderer>(colour_scheme_name);
audio_renderer_provider = agi::make_unique<AudioWaveformRenderer>(colour_scheme_name);
}
audio_renderer->SetRenderer(audio_renderer_provider.get());
@ -1087,7 +1087,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event)
if (markers.size())
{
RemoveTrackCursor();
audio_marker = agi::util::make_unique<AudioMarkerInteractionObject>(markers, timing, this, (wxMouseButton)event.GetButton());
audio_marker = agi::make_unique<AudioMarkerInteractionObject>(markers, timing, this, (wxMouseButton)event.GetButton());
SetDraggedObject(audio_marker.get());
return;
}

View file

@ -35,7 +35,7 @@
#include "selection_controller.h"
#include "utils.h"
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <algorithm>
#include <boost/locale/boundary.hpp>
@ -66,7 +66,7 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c)
, audio_opened(c->audioController->AddAudioOpenListener(&AudioKaraoke::OnAudioOpened, this))
, audio_closed(c->audioController->AddAudioCloseListener(&AudioKaraoke::OnAudioClosed, this))
, active_line_changed(c->selectionController->AddActiveLineListener(&AudioKaraoke::OnActiveLineChanged, this))
, kara(agi::util::make_unique<AssKaraoke>())
, kara(agi::make_unique<AssKaraoke>())
{
using std::bind;

View file

@ -26,7 +26,7 @@
#include "pen.h"
#include "video_context.h"
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <algorithm>
@ -48,7 +48,7 @@ AudioMarkerProviderKeyframes::AudioMarkerProviderKeyframes(agi::Context *c, cons
, timecode_slot(vc->AddTimecodesListener(&AudioMarkerProviderKeyframes::Update, this))
, enabled_slot(OPT_SUB(opt_name, &AudioMarkerProviderKeyframes::Update, this))
, enabled_opt(OPT_GET(opt_name))
, style(agi::util::make_unique<Pen>("Colour/Audio Display/Keyframe"))
, style(agi::make_unique<Pen>("Colour/Audio Display/Keyframe"))
{
Update();
}
@ -122,7 +122,7 @@ void VideoPositionMarkerProvider::Update(int frame_number) {
void VideoPositionMarkerProvider::OptChanged(agi::OptionValue const& opt) {
if (opt.GetBool()) {
video_seek_slot.Unblock();
marker = agi::util::make_unique<VideoPositionMarker>();
marker = agi::make_unique<VideoPositionMarker>();
marker->SetPosition(vc->GetFrameN());
}
else {
@ -137,7 +137,7 @@ void VideoPositionMarkerProvider::GetMarkers(const TimeRange &range, AudioMarker
}
SecondsMarkerProvider::SecondsMarkerProvider()
: pen(agi::util::make_unique<Pen>("Colour/Audio Display/Seconds Line", 1, wxPENSTYLE_DOT))
: pen(agi::make_unique<Pen>("Colour/Audio Display/Seconds Line", 1, wxPENSTYLE_DOT))
, enabled(OPT_GET("Audio/Display/Draw/Seconds"))
, enabled_opt_changed(OPT_SUB("Audio/Display/Draw/Seconds", &SecondsMarkerProvider::EnabledOptChanged, this))
{

View file

@ -42,7 +42,7 @@
#include "options.h"
#include <libaegisub/log.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <algorithm>
#include <alsa/asoundlib.h>
@ -461,7 +461,7 @@ void AlsaPlayer::SetVolume(double vol)
std::unique_ptr<AudioPlayer> CreateAlsaPlayer(AudioProvider *provider, wxWindow *)
{
return agi::util::make_unique<AlsaPlayer>(provider);
return agi::make_unique<AlsaPlayer>(provider);
}
#endif // WITH_ALSA

View file

@ -41,7 +41,7 @@
#include "utils.h"
#include <libaegisub/log.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <mmsystem.h>
#include <dsound.h>
@ -368,7 +368,7 @@ void DirectSoundPlayerThread::Stop() {
}
std::unique_ptr<AudioPlayer> CreateDirectSoundPlayer(AudioProvider *provider, wxWindow *parent) {
return agi::util::make_unique<DirectSoundPlayer>(provider, parent);
return agi::make_unique<DirectSoundPlayer>(provider, parent);
}
#endif // WITH_DIRECTSOUND

View file

@ -43,7 +43,7 @@
#include <libaegisub/scoped_ptr.h>
#include <libaegisub/log.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <mmsystem.h>
#include <process.h>
@ -821,7 +821,7 @@ DirectSoundPlayer2::DirectSoundPlayer2(AudioProvider *provider, wxWindow *parent
try
{
thread = agi::util::make_unique<DirectSoundPlayer2Thread>(provider, WantedLatency, BufferLength, parent);
thread = agi::make_unique<DirectSoundPlayer2Thread>(provider, WantedLatency, BufferLength, parent);
}
catch (const char *msg)
{
@ -936,7 +936,7 @@ void DirectSoundPlayer2::SetVolume(double vol)
}
std::unique_ptr<AudioPlayer> CreateDirectSound2Player(AudioProvider *provider, wxWindow *parent) {
return agi::util::make_unique<DirectSoundPlayer2>(provider, parent);
return agi::make_unique<DirectSoundPlayer2>(provider, parent);
}
#endif // WITH_DIRECTSOUND

View file

@ -40,7 +40,7 @@
#include "utils.h"
#include <libaegisub/log.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#ifdef __WINDOWS__
#include <al.h>
@ -286,7 +286,7 @@ int64_t OpenALPlayer::GetCurrentPosition()
std::unique_ptr<AudioPlayer> CreateOpenALPlayer(AudioProvider *provider, wxWindow *)
{
return agi::util::make_unique<OpenALPlayer>(provider);
return agi::make_unique<OpenALPlayer>(provider);
}
#endif // WITH_OPENAL

View file

@ -40,7 +40,7 @@
#include "utils.h"
#include <libaegisub/log.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <fcntl.h>
#include <sys/ioctl.h>
@ -281,7 +281,7 @@ int64_t OSSPlayer::GetCurrentPosition()
}
std::unique_ptr<AudioPlayer> CreateOSSPlayer(AudioProvider *provider, wxWindow *) {
return agi::util::make_unique<OSSPlayer>(provider);
return agi::make_unique<OSSPlayer>(provider);
}
#endif // WITH_OSS

View file

@ -42,7 +42,7 @@
#include "utils.h"
#include <libaegisub/log.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
DEFINE_SIMPLE_EXCEPTION(PortAudioError, agi::AudioPlayerOpenError, "audio/player/open/portaudio")
@ -282,7 +282,7 @@ bool PortAudioPlayer::IsPlaying() {
}
std::unique_ptr<AudioPlayer> CreatePortAudioPlayer(AudioProvider *provider, wxWindow *) {
return agi::util::make_unique<PortAudioPlayer>(provider);
return agi::make_unique<PortAudioPlayer>(provider);
}
#endif // WITH_PORTAUDIO

View file

@ -40,7 +40,7 @@
#include "utils.h"
#include <libaegisub/log.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <cstdio>
#include <pulse/pulseaudio.h>
@ -334,6 +334,6 @@ void PulseAudioPlayer::pa_stream_notify(pa_stream *p, PulseAudioPlayer *thread)
}
std::unique_ptr<AudioPlayer> CreatePulseAudioPlayer(AudioProvider *provider, wxWindow *) {
return agi::util::make_unique<PulseAudioPlayer>(provider);
return agi::make_unique<PulseAudioPlayer>(provider);
}
#endif // WITH_LIBPULSE

View file

@ -43,7 +43,7 @@
#include <libaegisub/background_runner.h>
#include <libaegisub/fs.h>
#include <libaegisub/log.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <boost/range/iterator_range.hpp>

View file

@ -45,7 +45,7 @@
#include <libaegisub/charset_conv.h>
#include <libaegisub/fs.h>
#include <libaegisub/path.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <mutex>
@ -146,6 +146,6 @@ void AvisynthAudioProvider::FillBuffer(void *buf, int64_t start, int64_t count)
}
std::unique_ptr<AudioProvider> CreateAvisynthAudioProvider(agi::fs::path const& file, agi::BackgroundRunner *) {
return agi::util::make_unique<AvisynthAudioProvider>(file);
return agi::make_unique<AvisynthAudioProvider>(file);
}
#endif

View file

@ -24,7 +24,7 @@
#include "audio_controller.h"
#include <libaegisub/log.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <limits>
@ -131,7 +131,7 @@ public:
}
};
/// Sample doubler with linear interpolation for the agi::util::make_unique<samples>
/// Sample doubler with linear interpolation for the agi::make_unique<samples>
/// Requires 16-bit mono input
class SampleDoublingAudioProvider final : public AudioProviderWrapper {
public:
@ -177,25 +177,25 @@ std::unique_ptr<AudioProvider> CreateConvertAudioProvider(std::unique_ptr<AudioP
if (provider->AreSamplesFloat()) {
LOG_D("audio_provider") << "Converting float to S16";
if (provider->GetBytesPerSample() == sizeof(float))
provider = agi::util::make_unique<FloatConvertAudioProvider<float, int16_t>>(std::move(provider));
provider = agi::make_unique<FloatConvertAudioProvider<float, int16_t>>(std::move(provider));
else
provider = agi::util::make_unique<FloatConvertAudioProvider<double, int16_t>>(std::move(provider));
provider = agi::make_unique<FloatConvertAudioProvider<double, int16_t>>(std::move(provider));
}
if (provider->GetBytesPerSample() != 2) {
LOG_D("audio_provider") << "Converting " << provider->GetBytesPerSample() << " bytes per sample or wrong endian to S16";
provider = agi::util::make_unique<BitdepthConvertAudioProvider<int16_t>>(std::move(provider));
provider = agi::make_unique<BitdepthConvertAudioProvider<int16_t>>(std::move(provider));
}
// We currently only support mono audio
if (provider->GetChannels() != 1) {
LOG_D("audio_provider") << "Downmixing to mono from " << provider->GetChannels() << " channels";
provider = agi::util::make_unique<DownmixAudioProvider>(std::move(provider));
provider = agi::make_unique<DownmixAudioProvider>(std::move(provider));
}
// Some players don't like low sample rate audio
while (provider->GetSampleRate() < 32000) {
LOG_D("audio_provider") << "Doubling sample rate";
provider = agi::util::make_unique<SampleDoublingAudioProvider>(std::move(provider));
provider = agi::make_unique<SampleDoublingAudioProvider>(std::move(provider));
}
return provider;

View file

@ -35,7 +35,7 @@
#include "include/aegisub/audio_provider.h"
#include <libaegisub/fs.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <boost/algorithm/string/predicate.hpp>
@ -89,5 +89,5 @@ public:
std::unique_ptr<AudioProvider> CreateDummyAudioProvider(agi::fs::path const& file, agi::BackgroundRunner *) {
if (!boost::starts_with(file.string(), "dummy-audio:"))
return {};
return agi::util::make_unique<DummyAudioProvider>(file);
return agi::make_unique<DummyAudioProvider>(file);
}

View file

@ -40,7 +40,7 @@
#include "options.h"
#include <libaegisub/fs.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <map>
@ -207,7 +207,7 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) {
}
std::unique_ptr<AudioProvider> CreateFFmpegSourceAudioProvider(agi::fs::path const& file, agi::BackgroundRunner *br) {
return agi::util::make_unique<FFmpegSourceAudioProvider>(file, br);
return agi::make_unique<FFmpegSourceAudioProvider>(file, br);
}
#endif /* WITH_FFMS2 */

View file

@ -23,7 +23,7 @@
#include <libaegisub/file_mapping.h>
#include <libaegisub/fs.h>
#include <libaegisub/path.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/replace.hpp>
@ -72,7 +72,7 @@ public:
% (long long)time(nullptr)
% (long long)boost::interprocess::ipcdetail::get_current_process_id());
file = agi::util::make_unique<agi::temp_file_mapping>(cache_dir / filename, num_samples * bytes_per_sample);
file = agi::make_unique<agi::temp_file_mapping>(cache_dir / filename, num_samples * bytes_per_sample);
decoder = std::thread([&] {
int64_t block = 65536;
for (int64_t i = 0; i < num_samples; i += block) {
@ -92,5 +92,5 @@ public:
}
std::unique_ptr<AudioProvider> CreateHDAudioProvider(std::unique_ptr<AudioProvider> src) {
return agi::util::make_unique<HDAudioProvider>(std::move(src));
return agi::make_unique<HDAudioProvider>(std::move(src));
}

View file

@ -18,7 +18,7 @@
#include "include/aegisub/audio_provider.h"
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <memory>
#include <mutex>
@ -41,5 +41,5 @@ public:
}
std::unique_ptr<AudioProvider> CreateLockAudioProvider(std::unique_ptr<AudioProvider> src) {
return agi::util::make_unique<LockAudioProvider>(std::move(src));
return agi::make_unique<LockAudioProvider>(std::move(src));
}

View file

@ -40,7 +40,7 @@
#include <libaegisub/file_mapping.h>
#include <libaegisub/fs.h>
#include <libaegisub/log.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <vector>
@ -51,7 +51,7 @@ protected:
std::unique_ptr<agi::read_file_mapping> file;
PCMAudioProvider(agi::fs::path const& filename)
: file(agi::util::make_unique<agi::read_file_mapping>(filename))
: file(agi::make_unique<agi::read_file_mapping>(filename))
{
float_samples = false;
}
@ -365,7 +365,7 @@ std::unique_ptr<AudioProvider> CreatePCMAudioProvider(agi::fs::path const& filen
std::string msg;
try {
return agi::util::make_unique<RiffWavPCMAudioProvider>(filename);
return agi::make_unique<RiffWavPCMAudioProvider>(filename);
}
catch (agi::AudioDataNotFoundError const& err) {
msg = "RIFF PCM WAV audio provider: " + err.GetMessage();
@ -376,7 +376,7 @@ std::unique_ptr<AudioProvider> CreatePCMAudioProvider(agi::fs::path const& filen
}
try {
return agi::util::make_unique<Wave64AudioProvider>(filename);
return agi::make_unique<Wave64AudioProvider>(filename);
}
catch (agi::AudioDataNotFoundError const& err) {
msg += "\nWave64 audio provider: " + err.GetMessage();

View file

@ -37,7 +37,7 @@
#include "audio_controller.h"
#include "compat.h"
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <array>
#include <boost/container/stable_vector.hpp>
@ -112,5 +112,5 @@ void RAMAudioProvider::FillBuffer(void *buf, int64_t start, int64_t count) const
}
std::unique_ptr<AudioProvider> CreateRAMAudioProvider(std::unique_ptr<AudioProvider> src) {
return agi::util::make_unique<RAMAudioProvider>(std::move(src));
return agi::make_unique<RAMAudioProvider>(std::move(src));
}

View file

@ -35,7 +35,7 @@
#include "include/aegisub/audio_provider.h"
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <algorithm>
#include <functional>
@ -61,7 +61,7 @@ AudioRendererBitmapCacheBitmapFactory::AudioRendererBitmapCacheBitmapFactory(Aud
std::unique_ptr<wxBitmap> AudioRendererBitmapCacheBitmapFactory::ProduceBlock(int /* i */)
{
return agi::util::make_unique<wxBitmap>(renderer->cache_bitmap_width, renderer->pixel_height, 24);
return agi::make_unique<wxBitmap>(renderer->cache_bitmap_width, renderer->pixel_height, 24);
}
size_t AudioRendererBitmapCacheBitmapFactory::GetBlockSize() const

View file

@ -42,7 +42,7 @@
#include "utils.h"
#include <libaegisub/log.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <algorithm>
@ -123,7 +123,7 @@ void AudioSpectrumRenderer::RecreateCache()
if (provider)
{
size_t block_count = (size_t)((provider->GetNumSamples() + (size_t)(1<<derivation_dist) - 1) >> derivation_dist);
cache = agi::util::make_unique<AudioSpectrumCache>(block_count, this);
cache = agi::make_unique<AudioSpectrumCache>(block_count, this);
#ifdef WITH_FFTW3
dft_input = fftw_alloc_real(2<<derivation_size);

View file

@ -43,7 +43,7 @@
#include "selection_controller.h"
#include "utils.h"
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <boost/range/algorithm.hpp>
#include <cstdint>
@ -411,7 +411,7 @@ public:
std::unique_ptr<AudioTimingController> CreateDialogueTimingController(agi::Context *c)
{
return agi::util::make_unique<AudioTimingControllerDialogue>(c);
return agi::make_unique<AudioTimingControllerDialogue>(c);
}
AudioTimingControllerDialogue::AudioTimingControllerDialogue(agi::Context *c)

View file

@ -34,7 +34,7 @@
#include "selection_controller.h"
#include "utils.h"
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <boost/range/algorithm/copy.hpp>
#include <boost/range/adaptor/filtered.hpp>
@ -152,7 +152,7 @@ public:
std::unique_ptr<AudioTimingController> CreateKaraokeTimingController(agi::Context *c, AssKaraoke *kara, agi::signal::Connection& file_changed)
{
return agi::util::make_unique<AudioTimingControllerKaraoke>(c, kara, file_changed);
return agi::make_unique<AudioTimingControllerKaraoke>(c, kara, file_changed);
}
AudioTimingControllerKaraoke::AudioTimingControllerKaraoke(agi::Context *c, AssKaraoke *kara, agi::signal::Connection& file_changed)

View file

@ -48,7 +48,7 @@
#include <libaegisub/dispatch.h>
#include <libaegisub/fs.h>
#include <libaegisub/path.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/trim.hpp>
@ -482,7 +482,7 @@ namespace Automation4 {
wxLogError(_("The file was not recognised as an Automation script: %s"), filename.wstring());
}
return create_unknown ? agi::util::make_unique<UnknownScript>(filename) : nullptr;
return create_unknown ? agi::make_unique<UnknownScript>(filename) : nullptr;
}
std::vector<std::unique_ptr<ScriptFactory>>& ScriptFactory::Factories()

View file

@ -53,7 +53,7 @@
#include <libaegisub/access.h>
#include <libaegisub/path.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <algorithm>
#include <boost/algorithm/string/classification.hpp>
@ -773,7 +773,7 @@ namespace Automation4 {
int LuaCommand::LuaRegister(lua_State *L)
{
static std::mutex mutex;
auto command = agi::util::make_unique<LuaCommand>(L);
auto command = agi::make_unique<LuaCommand>(L);
{
std::lock_guard<std::mutex> lock(mutex);
cmd::reg(std::move(command));
@ -1048,7 +1048,7 @@ namespace Automation4 {
int LuaExportFilter::LuaRegister(lua_State *L)
{
static std::mutex mutex;
auto filter = agi::util::make_unique<LuaExportFilter>(L);
auto filter = agi::make_unique<LuaExportFilter>(L);
{
std::lock_guard<std::mutex> lock(mutex);
AssExportFilterChain::Register(std::move(filter));
@ -1130,7 +1130,7 @@ namespace Automation4 {
std::unique_ptr<Script> LuaScriptFactory::Produce(agi::fs::path const& filename) const
{
if (agi::fs::HasExtension(filename, "lua") || agi::fs::HasExtension(filename, "moon"))
return agi::util::make_unique<LuaScript>(filename);
return agi::make_unique<LuaScript>(filename);
return nullptr;
}
}

View file

@ -43,7 +43,7 @@
#include "utils.h"
#include <libaegisub/exception.h>
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <algorithm>
#include <boost/algorithm/string/case_conv.hpp>
@ -241,7 +241,7 @@ namespace Automation4 {
try {
if (lclass == "info")
result = agi::util::make_unique<AssInfo>(get_string_field(L, "key", "info"), get_string_field(L, "value", "info"));
result = agi::make_unique<AssInfo>(get_string_field(L, "key", "info"), get_string_field(L, "value", "info"));
else if (lclass == "style") {
auto sty = new AssStyle;
result.reset(sty);
@ -357,7 +357,7 @@ namespace Automation4 {
// Just in case an insane user inserted non-info lines into the
// script info section...
while (lines[i]) ++i;
lines_to_delete.emplace_back(agi::util::make_unique<AssInfo>(info));
lines_to_delete.emplace_back(agi::make_unique<AssInfo>(info));
lines[i++] = lines_to_delete.back().get();
}
script_info_copied = true;

View file

@ -42,7 +42,7 @@
#include "utils.h"
#include "validators.h"
#include <libaegisub/util.h>
#include <libaegisub/make_unique.h>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/range/adaptors.hpp>
@ -426,26 +426,26 @@ namespace Automation4 {
// Check control class and create relevant control
if (controlclass == "label")
ctl = agi::util::make_unique<LuaControl::Label>(L);
ctl = agi::make_unique<LuaControl::Label>(L);
else if (controlclass == "edit")
ctl = agi::util::make_unique<LuaControl::Edit>(L);
ctl = agi::make_unique<LuaControl::Edit>(L);
else if (controlclass == "intedit")
ctl = agi::util::make_unique<LuaControl::IntEdit>(L);
ctl = agi::make_unique<LuaControl::IntEdit>(L);
else if (controlclass == "floatedit")
ctl = agi::util::make_unique<LuaControl::FloatEdit>(L);
ctl = agi::make_unique<LuaControl::FloatEdit>(L);
else if (controlclass == "textbox")
ctl = agi::util::make_unique<LuaControl::Textbox>(L);
ctl = agi::make_unique<LuaControl::Textbox>(L);
else if (controlclass == "dropdown")
ctl = agi::util::make_unique<LuaControl::Dropdown>(L);
ctl = agi::make_unique<LuaControl::Dropdown>(L);
else if (controlclass == "checkbox")
ctl = agi::util::make_unique<LuaControl::Checkbox>(L);
ctl = agi::make_unique<LuaControl::Checkbox>(L);
else if (controlclass == "color")
ctl = agi::util::make_unique<LuaControl::Color>(L, false);
ctl = agi::make_unique<LuaControl::Color>(L, false);
else if (controlclass == "coloralpha")
ctl = agi::util::make_unique<LuaControl::Color>(L, true);
ctl = agi::make_unique<LuaControl::Color>(L, true);
else if (controlclass == "alpha")