Update to v106r59 release.

byuu says:

Changelog:

  - fixed bug in Emulator::Game::Memory::operator bool()
  - nall: renamed view<string> back to `string_view`
  - nall:: implemented `array_view`
  - Game Boy: split cartridge-specific input mappings (rumble,
    accelerometer) to their own separate ports
  - Game Boy: fixed MBC7 accelerometer x-axis
  - icarus: Game Boy, Super Famicom, Mega Drive cores output internal
    header game titles to heuristics manifests
  - higan, icarus, hiro/gtk: improve viewport geometry configuration;
    fixed higan crashing bug with XShm driver
  - higan: connect Video::poll(),update() functionality
  - hiro, ruby: several compilation / bugfixes, should get the macOS
    port compiling again, hopefully [Sintendo]
  - ruby/video/xshm: fix crashing bug on window resize
      - a bit hacky; it's throwing BadAccess Xlib warnings, but they're
        not fatal, so I am catching and ignoring them
  - bsnes: removed Application::Windows::onModalChange hook that's no
    longer needed [Screwtape]
This commit is contained in:
Tim Allen
2018-08-26 16:49:54 +10:00
parent f9adb4d2c6
commit bd814f0358
89 changed files with 1079 additions and 2241 deletions

View File

@@ -31,6 +31,10 @@ template<typename T> vector<T>::operator bool() const {
return _size;
}
template<typename T> vector<T>::operator array_view<T>() const {
return {data(), size()};
}
template<typename T> template<typename Cast> auto vector<T>::capacity() const -> uint {
return (_left + _size + _right) * sizeof(T) / sizeof(Cast);
}
@@ -39,12 +43,12 @@ template<typename T> template<typename Cast> auto vector<T>::size() const -> uin
return _size * sizeof(T) / sizeof(Cast);
}
template<typename T> template<typename Cast> auto vector<T>::data(uint offset) -> Cast* {
return (Cast*)_pool + offset;
template<typename T> template<typename Cast> auto vector<T>::data() -> Cast* {
return (Cast*)_pool;
}
template<typename T> template<typename Cast> auto vector<T>::data(uint offset) const -> const Cast* {
return (const Cast*)_pool + offset;
template<typename T> template<typename Cast> auto vector<T>::data() const -> const Cast* {
return (const Cast*)_pool;
}
}

View File

@@ -2,6 +2,9 @@
namespace nall {
//nall::vector acts internally as a deque (double-ended queue)
//it does this because it's essentially free to do so, only costing an extra integer in sizeof(vector)
template<typename T> auto vector<T>::reset() -> void {
if(!_pool) return;
@@ -14,6 +17,18 @@ template<typename T> auto vector<T>::reset() -> void {
_right = 0;
}
//acquire ownership of allocated memory
template<typename T> auto vector<T>::acquire(const T* data, uint size, uint capacity) -> void {
reset();
_pool = data;
_size = size;
_left = 0;
_right = capacity ? capacity : size;
}
//release ownership of allocated memory
template<typename T> auto vector<T>::release() -> T* {
auto pool = _pool;
_pool = nullptr;
@@ -23,6 +38,11 @@ template<typename T> auto vector<T>::release() -> T* {
return pool;
}
//reserve allocates memory for objects, but does not initialize them
//when the vector desired size is known, this can be used to avoid growing the capacity dynamically
//reserve will not actually shrink the capacity, only expand it
//shrinking the capacity would destroy objects, and break amortized growth with reallocate and resize
template<typename T> auto vector<T>::reserveLeft(uint capacity) -> bool {
if(_size + _left >= capacity) return false;
@@ -51,6 +71,43 @@ template<typename T> auto vector<T>::reserveRight(uint capacity) -> bool {
return true;
}
//reallocation is meant for POD types, to avoid the overhead of initialization
//do not use with non-POD types, or they will not be properly constructed or destructed
template<typename T> auto vector<T>::reallocateLeft(uint size) -> bool {
if(size < _size) { //shrink
_pool += _size - size;
_left += _size - size;
_size = size;
return true;
}
if(size > _size) { //grow
reserveLeft(size);
_pool -= size - _size;
_left -= size - _size;
_size = size;
return true;
}
return false;
}
template<typename T> auto vector<T>::reallocateRight(uint size) -> bool {
if(size < _size) { //shrink
_right += _size - size;
_size = size;
return true;
}
if(size > _size) { //grow
reserveRight(size);
_right -= size - _size;
_size = size;
return true;
}
return false;
}
//resize is meant for non-POD types, and will properly construct objects
template<typename T> auto vector<T>::resizeLeft(uint size, const T& value) -> bool {
if(size < _size) { //shrink
for(uint n : range(_size - size)) _pool[n].~T();

View File

@@ -2,6 +2,10 @@
namespace nall {
template<typename T> auto vector<T>::fill(const T& value) -> void {
for(uint n : range(size())) _pool[n] = value;
}
template<typename T> auto vector<T>::sort(const function<bool (const T& lhs, const T& rhs)>& comparator) -> void {
nall::sort(_pool, _size, comparator);
}