mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-24 23:22:25 +01:00
byuu says: This will easily be the biggest diff in the history of higan. And not in a good way. * target-higan and target-loki have been blown away completely * nall and ruby massively updated * phoenix replaced with hiro (pretty near a total rewrite) * target-higan restarted using hiro (just a window for now) * all emulation cores updated to compile again * installation changed to not require root privileges (installs locally) For the foreseeable future (maybe even permanently?), the new higan UI will only build under Linux/BSD with GTK+ 2.20+. Probably the most likely route for Windows/OS X will be to try and figure out how to build hiro/GTK on those platforms, as awful as that would be. The other alternative would be to produce new UIs for those platforms ... which would actually be a good opportunity to make something much more user friendly. Being that I just started on this a few hours ago, that means that for at least a few weeks, don't expect to be able to actually play any games. Right now, you can pretty much just compile the binary and that's it. It's quite possible that some nall changes didn't produce compilation errors, but will produce runtime errors. So until the UI can actually load games, we won't know if anything is broken. But we should mostly be okay. It was mostly just trim<1> -> trim changes, moving to Hash::SHA256 (much cleaner), and patching some reckless memory copy functions enough to compile. Progress isn't going to be like it was before: I'm now dividing my time much thinner between studying and other hobbies. My aim this time is not to produce a binary for everyone to play games on. Rather, it's to keep the emulator alive. I want to be able to apply critical patches again. And I would also like the base of the emulator to live on, for use in other emulator frontends that utilize higan.
224 lines
6.9 KiB
C++
224 lines
6.9 KiB
C++
#ifdef NALL_STRING_INTERNAL_HPP
|
|
|
|
//convert any (supported) type to a const char* without constructing a new nall::string
|
|
//this is used inside string{...} to build nall::string values
|
|
|
|
namespace nall {
|
|
|
|
//base types
|
|
|
|
template<> struct stringify<bool> {
|
|
bool _value;
|
|
auto data() const -> const char* { return _value ? "true" : "false"; }
|
|
auto size() const -> unsigned { return _value ? 4 : 5; }
|
|
stringify(bool value) : _value(value) {}
|
|
};
|
|
|
|
template<> struct stringify<char> {
|
|
char _data[2];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return 1; }
|
|
stringify(char source) { _data[0] = source; _data[1] = 0; }
|
|
};
|
|
|
|
//signed integers
|
|
|
|
template<> struct stringify<signed char> {
|
|
char _data[2 + sizeof(signed char) * 3];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(signed char source) { integer(_data, source); }
|
|
};
|
|
|
|
template<> struct stringify<signed short> {
|
|
char _data[2 + sizeof(signed short) * 3];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(signed short source) { integer(_data, source); }
|
|
};
|
|
|
|
template<> struct stringify<signed int> {
|
|
char _data[2 + sizeof(signed int) * 3];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(signed int source) { integer(_data, source); }
|
|
};
|
|
|
|
template<> struct stringify<signed long> {
|
|
char _data[2 + sizeof(signed long) * 3];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(signed long source) { integer(_data, source); }
|
|
};
|
|
|
|
template<> struct stringify<signed long long> {
|
|
char _data[2 + sizeof(signed long long) * 3];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(signed long long source) { integer(_data, source); }
|
|
};
|
|
|
|
template<unsigned bits> struct stringify<int_t<bits>> {
|
|
char _data[2 + sizeof(intmax_t) * 3];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(int_t<bits> source) { integer(_data, source); }
|
|
};
|
|
|
|
//unsigned integers
|
|
|
|
template<> struct stringify<unsigned char> {
|
|
char _data[1 + sizeof(unsigned char) * 3];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(unsigned char source) { decimal(_data, source); }
|
|
};
|
|
|
|
template<> struct stringify<unsigned short> {
|
|
char _data[1 + sizeof(unsigned short) * 3];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(unsigned short source) { decimal(_data, source); }
|
|
};
|
|
|
|
template<> struct stringify<unsigned int> {
|
|
char _data[1 + sizeof(unsigned int) * 3];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(unsigned int source) { decimal(_data, source); }
|
|
};
|
|
|
|
template<> struct stringify<unsigned long> {
|
|
char _data[1 + sizeof(unsigned long) * 3];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(unsigned long source) { decimal(_data, source); }
|
|
};
|
|
|
|
template<> struct stringify<unsigned long long> {
|
|
char _data[1 + sizeof(unsigned long long) * 3];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(unsigned long long source) { decimal(_data, source); }
|
|
};
|
|
|
|
template<unsigned bits> struct stringify<uint_t<bits>> {
|
|
char _data[1 + sizeof(uintmax_t) * 3];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(uint_t<bits> source) { decimal(_data, source); }
|
|
};
|
|
|
|
//floating-point
|
|
|
|
template<> struct stringify<float> {
|
|
char _data[256];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(float source) { real(_data, source); }
|
|
};
|
|
|
|
template<> struct stringify<double> {
|
|
char _data[256];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(double source) { real(_data, source); }
|
|
};
|
|
|
|
template<> struct stringify<long double> {
|
|
char _data[256];
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(long double source) { real(_data, source); }
|
|
};
|
|
|
|
//arrays
|
|
|
|
template<> struct stringify<vector<uint8_t>> {
|
|
vector<char> _text;
|
|
auto data() const -> const char* { return _text.data(); }
|
|
auto size() const -> unsigned { return _text.size(); }
|
|
stringify(vector<uint8_t> source) {
|
|
_text.resize(source.size() + 1);
|
|
memory::copy(_text.data(), source.data(), source.size());
|
|
_text[_text.size()] = 0;
|
|
}
|
|
};
|
|
|
|
template<> struct stringify<const vector<uint8_t>&> {
|
|
vector<char> _text;
|
|
auto data() const -> const char* { return _text.data(); }
|
|
auto size() const -> unsigned { return _text.size(); }
|
|
stringify(const vector<uint8_t>& source) {
|
|
_text.resize(source.size() + 1);
|
|
memory::copy(_text.data(), source.data(), source.size());
|
|
_text[_text.size()] = 0;
|
|
}
|
|
};
|
|
|
|
//char arrays
|
|
|
|
template<> struct stringify<char*> {
|
|
const char* _data;
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(char* source) : _data(source) {}
|
|
};
|
|
|
|
template<> struct stringify<const char*> {
|
|
const char* _data;
|
|
auto data() const -> const char* { return _data; }
|
|
auto size() const -> unsigned { return strlen(_data); }
|
|
stringify(const char* source) : _data(source) {}
|
|
};
|
|
|
|
//strings
|
|
|
|
template<> struct stringify<string> {
|
|
const string& _text;
|
|
auto data() const -> const char* { return _text.data(); }
|
|
auto size() const -> unsigned { return _text.size(); }
|
|
stringify(const string& source) : _text(source) {}
|
|
};
|
|
|
|
template<> struct stringify<const string&> {
|
|
const string& _text;
|
|
auto data() const -> const char* { return _text.data(); }
|
|
auto size() const -> unsigned { return _text.size(); }
|
|
stringify(const string& source) : _text(source) {}
|
|
};
|
|
|
|
#if defined(QSTRING_H)
|
|
|
|
//Qt
|
|
|
|
template<> struct stringify<QString> {
|
|
const QString& _text;
|
|
auto data() const -> const char* { return _text.toUtf8().constData(); }
|
|
auto size() const -> unsigned { return _text.size(); }
|
|
stringify(const QString& source) : _text(source) {}
|
|
};
|
|
|
|
template<> struct stringify<const QString&> {
|
|
const QString& _text;
|
|
auto data() const -> const char* { return _text.toUtf8().constData(); }
|
|
auto size() const -> unsigned { return _text.size(); }
|
|
stringify(const QString& source) : _text(source) {}
|
|
};
|
|
|
|
string::operator QString() const {
|
|
return QString::fromUtf8(*this);
|
|
}
|
|
|
|
#endif
|
|
|
|
//
|
|
|
|
template<typename T> auto make_string(T value) -> stringify<T> {
|
|
return stringify<T>(std::forward<T>(value));
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|