From 2bd71e7e9bf5a4151b1594522e5b7caead67d0a9 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 23 Jun 2016 20:52:44 -0400 Subject: [PATCH] `.reset` is the more normal way to reassign a `unique_ptr`. --- Machines/Electron/Electron.cpp | 4 ++-- Machines/Typer.hpp | 2 +- Machines/Vic-20/Vic20.cpp | 2 +- Outputs/CRT/CRT.cpp | 8 ++++---- Outputs/CRT/Internals/CRTOpenGL.cpp | 12 ++++++------ Outputs/CRT/Internals/Shaders/IntermediateShader.cpp | 2 +- Outputs/CRT/Internals/Shaders/OutputShader.cpp | 2 +- Outputs/CRT/Internals/TextureTarget.cpp | 2 +- Outputs/Speaker.hpp | 8 ++++---- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index f58328c03..fbbb1b91e 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -60,7 +60,7 @@ Machine::Machine() : void Machine::setup_output(float aspect_ratio) { - _crt = std::unique_ptr(new Outputs::CRT::CRT(crt_cycles_per_line, 8, Outputs::CRT::DisplayType::PAL50, 1)); + _crt.reset(new Outputs::CRT::CRT(crt_cycles_per_line, 8, Outputs::CRT::DisplayType::PAL50, 1)); _crt->set_rgb_sampling_function( "vec3 rgb_sample(usampler2D sampler, vec2 coordinate, vec2 icoordinate)" "{" @@ -927,7 +927,7 @@ inline void Tape::get_next_tape_pulse() } if(_input.pulse_stepper == nullptr || _input.current_pulse.length.clock_rate != _input.pulse_stepper->get_output_rate()) { - _input.pulse_stepper = std::unique_ptr(new SignalProcessing::Stepper(_input.current_pulse.length.clock_rate, 2000000)); + _input.pulse_stepper.reset(new SignalProcessing::Stepper(_input.current_pulse.length.clock_rate, 2000000)); } } diff --git a/Machines/Typer.hpp b/Machines/Typer.hpp index aa553471a..a54f270e8 100644 --- a/Machines/Typer.hpp +++ b/Machines/Typer.hpp @@ -39,7 +39,7 @@ class TypeRecipient: public Typer::Delegate { public: void set_typer_for_string(const char *string) { - _typer = std::unique_ptr(new Typer(string, get_typer_delay(), get_typer_frequency(), this)); + _typer.reset(new Typer(string, get_typer_delay(), get_typer_frequency(), this)); } protected: diff --git a/Machines/Vic-20/Vic20.cpp b/Machines/Vic-20/Vic20.cpp index b1c0b5ad7..6e1644d9d 100644 --- a/Machines/Vic-20/Vic20.cpp +++ b/Machines/Vic-20/Vic20.cpp @@ -98,7 +98,7 @@ void Machine::mos6522_did_change_interrupt_status(void *mos6522) void Machine::setup_output(float aspect_ratio) { - _mos6560 = std::unique_ptr(new MOS::MOS6560()); + _mos6560.reset(new MOS::MOS6560()); } void Machine::set_rom(ROMSlot slot, size_t length, const uint8_t *data) diff --git a/Outputs/CRT/CRT.cpp b/Outputs/CRT/CRT.cpp index f91f9c301..b151f627c 100644 --- a/Outputs/CRT/CRT.cpp +++ b/Outputs/CRT/CRT.cpp @@ -38,8 +38,8 @@ void CRT::set_new_timing(unsigned int cycles_per_line, unsigned int height_of_di _sync_capacitor_charge_threshold = (int)(syncCapacityLineChargeThreshold * _cycles_per_line); // create the two flywheels - _horizontal_flywheel = std::unique_ptr(new Flywheel(_cycles_per_line, (millisecondsHorizontalRetraceTime * _cycles_per_line) >> 6, _cycles_per_line >> 6)); - _vertical_flywheel = std::unique_ptr(new Flywheel(_cycles_per_line * height_of_display, scanlinesVerticalRetraceTime * _cycles_per_line, (_cycles_per_line * height_of_display) >> 3)); + _horizontal_flywheel.reset(new Flywheel(_cycles_per_line, (millisecondsHorizontalRetraceTime * _cycles_per_line) >> 6, _cycles_per_line >> 6)); + _vertical_flywheel.reset(new Flywheel(_cycles_per_line * height_of_display, scanlinesVerticalRetraceTime * _cycles_per_line, (_cycles_per_line * height_of_display) >> 3)); // figure out the divisor necessary to get the horizontal flywheel into a 16-bit range unsigned int real_clock_scan_period = (_cycles_per_line * height_of_display) / (_time_multiplier * _common_output_divisor); @@ -73,13 +73,13 @@ CRT::CRT(unsigned int common_output_divisor) : CRT::CRT(unsigned int cycles_per_line, unsigned int common_output_divisor, unsigned int height_of_display, ColourSpace colour_space, unsigned int colour_cycle_numerator, unsigned int colour_cycle_denominator, unsigned int buffer_depth) : CRT(common_output_divisor) { - _openGL_output_builder = std::unique_ptr(new OpenGLOutputBuilder(buffer_depth)); + _openGL_output_builder.reset(new OpenGLOutputBuilder(buffer_depth)); set_new_timing(cycles_per_line, height_of_display, colour_space, colour_cycle_numerator, colour_cycle_denominator); } CRT::CRT(unsigned int cycles_per_line, unsigned int common_output_divisor, DisplayType displayType, unsigned int buffer_depth) : CRT(common_output_divisor) { - _openGL_output_builder = std::unique_ptr(new OpenGLOutputBuilder(buffer_depth)); + _openGL_output_builder.reset(new OpenGLOutputBuilder(buffer_depth)); set_new_display_type(cycles_per_line, displayType); } diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index 1d888974f..66a5f9a96 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -122,16 +122,16 @@ OpenGLOutputBuilder::OpenGLOutputBuilder(unsigned int buffer_depth) : _last_output_height(0), _fence(nullptr) { - _buffer_builder = std::unique_ptr(new CRTInputBufferBuilder(buffer_depth)); + _buffer_builder.reset(new CRTInputBufferBuilder(buffer_depth)); glBlendFunc(GL_SRC_ALPHA, GL_CONSTANT_COLOR); glBlendColor(0.6f, 0.6f, 0.6f, 1.0f); // Create intermediate textures and bind to slots 0, 1 and 2 - compositeTexture = std::unique_ptr(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight, composite_texture_unit)); - separatedTexture = std::unique_ptr(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight, separated_texture_unit)); - filteredYTexture = std::unique_ptr(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight, filtered_y_texture_unit)); - filteredTexture = std::unique_ptr(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight, filtered_texture_unit)); + compositeTexture.reset(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight, composite_texture_unit)); + separatedTexture.reset(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight, separated_texture_unit)); + filteredYTexture.reset(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight, filtered_y_texture_unit)); + filteredTexture.reset(new OpenGL::TextureTarget(IntermediateBufferWidth, IntermediateBufferHeight, filtered_texture_unit)); // create the surce texture glGenTextures(1, &textureName); @@ -199,7 +199,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out // make sure there's a target to draw to if(!framebuffer || framebuffer->get_height() != output_height || framebuffer->get_width() != output_width) { - std::unique_ptr new_framebuffer = std::unique_ptr(new OpenGL::TextureTarget((GLsizei)output_width, (GLsizei)output_height, pixel_accumulation_texture_unit)); + std::unique_ptr new_framebuffer(new OpenGL::TextureTarget((GLsizei)output_width, (GLsizei)output_height, pixel_accumulation_texture_unit)); if(framebuffer) { new_framebuffer->bind_framebuffer(); diff --git a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp index 8d15a1291..b3ad6f5a8 100644 --- a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp +++ b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp @@ -86,7 +86,7 @@ std::unique_ptr IntermediateShader::make_shader(const char * "gl_Position = vec4(eyePosition, 0.0, 1.0);" "}", sampler_type, input_variable); - std::unique_ptr shader = std::unique_ptr(new IntermediateShader(vertex_shader, fragment_shader, bindings)); + std::unique_ptr shader(new IntermediateShader(vertex_shader, fragment_shader, bindings)); free(vertex_shader); return shader; diff --git a/Outputs/CRT/Internals/Shaders/OutputShader.cpp b/Outputs/CRT/Internals/Shaders/OutputShader.cpp index f543853a7..e139c954d 100644 --- a/Outputs/CRT/Internals/Shaders/OutputShader.cpp +++ b/Outputs/CRT/Internals/Shaders/OutputShader.cpp @@ -82,7 +82,7 @@ std::unique_ptr OutputShader::make_shader(const char *fragment_met "}", sampler_type, fragment_methods, colour_expression); - std::unique_ptr result = std::unique_ptr(new OutputShader(vertex_shader, fragment_shader, bindings)); + std::unique_ptr result(new OutputShader(vertex_shader, fragment_shader, bindings)); free(vertex_shader); free(fragment_shader); diff --git a/Outputs/CRT/Internals/TextureTarget.cpp b/Outputs/CRT/Internals/TextureTarget.cpp index ed0bffd84..6a6e5f426 100644 --- a/Outputs/CRT/Internals/TextureTarget.cpp +++ b/Outputs/CRT/Internals/TextureTarget.cpp @@ -89,7 +89,7 @@ void TextureTarget::draw(float aspect_ratio) "{" "fragColour = texture(texID, texCoordVarying);" "}"; - _pixel_shader = std::unique_ptr(new Shader(vertex_shader, fragment_shader, nullptr)); + _pixel_shader.reset(new Shader(vertex_shader, fragment_shader, nullptr)); _pixel_shader->bind(); glGenVertexArrays(1, &_drawing_vertex_array); diff --git a/Outputs/Speaker.hpp b/Outputs/Speaker.hpp index 6cfd434a2..4bcf10408 100644 --- a/Outputs/Speaker.hpp +++ b/Outputs/Speaker.hpp @@ -41,7 +41,7 @@ class Speaker { _output_cycles_per_second = cycles_per_second; if(_buffer_size != buffer_size) { - _buffer_in_progress = std::unique_ptr(new int16_t[buffer_size]); + _buffer_in_progress.reset(new int16_t[buffer_size]); _buffer_size = buffer_size; } set_needs_updated_filter_coefficients(); @@ -189,10 +189,10 @@ template class Filter: public Speaker { _coefficients_are_dirty = false; _buffer_in_progress_pointer = 0; - _stepper = std::unique_ptr(new SignalProcessing::Stepper((uint64_t)_input_cycles_per_second, (uint64_t)_output_cycles_per_second)); - _filter = std::unique_ptr(new SignalProcessing::FIRFilter((unsigned int)_number_of_taps, (float)_input_cycles_per_second, 0.0, (float)_output_cycles_per_second / 2.0f, SignalProcessing::FIRFilter::DefaultAttenuation)); + _stepper.reset(new SignalProcessing::Stepper((uint64_t)_input_cycles_per_second, (uint64_t)_output_cycles_per_second)); + _filter.reset(new SignalProcessing::FIRFilter((unsigned int)_number_of_taps, (float)_input_cycles_per_second, 0.0, (float)_output_cycles_per_second / 2.0f, SignalProcessing::FIRFilter::DefaultAttenuation)); - _input_buffer = std::unique_ptr(new int16_t[_number_of_taps]); + _input_buffer.reset(new int16_t[_number_of_taps]); _input_buffer_depth = 0; } };