diff --git a/higan/emulator/emulator.hpp b/higan/emulator/emulator.hpp index 15340dca..965f083d 100644 --- a/higan/emulator/emulator.hpp +++ b/higan/emulator/emulator.hpp @@ -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/"; diff --git a/higan/processor/tlcs900h/disassembler.cpp b/higan/processor/tlcs900h/disassembler.cpp new file mode 100644 index 00000000..119be1ec --- /dev/null +++ b/higan/processor/tlcs900h/disassembler.cpp @@ -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{__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 {}; +} diff --git a/higan/processor/tlcs900h/tlcs900h.cpp b/higan/processor/tlcs900h/tlcs900h.cpp index 5bc38758..bc39d244 100644 --- a/higan/processor/tlcs900h/tlcs900h.cpp +++ b/higan/processor/tlcs900h/tlcs900h.cpp @@ -23,6 +23,7 @@ namespace Processor { #include "instruction.cpp" #include "instructions.cpp" #include "serialization.cpp" +#include "disassembler.cpp" TLCS900H tlcs900h; diff --git a/higan/processor/tlcs900h/tlcs900h.hpp b/higan/processor/tlcs900h/tlcs900h.hpp index 59a83c80..4ab02a86 100644 --- a/higan/processor/tlcs900h/tlcs900h.hpp +++ b/higan/processor/tlcs900h/tlcs900h.hpp @@ -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; }; } diff --git a/higan/target-bsnes/presentation/presentation.cpp b/higan/target-bsnes/presentation/presentation.cpp index c50a6eaa..4d5da280 100644 --- a/higan/target-bsnes/presentation/presentation.cpp +++ b/higan/target-bsnes/presentation/presentation.cpp @@ -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; diff --git a/higan/target-bsnes/program/platform.cpp b/higan/target-bsnes/program/platform.cpp index 090fb299..e794a1f9 100644 --- a/higan/target-bsnes/program/platform.cpp +++ b/higan/target-bsnes/program/platform.cpp @@ -208,9 +208,6 @@ auto Program::load(uint id, string name, string type, vector 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)) { diff --git a/higan/target-higan/presentation/presentation.cpp b/higan/target-higan/presentation/presentation.cpp index 45a83bee..d2031a33 100644 --- a/higan/target-higan/presentation/presentation.cpp +++ b/higan/target-higan/presentation/presentation.cpp @@ -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; diff --git a/higan/target-higan/program/platform.cpp b/higan/target-higan/program/platform.cpp index 9119bad0..39508d4e 100644 --- a/higan/target-higan/program/platform.cpp +++ b/higan/target-higan/program/platform.cpp @@ -51,9 +51,6 @@ auto Program::load(uint id, string name, string type, vector 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)) { diff --git a/nall/algorithm.hpp b/nall/algorithm.hpp index 18a3b093..53fb6eb0 100644 --- a/nall/algorithm.hpp +++ b/nall/algorithm.hpp @@ -5,7 +5,7 @@ #undef min #undef max -namespace nall { namespace { +namespace nall { template auto min(const T& t, const U& u) -> T { return t < u ? t : (T)u; @@ -23,8 +23,4 @@ template auto max(const T& t, const U& u, return t > u ? max(t, forward

