mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-03 10:12:45 +02:00
Update to v093r02 release.
byuu says: Changelog: - nall: fixed major memory leak in string class - ruby: video shaders support #define-based settings now - phoenix/GTK+: support > 256x256 icons for window / task bar / alt-tab - sfc: remove random/ and config/, merge into system/ - ethos: delete higan.png (48x48), replace with higan512.png (512x512) as new higan.png - ethos: default gamma to 100% (no color adjustment) - ethos: use "Video Shaders/Display Emulation/" instead of "Video Shaders/Emulation/" - use g++ instead of g++-4.7 (g++ -v must be >= 4.7) - use -std=c++11 instead of -std=gnu++11 - applied a few patches from Debian upstream to make their packaging job easier So because colors are normalized in GLSL, I won't be able to offer video shaders absolute color literals. We will have to perform basic color conversion inside the core. As such, the current plan is to create some sort of Emulator::Settings interface. With that, I'll connect an option for color correction, which will be on by default. For FC/SFC, that will mean gamma correction (darker / stronger colors), and for GB/GBC/GBA, it will mean simulating the weird brightness levels of the displays. I am undecided on whether to use pea soup green for the GB or not. By not doing so, it'll be easier for the display emulation shader to do it.
This commit is contained in:
@@ -63,6 +63,7 @@ void string::reset() {
|
||||
|
||||
string& string::operator=(const string& source) {
|
||||
if(&source == this) return *this;
|
||||
reset();
|
||||
_data = source._data;
|
||||
_capacity = source._capacity;
|
||||
_size = source._size;
|
||||
@@ -71,6 +72,7 @@ string& string::operator=(const string& source) {
|
||||
|
||||
string& string::operator=(string&& source) {
|
||||
if(&source == this) return *this;
|
||||
reset();
|
||||
_data = std::move(source._data);
|
||||
_capacity = source._capacity;
|
||||
_size = source._size;
|
||||
@@ -80,17 +82,21 @@ string& string::operator=(string&& source) {
|
||||
}
|
||||
|
||||
template<typename T, typename... Args> string::string(T&& source, Args&&... args) {
|
||||
_capacity = 0;
|
||||
_size = 0;
|
||||
construct();
|
||||
sprint(*this, std::forward<T>(source), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
string::string() {
|
||||
_capacity = 0;
|
||||
_size = 0;
|
||||
construct();
|
||||
}
|
||||
|
||||
string::~string() {
|
||||
reset();
|
||||
}
|
||||
|
||||
void string::construct() {
|
||||
_capacity = 0;
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -63,6 +63,7 @@ void string::reset() {
|
||||
|
||||
string& string::operator=(const string& source) {
|
||||
if(&source == this) return *this;
|
||||
reset();
|
||||
if(source._capacity >= SSO) {
|
||||
_data = (char*)malloc(source._capacity + 1);
|
||||
_capacity = source._capacity;
|
||||
@@ -78,6 +79,7 @@ string& string::operator=(const string& source) {
|
||||
|
||||
string& string::operator=(string&& source) {
|
||||
if(&source == this) return *this;
|
||||
reset();
|
||||
memcpy(this, &source, sizeof(string));
|
||||
source._data = nullptr;
|
||||
source._capacity = SSO - 1;
|
||||
@@ -86,20 +88,22 @@ string& string::operator=(string&& source) {
|
||||
}
|
||||
|
||||
template<typename T, typename... Args> string::string(T&& source, Args&&... args) {
|
||||
_data = nullptr;
|
||||
_capacity = SSO - 1;
|
||||
_size = 0;
|
||||
construct();
|
||||
sprint(*this, std::forward<T>(source), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
string::string() {
|
||||
_data = nullptr;
|
||||
_capacity = SSO - 1;
|
||||
_size = 0;
|
||||
construct();
|
||||
}
|
||||
|
||||
string::~string() {
|
||||
if(_capacity >= SSO) free(_data);
|
||||
reset();
|
||||
}
|
||||
|
||||
void string::construct() {
|
||||
_data = nullptr;
|
||||
_capacity = SSO - 1;
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ void string::reset() {
|
||||
|
||||
string& string::operator=(const string& source) {
|
||||
if(&source == this) return *this;
|
||||
reset();
|
||||
_data = (char*)malloc(source._size + 1);
|
||||
_capacity = source._size;
|
||||
_size = source._size;
|
||||
@@ -59,6 +60,7 @@ string& string::operator=(const string& source) {
|
||||
|
||||
string& string::operator=(string&& source) {
|
||||
if(&source == this) return *this;
|
||||
reset();
|
||||
_data = source._data;
|
||||
_capacity = source._capacity;
|
||||
_size = source._size;
|
||||
@@ -69,20 +71,22 @@ string& string::operator=(string&& source) {
|
||||
}
|
||||
|
||||
template<typename T, typename... Args> string::string(T&& source, Args&&... args) {
|
||||
_data = nullptr;
|
||||
_capacity = 0;
|
||||
_size = 0;
|
||||
construct();
|
||||
sprint(*this, std::forward<T>(source), std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
string::string() {
|
||||
_data = nullptr;
|
||||
_capacity = 0;
|
||||
_size = 0;
|
||||
construct();
|
||||
}
|
||||
|
||||
string::~string() {
|
||||
if(_data) free(_data);
|
||||
reset();
|
||||
}
|
||||
|
||||
void string::construct() {
|
||||
_data = nullptr;
|
||||
_capacity = 0;
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -144,6 +144,9 @@ public:
|
||||
template<unsigned Limit, bool Insensitive, bool Quoted> inline string& ureplace(rstring, rstring);
|
||||
inline string& _append(const char*);
|
||||
|
||||
private:
|
||||
inline void construct();
|
||||
|
||||
#if defined(QSTRING_H)
|
||||
public:
|
||||
inline operator QString() const;
|
||||
@@ -154,7 +157,6 @@ public:
|
||||
struct lstring : vector<string> {
|
||||
inline optional<unsigned> find(rstring) const;
|
||||
inline string merge(const string&) const;
|
||||
inline string concatenate(const string&) const; //deprecated
|
||||
inline lstring& isort();
|
||||
inline lstring& strip();
|
||||
inline void append() {}
|
||||
@@ -188,6 +190,7 @@ inline string notdir(string name);
|
||||
inline string parentdir(string name);
|
||||
inline string basename(string name);
|
||||
inline string extension(string name);
|
||||
inline string tempname();
|
||||
|
||||
//format.hpp
|
||||
template<signed precision = 0, char padchar = ' '> inline string format(const string& value);
|
||||
|
@@ -62,6 +62,7 @@ inline void utf8_write(char* s, const UTF8& utf8);
|
||||
template<bool Insensitive> alwaysinline bool chrequal(char x, char y);
|
||||
template<bool Quoted, typename T> alwaysinline bool quoteskip(T*& p);
|
||||
template<bool Quoted, typename T> alwaysinline bool quotecopy(char*& t, T*& p);
|
||||
inline char* strduplicate(const char* s);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -11,29 +11,40 @@ bool chrequal(char x, char y) {
|
||||
template<bool Quoted, typename T>
|
||||
bool quoteskip(T*& p) {
|
||||
if(Quoted == false) return false;
|
||||
if(*p != '\'' && *p != '\"') return false;
|
||||
if(*p != '\"') return false;
|
||||
|
||||
while(*p == '\'' || *p == '\"') {
|
||||
while(*p == '\"') {
|
||||
char x = *p++;
|
||||
while(*p && *p++ != x);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<bool Quoted, typename T>
|
||||
bool quotecopy(char*& t, T*& p) {
|
||||
if(Quoted == false) return false;
|
||||
if(*p != '\'' && *p != '\"') return false;
|
||||
if(*p != '\"') return false;
|
||||
|
||||
while(*p == '\'' || *p == '\"') {
|
||||
while(*p == '\"') {
|
||||
char x = *p++;
|
||||
*t++ = x;
|
||||
while(*p && *p != x) *t++ = *p++;
|
||||
*t++ = *p++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//strdup() is not a standard function, so recreate it
|
||||
char* strduplicate(const char* s) {
|
||||
if(s == nullptr) return nullptr;
|
||||
unsigned length = strlen(s);
|
||||
char* result = (char*)malloc(length + 1);
|
||||
strcpy(result, s);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -75,10 +75,12 @@ bool string::operator> (const char* str) const { return strcmp(data(), str) > 0
|
||||
bool string::operator>=(const char* str) const { return strcmp(data(), str) >= 0; }
|
||||
|
||||
string::string(const string& source) {
|
||||
construct();
|
||||
operator=(source);
|
||||
}
|
||||
|
||||
string::string(string&& source) {
|
||||
construct();
|
||||
operator=(std::move(source));
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ inline string literalNumber(const char*& s) {
|
||||
if(p[0] == '%' || (p[0] == '0' && p[1] == 'b')) {
|
||||
unsigned prefix = 1 + (p[0] == '0');
|
||||
p += prefix;
|
||||
while(p[0] == '0' || p[0] == '1') p++;
|
||||
while(p[0] == '\'' || p[0] == '0' || p[0] == '1') p++;
|
||||
if(p - s <= prefix) throw "invalid binary literal";
|
||||
string result = substr(s, 0, p - s);
|
||||
s = p;
|
||||
@@ -30,7 +30,7 @@ inline string literalNumber(const char*& s) {
|
||||
if(p[0] == '0' && p[1] == 'o') {
|
||||
unsigned prefix = 1 + (p[0] == '0');
|
||||
p += prefix;
|
||||
while(p[0] >= '0' && p[0] <= '7') p++;
|
||||
while(p[0] == '\'' || (p[0] >= '0' && p[0] <= '7')) p++;
|
||||
if(p - s <= prefix) throw "invalid octal literal";
|
||||
string result = substr(s, 0, p - s);
|
||||
s = p;
|
||||
@@ -41,7 +41,7 @@ inline string literalNumber(const char*& s) {
|
||||
if(p[0] == '$' || (p[0] == '0' && p[1] == 'x')) {
|
||||
unsigned prefix = 1 + (p[0] == '0');
|
||||
p += prefix;
|
||||
while((p[0] >= '0' && p[0] <= '9') || (p[0] >= 'A' && p[0] <= 'F') || (p[0] >= 'a' && p[0] <= 'f')) p++;
|
||||
while(p[0] == '\'' || (p[0] >= '0' && p[0] <= '9') || (p[0] >= 'A' && p[0] <= 'F') || (p[0] >= 'a' && p[0] <= 'f')) p++;
|
||||
if(p - s <= prefix) throw "invalid hex literal";
|
||||
string result = substr(s, 0, p - s);
|
||||
s = p;
|
||||
@@ -49,7 +49,7 @@ inline string literalNumber(const char*& s) {
|
||||
}
|
||||
|
||||
//decimal
|
||||
while(p[0] >= '0' && p[0] <= '9') p++;
|
||||
while(p[0] == '\'' || (p[0] >= '0' && p[0] <= '9')) p++;
|
||||
if(p[0] != '.') {
|
||||
string result = substr(s, 0, p - s);
|
||||
s = p;
|
||||
@@ -58,7 +58,7 @@ inline string literalNumber(const char*& s) {
|
||||
|
||||
//floating-point
|
||||
p++;
|
||||
while(p[0] >= '0' && p[0] <= '9') p++;
|
||||
while(p[0] == '\'' || (p[0] >= '0' && p[0] <= '9')) p++;
|
||||
string result = substr(s, 0, p - s);
|
||||
s = p;
|
||||
return result;
|
||||
|
@@ -69,6 +69,16 @@ string extension(string name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
string tempname() {
|
||||
string path = temppath();
|
||||
srand(time(nullptr));
|
||||
while(true) {
|
||||
uint32_t seed = rand();
|
||||
string filename = {path, ".temporary-", hex<8>(seed)};
|
||||
if(access(filename, F_OK) != 0) return filename;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -18,11 +18,6 @@ string lstring::merge(const string& separator) const {
|
||||
return output;
|
||||
}
|
||||
|
||||
//deprecated: alias to merge()
|
||||
string lstring::concatenate(const string& separator) const {
|
||||
return merge(separator);
|
||||
}
|
||||
|
||||
lstring& lstring::isort() {
|
||||
nall::sort(pool, objectsize, [](const string& x, const string& y) {
|
||||
return istrcmp(x, y) < 0;
|
||||
|
@@ -115,7 +115,7 @@ struct Node {
|
||||
|
||||
if(path.size() == 0) result.append(node);
|
||||
else {
|
||||
auto list = node.find(path.concatenate("/"));
|
||||
auto list = node.find(path.merge("/"));
|
||||
for(auto& item : list) result.append(item);
|
||||
}
|
||||
}
|
||||
|
@@ -3,33 +3,22 @@
|
||||
namespace nall {
|
||||
|
||||
string activepath() {
|
||||
string result;
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
wchar_t path[PATH_MAX] = L"";
|
||||
auto unused = _wgetcwd(path, PATH_MAX);
|
||||
result = (const char*)utf8_t(path);
|
||||
result.transform("\\", "/");
|
||||
#else
|
||||
char path[PATH_MAX] = "";
|
||||
auto unused = getcwd(path, PATH_MAX);
|
||||
result = path;
|
||||
#endif
|
||||
string result = path;
|
||||
if(result.empty()) result = ".";
|
||||
result.transform("\\", "/");
|
||||
if(result.endswith("/") == false) result.append("/");
|
||||
return result;
|
||||
}
|
||||
|
||||
string realpath(const string& name) {
|
||||
string result;
|
||||
#if defined(PLATFORM_WINDOWS)
|
||||
wchar_t path[PATH_MAX] = L"";
|
||||
if(_wfullpath(path, utf16_t(name), PATH_MAX)) result = (const char*)utf8_t(path);
|
||||
result.transform("\\", "/");
|
||||
#else
|
||||
char path[PATH_MAX] = "";
|
||||
if(::realpath(name, path)) result = path;
|
||||
#endif
|
||||
if(result.empty()) result = {activepath(), name};
|
||||
result.transform("\\", "/");
|
||||
if(result.endswith("/") == false) result.append("/");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ string& string::ureplace(rstring key, rstring token) {
|
||||
signed displacementSize = displacement * counter;
|
||||
|
||||
if(token.size() > key.size()) {
|
||||
t = base = strdup(data());
|
||||
t = base = strduplicate(data());
|
||||
reserve((unsigned)(p - data()) + displacementSize);
|
||||
}
|
||||
char* o = data();
|
||||
|
Reference in New Issue
Block a user