Replace uses of deprecated std::auto_ptr with std::unique_ptr.

Change-Id: I8d67fc6f3ce168f4d8b6330549f766dbf5374d61
This commit is contained in:
Lisa Velden 2018-01-22 11:41:20 +01:00
parent 1653953c39
commit d707c67276
11 changed files with 25 additions and 73 deletions

View File

@ -3,7 +3,7 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= libwebm
LOCAL_CPPFLAGS:=-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
LOCAL_CPPFLAGS+=-D__STDC_LIMIT_MACROS -Wno-extern-c-compat
LOCAL_CPPFLAGS+=-D__STDC_LIMIT_MACROS -std=c++11
LOCAL_C_INCLUDES:= $(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES:= $(LOCAL_PATH)

View File

@ -21,9 +21,7 @@ option(ENABLE_IWYU "Enables include-what-you-use support." OFF)
option(ENABLE_WERROR "Enable warnings as errors." OFF)
option(ENABLE_WEBM_PARSER "Enables new parser API." OFF)
if (ENABLE_TESTS OR ENABLE_WEBMTS OR ENABLE_WEBMINFO OR ENABLE_WEBM_PARSER)
require_cxx_flag_nomsvc("-std=c++11")
endif ()
require_cxx_flag_nomsvc("-std=c++11")
add_cxx_preproc_definition("__STDC_CONSTANT_MACROS")
add_cxx_preproc_definition("__STDC_FORMAT_MACROS")

View File

@ -2,7 +2,7 @@ CXX := g++
DEFINES := -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
DEFINES += -D__STDC_LIMIT_MACROS
INCLUDES := -I.
CXXFLAGS := -W -Wall -g
CXXFLAGS := -W -Wall -g -std=c++11
ALL_CXXFLAGS := -MMD -MP $(DEFINES) $(INCLUDES) $(CXXFLAGS)
LIBWEBMA := libwebm.a
LIBWEBMSO := libwebm.so

View File

@ -36,10 +36,10 @@ bool CopyMasteringMetadata(const mkvparser::MasteringMetadata& parser_mm,
if (MasteringMetadataValuePresent(parser_mm.luminance_min))
muxer_mm->set_luminance_min(parser_mm.luminance_min);
PrimaryChromaticityPtr r_ptr(NULL);
PrimaryChromaticityPtr g_ptr(NULL);
PrimaryChromaticityPtr b_ptr(NULL);
PrimaryChromaticityPtr wp_ptr(NULL);
PrimaryChromaticityPtr r_ptr(nullptr);
PrimaryChromaticityPtr g_ptr(nullptr);
PrimaryChromaticityPtr b_ptr(nullptr);
PrimaryChromaticityPtr wp_ptr(nullptr);
if (parser_mm.r) {
if (!CopyPrimaryChromaticity(*parser_mm.r, &r_ptr))

View File

@ -47,19 +47,7 @@ struct Vp9CodecFeatures {
int chroma_subsampling;
};
// disable deprecation warnings for auto_ptr
#if defined(__GNUC__)
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#endif
typedef std::auto_ptr<mkvmuxer::PrimaryChromaticity> PrimaryChromaticityPtr;
#if defined(__GNUC__)
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
#pragma GCC diagnostic pop
#endif
#endif
typedef std::unique_ptr<mkvmuxer::PrimaryChromaticity> PrimaryChromaticityPtr;
bool CopyPrimaryChromaticity(const mkvparser::PrimaryChromaticity& parser_pc,
PrimaryChromaticityPtr* muxer_pc);

View File

@ -26,13 +26,6 @@
#include "mkvmuxer/mkvwriter.h"
#include "mkvparser/mkvparser.h"
// disable deprecation warnings for auto_ptr
#if defined(__GNUC__)
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#endif
namespace mkvmuxer {
const float PrimaryChromaticity::kChromaticityMin = 0.0f;
@ -76,7 +69,7 @@ bool StrCpy(const char* src, char** dst_ptr) {
return true;
}
typedef std::auto_ptr<PrimaryChromaticity> PrimaryChromaticityPtr;
typedef std::unique_ptr<PrimaryChromaticity> PrimaryChromaticityPtr;
bool CopyChromaticity(const PrimaryChromaticity* src,
PrimaryChromaticityPtr* dst) {
if (!dst)
@ -1061,22 +1054,22 @@ bool MasteringMetadata::Write(IMkvWriter* writer) const {
bool MasteringMetadata::SetChromaticity(
const PrimaryChromaticity* r, const PrimaryChromaticity* g,
const PrimaryChromaticity* b, const PrimaryChromaticity* white_point) {
PrimaryChromaticityPtr r_ptr(NULL);
PrimaryChromaticityPtr r_ptr(nullptr);
if (r) {
if (!CopyChromaticity(r, &r_ptr))
return false;
}
PrimaryChromaticityPtr g_ptr(NULL);
PrimaryChromaticityPtr g_ptr(nullptr);
if (g) {
if (!CopyChromaticity(g, &g_ptr))
return false;
}
PrimaryChromaticityPtr b_ptr(NULL);
PrimaryChromaticityPtr b_ptr(nullptr);
if (b) {
if (!CopyChromaticity(b, &b_ptr))
return false;
}
PrimaryChromaticityPtr wp_ptr(NULL);
PrimaryChromaticityPtr wp_ptr(nullptr);
if (white_point) {
if (!CopyChromaticity(white_point, &wp_ptr))
return false;
@ -1242,7 +1235,7 @@ bool Colour::Write(IMkvWriter* writer) const {
}
bool Colour::SetMasteringMetadata(const MasteringMetadata& mastering_metadata) {
std::auto_ptr<MasteringMetadata> mm_ptr(new MasteringMetadata());
std::unique_ptr<MasteringMetadata> mm_ptr(new MasteringMetadata());
if (!mm_ptr.get())
return false;
@ -1550,7 +1543,7 @@ bool VideoTrack::Write(IMkvWriter* writer) const {
}
bool VideoTrack::SetColour(const Colour& colour) {
std::auto_ptr<Colour> colour_ptr(new Colour());
std::unique_ptr<Colour> colour_ptr(new Colour());
if (!colour_ptr.get())
return false;
@ -1578,7 +1571,7 @@ bool VideoTrack::SetColour(const Colour& colour) {
}
bool VideoTrack::SetProjection(const Projection& projection) {
std::auto_ptr<Projection> projection_ptr(new Projection());
std::unique_ptr<Projection> projection_ptr(new Projection());
if (!projection_ptr.get())
return false;

View File

@ -29,11 +29,6 @@
#include "sample_muxer_metadata.h"
// disable deprecation warnings for auto_ptr
#if defined(__GNUC__) && __GNUC__ >= 5
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
namespace {
void Usage() {
@ -350,7 +345,7 @@ int main(int argc, char* argv[]) {
return EXIT_FAILURE;
}
const std::auto_ptr<mkvparser::Segment> parser_segment(parser_segment_);
const std::unique_ptr<mkvparser::Segment> parser_segment(parser_segment_);
ret = parser_segment->Load();
if (ret < 0) {
printf("\n Segment::Load() failed.");

View File

@ -22,13 +22,6 @@
#include "common/webmids.h"
// disable deprecation warnings for auto_ptr
#if defined(__GNUC__)
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#endif
namespace mkvparser {
const float MasteringMetadata::kValueNotPresent = FLT_MAX;
const long long Colour::kValueNotPresent = LLONG_MAX;
@ -5017,7 +5010,7 @@ bool MasteringMetadata::Parse(IMkvReader* reader, long long mm_start,
if (!reader || *mm)
return false;
std::auto_ptr<MasteringMetadata> mm_ptr(new MasteringMetadata());
std::unique_ptr<MasteringMetadata> mm_ptr(new MasteringMetadata());
if (!mm_ptr.get())
return false;
@ -5106,7 +5099,7 @@ bool Colour::Parse(IMkvReader* reader, long long colour_start,
if (!reader || *colour)
return false;
std::auto_ptr<Colour> colour_ptr(new Colour());
std::unique_ptr<Colour> colour_ptr(new Colour());
if (!colour_ptr.get())
return false;
@ -5204,7 +5197,7 @@ bool Projection::Parse(IMkvReader* reader, long long start, long long size,
if (!reader || *projection)
return false;
std::auto_ptr<Projection> projection_ptr(new Projection());
std::unique_ptr<Projection> projection_ptr(new Projection());
if (!projection_ptr.get())
return false;

View File

@ -16,13 +16,6 @@
#include "mkvparser/mkvparser.h"
#include "mkvparser/mkvreader.h"
// disable deprecation warnings for auto_ptr
#if defined(__GNUC__)
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#endif
namespace {
const wchar_t* utf8towcs(const char* str) {
if (str == NULL)
@ -115,7 +108,7 @@ int main(int argc, char* argv[]) {
return EXIT_FAILURE;
}
const std::auto_ptr<seg_t> pSegment(pSegment_);
const std::unique_ptr<seg_t> pSegment(pSegment_);
ret = pSegment->Load();
if (ret < 0) {

View File

@ -20,19 +20,12 @@
using std::string;
// disable deprecation warnings for auto_ptr
#if defined(__GNUC__)
#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#endif
namespace libwebm {
namespace vttdemux {
typedef long long mkvtime_t; // NOLINT
typedef long long mkvpos_t; // NOLINT
typedef std::auto_ptr<mkvparser::Segment> segment_ptr_t;
typedef std::unique_ptr<mkvparser::Segment> segment_ptr_t;
// WebVTT metadata tracks have a type (encoded in the CodecID for the track).
// We use |type| to synthesize a filename for the out-of-band WebVTT |file|.

View File

@ -1190,8 +1190,7 @@ int main(int argc, char* argv[]) {
return EXIT_FAILURE;
}
// TODO(fgalligan): Replace auto_ptr with scoped_ptr.
std::auto_ptr<mkvparser::MkvReader> reader(
std::unique_ptr<mkvparser::MkvReader> reader(
new (std::nothrow) mkvparser::MkvReader()); // NOLINT
if (reader->Open(input.c_str())) {
fprintf(stderr, "Error opening file:%s\n", input.c_str());
@ -1199,7 +1198,7 @@ int main(int argc, char* argv[]) {
}
long long int pos = 0;
std::auto_ptr<mkvparser::EBMLHeader> ebml_header(
std::unique_ptr<mkvparser::EBMLHeader> ebml_header(
new (std::nothrow) mkvparser::EBMLHeader()); // NOLINT
if (ebml_header->Parse(reader.get(), pos) < 0) {
fprintf(stderr, "Error parsing EBML header.\n");
@ -1217,7 +1216,7 @@ int main(int argc, char* argv[]) {
fprintf(stderr, "Segment::CreateInstance() failed.\n");
return EXIT_FAILURE;
}
std::auto_ptr<mkvparser::Segment> segment(temp_segment);
std::unique_ptr<mkvparser::Segment> segment(temp_segment);
if (segment->Load() < 0) {
fprintf(stderr, "Segment::Load() failed.\n");