Remove scoped_ptr (now unique_ptr), midi

This commit is contained in:
Henrik Rydgård 2015-09-19 10:21:42 +02:00
parent 45e3b7122b
commit df47f41db6
11 changed files with 6 additions and 180 deletions

View File

@ -892,7 +892,6 @@ add_library(native STATIC
ext/native/base/linked_ptr.h
ext/native/base/logging.h
ext/native/base/mutex.h
ext/native/base/scoped_ptr.h
ext/native/base/stringutil.cpp
ext/native/base/stringutil.h
ext/native/base/timeutil.cpp
@ -976,6 +975,8 @@ add_library(native STATIC
ext/native/math/lin/vec3.h
ext/native/math/math_util.cpp
ext/native/math/math_util.h
ext/native/net/http_server.cpp
ext/native/net/http_server.h
ext/native/net/http_client.cpp
ext/native/net/http_client.h
ext/native/net/resolve.cpp

View File

@ -127,7 +127,6 @@ HEADERS += $$P/ext/native/audio/*.h \
$$P/ext/native/base/linked_ptr.h \
$$P/ext/native/base/logging.h \
$$P/ext/native/base/mutex.h \
$$P/ext/native/base/scoped_ptr.h \
$$P/ext/native/base/stringutil.h \
$$P/ext/native/base/timeutil.h \
$$P/ext/native/data/compression.h \

View File

@ -63,7 +63,6 @@ LOCAL_SRC_FILES :=\
math/lin/quat.cpp.arm \
math/lin/vec3.cpp.arm \
math/lin/matrix4x4.cpp.arm \
midi/midi_input.cpp \
net/http_client.cpp \
net/http_server.cpp \
net/http_headers.cpp \

View File

@ -1,30 +0,0 @@
#pragma once
// Trivial implementation of boost::scoped_ptr, in a way that I prefer.
template<class T>
class scoped_ptr {
public:
scoped_ptr() : ptr_(0) {}
scoped_ptr(T *p) : ptr_(p) {}
~scoped_ptr() {
delete ptr_;
}
void reset(T *p) {
delete ptr_;
ptr_ = p;
}
T *release() {
T *p = ptr_;
ptr_ = 0;
return p;
}
T *operator->() { return ptr_; }
const T *operator->() const { return ptr_; }
const T *get() const { return ptr_; }
T *get() { return ptr_; }
private:
scoped_ptr(const scoped_ptr<T> &other);
void operator=(const scoped_ptr<T> &other);
T *ptr_;
};

View File

@ -1,12 +0,0 @@
set(SRCS
midi_input.cpp
)
set(SRCS ${SRCS})
add_library(midi STATIC ${SRCS})
if(UNIX)
add_definitions(-fPIC)
endif(UNIX)

View File

@ -1,90 +0,0 @@
#ifdef _WIN32
// Windows implementation.
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <MMSystem.h>
#include <vector>
#include <string>
#include "base/basictypes.h"
#include "base/logging.h"
#include "midi/midi_input.h"
#include "util/text/utf8.h"
std::vector<std::string> MidiInGetDevices() {
int numDevs = midiInGetNumDevs();
std::vector<std::string> devices;
for (int i = 0; i < numDevs; i++) {
MIDIINCAPS caps;
midiInGetDevCaps(i, &caps, sizeof(caps));
devices.push_back(ConvertWStringToUTF8(caps.szPname));
}
return devices;
}
static void CALLBACK MidiCallback(HMIDIIN hMidiIn, UINT wMsg, DWORD_PTR dwInstance, DWORD_PTR dwParam1, DWORD_PTR dwParam2) {
MidiListener *listener = (MidiListener*)dwInstance;
uint8_t cmd[3] = {0};
switch (wMsg) {
case MM_MIM_OPEN:
ILOG("Got MIDI Open message");
break;
case MM_MIM_CLOSE:
ILOG("Got MIDI Close message");
break;
case MM_MIM_DATA:
cmd[0] = dwParam1 & 0xFF;
cmd[1] = (dwParam1 >> 8) & 0xFF;
cmd[2] = (dwParam1 >> 16) & 0xFF;
// time = dwParam2 & 0xFFFF;
ILOG("Got MIDI Data: %02x %02x %02x", cmd[0], cmd[1], cmd[2]);
listener->midiEvent(cmd);
break;
default:
WLOG("Got unexpected MIDI message: %08x", (uint32_t)wMsg);
break;
}
}
MidiDevice MidiInStart(int deviceID, MidiListener *listener) {
HMIDIIN hMidiIn;
MMRESULT result = midiInOpen(&hMidiIn, deviceID, (DWORD_PTR)(&MidiCallback), (DWORD_PTR)listener, CALLBACK_FUNCTION);
midiInStart(hMidiIn);
return (MidiDevice)hMidiIn;
}
void MidiInStop(MidiDevice device) {
HMIDIIN hMidiIn = (HMIDIIN)device;
midiInStop(hMidiIn);
midiInClose(hMidiIn);
}
#else
#include <vector>
#include <string>
#include "base/basictypes.h"
#include "base/logging.h"
#include "midi/midi_input.h"
// Stubs for other platforms.
std::vector<std::string> MidiInGetDevices() {
return std::vector<std::string>();
}
MidiDevice MidiInStart(int deviceID, MidiListener *listener) {
FLOG("Invalid MIDI device");
return 0;
}
void MidiInStop(MidiDevice device) {
FLOG("Invalid MIDI device");
}
#endif

View File

@ -1,27 +0,0 @@
// MIDI input.
//
// Currently, this is just a platform-clean wrapper around the Win32 MIDI input facilities.
// Thus, it only supports Windows. Other platforms will get an empty list of midi in devices.
#pragma once
#include <vector>
#include <string>
#include "base/basictypes.h"
typedef void *MidiDevice;
// Listeners inherit from this. Pass them into MidiInStart.
class MidiListener
{
public:
virtual ~MidiListener() {}
virtual void midiEvent(const uint8_t *cmd) = 0;
};
// Gets the names of the devices in a vector. The device identifier is the index in the vector.
std::vector<std::string> MidiInGetDevices();
MidiDevice MidiInStart(int deviceID, MidiListener *listener);
void MidiInStop(MidiDevice device);

View File

@ -200,7 +200,6 @@
<ClInclude Include="base\logging.h" />
<ClInclude Include="base\mutex.h" />
<ClInclude Include="base\NativeApp.h" />
<ClInclude Include="base\scoped_ptr.h" />
<ClInclude Include="base\stringutil.h" />
<ClInclude Include="base\timeutil.h" />
<ClInclude Include="data\compression.h" />
@ -264,7 +263,6 @@
<ClInclude Include="math\math_util.h" />
<ClInclude Include="math\fast\fast_math.h" />
<ClInclude Include="math\fast\fast_matrix.h" />
<ClInclude Include="midi\midi_input.h" />
<ClInclude Include="net\http_client.h" />
<ClInclude Include="net\http_headers.h" />
<ClInclude Include="net\http_server.h" />
@ -735,7 +733,6 @@
<ClCompile Include="math\fast\fast_matrix_sse.c">
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AssemblyAndSourceCode</AssemblerOutput>
</ClCompile>
<ClCompile Include="midi\midi_input.cpp" />
<ClCompile Include="net\http_client.cpp" />
<ClCompile Include="net\http_headers.cpp" />
<ClCompile Include="net\http_server.cpp" />

View File

@ -84,9 +84,6 @@
<ClInclude Include="base\basictypes.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="base\scoped_ptr.h">
<Filter>base</Filter>
</ClInclude>
<ClInclude Include="gfx\gl_lost_manager.h">
<Filter>gfx</Filter>
</ClInclude>
@ -138,9 +135,6 @@
<ClInclude Include="ui\ui.h">
<Filter>ui</Filter>
</ClInclude>
<ClInclude Include="midi\midi_input.h">
<Filter>midi</Filter>
</ClInclude>
<ClInclude Include="file\dialog.h">
<Filter>file</Filter>
</ClInclude>
@ -434,9 +428,6 @@
<ClCompile Include="ui\ui.cpp">
<Filter>ui</Filter>
</ClCompile>
<ClCompile Include="midi\midi_input.cpp">
<Filter>midi</Filter>
</ClCompile>
<ClCompile Include="file\dialog.cpp">
<Filter>file</Filter>
</ClCompile>
@ -847,9 +838,6 @@
<Filter Include="ui">
<UniqueIdentifier>{d738c2d1-749d-4b60-b98f-f3da0bbbf40c}</UniqueIdentifier>
</Filter>
<Filter Include="midi">
<UniqueIdentifier>{4710a9a2-d1fa-4920-ba1b-a7527902be53}</UniqueIdentifier>
</Filter>
<Filter Include="util">
<UniqueIdentifier>{e36ca540-863c-496b-b0f4-b1ece3e72feb}</UniqueIdentifier>
</Filter>

View File

@ -25,6 +25,7 @@
#include "base/buffer.h"
#include "file/fd_util.h"
#include "net/http_server.h"
#include "thread/executor.h"
namespace http {

View File

@ -11,12 +11,12 @@
#include <vector>
#include <cmath>
#include <cstdio>
#include <memory>
#include "base/logging.h"
#include "base/functional.h"
#include "base/mutex.h"
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "gfx/texture_atlas.h"
#include "math/lin/matrix4x4.h"
#include "math/math_util.h"
@ -365,7 +365,7 @@ public:
protected:
// Inputs to layout
scoped_ptr<LayoutParams> layoutParams_;
std::unique_ptr<LayoutParams> layoutParams_;
std::string tag_;
Visibility visibility_;
@ -377,7 +377,7 @@ protected:
// Outputs of layout. X/Y are absolute screen coordinates, hierarchy is "gone" here.
Bounds bounds_;
scoped_ptr<Matrix4x4> transform_;
std::unique_ptr<Matrix4x4> transform_;
private:
bool *enabledPtr_;