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/OSBindings/Mac/Clock Signal/Documents/Atari2600Document.swift b/OSBindings/Mac/Clock Signal/Documents/Atari2600Document.swift index 9f6c508ed..9b91f4890 100644 --- a/OSBindings/Mac/Clock Signal/Documents/Atari2600Document.swift +++ b/OSBindings/Mac/Clock Signal/Documents/Atari2600Document.swift @@ -11,8 +11,10 @@ import Cocoa class Atari2600Document: MachineDocument { private var atari2600 = CSAtari2600() - override func machine() -> CSMachine? { - return atari2600 + override var machine: CSMachine! { + get { + return atari2600 + } } // MARK: NSDocument overrides diff --git a/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift b/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift index 25fdcfb8c..ab727c6d4 100644 --- a/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift +++ b/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift @@ -12,8 +12,10 @@ import AudioToolbox class ElectronDocument: MachineDocument { private lazy var electron = CSElectron() - override func machine() -> CSMachine! { - return electron + override var machine: CSMachine! { + get { + return electron + } } override func aspectRatio() -> NSSize { diff --git a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift index 0a0c55194..3f534d486 100644 --- a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift +++ b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift @@ -20,8 +20,10 @@ class MachineDocument: { lazy var actionLock = NSLock() lazy var drawLock = NSLock() - func machine() -> CSMachine! { - return nil + var machine: CSMachine! { + get { + return nil + } } func aspectRatio() -> NSSize { @@ -54,11 +56,11 @@ class MachineDocument: let displayAspectRatio = self.aspectRatio() aController.window?.contentAspectRatio = displayAspectRatio openGLView.performWithGLContext({ - self.machine().setView(self.openGLView, aspectRatio: Float(displayAspectRatio.width / displayAspectRatio.height)) + self.machine.setView(self.openGLView, aspectRatio: Float(displayAspectRatio.width / displayAspectRatio.height)) }) setupClockRate() - self.machine().delegate = self + self.machine.delegate = self } func machineDidChangeClockRate(machine: CSMachine!) { @@ -68,15 +70,15 @@ class MachineDocument: private func setupClockRate() { // establish and provide the audio queue, taking advice as to an appropriate sampling rate let maximumSamplingRate = CSAudioQueue.preferredSamplingRate() - let selectedSamplingRate = self.machine().idealSamplingRateFromRange(NSRange(location: 0, length: NSInteger(maximumSamplingRate))) + let selectedSamplingRate = self.machine.idealSamplingRateFromRange(NSRange(location: 0, length: NSInteger(maximumSamplingRate))) if selectedSamplingRate > 0 { audioQueue = CSAudioQueue(samplingRate: Float64(selectedSamplingRate)) audioQueue.delegate = self - self.machine().audioQueue = self.audioQueue - self.machine().setAudioSamplingRate(selectedSamplingRate, bufferSize:audioQueue.bufferSize / 2) + self.machine.audioQueue = self.audioQueue + self.machine.setAudioSamplingRate(selectedSamplingRate, bufferSize:audioQueue.bufferSize / 2) } - self.bestEffortUpdater.clockRate = self.machine().clockRate + self.bestEffortUpdater.clockRate = self.machine.clockRate } override func close() { @@ -94,7 +96,7 @@ class MachineDocument: func paste(sender: AnyObject!) { let pasteboard = NSPasteboard.generalPasteboard() if let string = pasteboard.stringForType(NSPasteboardTypeString) { - self.machine().paste(string) + self.machine.paste(string) } } @@ -106,7 +108,7 @@ class MachineDocument: func runForNumberOfCycles(numberOfCycles: Int32) { let cyclesToRunFor = min(numberOfCycles, Int32(bestEffortUpdater.clockRate / 10)) if actionLock.tryLock() { - self.machine().runForNumberOfCycles(cyclesToRunFor) + self.machine.runForNumberOfCycles(cyclesToRunFor) actionLock.unlock() } } @@ -129,7 +131,7 @@ class MachineDocument: final func openGLView(view: CSOpenGLView, drawViewOnlyIfDirty onlyIfDirty: Bool) { bestEffortUpdater.update() if drawLock.tryLock() { - self.machine().drawViewForPixelSize(view.backingSize, onlyIfDirty: onlyIfDirty) + self.machine.drawViewForPixelSize(view.backingSize, onlyIfDirty: onlyIfDirty) drawLock.unlock() } } @@ -141,7 +143,7 @@ class MachineDocument: // MARK: Key forwarding private func withKeyboardMachine(action: (CSKeyboardMachine) -> ()) { - if let keyboardMachine = self.machine() as? CSKeyboardMachine { + if let keyboardMachine = self.machine as? CSKeyboardMachine { action(keyboardMachine) } } diff --git a/OSBindings/Mac/Clock Signal/Documents/Vic20Document.swift b/OSBindings/Mac/Clock Signal/Documents/Vic20Document.swift index 4ce301cee..6339c4276 100644 --- a/OSBindings/Mac/Clock Signal/Documents/Vic20Document.swift +++ b/OSBindings/Mac/Clock Signal/Documents/Vic20Document.swift @@ -11,8 +11,10 @@ import Foundation class Vic20Document: MachineDocument { private lazy var vic20 = CSVic20() - override func machine() -> CSMachine! { - return vic20 + override var machine: CSMachine! { + get { + return vic20 + } } // MARK: NSDocument overrides 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; } };