(p)...) : max(u, forward

(p)...); } -//template auto ternary(bool test, const T& lhs, const U& rhs) -> T { -// return test ? lhs : (T)rhs; -//} - -}} +} diff --git a/nall/beat/archive/container.hpp b/nall/beat/archive/container.hpp index de523f10..bdfce1da 100644 --- a/nall/beat/archive/container.hpp +++ b/nall/beat/archive/container.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace Beat { namespace Archive { +namespace nall::Beat::Archive { struct Container { Container(array_view = {}); @@ -197,4 +197,4 @@ auto Container::sort() -> void { nodes.sort([&](auto& lhs, auto& rhs) { return string::icompare(lhs->name, rhs->name) < 0; }); } -}}} +} diff --git a/nall/beat/archive/create.hpp b/nall/beat/archive/create.hpp index b365ec85..7014e489 100644 --- a/nall/beat/archive/create.hpp +++ b/nall/beat/archive/create.hpp @@ -3,7 +3,7 @@ #include #include -namespace nall { namespace Beat { namespace Archive { +namespace nall::Beat::Archive { auto create(Container& container, string name) -> vector { auto& metadata = container.metadata; @@ -83,4 +83,4 @@ auto create(Container& container, string name) -> vector { return memory; } -}}} +} diff --git a/nall/beat/archive/extract.hpp b/nall/beat/archive/extract.hpp index 87a79270..41e48891 100644 --- a/nall/beat/archive/extract.hpp +++ b/nall/beat/archive/extract.hpp @@ -3,7 +3,7 @@ #include #include -namespace nall { namespace Beat { namespace Archive { +namespace nall::Beat::Archive { auto extract(Container& container) -> bool { function extract = [&](auto metadata) { @@ -24,4 +24,4 @@ auto extract(Container& container) -> bool { return true; } -}}} +} diff --git a/nall/beat/archive/node.hpp b/nall/beat/archive/node.hpp index 02692929..a8821ff7 100644 --- a/nall/beat/archive/node.hpp +++ b/nall/beat/archive/node.hpp @@ -10,7 +10,7 @@ #include #include -namespace nall { namespace Beat { namespace Archive { +namespace nall::Beat::Archive { struct Node { static auto create(string name, string location) -> shared_pointer; @@ -329,4 +329,4 @@ auto Node::getGroup() const -> string { return permission.group.name; } -}}} +} diff --git a/nall/beat/single/apply.hpp b/nall/beat/single/apply.hpp index 57002298..cd81762a 100644 --- a/nall/beat/single/apply.hpp +++ b/nall/beat/single/apply.hpp @@ -1,6 +1,6 @@ #pragma once -namespace nall { namespace Beat { namespace Single { +namespace nall::Beat::Single { inline auto apply(array_view source, array_view beat, maybe manifest = {}, maybe result = {}) -> maybe> { #define error(text) { if(result) *result = {"error: ", text}; return {}; } @@ -85,4 +85,4 @@ inline auto apply(array_view source, array_view beat, maybe -namespace nall { namespace Beat { namespace Single { +namespace nall::Beat::Single { inline auto create(array_view source, array_view target, string_view manifest = {}) -> vector { vector beat; @@ -93,4 +93,4 @@ inline auto create(array_view source, array_view target, strin return beat; } -}}} +} diff --git a/nall/chrono.hpp b/nall/chrono.hpp index abefb4a4..5226eb3f 100644 --- a/nall/chrono.hpp +++ b/nall/chrono.hpp @@ -3,21 +3,21 @@ #include #include -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& f, uint64_t times = 1) -> void { +inline auto benchmark(const function& 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 { } } -}}} +} diff --git a/nall/cipher/chacha20.hpp b/nall/cipher/chacha20.hpp index 3df44272..66b71663 100644 --- a/nall/cipher/chacha20.hpp +++ b/nall/cipher/chacha20.hpp @@ -3,7 +3,7 @@ #include #include -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 { } }; -}} +} diff --git a/nall/database/odbc.hpp b/nall/database/odbc.hpp index a714c6ac..bd3cba17 100644 --- a/nall/database/odbc.hpp +++ b/nall/database/odbc.hpp @@ -1,12 +1,14 @@ #pragma once +//legacy code; no longer used + #include #include #include #include -namespace nall { namespace Database { +namespace nall::Database { struct ODBC { struct Statement { @@ -294,4 +296,4 @@ private: SQLRETURN _result = SQL_SUCCESS; }; -}} +} diff --git a/nall/database/sqlite3.hpp b/nall/database/sqlite3.hpp index b78cf41f..772bd139 100644 --- a/nall/database/sqlite3.hpp +++ b/nall/database/sqlite3.hpp @@ -10,7 +10,7 @@ #include #include -namespace nall { namespace Database { +namespace nall::Database { struct SQLite3 { struct Statement { @@ -200,4 +200,4 @@ protected: sqlite3* _database = nullptr; }; -}} +} diff --git a/nall/decode/base.hpp b/nall/decode/base.hpp index c79d7c94..d20f1a5e 100644 --- a/nall/decode/base.hpp +++ b/nall/decode/base.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace Decode { +namespace nall::Decode { template inline auto Base(const string& value) -> T { static const string format = @@ -34,4 +34,4 @@ template inline auto Base(const string& value) -> T { return result; } -}} +} diff --git a/nall/decode/base64.hpp b/nall/decode/base64.hpp index b9c06b5f..a613d346 100644 --- a/nall/decode/base64.hpp +++ b/nall/decode/base64.hpp @@ -1,6 +1,6 @@ #pragma once -namespace nall { namespace Decode { +namespace nall::Decode { inline auto Base64(const string& text) -> vector { static bool initialized = false; @@ -44,4 +44,4 @@ inline auto Base64(const string& text) -> vector { return result; } -}} +} diff --git a/nall/decode/bmp.hpp b/nall/decode/bmp.hpp index 8aeab788..8aa725a3 100644 --- a/nall/decode/bmp.hpp +++ b/nall/decode/bmp.hpp @@ -1,6 +1,6 @@ #pragma once -namespace nall { namespace Decode { +namespace nall::Decode { struct BMP { BMP() = default; @@ -73,4 +73,4 @@ private: } }; -}} +} diff --git a/nall/decode/bwt.hpp b/nall/decode/bwt.hpp index 3c7fc5f9..5aeb1f8c 100644 --- a/nall/decode/bwt.hpp +++ b/nall/decode/bwt.hpp @@ -4,7 +4,7 @@ #include -namespace nall { namespace Decode { +namespace nall::Decode { inline auto BWT(array_view input) -> vector { vector output; @@ -44,4 +44,4 @@ inline auto BWT(array_view input) -> vector { return output; } -}} +} diff --git a/nall/decode/gzip.hpp b/nall/decode/gzip.hpp index 15ad463d..20f754cd 100644 --- a/nall/decode/gzip.hpp +++ b/nall/decode/gzip.hpp @@ -3,7 +3,7 @@ #include #include -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); } -}} +} diff --git a/nall/decode/html.hpp b/nall/decode/html.hpp index 927d699b..ccec3e8d 100644 --- a/nall/decode/html.hpp +++ b/nall/decode/html.hpp @@ -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; } -}} +} diff --git a/nall/decode/huffman.hpp b/nall/decode/huffman.hpp index 7a19dc56..cb8c3929 100644 --- a/nall/decode/huffman.hpp +++ b/nall/decode/huffman.hpp @@ -1,6 +1,6 @@ #pragma once -namespace nall { namespace Decode { +namespace nall::Decode { inline auto Huffman(array_view input) -> vector { vector output; @@ -33,4 +33,4 @@ inline auto Huffman(array_view input) -> vector { return output; } -}} +} diff --git a/nall/decode/inflate.hpp b/nall/decode/inflate.hpp index e07fd527..0f659b70 100644 --- a/nall/decode/inflate.hpp +++ b/nall/decode/inflate.hpp @@ -1,8 +1,11 @@ #pragma once +//a bad implementation of inflate from zlib/minizip +//todo: replace with Talarubi's version + #include -namespace nall { namespace Decode { +namespace nall::Decode { namespace puff { inline auto puff( @@ -343,4 +346,4 @@ inline auto puff( } -}} +} diff --git a/nall/decode/lzsa.hpp b/nall/decode/lzsa.hpp index 4cdad5c6..a0e9c9c4 100644 --- a/nall/decode/lzsa.hpp +++ b/nall/decode/lzsa.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace Decode { +namespace nall::Decode { inline auto LZSA(array_view input) -> vector { vector output; @@ -69,4 +69,4 @@ inline auto LZSA(array_view input) -> vector { return output; } -}} +} diff --git a/nall/decode/mtf.hpp b/nall/decode/mtf.hpp index d105b93e..d70e1683 100644 --- a/nall/decode/mtf.hpp +++ b/nall/decode/mtf.hpp @@ -2,7 +2,7 @@ //move to front -namespace nall { namespace Decode { +namespace nall::Decode { inline auto MTF(array_view input) -> vector { vector output; @@ -22,4 +22,4 @@ inline auto MTF(array_view input) -> vector { return output; } -}} +} diff --git a/nall/decode/png.hpp b/nall/decode/png.hpp index 3e884d06..f5c2eeda 100644 --- a/nall/decode/png.hpp +++ b/nall/decode/png.hpp @@ -3,7 +3,7 @@ #include #include -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; } -}} +} diff --git a/nall/decode/rle.hpp b/nall/decode/rle.hpp index f7f83abb..4a6c67ca 100644 --- a/nall/decode/rle.hpp +++ b/nall/decode/rle.hpp @@ -1,6 +1,6 @@ #pragma once -namespace nall { namespace Decode { +namespace nall::Decode { template //S = word size; M = match length inline auto RLE(array_view input) -> vector { @@ -41,4 +41,4 @@ inline auto RLE(array_view input) -> vector { return output; } -}} +} diff --git a/nall/decode/url.hpp b/nall/decode/url.hpp index 7f059386..56526c92 100644 --- a/nall/decode/url.hpp +++ b/nall/decode/url.hpp @@ -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; } -}} +} diff --git a/nall/decode/zip.hpp b/nall/decode/zip.hpp index ae346889..316009dd 100644 --- a/nall/decode/zip.hpp +++ b/nall/decode/zip.hpp @@ -5,7 +5,7 @@ #include #include -namespace nall { namespace Decode { +namespace nall::Decode { struct ZIP { struct File { @@ -133,4 +133,4 @@ public: vector file; }; -}} +} diff --git a/nall/dsp/dsp.hpp b/nall/dsp/dsp.hpp index 2e0d160a..f8bf82e2 100644 --- a/nall/dsp/dsp.hpp +++ b/nall/dsp/dsp.hpp @@ -1,5 +1,5 @@ #pragma once -namespace nall { namespace DSP { +namespace nall::DSP { -}} +} diff --git a/nall/dsp/iir/biquad.hpp b/nall/dsp/iir/biquad.hpp index 661a204a..16dfd046 100644 --- a/nall/dsp/iir/biquad.hpp +++ b/nall/dsp/iir/biquad.hpp @@ -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); } -}}} +} diff --git a/nall/dsp/iir/dc-removal.hpp b/nall/dsp/iir/dc-removal.hpp index 1fc17e65..3fdbf3a5 100644 --- a/nall/dsp/iir/dc-removal.hpp +++ b/nall/dsp/iir/dc-removal.hpp @@ -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; } -}}} +} diff --git a/nall/dsp/iir/one-pole.hpp b/nall/dsp/iir/one-pole.hpp index 99d0a682..a2f6d980 100644 --- a/nall/dsp/iir/one-pole.hpp +++ b/nall/dsp/iir/one-pole.hpp @@ -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; } -}}} +} diff --git a/nall/dsp/resampler/cubic.hpp b/nall/dsp/resampler/cubic.hpp index 3962a244..1b184a69 100644 --- a/nall/dsp/resampler/cubic.hpp +++ b/nall/dsp/resampler/cubic.hpp @@ -3,7 +3,7 @@ #include #include -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; } -}}} +} diff --git a/nall/elliptic-curve/curve25519.hpp b/nall/elliptic-curve/curve25519.hpp index c8cf2e46..194efdd1 100644 --- a/nall/elliptic-curve/curve25519.hpp +++ b/nall/elliptic-curve/curve25519.hpp @@ -6,7 +6,7 @@ #include #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: } }; -}} +} diff --git a/nall/elliptic-curve/ed25519.hpp b/nall/elliptic-curve/ed25519.hpp index 3b14a4e6..afce41b1 100644 --- a/nall/elliptic-curve/ed25519.hpp +++ b/nall/elliptic-curve/ed25519.hpp @@ -7,7 +7,7 @@ #include #endif -namespace nall { namespace EllipticCurve { +namespace nall::EllipticCurve { static const uint256_t L = (1_u256 << 252) + 27742317777372353535851937790883648493_u256; @@ -141,4 +141,4 @@ private: } }; -}} +} diff --git a/nall/elliptic-curve/modulo25519-optimized.hpp b/nall/elliptic-curve/modulo25519-optimized.hpp index 6917901b..4d2ec010 100644 --- a/nall/elliptic-curve/modulo25519-optimized.hpp +++ b/nall/elliptic-curve/modulo25519-optimized.hpp @@ -2,7 +2,7 @@ #include -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 -}} +} diff --git a/nall/elliptic-curve/modulo25519-reference.hpp b/nall/elliptic-curve/modulo25519-reference.hpp index 18b35b8d..f9eb485a 100644 --- a/nall/elliptic-curve/modulo25519-reference.hpp +++ b/nall/elliptic-curve/modulo25519-reference.hpp @@ -5,7 +5,7 @@ #include -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); } -}} +} diff --git a/nall/encode/base.hpp b/nall/encode/base.hpp index d1f7ad73..ac55486e 100644 --- a/nall/encode/base.hpp +++ b/nall/encode/base.hpp @@ -7,7 +7,7 @@ #include -namespace nall { namespace Encode { +namespace nall::Encode { template inline auto Base(T value) -> string { static const string format = @@ -35,4 +35,4 @@ template inline auto Base(T value) -> string { return result; } -}} +} diff --git a/nall/encode/base64.hpp b/nall/encode/base64.hpp index 36e90fed..a1d518cf 100644 --- a/nall/encode/base64.hpp +++ b/nall/encode/base64.hpp @@ -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); } -}} +} diff --git a/nall/encode/bmp.hpp b/nall/encode/bmp.hpp index f01d370b..1ccc9304 100644 --- a/nall/encode/bmp.hpp +++ b/nall/encode/bmp.hpp @@ -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 { } }; -}} +} diff --git a/nall/encode/bwt.hpp b/nall/encode/bwt.hpp index a4b104d3..84e00d9c 100644 --- a/nall/encode/bwt.hpp +++ b/nall/encode/bwt.hpp @@ -4,7 +4,7 @@ #include -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 input) -> vector { return output; } -}} +} diff --git a/nall/encode/html.hpp b/nall/encode/html.hpp index fa854474..6e4fd04b 100644 --- a/nall/encode/html.hpp +++ b/nall/encode/html.hpp @@ -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; } -}} +} diff --git a/nall/encode/huffman.hpp b/nall/encode/huffman.hpp index 15ec855b..18aa25f1 100644 --- a/nall/encode/huffman.hpp +++ b/nall/encode/huffman.hpp @@ -1,6 +1,6 @@ #pragma once -namespace nall { namespace Encode { +namespace nall::Encode { inline auto Huffman(array_view input) -> vector { vector output; @@ -81,4 +81,4 @@ inline auto Huffman(array_view input) -> vector { return output; } -}} +} diff --git a/nall/encode/lzsa.hpp b/nall/encode/lzsa.hpp index 1022836d..2ca59b6e 100644 --- a/nall/encode/lzsa.hpp +++ b/nall/encode/lzsa.hpp @@ -6,7 +6,7 @@ #include #include -namespace nall { namespace Encode { +namespace nall::Encode { inline auto LZSA(array_view input) -> vector { vector output; @@ -83,4 +83,4 @@ inline auto LZSA(array_view input) -> vector { return output; } -}} +} diff --git a/nall/encode/mtf.hpp b/nall/encode/mtf.hpp index b87e8668..42f24b19 100644 --- a/nall/encode/mtf.hpp +++ b/nall/encode/mtf.hpp @@ -2,7 +2,7 @@ //move to front -namespace nall { namespace Encode { +namespace nall::Encode { inline auto MTF(array_view input) -> vector { vector output; @@ -27,4 +27,4 @@ inline auto MTF(array_view input) -> vector { return output; } -}} +} diff --git a/nall/encode/rle.hpp b/nall/encode/rle.hpp index bcdae714..da88fff9 100644 --- a/nall/encode/rle.hpp +++ b/nall/encode/rle.hpp @@ -1,6 +1,6 @@ #pragma once -namespace nall { namespace Encode { +namespace nall::Encode { template //S = word size; M = match length inline auto RLE(array_view input) -> vector { @@ -53,4 +53,4 @@ inline auto RLE(array_view input) -> vector { return output; } -}} +} diff --git a/nall/encode/url.hpp b/nall/encode/url.hpp index 1e253814..1f422e5d 100644 --- a/nall/encode/url.hpp +++ b/nall/encode/url.hpp @@ -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; } -}} +} diff --git a/nall/encode/zip.hpp b/nall/encode/zip.hpp index f4897784..b98376d7 100644 --- a/nall/encode/zip.hpp +++ b/nall/encode/zip.hpp @@ -5,7 +5,7 @@ #include #include -namespace nall { namespace Encode { +namespace nall::Encode { struct ZIP { ZIP(const string& filename) { @@ -98,4 +98,4 @@ protected: vector directory; }; -}} +} diff --git a/nall/hash/crc16.hpp b/nall/hash/crc16.hpp index 77441426..8058a40b 100644 --- a/nall/hash/crc16.hpp +++ b/nall/hash/crc16.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace Hash { +namespace nall::Hash { struct CRC16 : Hash { using Hash::input; @@ -52,4 +52,4 @@ private: uint16_t checksum = 0; }; -}} +} diff --git a/nall/hash/crc32.hpp b/nall/hash/crc32.hpp index e7cd9407..39318713 100644 --- a/nall/hash/crc32.hpp +++ b/nall/hash/crc32.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace Hash { +namespace nall::Hash { struct CRC32 : Hash { using Hash::input; @@ -52,4 +52,4 @@ private: uint32_t checksum = 0; }; -}} +} diff --git a/nall/hash/crc64.hpp b/nall/hash/crc64.hpp index d32f3388..7364b0d8 100644 --- a/nall/hash/crc64.hpp +++ b/nall/hash/crc64.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace Hash { +namespace nall::Hash { struct CRC64 : Hash { using Hash::input; @@ -52,4 +52,4 @@ private: uint64_t checksum = 0; }; -}} +} diff --git a/nall/hash/hash.hpp b/nall/hash/hash.hpp index 775475f4..4565fe3d 100644 --- a/nall/hash/hash.hpp +++ b/nall/hash/hash.hpp @@ -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 { } }; -}} +} diff --git a/nall/hash/sha224.hpp b/nall/hash/sha224.hpp index ecf7572e..6bcf7858 100644 --- a/nall/hash/sha224.hpp +++ b/nall/hash/sha224.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace Hash { +namespace nall::Hash { struct SHA224 : Hash { using Hash::input; @@ -103,4 +103,4 @@ private: uint64_t length = 0; }; -}} +} diff --git a/nall/hash/sha256.hpp b/nall/hash/sha256.hpp index 8f7fe9e4..27f42a04 100644 --- a/nall/hash/sha256.hpp +++ b/nall/hash/sha256.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace Hash { +namespace nall::Hash { struct SHA256 : Hash { using Hash::input; @@ -103,4 +103,4 @@ private: uint64_t length = 0; }; -}} +} diff --git a/nall/hash/sha384.hpp b/nall/hash/sha384.hpp index 63ad43f2..09dbbdb1 100644 --- a/nall/hash/sha384.hpp +++ b/nall/hash/sha384.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace Hash { +namespace nall::Hash { struct SHA384 : Hash { using Hash::input; @@ -116,4 +116,4 @@ private: uint128_t length = 0; }; -}} +} diff --git a/nall/hash/sha512.hpp b/nall/hash/sha512.hpp index 83c91e24..f76d2d52 100644 --- a/nall/hash/sha512.hpp +++ b/nall/hash/sha512.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace Hash { +namespace nall::Hash { struct SHA512 : Hash { using Hash::input; @@ -116,4 +116,4 @@ private: uint128_t length = 0; }; -}} +} diff --git a/nall/hid.hpp b/nall/hid.hpp index d312a11b..e002c656 100644 --- a/nall/hid.hpp +++ b/nall/hid.hpp @@ -5,7 +5,7 @@ #include #include -namespace nall { namespace HID { +namespace nall::HID { struct Input { Input(const string& name) : _name(name) {} @@ -118,4 +118,4 @@ private: bool _rumble = false; }; -}} +} diff --git a/nall/http/client.hpp b/nall/http/client.hpp index fa017546..17a6a43f 100644 --- a/nall/http/client.hpp +++ b/nall/http/client.hpp @@ -2,7 +2,7 @@ #include -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 { } } -}} +} diff --git a/nall/http/message.hpp b/nall/http/message.hpp index 59a9e2ea..1f7f237d 100644 --- a/nall/http/message.hpp +++ b/nall/http/message.hpp @@ -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; }; -}} +} diff --git a/nall/http/request.hpp b/nall/http/request.hpp index b55ee308..081c1c74 100644 --- a/nall/http/request.hpp +++ b/nall/http/request.hpp @@ -4,7 +4,7 @@ #include #include -namespace nall { namespace HTTP { +namespace nall::HTTP { struct Request : Message { using type = Request; @@ -181,4 +181,4 @@ auto Request::setBody() -> bool { return true; } -}} +} diff --git a/nall/http/response.hpp b/nall/http/response.hpp index a72f2b85..eee06bc4 100644 --- a/nall/http/response.hpp +++ b/nall/http/response.hpp @@ -2,7 +2,7 @@ #include -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; } -}} +} diff --git a/nall/http/role.hpp b/nall/http/role.hpp index 522cf5c0..28837f5b 100644 --- a/nall/http/role.hpp +++ b/nall/http/role.hpp @@ -6,7 +6,7 @@ #include #include -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; } -}} +} diff --git a/nall/http/server.hpp b/nall/http/server.hpp index a987e2b3..3454ccf3 100644 --- a/nall/http/server.hpp +++ b/nall/http/server.hpp @@ -3,7 +3,7 @@ #include #include -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(); } -}} +} diff --git a/nall/location.hpp b/nall/location.hpp index 21c32c66..4f1b3a51 100644 --- a/nall/location.hpp +++ b/nall/location.hpp @@ -2,7 +2,7 @@ #include -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)}; } -}} +} diff --git a/nall/mac/poly1305.hpp b/nall/mac/poly1305.hpp index 88b74882..befbf46e 100644 --- a/nall/mac/poly1305.hpp +++ b/nall/mac/poly1305.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace MAC { +namespace nall::MAC { struct Poly1305 { auto authenticate(array_view memory, uint256_t nonce) -> uint128_t { @@ -119,4 +119,4 @@ private: uint offset; }; -}} +} diff --git a/nall/matrix.hpp b/nall/matrix.hpp index 7acb7fda..a4c67095 100644 --- a/nall/matrix.hpp +++ b/nall/matrix.hpp @@ -1,6 +1,9 @@ #pragma once -namespace nall { namespace Matrix { +//matrix multiplication primitives +//used in: ruby/opengl/quark + +namespace nall::Matrix { template inline auto Multiply( T* output, @@ -30,4 +33,4 @@ const T* ydata, uint yrows, uint ycols return output; } -}} +} diff --git a/nall/memory.hpp b/nall/memory.hpp index 658eb19e..9eba671a 100644 --- a/nall/memory.hpp +++ b/nall/memory.hpp @@ -3,7 +3,7 @@ #include #include -namespace nall { namespace memory { +namespace nall::memory { template inline auto allocate(uint size) -> T*; template inline auto allocate(uint size, const T& value) -> T*; @@ -33,9 +33,9 @@ namespace nall { namespace memory { template inline auto writel(void* target, T data) -> void; template 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 auto writem(void* target, T data) -> void { for(int n = size - 1; n >= 0; n--) *p++ = data >> n * 8; } -}} +} diff --git a/nall/path.hpp b/nall/path.hpp index 6adf9c65..9e4369fe 100644 --- a/nall/path.hpp +++ b/nall/path.hpp @@ -2,7 +2,7 @@ #include -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; } -}} +} diff --git a/nall/platform.hpp b/nall/platform.hpp index 9140f68f..d16c4392 100644 --- a/nall/platform.hpp +++ b/nall/platform.hpp @@ -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 diff --git a/nall/serializer.hpp b/nall/serializer.hpp index 1b2dc94c..16238c2c 100644 --- a/nall/serializer.hpp +++ b/nall/serializer.hpp @@ -166,4 +166,4 @@ private: uint _capacity = 0; }; -}; +} diff --git a/nall/string/eval/evaluator.hpp b/nall/string/eval/evaluator.hpp index 5ed01f12..cecffd40 100644 --- a/nall/string/eval/evaluator.hpp +++ b/nall/string/eval/evaluator.hpp @@ -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 { } } -}} +} diff --git a/nall/string/eval/literal.hpp b/nall/string/eval/literal.hpp index 4efd94aa..4c106fcf 100644 --- a/nall/string/eval/literal.hpp +++ b/nall/string/eval/literal.hpp @@ -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"; } -}} +} diff --git a/nall/string/eval/node.hpp b/nall/string/eval/node.hpp index 54f7e7a0..d02a928e 100644 --- a/nall/string/eval/node.hpp +++ b/nall/string/eval/node.hpp @@ -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; } }; -}} +} diff --git a/nall/string/eval/parser.hpp b/nall/string/eval/parser.hpp index 5e8ebe52..f736d228 100644 --- a/nall/string/eval/parser.hpp +++ b/nall/string/eval/parser.hpp @@ -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; } -}} +} diff --git a/nall/string/markup/bml.hpp b/nall/string/markup/bml.hpp index 84f08584..3bf05ddf 100644 --- a/nall/string/markup/bml.hpp +++ b/nall/string/markup/bml.hpp @@ -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; } -}} +} diff --git a/nall/string/markup/find.hpp b/nall/string/markup/find.hpp index 8cbdd4fc..8af6abaf 100644 --- a/nall/string/markup/find.hpp +++ b/nall/string/markup/find.hpp @@ -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(); } -}} +} diff --git a/nall/string/markup/node.hpp b/nall/string/markup/node.hpp index 5cbe06c1..d8df5049 100644 --- a/nall/string/markup/node.hpp +++ b/nall/string/markup/node.hpp @@ -1,6 +1,6 @@ #pragma once -namespace nall { namespace Markup { +namespace nall::Markup { struct Node; struct ManagedNode; @@ -136,4 +136,4 @@ protected: SharedNode shared; }; -}} +} diff --git a/nall/string/markup/xml.hpp b/nall/string/markup/xml.hpp index b0d946af..27109101 100644 --- a/nall/string/markup/xml.hpp +++ b/nall/string/markup/xml.hpp @@ -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; } -}} +} diff --git a/nall/string/transform/cml.hpp b/nall/string/transform/cml.hpp index 0d1935b5..eaa9643f 100644 --- a/nall/string/transform/cml.hpp +++ b/nall/string/transform/cml.hpp @@ -6,7 +6,7 @@ #include -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; } -}} +} diff --git a/nall/string/transform/dml.hpp b/nall/string/transform/dml.hpp index 31d6ae86..42f3215d 100644 --- a/nall/string/transform/dml.hpp +++ b/nall/string/transform/dml.hpp @@ -6,7 +6,7 @@ #include -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("&"); 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; } -}} +} diff --git a/nall/terminal.hpp b/nall/terminal.hpp index eae4edc5..90041639 100644 --- a/nall/terminal.hpp +++ b/nall/terminal.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace terminal { +namespace nall::terminal { inline auto escapable() -> bool { #if defined(PLATFORM_WINDOWS) @@ -62,4 +62,4 @@ template inline auto gray(P&&... p) -> string { } -}} +} diff --git a/nall/utility.hpp b/nall/utility.hpp index f1ab1a7a..717da4e3 100644 --- a/nall/utility.hpp +++ b/nall/utility.hpp @@ -4,6 +4,8 @@ namespace nall { +using std::tuple; + template struct base_from_member { base_from_member(T value) : value(value) {} T value; diff --git a/nall/vfs/fs/file.hpp b/nall/vfs/fs/file.hpp index 5cd4d1ff..9b860aa8 100644 --- a/nall/vfs/fs/file.hpp +++ b/nall/vfs/fs/file.hpp @@ -2,7 +2,7 @@ #include -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; }; -}}} +} diff --git a/nall/vfs/memory/file.hpp b/nall/vfs/memory/file.hpp index 12b93dab..e55584a8 100644 --- a/nall/vfs/memory/file.hpp +++ b/nall/vfs/memory/file.hpp @@ -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; }; -}}} +} diff --git a/nall/vfs/vfs.hpp b/nall/vfs/vfs.hpp index e8e05e1d..ae985820 100644 --- a/nall/vfs/vfs.hpp +++ b/nall/vfs/vfs.hpp @@ -3,7 +3,7 @@ #include #include -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; -}}} +} #include #include diff --git a/nall/xorg/clipboard.hpp b/nall/xorg/clipboard.hpp index 24b5ea9c..09f06fd9 100644 --- a/nall/xorg/clipboard.hpp +++ b/nall/xorg/clipboard.hpp @@ -2,7 +2,7 @@ #include -namespace nall { namespace Clipboard { +namespace nall::Clipboard { auto clear() -> void { XDisplay display; @@ -11,4 +11,4 @@ auto clear() -> void { } } -}} +} diff --git a/ruby/ruby.hpp b/ruby/ruby.hpp index 5fcae08d..5be87c32 100644 --- a/ruby/ruby.hpp +++ b/ruby/ruby.hpp @@ -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; diff --git a/ruby/video/video.cpp b/ruby/video/video.cpp index 7c54dd84..0b4f3383 100644 --- a/ruby/video/video.cpp +++ b/ruby/video/video.cpp @@ -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 { diff --git a/ruby/video/video.hpp b/ruby/video/video.hpp index 456f6d06..574bc0f1 100644 --- a/ruby/video/video.hpp +++ b/ruby/video/video.hpp @@ -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;