Update to v106r81 release.

byuu says:

First 32 instructions implemented in the TLCS900H disassembler. Only 992
to go!

I removed the use of anonymous namespaces in nall. It was something I
rarely used, because it rarely did what I wanted.

I updated all nested namespaces to use C++17-style namespace Foo::Bar {}
syntax instead of classic C++-style namespace Foo { namespace Bar {}}.

I updated ruby::Video::acquire() to return a struct, so we can use C++17
structured bindings. Long term, I want to get away from all functions
that take references for output only. Even though C++ botched structured
bindings by not allowing you to bind to existing variables, it's even
worse to have function calls that take arguments by reference and then
write to them. From the caller side, you can't tell the value is being
written, nor that the value passed in doesn't matter, which is terrible.
This commit is contained in:
Tim Allen 2019-01-16 11:46:42 +11:00
parent 25145f59cc
commit 559a6585ef
94 changed files with 371 additions and 224 deletions

View File

@ -30,7 +30,7 @@ using namespace nall;
namespace Emulator {
static const string Name = "higan";
static const string Version = "106.80";
static const string Version = "106.81";
static const string Author = "byuu";
static const string License = "GPLv3";
static const string Website = "https://byuu.org/";

View File

@ -0,0 +1,136 @@
auto TLCS900H::disassemble() -> string {
string output;
output.append(hex(r.pc.l.l0, 6L), " ");
output.append(disassembleInstruction());
output.size(-48);
output.append("I", r.iff);
output.append("R", r.rfp);
output.append(r.s ? "S" : "s");
output.append(r.z ? "Z" : "z");
output.append(r.h ? "H" : "h");
output.append(r.v ? "V" : "v");
output.append(r.n ? "N" : "n");
output.append(r.c ? "C" : "c");
return output;
}
auto TLCS900H::disassembleInstruction() -> string {
uint8 opcode[8] = {};
string opRegister;
string opSourceMemory;
string opTargetMemory;
auto pc = r.pc.l.l0;
auto fetch8n = [&]() -> uint8 {
return disassembleRead(pc++);
};
auto fetch16n = [&]() -> uint16 {
uint16 data = fetch8n() << 0;
return data | fetch8n() << 8;
};
auto fetch24n = [&]() -> uint24 {
uint24 data = fetch8n() << 0;
data |= fetch8n() << 8;
return data |= fetch8n() << 16;
};
auto fetch32n = [&]() -> uint32 {
uint32 data = fetch8n() << 0;
data |= fetch8n() << 8;
data |= fetch8n() << 16;
return data |= fetch8n() << 24;
};
auto fetch8i = [&]() -> int8 { return (int8)fetch8n(); };
auto fetch16i = [&]() -> int16 { return (int16)fetch16n(); };
auto direct16n = [&]() -> string {
return {"0x", hex(fetch16n(), 4L)};
};
auto direct24n = [&]() -> string {
return {"0x", hex(fetch24n(), 6L)};
};
auto displacement16i = [&]() -> string {
auto displacement = fetch16i();
if(displacement < 0) return {"-0x", hex(abs(displacement), 4L)};
return {"+0x", hex(displacement, 4L)};
};
auto displacementPC16i = [&]() -> string {
auto displacement = fetch16i();
return {"0x", hex(pc + displacement, 6L)};
};
auto immediate8n = [&]() -> string {
return {"#0x", hex(fetch8n(), 2L)};
};
auto immediate16n = [&]() -> string {
return {"#0x", hex(fetch16n(), 4L)};
};
auto indirect8n = [&]() -> string {
return {"(0x", hex(fetch8n(), 2L), ")"};
};
#define op(name, ...) return {pad(name, -6), vector<string>{__VA_ARGS__}.merge(",")}
#define bad() return {pad("???", -6), hex(opcode[0], 2L)}
switch(opcode[0] = fetch8n()) {
case 0x00: op("nop");
case 0x01: bad();
case 0x02: op("push", "sr");
case 0x03: op("pop", "sr");
case 0x04: bad();
case 0x05: op("halt");
case 0x06: {
uint3 immediate = fetch8n();
if(immediate == 7) op("di");
op("ei", {"#", immediate});
}
case 0x07: op("reti");
case 0x08: op("ld", indirect8n(), immediate8n());
case 0x09: op("push", immediate8n());
case 0x0a: op("ldw", indirect8n(), immediate16n());
case 0x0b: op("push", immediate16n());
case 0x0c: op("incf");
case 0x0d: op("decf");
case 0x0e: op("ret");
case 0x0f: op("retd", displacement16i());
case 0x10: op("rcf");
case 0x11: op("scf");
case 0x12: op("ccf");
case 0x13: op("zcf");
case 0x14: op("push", "a");
case 0x15: op("pop", "a");
case 0x16: op("ex", "f", "f'");
case 0x17: {
uint2 immediate = fetch8n();
op("ldf", {"#", immediate});
}
case 0x18: op("push", "f");
case 0x19: op("pop", "f");
case 0x1a: op("jp", direct16n());
case 0x1b: op("jp", direct24n());
case 0x1c: op("call", direct16n());
case 0x1d: op("call", direct24n());
case 0x1e: op("calr", displacementPC16i());
case 0x1f: bad();
default: bad();
}
#undef bad
#define bad() return {pad("???", -6), hex(opcode[0], 2L), " ", hex(opcode[1], 2L)}
if(opRegister) switch(opcode[1] = fetch8n()) {
default: bad();
}
#undef bad
#define bad() return {pad("???", -6), hex(opcode[0], 2L), " ", hex(opcode[1], 2L)}
if(opSourceMemory) switch(opcode[1] = fetch8n()) {
default: bad();
}
#undef bad
#define bad() return {pad("???", -6), hex(opcode[0], 2L), " ", hex(opcode[1], 2L)}
if(opTargetMemory) switch(opcode[1] = fetch8n()) {
default: bad();
}
#undef bad
#undef op
return {};
}

View File

@ -23,6 +23,7 @@ namespace Processor {
#include "instruction.cpp"
#include "instructions.cpp"
#include "serialization.cpp"
#include "disassembler.cpp"
TLCS900H tlcs900h;

View File

@ -262,6 +262,11 @@ struct TLCS900H {
static inline const uint4 True {0x08};
static inline const uint1 Undefined = 0;
//disassembler.cpp
virtual auto disassembleRead(uint24 address) -> uint8 { return rand(); }
auto disassemble() -> string;
auto disassembleInstruction() -> string;
};
}

View File

@ -232,11 +232,9 @@ auto Presentation::clearViewport() -> void {
uint32_t opaqueBlack = 0xff000000;
if(settings.video.format == "RGB30") opaqueBlack = 0xc0000000;
uint32_t* output;
uint length;
uint width = 16;
uint height = 16;
if(video.acquire(output, length, width, height)) {
if(auto [output, length] = video.acquire(width, height); output) {
for(uint y : range(height)) {
auto line = output + y * (length >> 2);
for(uint x : range(width)) *line++ = opaqueBlack;

View File

@ -208,9 +208,6 @@ auto Program::load(uint id, string name, string type, vector<string> options) ->
}
auto Program::videoFrame(const uint32* data, uint pitch, uint width, uint height) -> void {
uint32_t* output;
uint length;
//this relies on the UI only running between Emulator::Scheduler::Event::Frame events
//this will always be the case; so we can avoid an unnecessary copy or one-frame delay here
//if the core were to exit between a frame event, the next frame might've been only partially rendered
@ -225,7 +222,7 @@ auto Program::videoFrame(const uint32* data, uint pitch, uint width, uint height
if(height == 480) data += 16 * pitch, height -= 32;
}
if(video.acquire(output, length, width, height)) {
if(auto [output, length] = video.acquire(width, height); output) {
length >>= 2;
for(auto y : range(height)) {

View File

@ -328,11 +328,9 @@ auto Presentation::clearViewport() -> void {
if(!emulator || !emulator->loaded()) viewportLayout.setPadding();
if(!visible() || !video) return;
uint32_t* output;
uint length = 0;
uint width = 16;
uint height = 16;
if(video->acquire(output, length, width, height)) {
if(auto [output, length] = video->acquire(width, height); output) {
for(uint y : range(height)) {
auto line = output + y * (length >> 2);
for(uint x : range(width)) *line++ = 0xff000000;

View File

@ -51,9 +51,6 @@ auto Program::load(uint id, string name, string type, vector<string> options) ->
}
auto Program::videoFrame(const uint32* data, uint pitch, uint width, uint height) -> void {
uint32_t* output;
uint length;
pitch >>= 2;
if(!settings["View/Overscan"].boolean()) {
@ -69,7 +66,7 @@ auto Program::videoFrame(const uint32* data, uint pitch, uint width, uint height
}
}
if(video->acquire(output, length, width, height)) {
if(auto [output, length] = video->acquire(width, height); output) {
length >>= 2;
for(auto y : range(height)) {

View File

@ -5,7 +5,7 @@
#undef min
#undef max
namespace nall { namespace {
namespace nall {
template<typename T, typename U> auto min(const T& t, const U& u) -> T {
return t < u ? t : (T)u;
@ -23,8 +23,4 @@ template<typename T, typename U, typename... P> auto max(const T& t, const U& u,
return t > u ? max(t, forward<P>(p)...) : max(u, forward<P>(p)...);
}
//template<typename T, typename U> auto ternary(bool test, const T& lhs, const U& rhs) -> T {
// return test ? lhs : (T)rhs;
//}
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/beat/archive/node.hpp>
namespace nall { namespace Beat { namespace Archive {
namespace nall::Beat::Archive {
struct Container {
Container(array_view<uint8_t> = {});
@ -197,4 +197,4 @@ auto Container::sort() -> void {
nodes.sort([&](auto& lhs, auto& rhs) { return string::icompare(lhs->name, rhs->name) < 0; });
}
}}}
}

View File

@ -3,7 +3,7 @@
#include <nall/beat/archive/node.hpp>
#include <nall/beat/archive/container.hpp>
namespace nall { namespace Beat { namespace Archive {
namespace nall::Beat::Archive {
auto create(Container& container, string name) -> vector<uint8_t> {
auto& metadata = container.metadata;
@ -83,4 +83,4 @@ auto create(Container& container, string name) -> vector<uint8_t> {
return memory;
}
}}}
}

View File

@ -3,7 +3,7 @@
#include <nall/beat/archive/node.hpp>
#include <nall/beat/archive/container.hpp>
namespace nall { namespace Beat { namespace Archive {
namespace nall::Beat::Archive {
auto extract(Container& container) -> bool {
function<void (Markup::Node)> extract = [&](auto metadata) {
@ -24,4 +24,4 @@ auto extract(Container& container) -> bool {
return true;
}
}}}
}

View File

@ -10,7 +10,7 @@
#include <nall/decode/lzsa.hpp>
#include <nall/encode/lzsa.hpp>
namespace nall { namespace Beat { namespace Archive {
namespace nall::Beat::Archive {
struct Node {
static auto create(string name, string location) -> shared_pointer<Node>;
@ -329,4 +329,4 @@ auto Node::getGroup() const -> string {
return permission.group.name;
}
}}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Beat { namespace Single {
namespace nall::Beat::Single {
inline auto apply(array_view<uint8_t> source, array_view<uint8_t> beat, maybe<string&> manifest = {}, maybe<string&> result = {}) -> maybe<vector<uint8_t>> {
#define error(text) { if(result) *result = {"error: ", text}; return {}; }
@ -85,4 +85,4 @@ inline auto apply(array_view<uint8_t> source, array_view<uint8_t> beat, maybe<st
#undef success
}
}}}
}

View File

@ -2,7 +2,7 @@
#include <nall/suffix-array.hpp>
namespace nall { namespace Beat { namespace Single {
namespace nall::Beat::Single {
inline auto create(array_view<uint8_t> source, array_view<uint8_t> target, string_view manifest = {}) -> vector<uint8_t> {
vector<uint8_t> beat;
@ -93,4 +93,4 @@ inline auto create(array_view<uint8_t> source, array_view<uint8_t> target, strin
return beat;
}
}}}
}

View File

@ -3,21 +3,21 @@
#include <nall/function.hpp>
#include <nall/string.hpp>
namespace nall { namespace chrono { namespace {
namespace nall::chrono {
//passage of time functions (from unknown epoch)
auto nanosecond() -> uint64_t {
inline auto nanosecond() -> uint64_t {
timespec tv;
clock_gettime(CLOCK_MONOTONIC, &tv);
return tv.tv_sec * 1'000'000'000 + tv.tv_nsec;
}
auto microsecond() -> uint64_t { return nanosecond() / 1'000; }
auto millisecond() -> uint64_t { return nanosecond() / 1'000'000; }
auto second() -> uint64_t { return nanosecond() / 1'000'000'000; }
inline auto microsecond() -> uint64_t { return nanosecond() / 1'000; }
inline auto millisecond() -> uint64_t { return nanosecond() / 1'000'000; }
inline auto second() -> uint64_t { return nanosecond() / 1'000'000'000; }
auto benchmark(const function<void ()>& f, uint64_t times = 1) -> void {
inline auto benchmark(const function<void ()>& f, uint64_t times = 1) -> void {
auto start = nanosecond();
while(times--) f();
auto end = nanosecond();
@ -34,7 +34,7 @@ struct timeinfo {
hour(hour), minute(minute), second(second), weekday(weekday) {
}
explicit operator bool() const { return month; }
inline explicit operator bool() const { return month; }
uint year; //...
uint month; //1 - 12
@ -45,12 +45,12 @@ struct timeinfo {
uint weekday; //0 - 6
};
auto timestamp() -> uint64_t {
inline auto timestamp() -> uint64_t {
return ::time(nullptr);
}
namespace utc {
auto timeinfo(uint64_t time = 0) -> chrono::timeinfo {
inline auto timeinfo(uint64_t time = 0) -> chrono::timeinfo {
auto stamp = time ? (time_t)time : (time_t)timestamp();
auto info = gmtime(&stamp);
return {
@ -64,24 +64,24 @@ namespace utc {
};
}
auto year(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).year, 4, '0'); }
auto month(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).month, 2, '0'); }
auto day(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).day, 2, '0'); }
auto hour(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).hour, 2, '0'); }
auto minute(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).minute, 2, '0'); }
auto second(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).second, 2, '0'); }
inline auto year(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).year, 4, '0'); }
inline auto month(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).month, 2, '0'); }
inline auto day(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).day, 2, '0'); }
inline auto hour(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).hour, 2, '0'); }
inline auto minute(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).minute, 2, '0'); }
inline auto second(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).second, 2, '0'); }
auto date(uint64_t timestamp = 0) -> string {
inline auto date(uint64_t timestamp = 0) -> string {
auto t = timeinfo(timestamp);
return {pad(t.year, 4, '0'), "-", pad(t.month, 2, '0'), "-", pad(t.day, 2, '0')};
}
auto time(uint64_t timestamp = 0) -> string {
inline auto time(uint64_t timestamp = 0) -> string {
auto t = timeinfo(timestamp);
return {pad(t.hour, 2, '0'), ":", pad(t.minute, 2, '0'), ":", pad(t.second, 2, '0')};
}
auto datetime(uint64_t timestamp = 0) -> string {
inline auto datetime(uint64_t timestamp = 0) -> string {
auto t = timeinfo(timestamp);
return {
pad(t.year, 4, '0'), "-", pad(t.month, 2, '0'), "-", pad(t.day, 2, '0'), " ",
@ -91,7 +91,7 @@ namespace utc {
}
namespace local {
auto timeinfo(uint64_t time = 0) -> chrono::timeinfo {
inline auto timeinfo(uint64_t time = 0) -> chrono::timeinfo {
auto stamp = time ? (time_t)time : (time_t)timestamp();
auto info = localtime(&stamp);
return {
@ -105,24 +105,24 @@ namespace local {
};
}
auto year(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).year, 4, '0'); }
auto month(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).month, 2, '0'); }
auto day(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).day, 2, '0'); }
auto hour(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).hour, 2, '0'); }
auto minute(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).minute, 2, '0'); }
auto second(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).second, 2, '0'); }
inline auto year(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).year, 4, '0'); }
inline auto month(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).month, 2, '0'); }
inline auto day(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).day, 2, '0'); }
inline auto hour(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).hour, 2, '0'); }
inline auto minute(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).minute, 2, '0'); }
inline auto second(uint64_t timestamp = 0) -> string { return pad(timeinfo(timestamp).second, 2, '0'); }
auto date(uint64_t timestamp = 0) -> string {
inline auto date(uint64_t timestamp = 0) -> string {
auto t = timeinfo(timestamp);
return {pad(t.year, 4, '0'), "-", pad(t.month, 2, '0'), "-", pad(t.day, 2, '0')};
}
auto time(uint64_t timestamp = 0) -> string {
inline auto time(uint64_t timestamp = 0) -> string {
auto t = timeinfo(timestamp);
return {pad(t.hour, 2, '0'), ":", pad(t.minute, 2, '0'), ":", pad(t.second, 2, '0')};
}
auto datetime(uint64_t timestamp = 0) -> string {
inline auto datetime(uint64_t timestamp = 0) -> string {
auto t = timeinfo(timestamp);
return {
pad(t.year, 4, '0'), "-", pad(t.month, 2, '0'), "-", pad(t.day, 2, '0'), " ",
@ -131,4 +131,4 @@ namespace local {
}
}
}}}
}

View File

@ -3,7 +3,7 @@
#include <nall/arithmetic.hpp>
#include <nall/array-view.hpp>
namespace nall { namespace Cipher {
namespace nall::Cipher {
//64-bit nonce; 64-bit x 64-byte (256GB) counter
struct ChaCha20 {
@ -106,4 +106,4 @@ struct XChaCha20 : ChaCha20 {
}
};
}}
}

View File

@ -1,12 +1,14 @@
#pragma once
//legacy code; no longer used
#include <nall/string.hpp>
#include <sql.h>
#include <sqltypes.h>
#include <sqlext.h>
namespace nall { namespace Database {
namespace nall::Database {
struct ODBC {
struct Statement {
@ -294,4 +296,4 @@ private:
SQLRETURN _result = SQL_SUCCESS;
};
}}
}

View File

@ -10,7 +10,7 @@
#include <nall/stdint.hpp>
#include <nall/string.hpp>
namespace nall { namespace Database {
namespace nall::Database {
struct SQLite3 {
struct Statement {
@ -200,4 +200,4 @@ protected:
sqlite3* _database = nullptr;
};
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/arithmetic.hpp>
namespace nall { namespace Decode {
namespace nall::Decode {
template<uint Bits, typename T> inline auto Base(const string& value) -> T {
static const string format =
@ -34,4 +34,4 @@ template<uint Bits, typename T> inline auto Base(const string& value) -> T {
return result;
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Decode {
namespace nall::Decode {
inline auto Base64(const string& text) -> vector<uint8_t> {
static bool initialized = false;
@ -44,4 +44,4 @@ inline auto Base64(const string& text) -> vector<uint8_t> {
return result;
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Decode {
namespace nall::Decode {
struct BMP {
BMP() = default;
@ -73,4 +73,4 @@ private:
}
};
}}
}

View File

@ -4,7 +4,7 @@
#include <nall/suffix-array.hpp>
namespace nall { namespace Decode {
namespace nall::Decode {
inline auto BWT(array_view<uint8_t> input) -> vector<uint8_t> {
vector<uint8_t> output;
@ -44,4 +44,4 @@ inline auto BWT(array_view<uint8_t> input) -> vector<uint8_t> {
return output;
}
}}
}

View File

@ -3,7 +3,7 @@
#include <nall/file.hpp>
#include <nall/decode/inflate.hpp>
namespace nall { namespace Decode {
namespace nall::Decode {
struct GZIP {
inline ~GZIP();
@ -75,4 +75,4 @@ auto GZIP::decompress(const uint8_t* data, uint size) -> bool {
return inflate(this->data, this->size, data + p, size - p - 8);
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Decode {
namespace nall::Decode {
inline auto HTML(const string& input) -> string {
string output;
@ -37,4 +37,4 @@ inline auto HTML(const string& input) -> string {
return output;
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Decode {
namespace nall::Decode {
inline auto Huffman(array_view<uint8_t> input) -> vector<uint8_t> {
vector<uint8_t> output;
@ -33,4 +33,4 @@ inline auto Huffman(array_view<uint8_t> input) -> vector<uint8_t> {
return output;
}
}}
}

View File

@ -1,8 +1,11 @@
#pragma once
//a bad implementation of inflate from zlib/minizip
//todo: replace with Talarubi's version
#include <setjmp.h>
namespace nall { namespace Decode {
namespace nall::Decode {
namespace puff {
inline auto puff(
@ -343,4 +346,4 @@ inline auto puff(
}
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/decode/huffman.hpp>
namespace nall { namespace Decode {
namespace nall::Decode {
inline auto LZSA(array_view<uint8_t> input) -> vector<uint8_t> {
vector<uint8_t> output;
@ -69,4 +69,4 @@ inline auto LZSA(array_view<uint8_t> input) -> vector<uint8_t> {
return output;
}
}}
}

View File

@ -2,7 +2,7 @@
//move to front
namespace nall { namespace Decode {
namespace nall::Decode {
inline auto MTF(array_view<uint8_t> input) -> vector<uint8_t> {
vector<uint8_t> output;
@ -22,4 +22,4 @@ inline auto MTF(array_view<uint8_t> input) -> vector<uint8_t> {
return output;
}
}}
}

View File

@ -3,7 +3,7 @@
#include <nall/string.hpp>
#include <nall/decode/inflate.hpp>
namespace nall { namespace Decode {
namespace nall::Decode {
struct PNG {
inline PNG();
@ -329,4 +329,4 @@ auto PNG::readbits(const uint8_t*& data) -> uint {
return result;
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Decode {
namespace nall::Decode {
template<uint S = 1, uint M = 4 / S> //S = word size; M = match length
inline auto RLE(array_view<uint8_t> input) -> vector<uint8_t> {
@ -41,4 +41,4 @@ inline auto RLE(array_view<uint8_t> input) -> vector<uint8_t> {
return output;
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Decode {
namespace nall::Decode {
//returns empty string on malformed content
inline auto URL(string_view input) -> string {
@ -36,4 +36,4 @@ inline auto URL(string_view input) -> string {
return output;
}
}}
}

View File

@ -5,7 +5,7 @@
#include <nall/vector.hpp>
#include <nall/decode/inflate.hpp>
namespace nall { namespace Decode {
namespace nall::Decode {
struct ZIP {
struct File {
@ -133,4 +133,4 @@ public:
vector<File> file;
};
}}
}

View File

@ -1,5 +1,5 @@
#pragma once
namespace nall { namespace DSP {
namespace nall::DSP {
}}
}

View File

@ -4,7 +4,7 @@
//transposed direct form II biquadratic second-order IIR filter
namespace nall { namespace DSP { namespace IIR {
namespace nall::DSP::IIR {
struct Biquad {
enum class Type : uint {
@ -154,4 +154,4 @@ auto Biquad::butterworth(uint order, uint phase) -> double {
return -0.5 / cos(Math::Pi * (phase + order + 0.5) / order);
}
}}}
}

View File

@ -4,7 +4,7 @@
//DC offset removal IIR filter
namespace nall { namespace DSP { namespace IIR {
namespace nall::DSP::IIR {
struct DCRemoval {
inline auto reset() -> void;
@ -26,4 +26,4 @@ auto DCRemoval::process(double in) -> double {
return x;
}
}}}
}

View File

@ -4,7 +4,7 @@
//one-pole first-order IIR filter
namespace nall { namespace DSP { namespace IIR {
namespace nall::DSP::IIR {
struct OnePole {
enum class Type : uint {
@ -43,4 +43,4 @@ auto OnePole::process(double in) -> double {
return z1 = in * a0 + z1 * b1;
}
}}}
}

View File

@ -3,7 +3,7 @@
#include <nall/queue.hpp>
#include <nall/dsp/dsp.hpp>
namespace nall { namespace DSP { namespace Resampler {
namespace nall::DSP::Resampler {
struct Cubic {
inline auto reset(double inputFrequency, double outputFrequency = 0, uint queueSize = 0) -> void;
@ -67,4 +67,4 @@ auto Cubic::write(double sample) -> void {
mu -= 1.0;
}
}}}
}

View File

@ -6,7 +6,7 @@
#include <nall/elliptic-curve/modulo25519-optimized.hpp>
#endif
namespace nall { namespace EllipticCurve {
namespace nall::EllipticCurve {
struct Curve25519 {
auto sharedKey(uint256_t secretKey, uint256_t basepoint = 9) const -> uint256_t {
@ -54,4 +54,4 @@ private:
}
};
}}
}

View File

@ -7,7 +7,7 @@
#include <nall/elliptic-curve/modulo25519-optimized.hpp>
#endif
namespace nall { namespace EllipticCurve {
namespace nall::EllipticCurve {
static const uint256_t L = (1_u256 << 252) + 27742317777372353535851937790883648493_u256;
@ -141,4 +141,4 @@ private:
}
};
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/arithmetic/barrett.hpp>
namespace nall { namespace EllipticCurve {
namespace nall::EllipticCurve {
static const uint256_t P = (1_u256 << 255) - 19;
@ -215,4 +215,4 @@ inline auto squareRoot(const Modulo25519& lhs) -> Modulo25519 {
#undef Mask
}}
}

View File

@ -5,7 +5,7 @@
#include <nall/arithmetic/barrett.hpp>
namespace nall { namespace EllipticCurve {
namespace nall::EllipticCurve {
static const uint256_t P = (1_u256 << 255) - 19;
@ -81,4 +81,4 @@ inline auto cswap(bool condition, Modulo25519& lhs, Modulo25519& rhs) -> void {
if(condition) swap(lhs, rhs);
}
}}
}

View File

@ -7,7 +7,7 @@
#include <nall/arithmetic.hpp>
namespace nall { namespace Encode {
namespace nall::Encode {
template<uint Bits, typename T> inline auto Base(T value) -> string {
static const string format =
@ -35,4 +35,4 @@ template<uint Bits, typename T> inline auto Base(T value) -> string {
return result;
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Encode {
namespace nall::Encode {
inline auto Base64(const void* vdata, uint size, const string& format = "MIME") -> string {
static bool initialized = false;
@ -65,4 +65,4 @@ inline auto Base64(const string& text, const string& format = "MIME") -> string
return Base64(text.data(), text.size(), format);
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Encode {
namespace nall::Encode {
struct BMP {
static auto create(const string& filename, const void* data, uint pitch, uint width, uint height, bool alpha) -> bool {
@ -44,4 +44,4 @@ struct BMP {
}
};
}}
}

View File

@ -4,7 +4,7 @@
#include <nall/suffix-array.hpp>
namespace nall { namespace Encode {
namespace nall::Encode {
/*
A standard suffix array cannot produce a proper burrows-wheeler transform, due to rotations.
@ -83,4 +83,4 @@ inline auto BWT(array_view<uint8_t> input) -> vector<uint8_t> {
return output;
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Encode {
namespace nall::Encode {
inline auto HTML(const string& input) -> string {
string output;
@ -15,4 +15,4 @@ inline auto HTML(const string& input) -> string {
return output;
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Encode {
namespace nall::Encode {
inline auto Huffman(array_view<uint8_t> input) -> vector<uint8_t> {
vector<uint8_t> output;
@ -81,4 +81,4 @@ inline auto Huffman(array_view<uint8_t> input) -> vector<uint8_t> {
return output;
}
}}
}

View File

@ -6,7 +6,7 @@
#include <nall/encode/mtf.hpp>
#include <nall/encode/rle.hpp>
namespace nall { namespace Encode {
namespace nall::Encode {
inline auto LZSA(array_view<uint8_t> input) -> vector<uint8_t> {
vector<uint8_t> output;
@ -83,4 +83,4 @@ inline auto LZSA(array_view<uint8_t> input) -> vector<uint8_t> {
return output;
}
}}
}

View File

@ -2,7 +2,7 @@
//move to front
namespace nall { namespace Encode {
namespace nall::Encode {
inline auto MTF(array_view<uint8_t> input) -> vector<uint8_t> {
vector<uint8_t> output;
@ -27,4 +27,4 @@ inline auto MTF(array_view<uint8_t> input) -> vector<uint8_t> {
return output;
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Encode {
namespace nall::Encode {
template<uint S = 1, uint M = 4 / S> //S = word size; M = match length
inline auto RLE(array_view<uint8_t> input) -> vector<uint8_t> {
@ -53,4 +53,4 @@ inline auto RLE(array_view<uint8_t> input) -> vector<uint8_t> {
return output;
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Encode {
namespace nall::Encode {
inline auto URL(string_view input) -> string {
string output;
@ -24,4 +24,4 @@ inline auto URL(string_view input) -> string {
return output;
}
}}
}

View File

@ -5,7 +5,7 @@
#include <nall/string.hpp>
#include <nall/hash/crc32.hpp>
namespace nall { namespace Encode {
namespace nall::Encode {
struct ZIP {
ZIP(const string& filename) {
@ -98,4 +98,4 @@ protected:
vector<entry_t> directory;
};
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/hash/hash.hpp>
namespace nall { namespace Hash {
namespace nall::Hash {
struct CRC16 : Hash {
using Hash::input;
@ -52,4 +52,4 @@ private:
uint16_t checksum = 0;
};
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/hash/hash.hpp>
namespace nall { namespace Hash {
namespace nall::Hash {
struct CRC32 : Hash {
using Hash::input;
@ -52,4 +52,4 @@ private:
uint32_t checksum = 0;
};
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/hash/hash.hpp>
namespace nall { namespace Hash {
namespace nall::Hash {
struct CRC64 : Hash {
using Hash::input;
@ -52,4 +52,4 @@ private:
uint64_t checksum = 0;
};
}}
}

View File

@ -13,7 +13,7 @@
Name(const string& data) : Name() { input(data); } \
using Hash::input; \
namespace nall { namespace Hash {
namespace nall::Hash {
struct Hash {
virtual auto reset() -> void = 0;
@ -44,4 +44,4 @@ struct Hash {
}
};
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/hash/hash.hpp>
namespace nall { namespace Hash {
namespace nall::Hash {
struct SHA224 : Hash {
using Hash::input;
@ -103,4 +103,4 @@ private:
uint64_t length = 0;
};
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/hash/hash.hpp>
namespace nall { namespace Hash {
namespace nall::Hash {
struct SHA256 : Hash {
using Hash::input;
@ -103,4 +103,4 @@ private:
uint64_t length = 0;
};
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/hash/hash.hpp>
namespace nall { namespace Hash {
namespace nall::Hash {
struct SHA384 : Hash {
using Hash::input;
@ -116,4 +116,4 @@ private:
uint128_t length = 0;
};
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/hash/hash.hpp>
namespace nall { namespace Hash {
namespace nall::Hash {
struct SHA512 : Hash {
using Hash::input;
@ -116,4 +116,4 @@ private:
uint128_t length = 0;
};
}}
}

View File

@ -5,7 +5,7 @@
#include <nall/string.hpp>
#include <nall/vector.hpp>
namespace nall { namespace HID {
namespace nall::HID {
struct Input {
Input(const string& name) : _name(name) {}
@ -118,4 +118,4 @@ private:
bool _rumble = false;
};
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/http/role.hpp>
namespace nall { namespace HTTP {
namespace nall::HTTP {
struct Client : Role {
inline auto open(const string& hostname, uint port = 80) -> bool;
@ -53,4 +53,4 @@ auto Client::close() -> void {
}
}
}}
}

View File

@ -3,7 +3,7 @@
//httpMessage: base class for httpRequest and httpResponse
//provides shared functionality
namespace nall { namespace HTTP {
namespace nall::HTTP {
struct Variable {
string name;
@ -96,4 +96,4 @@ struct Message {
string _body;
};
}}
}

View File

@ -4,7 +4,7 @@
#include <nall/encode/url.hpp>
#include <nall/http/message.hpp>
namespace nall { namespace HTTP {
namespace nall::HTTP {
struct Request : Message {
using type = Request;
@ -181,4 +181,4 @@ auto Request::setBody() -> bool {
return true;
}
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/http/message.hpp>
namespace nall { namespace HTTP {
namespace nall::HTTP {
struct Response : Message {
using type = Response;
@ -254,4 +254,4 @@ auto Response::setText(const string& value) -> type& {
return *this;
}
}}
}

View File

@ -6,7 +6,7 @@
#include <nall/http/request.hpp>
#include <nall/http/response.hpp>
namespace nall { namespace HTTP {
namespace nall::HTTP {
struct Role {
struct Settings {
@ -155,4 +155,4 @@ auto Role::upload(int fd, const Message& message) -> bool {
return false;
}
}}
}

View File

@ -3,7 +3,7 @@
#include <nall/service.hpp>
#include <nall/http/role.hpp>
namespace nall { namespace HTTP {
namespace nall::HTTP {
struct Server : Role, service {
inline auto open(uint port = 8080, const string& serviceName = "", const string& command = "") -> bool;
@ -223,4 +223,4 @@ auto Server::close() -> void {
ipv6_close();
}
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/string.hpp>
namespace nall { namespace Location {
namespace nall::Location {
// (/parent/child.type/)
// (/parent/child.type/)name.type
@ -75,4 +75,4 @@ inline auto notsuffix(string_view self) -> string {
return {path(self), prefix(self)};
}
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/arithmetic.hpp>
namespace nall { namespace MAC {
namespace nall::MAC {
struct Poly1305 {
auto authenticate(array_view<uint8_t> memory, uint256_t nonce) -> uint128_t {
@ -119,4 +119,4 @@ private:
uint offset;
};
}}
}

View File

@ -1,6 +1,9 @@
#pragma once
namespace nall { namespace Matrix {
//matrix multiplication primitives
//used in: ruby/opengl/quark
namespace nall::Matrix {
template<typename T> inline auto Multiply(
T* output,
@ -30,4 +33,4 @@ const T* ydata, uint yrows, uint ycols
return output;
}
}}
}

View File

@ -3,7 +3,7 @@
#include <nall/algorithm.hpp>
#include <nall/stdint.hpp>
namespace nall { namespace memory {
namespace nall::memory {
template<typename T = uint8_t> inline auto allocate(uint size) -> T*;
template<typename T = uint8_t> inline auto allocate(uint size, const T& value) -> T*;
@ -33,9 +33,9 @@ namespace nall { namespace memory {
template<uint size, typename T = uint64_t> inline auto writel(void* target, T data) -> void;
template<uint size, typename T = uint64_t> inline auto writem(void* target, T data) -> void;
}}
}
namespace nall { namespace memory {
namespace nall::memory {
//implementation notes:
//memcmp, memcpy, memmove have terrible performance on small block sizes (FreeBSD 10.0-amd64)
@ -160,4 +160,4 @@ template<uint size, typename T> auto writem(void* target, T data) -> void {
for(int n = size - 1; n >= 0; n--) *p++ = data >> n * 8;
}
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/string.hpp>
namespace nall { namespace Path {
namespace nall::Path {
inline auto active() -> string {
char path[PATH_MAX] = "";
@ -130,4 +130,4 @@ inline auto temporary() -> string {
return result;
}
}}
}

View File

@ -113,6 +113,7 @@ namespace Math {
#define alwaysinline inline
#endif
//P0627: [[unreachable]] -- impossible to simulate with identical syntax, must omit brackets ...
#if defined(COMPILER_CLANG) || defined(COMPILER_GCC)
#define unreachable __builtin_unreachable()
#else

View File

@ -166,4 +166,4 @@ private:
uint _capacity = 0;
};
};
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Eval {
namespace nall::Eval {
inline auto evaluateExpression(Node* node) -> string {
#define p(n) evaluateExpression(node->link[n])
@ -143,4 +143,4 @@ inline auto real(const string& expression) -> maybe<long double> {
}
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Eval {
namespace nall::Eval {
inline auto isLiteral(const char*& s) -> bool {
char n = s[0];
@ -96,4 +96,4 @@ inline auto literal(const char*& s) -> string {
throw "invalid literal";
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Eval {
namespace nall::Eval {
struct Node {
enum class Type : uint {
@ -34,4 +34,4 @@ struct Node {
~Node() { for(auto& node : link) delete node; }
};
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Eval {
namespace nall::Eval {
inline auto whitespace(char n) -> bool {
return n == ' ' || n == '\t' || n == '\r' || n == '\n';
@ -161,4 +161,4 @@ inline auto parse(const string& expression) -> Node* {
return result;
}
}}
}

View File

@ -3,7 +3,7 @@
//BML v1.0 parser
//revision 0.04
namespace nall { namespace BML {
namespace nall::BML {
//metadata is used to store nesting level
@ -186,4 +186,4 @@ inline auto serialize(const Markup::Node& node, string_view spacing = {}, uint d
return result;
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Markup {
namespace nall::Markup {
auto ManagedNode::_evaluate(string query) const -> bool {
if(!query) return true;
@ -134,4 +134,4 @@ auto ManagedNode::_create(const string& path) -> Node {
return _children.right();
}
}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace Markup {
namespace nall::Markup {
struct Node;
struct ManagedNode;
@ -136,4 +136,4 @@ protected:
SharedNode shared;
};
}}
}

View File

@ -3,7 +3,7 @@
//XML v1.0 subset parser
//revision 0.04
namespace nall { namespace XML {
namespace nall::XML {
//metadata:
// 0 = element
@ -214,4 +214,4 @@ inline auto unserialize(const string& markup) -> Markup::SharedNode {
return node;
}
}}
}

View File

@ -6,7 +6,7 @@
#include <nall/location.hpp>
namespace nall { namespace {
namespace nall {
struct CML {
auto& setPath(const string& pathname) { settings.path = pathname; return *this; }
@ -34,20 +34,20 @@ private:
auto parseDocument(const string& filedata, const string& pathname, uint depth) -> bool;
};
auto CML::parse(const string& filename) -> string {
inline auto CML::parse(const string& filename) -> string {
if(!settings.path) settings.path = Location::path(filename);
string document = settings.reader ? settings.reader(filename) : string::read(filename);
parseDocument(document, settings.path, 0);
return state.output;
}
auto CML::parse(const string& filedata, const string& pathname) -> string {
inline auto CML::parse(const string& filedata, const string& pathname) -> string {
settings.path = pathname;
parseDocument(filedata, settings.path, 0);
return state.output;
}
auto CML::parseDocument(const string& filedata, const string& pathname, uint depth) -> bool {
inline auto CML::parseDocument(const string& filedata, const string& pathname, uint depth) -> bool {
if(depth >= 100) return false; //prevent infinite recursion
auto vendorAppend = [&](const string& name, const string& value) {
@ -102,4 +102,4 @@ auto CML::parseDocument(const string& filedata, const string& pathname, uint dep
return true;
}
}}
}

View File

@ -6,7 +6,7 @@
#include <nall/location.hpp>
namespace nall { namespace {
namespace nall {
struct DML {
auto& setAllowHTML(bool allowHTML) { settings.allowHTML = allowHTML; return *this; }
@ -40,20 +40,20 @@ private:
auto markup(const string& text) -> string;
};
auto DML::parse(const string& filedata, const string& pathname) -> string {
inline auto DML::parse(const string& filedata, const string& pathname) -> string {
settings.path = pathname;
parseDocument(filedata, settings.path, 0);
return state.output;
}
auto DML::parse(const string& filename) -> string {
inline auto DML::parse(const string& filename) -> string {
if(!settings.path) settings.path = Location::path(filename);
string document = settings.reader ? settings.reader(filename) : string::read(filename);
parseDocument(document, settings.path, 0);
return state.output;
}
auto DML::parseDocument(const string& filedata, const string& pathname, uint depth) -> bool {
inline auto DML::parseDocument(const string& filedata, const string& pathname, uint depth) -> bool {
if(depth >= 100) return false; //attempt to prevent infinite recursion with reasonable limit
auto blocks = filedata.split("\n\n");
@ -62,7 +62,7 @@ auto DML::parseDocument(const string& filedata, const string& pathname, uint dep
return true;
}
auto DML::parseBlock(string& block, const string& pathname, uint depth) -> bool {
inline auto DML::parseBlock(string& block, const string& pathname, uint depth) -> bool {
if(!block.stripRight()) return true;
auto lines = block.split("\n");
@ -182,7 +182,7 @@ auto DML::parseBlock(string& block, const string& pathname, uint depth) -> bool
return true;
}
auto DML::count(const string& text, char value) -> uint {
inline auto DML::count(const string& text, char value) -> uint {
for(uint n = 0; n < text.size(); n++) {
if(text[n] != value) {
if(text[n] == ' ') return n;
@ -192,7 +192,7 @@ auto DML::count(const string& text, char value) -> uint {
return 0;
}
auto DML::escape(const string& text) -> string {
inline auto DML::escape(const string& text) -> string {
string output;
for(auto c : text) {
if(c == '&') { output.append("&amp;"); continue; }
@ -204,7 +204,7 @@ auto DML::escape(const string& text) -> string {
return output;
}
auto DML::markup(const string& s) -> string {
inline auto DML::markup(const string& s) -> string {
string t;
boolean strong;
@ -266,4 +266,4 @@ auto DML::markup(const string& s) -> string {
return t;
}
}}
}

View File

@ -2,7 +2,7 @@
#include <nall/string.hpp>
namespace nall { namespace terminal {
namespace nall::terminal {
inline auto escapable() -> bool {
#if defined(PLATFORM_WINDOWS)
@ -62,4 +62,4 @@ template<typename... P> inline auto gray(P&&... p) -> string {
}
}}
}

View File

@ -4,6 +4,8 @@
namespace nall {
using std::tuple;
template<typename T> struct base_from_member {
base_from_member(T value) : value(value) {}
T value;

View File

@ -2,7 +2,7 @@
#include <nall/file.hpp>
namespace nall { namespace vfs { namespace fs {
namespace nall::vfs::fs {
struct file : vfs::file {
static auto open(string location_, mode mode_) -> vfs::shared::file {
@ -48,4 +48,4 @@ private:
file_buffer _fp;
};
}}}
}

View File

@ -1,6 +1,6 @@
#pragma once
namespace nall { namespace vfs { namespace memory {
namespace nall::vfs::memory {
struct file : vfs::file {
~file() { delete[] _data; }
@ -45,4 +45,4 @@ private:
uintmax _offset = 0;
};
}}}
}

View File

@ -3,7 +3,7 @@
#include <nall/range.hpp>
#include <nall/shared-pointer.hpp>
namespace nall { namespace vfs {
namespace nall::vfs {
struct file {
enum class mode : uint { read, write, modify, create };
@ -65,11 +65,11 @@ struct file {
}
};
}}
}
namespace nall { namespace vfs { namespace shared {
namespace nall::vfs::shared {
using file = shared_pointer<vfs::file>;
}}}
}
#include <nall/vfs/fs/file.hpp>
#include <nall/vfs/memory/file.hpp>

View File

@ -2,7 +2,7 @@
#include <nall/xorg/xorg.hpp>
namespace nall { namespace Clipboard {
namespace nall::Clipboard {
auto clear() -> void {
XDisplay display;
@ -11,4 +11,4 @@ auto clear() -> void {
}
}
}}
}

View File

@ -21,6 +21,7 @@ using nall::function;
using nall::queue;
using nall::shared_pointer;
using nall::string;
using nall::tuple;
using nall::unique_pointer;
using nall::vector;

View File

@ -92,8 +92,10 @@ auto Video::clear() -> void {
return instance->clear();
}
auto Video::acquire(uint32_t*& data, uint& pitch, uint width, uint height) -> bool {
return instance->acquire(data, pitch, width, height);
auto Video::acquire(uint width, uint height) -> Acquire {
Acquire result;
if(instance->acquire(result.data, result.pitch, width, height)) return result;
return {};
}
auto Video::release() -> void {

View File

@ -86,7 +86,12 @@ struct Video {
auto configure(uint width, uint height, double inputFrequency, double outputFrequency) -> bool;
auto clear() -> void;
auto acquire(uint32_t*& data, uint& pitch, uint width, uint height) -> bool;
struct Acquire {
explicit operator bool() const { return data; }
uint32_t* data = nullptr;
uint pitch = 0;
};
auto acquire(uint width, uint height) -> Acquire;
auto release() -> void;
auto output() -> void;
auto poll() -> void;