mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
Instead of the new_intrusive<T>() functions, use intrusive(new T)
This means we no longer need 8 different functions for different numbers of arguments, and non-const references can now also be passed to constructors without problems. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1443 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -212,16 +212,16 @@ InputStreamP Package::openIn(const String& file) {
|
||||
InputStreamP stream;
|
||||
if (it->second.wasWritten()) {
|
||||
// written to this file, open the temp file
|
||||
stream = new_shared1<BufferedFileInputStream>(it->second.tempName);
|
||||
stream = shared(new BufferedFileInputStream(it->second.tempName));
|
||||
} else if (wxFileExists(filename+_("/")+file)) {
|
||||
// a file in directory package
|
||||
stream = new_shared1<BufferedFileInputStream>(filename+_("/")+file);
|
||||
stream = shared(new BufferedFileInputStream(filename+_("/")+file));
|
||||
} else if (wxFileExists(filename) && it->second.zipEntry) {
|
||||
// a file in a zip archive
|
||||
// somebody in wx thought seeking was no longer needed, it now only works with the 'compatability constructor'
|
||||
stream = new_shared2<wxZipInputStream>(filename, it->second.zipEntry->GetInternalName());
|
||||
stream = shared(new wxZipInputStream(filename, it->second.zipEntry->GetInternalName()));
|
||||
//stream = static_pointer_cast<wxZipInputStream>(
|
||||
// new_shared2<ZipFileInputStream>(filename, it->second.zipEntry));
|
||||
// shared(new ZipFileInputStream(filename, it->second.zipEntry)));
|
||||
} else {
|
||||
// shouldn't happen, packaged changed by someone else since opening it
|
||||
throw FileNotFoundError(file, filename);
|
||||
@@ -234,7 +234,7 @@ InputStreamP Package::openIn(const String& file) {
|
||||
}
|
||||
|
||||
OutputStreamP Package::openOut(const String& file) {
|
||||
return new_shared1<wxFileOutputStream>(nameOut(file));
|
||||
return shared(new wxFileOutputStream(nameOut(file)));
|
||||
}
|
||||
|
||||
String Package::nameOut(const String& file) {
|
||||
@@ -308,7 +308,7 @@ InputStreamP Package::openAbsoluteFile(const String& name) {
|
||||
size_t pos = name.find_first_of(_('\1'));
|
||||
if (pos == String::npos) {
|
||||
// temp or dir file
|
||||
shared_ptr<wxFileInputStream> f = new_shared1<wxFileInputStream>(name);
|
||||
shared_ptr<wxFileInputStream> f = shared(new wxFileInputStream(name));
|
||||
if (!f->IsOk()) throw FileNotFoundError(_("<unknown>"), name);
|
||||
return f;
|
||||
} else {
|
||||
|
||||
@@ -138,7 +138,7 @@ class Package : public IntrusivePtrVirtualBase {
|
||||
|
||||
protected:
|
||||
// TODO: I dislike putting this here very much. There ought to be a better way.
|
||||
virtual VCSP getVCS() { return new_intrusive<VCS>(); }
|
||||
virtual VCSP getVCS() { return intrusive(new VCS()); }
|
||||
|
||||
/// true if this is a zip file, false if a directory (updated on open/save)
|
||||
bool isZipfile() { return zipfile; }
|
||||
|
||||
@@ -65,12 +65,12 @@ PackagedP PackageManager::openAny(const String& name_, bool just_header) {
|
||||
if (!p) {
|
||||
// load with the right type, based on extension
|
||||
wxFileName fn(filename);
|
||||
if (fn.GetExt() == _("mse-game")) p = new_intrusive<Game>();
|
||||
else if (fn.GetExt() == _("mse-style")) p = new_intrusive<StyleSheet>();
|
||||
else if (fn.GetExt() == _("mse-locale")) p = new_intrusive<Locale>();
|
||||
else if (fn.GetExt() == _("mse-include")) p = new_intrusive<IncludePackage>();
|
||||
else if (fn.GetExt() == _("mse-symbol-font")) p = new_intrusive<SymbolFont>();
|
||||
else if (fn.GetExt() == _("mse-export-template")) p = new_intrusive<ExportTemplate>();
|
||||
if (fn.GetExt() == _("mse-game")) p = intrusive(new Game);
|
||||
else if (fn.GetExt() == _("mse-style")) p = intrusive(new StyleSheet);
|
||||
else if (fn.GetExt() == _("mse-locale")) p = intrusive(new Locale);
|
||||
else if (fn.GetExt() == _("mse-include")) p = intrusive(new IncludePackage);
|
||||
else if (fn.GetExt() == _("mse-symbol-font")) p = intrusive(new SymbolFont);
|
||||
else if (fn.GetExt() == _("mse-export-template")) p = intrusive(new ExportTemplate);
|
||||
else {
|
||||
throw PackageError(_("Unrecognized package type: '") + fn.GetExt() + _("'\nwhile trying to open: ") + name);
|
||||
}
|
||||
@@ -273,7 +273,7 @@ void PackageDirectory::installedPackages(vector<InstallablePackageP>& packages_o
|
||||
PackageVersionP ver(new PackageVersion(
|
||||
is_local ? PackageVersion::STATUS_LOCAL : PackageVersion::STATUS_GLOBAL));
|
||||
ver->check_status(*pack);
|
||||
packages_out.push_back(new_intrusive2<InstallablePackage>(new_intrusive1<PackageDescription>(*pack), ver));
|
||||
packages_out.push_back(intrusive(new InstallablePackage(intrusive(new PackageDescription(*pack)), ver)));
|
||||
} catch (const Error&) {}
|
||||
++it2;
|
||||
} else if ((*it1)->name < *it2) {
|
||||
@@ -285,7 +285,7 @@ void PackageDirectory::installedPackages(vector<InstallablePackageP>& packages_o
|
||||
try {
|
||||
PackagedP pack = package_manager.openAny(*it2, true);
|
||||
(*it1)->check_status(*pack);
|
||||
packages_out.push_back(new_intrusive2<InstallablePackage>(new_intrusive1<PackageDescription>(*pack), *it1));
|
||||
packages_out.push_back(intrusive(new InstallablePackage(intrusive(new PackageDescription(*pack)), *it1)));
|
||||
} catch (const Error&) { db_changed = true; }
|
||||
++it1, ++it2;
|
||||
}
|
||||
@@ -339,7 +339,7 @@ void PackageDirectory::loadDatabase() {
|
||||
String filename = databaseFile();
|
||||
if (wxFileExists(filename)) {
|
||||
// packages file not existing is not an error
|
||||
shared_ptr<wxFileInputStream> file = new_shared1<wxFileInputStream>(filename);
|
||||
shared_ptr<wxFileInputStream> file = shared(new wxFileInputStream(filename));
|
||||
if (!file->Ok()) return; // failure is not an error
|
||||
Reader reader(file, nullptr, filename);
|
||||
reader.handle_greedy(*this);
|
||||
@@ -348,7 +348,7 @@ void PackageDirectory::loadDatabase() {
|
||||
}
|
||||
|
||||
void PackageDirectory::saveDatabase() {
|
||||
Writer writer(new_shared1<wxFileOutputStream>(databaseFile()), app_version);
|
||||
Writer writer(shared(new wxFileOutputStream(databaseFile())), app_version);
|
||||
writer.handle(*this);
|
||||
}
|
||||
String PackageDirectory::databaseFile() {
|
||||
|
||||
@@ -200,7 +200,7 @@ class Reader {
|
||||
*/
|
||||
template <typename T>
|
||||
intrusive_ptr<T> read_new(Reader& reader) {
|
||||
return new_intrusive<T>();
|
||||
return intrusive(new T());
|
||||
}
|
||||
|
||||
/// Update the 'index' member of a value for use by IndexMap
|
||||
|
||||
Reference in New Issue
Block a user