diff --git a/src/cli/cli_main.cpp b/src/cli/cli_main.cpp index 4e687e35..7eacbbcb 100644 --- a/src/cli/cli_main.cpp +++ b/src/cli/cli_main.cpp @@ -65,7 +65,7 @@ void CLISetInterface::setExportInfoCwd() { // write to the current directory ei.directory_relative = ei.directory_absolute = wxGetCwd(); // read from the current directory - ei.export_template = intrusive(new Package()); + ei.export_template = make_intrusive(); ei.export_template->open(ei.directory_absolute, true); } diff --git a/src/data/action/keyword.cpp b/src/data/action/keyword.cpp index 8187c313..db805405 100644 --- a/src/data/action/keyword.cpp +++ b/src/data/action/keyword.cpp @@ -21,7 +21,7 @@ DECLARE_TYPEOF_COLLECTION(KeywordModeP); AddKeywordAction::AddKeywordAction(Set& set) : KeywordListAction(set) - , action(ADD, intrusive(new Keyword()), set.keywords) + , action(ADD, make_intrusive(), set.keywords) { Keyword& keyword = *action.steps.front().item; // find default mode @@ -185,7 +185,7 @@ bool KeywordReminderTextValue::checkScript(const ScriptP& script) { const KeywordParam& kwp = *keyword.parameters[i]; String param_name = String(_("param")) << (int)(i+1); String param_value = _("") + (kwp.placeholder.empty() ? kwp.name : kwp.placeholder) + _(""); - ctx.setVariable(param_name, intrusive(new KeywordParamValue(kwp.name, _(""), _(""), param_value))); + ctx.setVariable(param_name, make_intrusive(kwp.name, _(""), _(""), param_value)); } script->eval(ctx); errors.clear(); diff --git a/src/data/action/set.cpp b/src/data/action/set.cpp index 07af2a50..39317673 100644 --- a/src/data/action/set.cpp +++ b/src/data/action/set.cpp @@ -23,7 +23,7 @@ DECLARE_TYPEOF_COLLECTION(int); AddCardAction::AddCardAction(Set& set) : CardListAction(set) - , action(ADD, intrusive(new Card(*set.game)), set.cards) + , action(ADD, make_intrusive(*set.game), set.cards) {} AddCardAction::AddCardAction(AddingOrRemoving ar, Set& set, const CardP& card) diff --git a/src/data/action/symbol_part.cpp b/src/data/action/symbol_part.cpp index 9bfc425b..85f1d4b4 100644 --- a/src/data/action/symbol_part.cpp +++ b/src/data/action/symbol_part.cpp @@ -398,7 +398,7 @@ ControlPointRemoveAction::ControlPointRemoveAction(const SymbolShapeP& shape, co FOR_EACH(point, shape->points) { if (to_delete.find(point) != to_delete.end()) { // remove this point - removals.push_back(intrusive(new SinglePointRemoveAction(shape, index))); + removals.push_back(make_intrusive(shape, index)); } ++index; } @@ -422,7 +422,7 @@ void ControlPointRemoveAction::perform(bool to_undo) { Action* control_point_remove_action(const SymbolShapeP& shape, const set& to_delete) { if (shape->points.size() - to_delete.size() < 2) { // TODO : remove part? - //intrusive(new ControlPointRemoveAllAction(part)); + //make_intrusive(part); return 0; // no action } else { return new ControlPointRemoveAction(shape, to_delete); diff --git a/src/data/add_cards_script.cpp b/src/data/add_cards_script.cpp index 8612a409..9099d833 100644 --- a/src/data/add_cards_script.cpp +++ b/src/data/add_cards_script.cpp @@ -34,7 +34,7 @@ void AddCardsScript::perform(Set& set, vector& out) { // is this a new card? if (contains(set.cards,card) || contains(out,card)) { // make copy - card = intrusive(new Card(*card)); + card = make_intrusive(*card); } out.push_back(card); } diff --git a/src/data/field.cpp b/src/data/field.cpp index 3facdfcc..2c5c885f 100644 --- a/src/data/field.cpp +++ b/src/data/field.cpp @@ -76,15 +76,15 @@ intrusive_ptr read_new(Reader& reader) { // there must be a type specified String type; reader.handle(_("type"), type); - if (type == _("text")) return intrusive(new TextField()); - else if (type == _("choice")) return intrusive(new ChoiceField()); - else if (type == _("multiple choice")) return intrusive(new MultipleChoiceField()); - else if (type == _("boolean")) return intrusive(new BooleanField()); - else if (type == _("image")) return intrusive(new ImageField()); - else if (type == _("symbol")) return intrusive(new SymbolField()); - else if (type == _("color")) return intrusive(new ColorField()); - else if (type == _("info")) return intrusive(new InfoField()); - else if (type == _("package choice")) return intrusive(new PackageChoiceField()); + if (type == _("text")) return make_intrusive(); + else if (type == _("choice")) return make_intrusive(); + else if (type == _("multiple choice")) return make_intrusive(); + else if (type == _("boolean")) return make_intrusive(); + else if (type == _("image")) return make_intrusive(); + else if (type == _("symbol")) return make_intrusive(); + else if (type == _("color")) return make_intrusive(); + else if (type == _("info")) return make_intrusive(); + else if (type == _("package choice")) return make_intrusive(); else if (type.empty()) { reader.warning(_ERROR_1_("expected key", _("type"))); throw ParseError(_ERROR_("aborting parsing")); diff --git a/src/data/field.hpp b/src/data/field.hpp index 5ec5a826..e77255ad 100644 --- a/src/data/field.hpp +++ b/src/data/field.hpp @@ -265,23 +265,23 @@ inline String type_name(const Value&) { virtual String typeName() const // implement newStyle and newValue -#define IMPLEMENT_FIELD_TYPE(Type, NAME) \ - StyleP Type ## Field::newStyle(const FieldP& thisP) const { \ - assert(thisP.get() == this); \ - return intrusive(new Type ## Style(static_pointer_cast(thisP))); \ - } \ - ValueP Type ## Field::newValue(const FieldP& thisP) const { \ - assert(thisP.get() == this); \ - return intrusive(new Type ## Value(static_pointer_cast(thisP))); \ - } \ - StyleP Type ## Style::clone() const { \ - return intrusive(new Type ## Style(*this)); \ - } \ - ValueP Type ## Value::clone() const { \ - return intrusive(new Type ## Value(*this)); \ - } \ - String Type ## Field::typeName() const { \ - return _(NAME); \ +#define IMPLEMENT_FIELD_TYPE(Type, NAME) \ + StyleP Type ## Field::newStyle(const FieldP& thisP) const { \ + assert(thisP.get() == this); \ + return make_intrusive(static_pointer_cast(thisP)); \ + } \ + ValueP Type ## Field::newValue(const FieldP& thisP) const { \ + assert(thisP.get() == this); \ + return make_intrusive(static_pointer_cast(thisP)); \ + } \ + StyleP Type ## Style::clone() const { \ + return make_intrusive(*this); \ + } \ + ValueP Type ## Value::clone() const { \ + return make_intrusive(*this); \ + } \ + String Type ## Field::typeName() const { \ + return _(NAME); \ } #define DECLARE_STYLE_TYPE(Type) \ diff --git a/src/data/field/boolean.cpp b/src/data/field/boolean.cpp index a95ef768..aed4b26d 100644 --- a/src/data/field/boolean.cpp +++ b/src/data/field/boolean.cpp @@ -12,8 +12,8 @@ // ----------------------------------------------------------------------------- : BooleanField BooleanField::BooleanField() { - choices->choices.push_back(intrusive(new Choice(_("yes")))); - choices->choices.push_back(intrusive(new Choice(_("no")))); + choices->choices.push_back(make_intrusive(_("yes"))); + choices->choices.push_back(make_intrusive(_("no"))); choices->initIds(); } @@ -32,10 +32,8 @@ BooleanStyle::BooleanStyle(const ChoiceFieldP& field) : ChoiceStyle(field) { render_style = RENDER_BOTH; - //choice_images[_("yes")] = ScriptableImage(_("buildin_image(\"bool_yes\")")); - //choice_images[_("no")] = ScriptableImage(_("buildin_image(\"bool_no\")")); - choice_images[_("yes")] = ScriptableImage(intrusive(new BuiltInImage(_("bool_yes")))); - choice_images[_("no")] = ScriptableImage(intrusive(new BuiltInImage(_("bool_no")))); + choice_images[_("yes")] = ScriptableImage(make_intrusive(_("bool_yes"))); + choice_images[_("no")] = ScriptableImage(make_intrusive(_("bool_no"))); } IMPLEMENT_REFLECTION(BooleanStyle) { diff --git a/src/data/field/image.cpp b/src/data/field/image.cpp index fb9fa0fe..7f291b79 100644 --- a/src/data/field/image.cpp +++ b/src/data/field/image.cpp @@ -48,5 +48,5 @@ void ImageValue::reflect(Writer& tag) { void ImageValue::reflect(GetMember& tag) {} void ImageValue::reflect(GetDefaultMember& tag) { // convert to ScriptImageP for scripting - tag.handle( (ScriptValueP)intrusive(new ImageValueToImage(filename, last_update)) ); + tag.handle( (ScriptValueP)make_intrusive(filename, last_update) ); } diff --git a/src/data/format/apprentice.cpp b/src/data/format/apprentice.cpp index 15ad2c2c..cb3962c3 100644 --- a/src/data/format/apprentice.cpp +++ b/src/data/format/apprentice.cpp @@ -538,7 +538,7 @@ void ApprCardDatabase::doRead(wxInputStream& in) { progress_target->onProgress(0.4f * float(i) / cards.size(), String(_("reading card ")) << i << _(" of ") << (int)cards.size()); } - card = intrusive(new ApprCardRecord()); + card = make_intrusive(); card->readHead(data); head_pos = in.TellI(); in.SeekI(card->data_pos); @@ -753,7 +753,7 @@ bool ApprenticeExportWindow::exportSet() { cardlist.removeSet(set->apprentice_code); // add cards from set FOR_EACH(card, set->cards) { - ApprCardRecordP rec = intrusive(new ApprCardRecord(*card, set->apprentice_code)); + ApprCardRecordP rec = make_intrusive(*card, set->apprentice_code); cardlist.cards.push_back(rec); } cardlist.write(); diff --git a/src/data/format/formats.cpp b/src/data/format/formats.cpp index ce1dfe40..68eebe45 100644 --- a/src/data/format/formats.cpp +++ b/src/data/format/formats.cpp @@ -10,9 +10,6 @@ #include #include -DECLARE_POINTER_TYPE(FileFormat); -DECLARE_TYPEOF_COLLECTION(FileFormatP); - // ----------------------------------------------------------------------------- : Formats // All supported file formats @@ -49,11 +46,11 @@ String export_formats(const Game& game) { } void export_set(Set& set, const String& filename, size_t format_index, bool is_copy) { - FileFormatP format = file_formats.at(format_index); - if (!format->canExport(*set.game)) { + FileFormat& format = *file_formats.at(format_index); + if (!format.canExport(*set.game)) { throw InternalError(_("File format doesn't apply to set")); } - format->exportSet(set, filename, is_copy); + format.exportSet(set, filename, is_copy); } SetP import_set(String name) { diff --git a/src/data/format/formats.hpp b/src/data/format/formats.hpp index 80949c4c..43fc6840 100644 --- a/src/data/format/formats.hpp +++ b/src/data/format/formats.hpp @@ -16,7 +16,6 @@ class Game; DECLARE_POINTER_TYPE(Set); DECLARE_POINTER_TYPE(Card); -DECLARE_POINTER_TYPE(FileFormat); // ----------------------------------------------------------------------------- : FileFormat @@ -47,6 +46,8 @@ class FileFormat : public IntrusivePtrVirtualBase { } }; +using FileFormatP = unique_ptr; + // ----------------------------------------------------------------------------- : Formats /// Initialize the list of file formats diff --git a/src/data/format/image_to_symbol.cpp b/src/data/format/image_to_symbol.cpp index 08f8247b..05e2c18b 100644 --- a/src/data/format/image_to_symbol.cpp +++ b/src/data/format/image_to_symbol.cpp @@ -187,10 +187,10 @@ SymbolShapeP read_symbol_shape(const ImageData& data) { } // add to shape and place a mark - shape->points.push_back(intrusive(new ControlPoint( + shape->points.push_back(make_intrusive( double(x) / data.width, double(y) / data.height - ))); + )); if (x > old_x) data(old_x, y) |= MARKED; // mark when moving right -> only mark the top of the shape last_move = (x + y) - (old_x + old_y); old_x = x; diff --git a/src/data/format/mse1.cpp b/src/data/format/mse1.cpp index 45209a28..38435a8a 100644 --- a/src/data/format/mse1.cpp +++ b/src/data/format/mse1.cpp @@ -30,7 +30,7 @@ class MSE1FileFormat : public FileFormat { }; FileFormatP mse1_file_format() { - return intrusive(new MSE1FileFormat()); + return make_unique(); } // ----------------------------------------------------------------------------- : Importing diff --git a/src/data/format/mse2.cpp b/src/data/format/mse2.cpp index 5e07cb2a..2d2e3f8d 100644 --- a/src/data/format/mse2.cpp +++ b/src/data/format/mse2.cpp @@ -45,5 +45,5 @@ class MSE2FileFormat : public FileFormat { }; FileFormatP mse2_file_format() { - return intrusive(new MSE2FileFormat()); + return make_unique(); } diff --git a/src/data/format/mtg_editor.cpp b/src/data/format/mtg_editor.cpp index 89d41139..8da9ea6e 100644 --- a/src/data/format/mtg_editor.cpp +++ b/src/data/format/mtg_editor.cpp @@ -44,7 +44,7 @@ class MtgEditorFileFormat : public FileFormat { }; FileFormatP mtg_editor_file_format() { - return intrusive(new MtgEditorFileFormat()); + return make_unique(); } // ----------------------------------------------------------------------------- : Importing @@ -69,7 +69,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) { // read file while (!f.Eof()) { // read a line - if (!current_card) current_card = intrusive(new Card(*set->game)); + if (!current_card) current_card = make_intrusive(*set->game); String line = file.ReadLine(); if (line == _("#SET###########")) { // set.title target = &set->value(_("title")).value; @@ -104,7 +104,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) { set->cards.push_back(current_card); } first = false; - current_card = intrusive(new Card(*set->game)); + current_card = make_intrusive(*set->game); target = ¤t_card->value(_("name")).value; } else if (line == _("#DATE##########")) { // date // remember date for generation of illustration filename diff --git a/src/data/game.cpp b/src/data/game.cpp index 57fed495..91219100 100644 --- a/src/data/game.cpp +++ b/src/data/game.cpp @@ -73,7 +73,7 @@ void Game::validate(Version v) { vector dims; FOR_EACH(f, card_fields) { if (f->show_statistics) { - dims.push_back(intrusive(new StatsDimension(*f))); + dims.push_back(make_intrusive(*f)); } } statistics_dimensions.insert(statistics_dimensions.begin(), dims.begin(), dims.end()); // push front @@ -82,7 +82,7 @@ void Game::validate(Version v) { { vector cats; FOR_EACH(dim, statistics_dimensions) { - cats.push_back(intrusive(new StatsCategory(dim))); + cats.push_back(make_intrusive(dim)); } statistics_categories.insert(statistics_categories.begin(), cats.begin(), cats.end()); // push front } diff --git a/src/data/installer.cpp b/src/data/installer.cpp index da93981e..536304fd 100644 --- a/src/data/installer.cpp +++ b/src/data/installer.cpp @@ -105,12 +105,12 @@ void Installer::install(bool local, bool check_dependencies) { } PackagedP pack; wxString fn(wxFileName(p).GetExt()); - if (fn == _("mse-game")) pack = intrusive(new Game()); - else if (fn == _("mse-style")) pack = intrusive(new StyleSheet()); - else if (fn == _("mse-locale")) pack = intrusive(new Locale()); - else if (fn == _("mse-include")) pack = intrusive(new IncludePackage()); - else if (fn == _("mse-symbol-font")) pack = intrusive(new SymbolFont()); - else if (fn == _("mse-export-template")) pack = intrusive(new ExportTemplate()); + if (fn == _("mse-game")) pack = make_intrusive(); + else if (fn == _("mse-style")) pack = make_intrusive(); + else if (fn == _("mse-locale")) pack = make_intrusive(); + else if (fn == _("mse-include")) pack = make_intrusive(); + else if (fn == _("mse-symbol-font")) pack = make_intrusive(); + else if (fn == _("mse-export-template")) pack = make_intrusive(); else { throw PackageError(_("Unrecognized package type: '") + fn + _("'\nwhile trying to install: ") + p); } @@ -186,7 +186,7 @@ void Installer::addPackage(Packaged& package) { return; // already added } } - packages.push_back(intrusive(new PackageDescription(package))); + packages.push_back(make_intrusive(package)); // use this as a filename? if (prefered_filename.empty()) { prefered_filename = package.name() + _(".mse-installer"); @@ -387,7 +387,7 @@ void merge(InstallablePackages& list1, const InstallablePackages& list2) { void merge(InstallablePackages& installed, const DownloadableInstallerP& installer) { InstallablePackages ips; FOR_EACH(p, installer->packages) { - ips.push_back(intrusive(new InstallablePackage(p,installer))); + ips.push_back(make_intrusive(p,installer)); } sort(ips); merge(installed, ips); @@ -625,5 +625,5 @@ InstallablePackageP mse_installable_package() { mse_description->position_hint = -100; mse_description->icon = load_resource_image(_("installer_program")); //mse_description->description = _LABEL_("magic set editor package"); - return intrusive(new InstallablePackage(mse_description, mse_version)); + return make_intrusive(mse_description, mse_version); } diff --git a/src/data/locale.cpp b/src/data/locale.cpp index f9272dab..fc874220 100644 --- a/src/data/locale.cpp +++ b/src/data/locale.cpp @@ -77,7 +77,7 @@ SubLocaleP find_wildcard(map& items, const String& name) { FOR_EACH_CONST(i, items) { if (i.second && match_wildcard(i.first, name)) return i.second; } - return intrusive(new SubLocale()); // so we don't search again + return make_intrusive(); // so we don't search again } SubLocaleP find_wildcard_and_set(map& items, const String& name) { return items[name] = find_wildcard(items, name); diff --git a/src/data/set.cpp b/src/data/set.cpp index 254891b8..9baa8903 100644 --- a/src/data/set.cpp +++ b/src/data/set.cpp @@ -29,13 +29,13 @@ DECLARE_TYPEOF_NO_REV(IndexMap); // ----------------------------------------------------------------------------- : Set Set::Set() - : vcs (intrusive(new VCS())) + : vcs (make_intrusive()) , script_manager(new SetScriptManager(*this)) {} Set::Set(const GameP& game) : game(game) - , vcs (intrusive(new VCS())) + , vcs (make_intrusive()) , script_manager(new SetScriptManager(*this)) { data.init(game->set_fields); @@ -44,7 +44,7 @@ Set::Set(const GameP& game) Set::Set(const StyleSheetP& stylesheet) : game(stylesheet->game) , stylesheet(stylesheet) - , vcs (intrusive(new VCS())) + , vcs (make_intrusive()) , script_manager(new SetScriptManager(*this)) { data.init(game->set_fields); @@ -164,7 +164,7 @@ void Set::validate(Version file_app_version) { } */ } // we want at least one card - if (cards.empty()) cards.push_back(intrusive(new Card(*game))); + if (cards.empty()) cards.push_back(make_intrusive(*game)); // update scripts script_manager->updateAll(); } @@ -234,7 +234,7 @@ void Set::reflect_cards (Writer& tag) { // ----------------------------------------------------------------------------- : Script utilities ScriptValueP make_iterator(const Set& set) { - return intrusive(new ScriptCollectionIterator >(&set.cards)); + return make_intrusive>>(&set.cards); } void mark_dependency_member(const Set& set, const String& name, const Dependency& dep) { @@ -279,7 +279,7 @@ int Set::positionOfCard(const CardP& card, const ScriptValueP& order_by, const S Profiler prof(t, order_by.get(), _("init order cache")); #endif // 3. initialize order cache - order = intrusive(new OrderCache(cards, values, filter ? &keep : nullptr)); + order = make_intrusive>(cards, values, filter ? &keep : nullptr); } return order->find(card); } diff --git a/src/data/settings.cpp b/src/data/settings.cpp index 767db060..89f46f32 100644 --- a/src/data/settings.cpp +++ b/src/data/settings.cpp @@ -203,7 +203,7 @@ void Settings::addRecentFile(const String& filename) { GameSettings& Settings::gameSettingsFor(const Game& game) { GameSettingsP& gs = game_settings[game.name()]; - if (!gs) gs = intrusive(new GameSettings); + if (!gs) gs = make_intrusive(); gs->initDefaults(game); return *gs; } @@ -222,7 +222,7 @@ ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field } StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet) { StyleSheetSettingsP& ss = stylesheet_settings[stylesheet.name()]; - if (!ss) ss = intrusive(new StyleSheetSettings); + if (!ss) ss = make_intrusive(); ss->useDefault(default_stylesheet_settings); // update default settings return *ss; } @@ -295,7 +295,7 @@ void Settings::read() { String filename = settingsFile(); if (wxFileExists(filename)) { // settings file not existing is not an error - shared_ptr file = shared(new wxFileInputStream(filename)); + shared_ptr file = make_shared(filename); if (!file->Ok()) return; // failure is not an error Reader reader(file, nullptr, filename); reader.handle_greedy(*this); @@ -303,6 +303,6 @@ void Settings::read() { } void Settings::write() { - Writer writer(shared(new wxFileOutputStream(settingsFile())), app_version); + Writer writer(make_shared(settingsFile()), app_version); writer.handle(*this); } diff --git a/src/data/symbol.cpp b/src/data/symbol.cpp index 57510eab..a95e7fc0 100644 --- a/src/data/symbol.cpp +++ b/src/data/symbol.cpp @@ -139,9 +139,9 @@ SymbolPartP read_new(Reader& reader) { // there must be a type specified String type; reader.handle(_("type"), type); - if (type == _("shape") || type.empty()) return intrusive(new SymbolShape); - else if (type == _("symmetry")) return intrusive(new SymbolSymmetry); - else if (type == _("group")) return intrusive(new SymbolGroup); + if (type == _("shape") || type.empty()) return make_intrusive(); + else if (type == _("symmetry")) return make_intrusive(); + else if (type == _("group")) return make_intrusive(); else { throw ParseError(_("Unsupported symbol part type: '") + type + _("'")); } @@ -200,7 +200,7 @@ SymbolPartP SymbolShape::clone() const { SymbolShapeP part(new SymbolShape(*this)); // also clone the control points FOR_EACH(p, part->points) { - p = intrusive(new ControlPoint(*p)); + p = make_intrusive(*p); } return part; } @@ -357,18 +357,18 @@ double Symbol::aspectRatio() const { // A default symbol part, a square, moved by d SymbolShapeP default_symbol_part(double d) { - SymbolShapeP part = intrusive(new SymbolShape); - part->points.push_back(intrusive(new ControlPoint(d + .2, d + .2))); - part->points.push_back(intrusive(new ControlPoint(d + .2, d + .8))); - part->points.push_back(intrusive(new ControlPoint(d + .8, d + .8))); - part->points.push_back(intrusive(new ControlPoint(d + .8, d + .2))); + SymbolShapeP part = make_intrusive(); + part->points.push_back(make_intrusive(d + .2, d + .2)); + part->points.push_back(make_intrusive(d + .2, d + .8)); + part->points.push_back(make_intrusive(d + .8, d + .8)); + part->points.push_back(make_intrusive(d + .8, d + .2)); part->name = _("Square"); return part; } // A default symbol, a square SymbolP default_symbol() { - SymbolP symbol = intrusive(new Symbol); + auto symbol = make_intrusive(); symbol->parts.push_back(default_symbol_part(0)); return symbol; } diff --git a/src/data/word_list.hpp b/src/data/word_list.hpp index e5b3402a..d849b399 100644 --- a/src/data/word_list.hpp +++ b/src/data/word_list.hpp @@ -54,7 +54,7 @@ class AutoReplace : public IntrusivePtrVirtualBase { String match; String replace; - inline AutoReplaceP clone() const { return intrusive(new AutoReplace(*this)); } + inline AutoReplaceP clone() const { return make_intrusive(*this); } DECLARE_REFLECTION(); }; diff --git a/src/gui/auto_replace_window.cpp b/src/gui/auto_replace_window.cpp index 6610094b..440cfce6 100644 --- a/src/gui/auto_replace_window.cpp +++ b/src/gui/auto_replace_window.cpp @@ -231,7 +231,7 @@ void AutoReplaceWindow::onRemove(wxCommandEvent&) { list->removeSelected(); } void AutoReplaceWindow::onAdd(wxCommandEvent&) { - list->addItem(intrusive(new AutoReplace())); + list->addItem(make_intrusive()); } void AutoReplaceWindow::onDefault(wxCommandEvent&) { use_auto_replace->SetValue(true); diff --git a/src/gui/control/filter_ctrl.hpp b/src/gui/control/filter_ctrl.hpp index 586dd2fe..c16eb349 100644 --- a/src/gui/control/filter_ctrl.hpp +++ b/src/gui/control/filter_ctrl.hpp @@ -31,7 +31,7 @@ class FilterCtrl : public wxControl { template intrusive_ptr > getFilter() const { if (hasFilter()) { - return intrusive(new QuickFilter(getFilterString())); + return make_intrusive>(getFilterString()); } else { return intrusive_ptr >(); } diff --git a/src/gui/control/graph.cpp b/src/gui/control/graph.cpp index 436f9cfa..f18b7bb9 100644 --- a/src/gui/control/graph.cpp +++ b/src/gui/control/graph.cpp @@ -1039,39 +1039,39 @@ void GraphControl::setLayout(GraphType type, bool force) { switch (type) { case GRAPH_TYPE_BAR: { intrusive_ptr combined(new GraphContainer()); - combined->add(intrusive(new GraphValueAxis(0, true))); - combined->add(intrusive(new GraphLabelAxis(0, HORIZONTAL))); - combined->add(intrusive(new BarGraph(0))); - combined->add(intrusive(new GraphStats(0, ALIGN_TOP_RIGHT))); - graph = intrusive(new GraphWithMargins(combined, 23,8,7,20)); + combined->add(make_intrusive(0, true)); + combined->add(make_intrusive(0, HORIZONTAL)); + combined->add(make_intrusive(0)); + combined->add(make_intrusive(0, ALIGN_TOP_RIGHT)); + graph = make_intrusive(combined, 23,8,7,20); break; } case GRAPH_TYPE_PIE: { intrusive_ptr combined(new GraphContainer()); - combined->add(intrusive(new GraphWithMargins(intrusive(new PieGraph(0)), 0,0,120,0))); - combined->add(intrusive(new GraphLegend(0, ALIGN_TOP_RIGHT, false))); - graph = intrusive(new GraphWithMargins(combined, 20,20,20,20)); + combined->add(make_intrusive(make_intrusive(0), 0,0,120,0)); + combined->add(make_intrusive(0, ALIGN_TOP_RIGHT, false)); + graph = make_intrusive(combined, 20,20,20,20); break; } case GRAPH_TYPE_STACK: { intrusive_ptr combined(new GraphContainer()); - combined->add(intrusive(new GraphValueAxis(0, false))); - combined->add(intrusive(new GraphLabelAxis(0, HORIZONTAL))); - combined->add(intrusive(new BarGraph2D(0,1))); - combined->add(intrusive(new GraphLegend(1, ALIGN_TOP_RIGHT, true))); - graph = intrusive(new GraphWithMargins(combined, 23,8,7,20)); + combined->add(make_intrusive(0, false)); + combined->add(make_intrusive(0, HORIZONTAL)); + combined->add(make_intrusive(0,1)); + combined->add(make_intrusive(1, ALIGN_TOP_RIGHT, true)); + graph = make_intrusive(combined, 23,8,7,20); break; } case GRAPH_TYPE_SCATTER: { intrusive_ptr combined(new GraphContainer()); - combined->add(intrusive(new GraphLabelAxis(0, HORIZONTAL, false, DRAW_LINES_MID))); - combined->add(intrusive(new GraphLabelAxis(1, VERTICAL, false, DRAW_LINES_MID))); - combined->add(intrusive(new ScatterGraph(0,1))); - graph = intrusive(new GraphWithMargins(combined, 80,8,7,20)); + combined->add(make_intrusive(0, HORIZONTAL, false, DRAW_LINES_MID)); + combined->add(make_intrusive(1, VERTICAL, false, DRAW_LINES_MID)); + combined->add(make_intrusive(0,1)); + graph = make_intrusive(combined, 80,8,7,20); break; } case GRAPH_TYPE_SCATTER_PIE: { intrusive_ptr combined(new GraphContainer()); - combined->add(intrusive(new GraphLabelAxis(0, HORIZONTAL, false, DRAW_LINES_MID))); - combined->add(intrusive(new GraphLabelAxis(1, VERTICAL, false, DRAW_LINES_MID))); - combined->add(intrusive(new ScatterPieGraph(0,1,2))); - graph = intrusive(new GraphWithMargins(combined, 80,8,7,20)); + combined->add(make_intrusive(0, HORIZONTAL, false, DRAW_LINES_MID)); + combined->add(make_intrusive(1, VERTICAL, false, DRAW_LINES_MID)); + combined->add(make_intrusive(0,1,2)); + graph = make_intrusive(combined, 80,8,7,20); break; } default: graph = GraphP(); @@ -1085,7 +1085,7 @@ GraphType GraphControl::getLayout() const { } void GraphControl::setData(const GraphDataPre& data) { - setData(intrusive(new GraphData(data))); + setData(make_intrusive(data)); } void GraphControl::setData(const GraphDataP& data) { if (graph) { diff --git a/src/gui/control/image_card_list.cpp b/src/gui/control/image_card_list.cpp index cc2d0f68..2cc047da 100644 --- a/src/gui/control/image_card_list.cpp +++ b/src/gui/control/image_card_list.cpp @@ -101,7 +101,7 @@ int ImageCardList::OnGetItemImage(long pos) const { return it->second; } else { // request a thumbnail - thumbnail_thread.request(intrusive(new CardThumbnailRequest(const_cast(this), val.filename))); + thumbnail_thread.request(make_intrusive(const_cast(this), val.filename)); } } return -1; diff --git a/src/gui/control/text_ctrl.cpp b/src/gui/control/text_ctrl.cpp index bfaf4f85..af600366 100644 --- a/src/gui/control/text_ctrl.cpp +++ b/src/gui/control/text_ctrl.cpp @@ -64,7 +64,7 @@ void TextCtrl::updateSize() { } void TextCtrl::setValue(String* value, bool untagged) { - setValue(intrusive(new FakeTextValue(getFieldP(), value, true, untagged))); + setValue(make_intrusive(getFieldP(), value, true, untagged)); } void TextCtrl::setValue(const FakeTextValueP& value) { value->retrieve(); diff --git a/src/gui/html_export_window.cpp b/src/gui/html_export_window.cpp index 459f7c05..47f0494b 100644 --- a/src/gui/html_export_window.cpp +++ b/src/gui/html_export_window.cpp @@ -32,7 +32,7 @@ HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set, const Export // init controls list = new PackageList(this, ID_EXPORT_LIST); options = new ExportOptionsEditor(this, wxID_ANY, wxNO_BORDER); - options->setSet(intrusive(new Set(set->stylesheet))); // dummy set + options->setSet(make_intrusive(set->stylesheet)); // dummy set // init sizers wxSizer* s = new wxBoxSizer(wxVERTICAL); s->Add(new wxStaticText(this, wxID_ANY, _LABEL_("html template")), 0, wxALL, 4); diff --git a/src/gui/new_window.cpp b/src/gui/new_window.cpp index c770620c..5946117a 100644 --- a/src/gui/new_window.cpp +++ b/src/gui/new_window.cpp @@ -92,7 +92,7 @@ void NewSetWindow::done() { try { if (!stylesheet_list->hasSelection()) return; StyleSheetP stylesheet = stylesheet_list->getSelection(); - set = intrusive(new Set(stylesheet)); + set = make_intrusive(stylesheet); set->validate(); EndModal(wxID_OK); } catch (const Error& e) { diff --git a/src/gui/package_update_list.cpp b/src/gui/package_update_list.cpp index fa784d1a..db4f4dde 100644 --- a/src/gui/package_update_list.cpp +++ b/src/gui/package_update_list.cpp @@ -228,7 +228,7 @@ void PackageUpdateList::initItems() { ti.setIcon(load_resource_image(_("installer_package"))); if (!p->description->icon_url.empty()) { // download icon - thumbnail_thread.request(intrusive(new PackageIconRequest(this,&ti))); + thumbnail_thread.request(make_intrusive(this,&ti)); } } else if (ti.position_type == TreeItem::TYPE_LOCALE) { // locale folder ti.setIcon(load_resource_image(_("installer_locales"))); diff --git a/src/gui/packages_window.cpp b/src/gui/packages_window.cpp index 0f3d6f5d..8121af90 100644 --- a/src/gui/packages_window.cpp +++ b/src/gui/packages_window.cpp @@ -214,7 +214,7 @@ PackagesWindow::PackagesWindow(Window* parent, const InstallerP& installer) { init(parent, true); // add installer - merge(installable_packages, intrusive(new DownloadableInstaller(installer))); + merge(installable_packages, make_intrusive(installer)); FOR_EACH(p, installable_packages) p->determineStatus(); // mark all packages in the installer for installation FOR_EACH(ip, installable_packages) { @@ -353,7 +353,7 @@ void PackagesWindow::onOk(wxCommandEvent& ev) { os.Write(*is); os.Close(); // open installer - ip->installer->installer = intrusive(new Installer()); + ip->installer->installer = make_intrusive(); ip->installer->installer->open(ip->installer->installer_file); } } diff --git a/src/gui/print_window.cpp b/src/gui/print_window.cpp index 251acb7c..fd77973c 100644 --- a/src/gui/print_window.cpp +++ b/src/gui/print_window.cpp @@ -187,7 +187,7 @@ PrintJobP make_print_job(Window* parent, const SetP& set, const ExportCardSelect return PrintJobP(); // cancel } else { // make print job - PrintJobP job = intrusive(new PrintJob(set)); + PrintJobP job = make_intrusive(set); job->layout_type = settings.print_layout = space->GetValue() ? LAYOUT_EQUAL_SPACE : LAYOUT_NO_SPACE; job->cards = wnd.getSelection(); return job; diff --git a/src/gui/set/console_panel.cpp b/src/gui/set/console_panel.cpp index 21d22ea8..0ffe75fe 100644 --- a/src/gui/set/console_panel.cpp +++ b/src/gui/set/console_panel.cpp @@ -77,7 +77,7 @@ class MessageCtrl : public wxScrolledWindow { Refresh(false); } void add_message(MessageType type, String const& text, bool joined_to_previous = false) { - add_message(intrusive(new ConsoleMessage(type,text,joined_to_previous))); + add_message(make_intrusive(type,text,joined_to_previous)); } bool have_selection() const { @@ -499,7 +499,7 @@ void ConsolePanel::exec(String const& command) { ScriptValueP result = ctx.eval(*script,false); get_pending_errors(); // show result - ConsoleMessageP message = intrusive(new ConsoleMessage(MESSAGE_OUTPUT)); + ConsoleMessageP message = make_intrusive(MESSAGE_OUTPUT); message->joined_to_previous = true; message->value = result; // type of result diff --git a/src/gui/set/keywords_panel.cpp b/src/gui/set/keywords_panel.cpp index 50b5bc18..1ecccd9d 100644 --- a/src/gui/set/keywords_panel.cpp +++ b/src/gui/set/keywords_panel.cpp @@ -344,9 +344,9 @@ void KeywordsPanel::onKeywordSelect(KeywordSelectEvent& ev) { if (ev.keyword) { Keyword& kw = *ev.keyword; sp->Show(fixed, kw.fixed); - keyword ->setValue(intrusive(new KeywordTextValue(keyword->getFieldP(), &kw, &kw.keyword, !kw.fixed, true))); - match ->setValue(intrusive(new KeywordTextValue(match->getFieldP(), &kw, &kw.match, !kw.fixed))); - rules ->setValue(intrusive(new KeywordTextValue(rules->getFieldP(), &kw, &kw.rules, !kw.fixed))); + keyword ->setValue(make_intrusive(keyword->getFieldP(), &kw, &kw.keyword, !kw.fixed, true)); + match ->setValue(make_intrusive(match->getFieldP(), &kw, &kw.match, !kw.fixed)); + rules ->setValue(make_intrusive(rules->getFieldP(), &kw, &kw.rules, !kw.fixed)); intrusive_ptr reminder_value(new KeywordReminderTextValue(*set, reminder->getFieldP(), &kw, !kw.fixed)); reminder->setValue(reminder_value); errors->SetLabel(reminder_value->errors); diff --git a/src/gui/set/random_pack_panel.cpp b/src/gui/set/random_pack_panel.cpp index 30222f54..5288797d 100644 --- a/src/gui/set/random_pack_panel.cpp +++ b/src/gui/set/random_pack_panel.cpp @@ -326,14 +326,14 @@ void CustomPackDialog::updateTotals() { } void CustomPackDialog::storePack() { - edited_pack = intrusive(new PackType()); + edited_pack = make_intrusive(); edited_pack->selectable = true; edited_pack->select = SELECT_ALL; edited_pack->name = name->GetValue(); FOR_EACH(pick,pickers) { int copies = pick.value->GetValue(); if (copies > 0) { - edited_pack->items.push_back(intrusive(new PackItem(pick.pack->name, copies))); + edited_pack->items.push_back(make_intrusive(pick.pack->name, copies)); } } } @@ -632,10 +632,10 @@ void RandomPackPanel::onCardSelect(CardSelectEvent& ev) { void RandomPackPanel::selectionChoices(ExportCardSelectionChoices& out) { if (!isInitialized()) return; - out.push_back(intrusive(new ExportCardSelectionChoice( + out.push_back(make_intrusive( _BUTTON_("export generated packs"), card_list->getCardsPtr() - ))); + )); } diff --git a/src/gui/set/stats_panel.cpp b/src/gui/set/stats_panel.cpp index fa979281..9152a89f 100644 --- a/src/gui/set/stats_panel.cpp +++ b/src/gui/set/stats_panel.cpp @@ -472,7 +472,7 @@ void StatsPanel::showCategory(const GraphType* prefer_layout) { // create axes GraphDataPre d; FOR_EACH(dim, dims) { - d.axes.push_back(intrusive(new GraphAxis( + d.axes.push_back(make_intrusive( dim->name, dim->colors.empty() ? AUTO_COLOR_EVEN : AUTO_COLOR_NO, dim->numeric, @@ -480,7 +480,7 @@ void StatsPanel::showCategory(const GraphType* prefer_layout) { &dim->colors, dim->groups.empty() ? nullptr : &dim->groups ) - )); + ); } // find values for each card for (size_t i = 0 ; i < set->cards.size() ; ++i) { diff --git a/src/gui/set/window.cpp b/src/gui/set/window.cpp index 7b7b936f..bed9d624 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -309,7 +309,7 @@ void SetWindow::onChangeSet() { updateTitle(); // make sure there is always at least one card // some things need this - if (set->cards.empty()) set->cards.push_back(intrusive(new Card(*set->game))); + if (set->cards.empty()) set->cards.push_back(make_intrusive(*set->game)); // all panels view the same set FOR_EACH(p, panels) { p->setSet(set); @@ -383,11 +383,11 @@ void SetWindow::onCardActivate(CardSelectEvent& ev) { } void SetWindow::selectionChoices(ExportCardSelectionChoices& out) { - out.push_back(intrusive(new ExportCardSelectionChoice(*set))); // entire set + out.push_back(make_intrusive(*set)); // entire set FOR_EACH(p, panels) { p->selectionChoices(out); } - out.push_back(intrusive(new ExportCardSelectionChoice())); // custom + out.push_back(make_intrusive()); // custom } // ----------------------------------------------------------------------------- : Window events - close diff --git a/src/gui/symbol/basic_shape_editor.cpp b/src/gui/symbol/basic_shape_editor.cpp index d14a9d16..01a8b877 100644 --- a/src/gui/symbol/basic_shape_editor.cpp +++ b/src/gui/symbol/basic_shape_editor.cpp @@ -186,7 +186,7 @@ void SymbolBasicShapeEditor::makeShape(Vector2D a, Vector2D b, bool constrained, // TODO : Move out of this class void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bool constrained) { - shape = intrusive(new SymbolShape); + shape = make_intrusive(); // What shape to make? switch (mode) { case ID_SHAPE_CIRCLE: { @@ -199,10 +199,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo // a circle has 4 control points, the first is: (x+r, y) db(0, kr) da(0, -kr) // kr is a magic constant const double kr = 0.5522847498f; // = 4/3 * (sqrt(2) - 1) - shape->points.push_back(intrusive(new ControlPoint(c.x + r.x, c.y, 0, kr * r.y, 0, -kr * r.y, LOCK_SIZE))); - shape->points.push_back(intrusive(new ControlPoint(c.x, c.y - r.y, kr * r.x, 0, -kr * r.x, 0, LOCK_SIZE))); - shape->points.push_back(intrusive(new ControlPoint(c.x - r.x, c.y, 0, -kr * r.y, 0, kr * r.y, LOCK_SIZE))); - shape->points.push_back(intrusive(new ControlPoint(c.x, c.y + r.y, -kr * r.x, 0, kr * r.x, 0, LOCK_SIZE))); + shape->points.push_back(make_intrusive(c.x + r.x, c.y, 0, kr * r.y, 0, -kr * r.y, LOCK_SIZE)); + shape->points.push_back(make_intrusive(c.x, c.y - r.y, kr * r.x, 0, -kr * r.x, 0, LOCK_SIZE)); + shape->points.push_back(make_intrusive(c.x - r.x, c.y, 0, -kr * r.y, 0, kr * r.y, LOCK_SIZE)); + shape->points.push_back(make_intrusive(c.x, c.y + r.y, -kr * r.x, 0, kr * r.x, 0, LOCK_SIZE)); break; } case ID_SHAPE_RECTANGLE: { // A rectangle / square @@ -212,10 +212,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo shape->name = capitalize(_TYPE_("rectangle")); } // a rectangle just has four corners - shape->points.push_back(intrusive(new ControlPoint(c.x - r.x, c.y - r.y))); - shape->points.push_back(intrusive(new ControlPoint(c.x + r.x, c.y - r.y))); - shape->points.push_back(intrusive(new ControlPoint(c.x + r.x, c.y + r.y))); - shape->points.push_back(intrusive(new ControlPoint(c.x - r.x, c.y + r.y))); + shape->points.push_back(make_intrusive(c.x - r.x, c.y - r.y)); + shape->points.push_back(make_intrusive(c.x + r.x, c.y - r.y)); + shape->points.push_back(make_intrusive(c.x + r.x, c.y + r.y)); + shape->points.push_back(make_intrusive(c.x - r.x, c.y + r.y)); break; } default: { // A polygon or star @@ -258,10 +258,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo // we can generate points for(int i = 0 ; i < n ; ++i) { double theta = alpha * i; - shape->points.push_back(intrusive(new ControlPoint( + shape->points.push_back(make_intrusive( c.x + ra * r.x * sin(theta), y - ra * r.y * cos(theta) - ))); + )); } } else { // a star is made using a smaller, inverted polygon at the inside @@ -280,16 +280,16 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo for(int i = 0 ; i < n ; ++i) { double theta = alpha * i; // from a - shape->points.push_back(intrusive(new ControlPoint( + shape->points.push_back(make_intrusive( c.x + ra * r.x * sin(theta), y - ra * r.y * cos(theta) - ))); + )); // from b theta = alpha * (i + 0.5); - shape->points.push_back(intrusive(new ControlPoint( + shape->points.push_back(make_intrusive( c.x + rb * r.x * sin(theta), y - rb * r.y * cos(theta) - ))); + )); } } break; diff --git a/src/gui/symbol/control.cpp b/src/gui/symbol/control.cpp index 7cb2bd1d..54e77615 100644 --- a/src/gui/symbol/control.cpp +++ b/src/gui/symbol/control.cpp @@ -39,23 +39,23 @@ void SymbolControl::switchEditor(const SymbolEditorBaseP& e) { void SymbolControl::onChangeSymbol() { selected_parts.setSymbol(symbol); - switchEditor(intrusive(new SymbolSelectEditor(this, false))); + switchEditor(make_intrusive(this, false)); Refresh(false); } void SymbolControl::onModeChange(wxCommandEvent& ev) { switch (ev.GetId()) { case ID_MODE_SELECT: - switchEditor(intrusive(new SymbolSelectEditor(this, false))); + switchEditor(make_intrusive(this, false)); break; case ID_MODE_ROTATE: - switchEditor(intrusive(new SymbolSelectEditor(this, true))); + switchEditor(make_intrusive(this, true)); break; case ID_MODE_POINTS: if (selected_parts.size() == 1) { selected_shape = selected_parts.getAShape(); if (selected_shape) { - switchEditor(intrusive(new SymbolPointEditor(this, selected_shape))); + switchEditor(make_intrusive(this, selected_shape)); } } break; @@ -64,10 +64,10 @@ void SymbolControl::onModeChange(wxCommandEvent& ev) { selected_parts.clear(); signalSelectionChange(); } - switchEditor(intrusive(new SymbolBasicShapeEditor(this))); + switchEditor(make_intrusive(this)); break; case ID_MODE_SYMMETRY: - switchEditor(intrusive(new SymbolSymmetryEditor(this, selected_parts.getASymmetry()))); + switchEditor(make_intrusive(this, selected_parts.getASymmetry())); break; } } @@ -110,7 +110,7 @@ void SymbolControl::onUpdateSelection() { } // begin editing another part selected_shape = shape; - editor = intrusive(new SymbolPointEditor(this, selected_shape)); + editor = make_intrusive(this, selected_shape); Refresh(false); } break; @@ -147,17 +147,17 @@ void SymbolControl::onUpdateSelection() { void SymbolControl::selectPart(const SymbolPartP& part) { selected_parts.select(part); - switchEditor(intrusive(new SymbolSelectEditor(this, false))); + switchEditor(make_intrusive(this, false)); signalSelectionChange(); } void SymbolControl::activatePart(const SymbolPartP& part) { if (part->isSymbolShape()) { selected_parts.select(part); - switchEditor(intrusive(new SymbolPointEditor(this, static_pointer_cast(part)))); + switchEditor(make_intrusive(this, static_pointer_cast(part))); } else if (part->isSymbolSymmetry()) { selected_parts.select(part); - switchEditor(intrusive(new SymbolSymmetryEditor(this, static_pointer_cast(part)))); + switchEditor(make_intrusive(this, static_pointer_cast(part))); } } diff --git a/src/gui/symbol/select_editor.cpp b/src/gui/symbol/select_editor.cpp index 79d89b50..6753a9a2 100644 --- a/src/gui/symbol/select_editor.cpp +++ b/src/gui/symbol/select_editor.cpp @@ -184,7 +184,7 @@ void SymbolSelectEditor::onCommand(int id) { control.Refresh(false); } else if (id == ID_EDIT_GROUP && !isEditing()) { // group selection, not when dragging - addAction(new GroupSymbolPartsAction(*getSymbol(), control.selected_parts.get(), intrusive(new SymbolGroup()))); + addAction(new GroupSymbolPartsAction(*getSymbol(), control.selected_parts.get(), make_intrusive())); control.Refresh(false); } else if (id == ID_EDIT_UNGROUP && !isEditing()) { // ungroup selection, not when dragging diff --git a/src/gui/symbol/symmetry_editor.cpp b/src/gui/symbol/symmetry_editor.cpp index 6698b95f..60df5354 100644 --- a/src/gui/symbol/symmetry_editor.cpp +++ b/src/gui/symbol/symmetry_editor.cpp @@ -118,7 +118,7 @@ void SymbolSymmetryEditor::onCommand(int id) { } resetActions(); } else if (id == ID_ADD_SYMMETRY) { - symmetry = intrusive(new SymbolSymmetry()); + symmetry = make_intrusive(); symmetry->kind = SYMMETRY_ROTATION; symmetry->copies = 2; symmetry->center = Vector2D(0.5,0.5); diff --git a/src/gui/symbol/window.cpp b/src/gui/symbol/window.cpp index 73a206f9..58ca2f3f 100644 --- a/src/gui/symbol/window.cpp +++ b/src/gui/symbol/window.cpp @@ -36,7 +36,7 @@ SymbolWindow::SymbolWindow(Window* parent, const String& filename) : performer(nullptr) { // open file - Reader reader(shared(new wxFileInputStream(filename)), nullptr, filename); + Reader reader(make_shared(filename), nullptr, filename); SymbolP symbol; reader.handle_greedy(symbol); init(parent, symbol); @@ -217,7 +217,7 @@ void SymbolWindow::onFileOpen(wxCommandEvent& ev) { String ext = n.GetExt(); SymbolP symbol; if (ext.Lower() == _("mse-symbol")) { - Reader reader(shared(new wxFileInputStream(name)), nullptr, name); + Reader reader(make_shared(name), nullptr, name); reader.handle_greedy(symbol); } else { wxBusyCursor busy; @@ -240,7 +240,7 @@ void SymbolWindow::onFileSaveAs(wxCommandEvent& ev) { String name = wxFileSelector(_("Save symbol"),settings.default_set_dir,_(""),_(""),_("Symbol files (*.mse-symbol)|*.mse-symbol"),wxFD_SAVE, this); if (!name.empty()) { settings.default_set_dir = wxPathOnly(name); - Writer writer(shared(new wxFileOutputStream(name)), file_version_symbol); + Writer writer(make_shared(name), file_version_symbol); writer.handle(control->getSymbol()); } } diff --git a/src/gui/value/choice.cpp b/src/gui/value/choice.cpp index 64209e48..9ff9444e 100644 --- a/src/gui/value/choice.cpp +++ b/src/gui/value/choice.cpp @@ -203,9 +203,9 @@ void DropDownChoiceListBase::generateThumbnailImages() { status = THUMB_OK; // no need to rebuild } else if (img.isReady()) { // request this thumbnail - thumbnail_thread.request( intrusive(new ChoiceThumbnailRequest( + thumbnail_thread.request(make_intrusive( &cve, i, status == THUMB_NOT_MADE && !img.local(), img.threadSafe() - ))); + )); } } } diff --git a/src/gui/value/package_choice.cpp b/src/gui/value/package_choice.cpp index 1e53101c..8493c767 100644 --- a/src/gui/value/package_choice.cpp +++ b/src/gui/value/package_choice.cpp @@ -116,5 +116,5 @@ void PackageChoiceValueEditor::change(const String& c) { void PackageChoiceValueEditor::initDropDown() { if (drop_down) return; - drop_down = shared(new DropDownPackageChoiceList(&editor(), this)); + drop_down = make_shared(&editor(), this); } diff --git a/src/gui/value/text.cpp b/src/gui/value/text.cpp index f17cf043..b9c8dade 100644 --- a/src/gui/value/text.cpp +++ b/src/gui/value/text.cpp @@ -1367,7 +1367,7 @@ void TextValueEditor::findWordLists() { throw Error(_ERROR_1_("word list type not found", name)); } // add to word_lists - word_lists.push_back(intrusive(new WordListPos(pos, end, word_list))); + word_lists.push_back(make_intrusive(pos, end, word_list)); // next pos = str.find(_(" read_new(Reader& reader) { // there must be a fill type specified String fill_type; reader.handle(_("fill_type"), fill_type); - if (fill_type == _("solid")) return intrusive(new SolidFillSymbolFilter); - else if (fill_type == _("linear gradient")) return intrusive(new LinearGradientSymbolFilter); - else if (fill_type == _("radial gradient")) return intrusive(new RadialGradientSymbolFilter); + if (fill_type == _("solid")) return make_intrusive(); + else if (fill_type == _("linear gradient")) return make_intrusive(); + else if (fill_type == _("radial gradient")) return make_intrusive(); else if (fill_type.empty()) { reader.warning(_ERROR_1_("expected key", _("fill type"))); throw ParseError(_ERROR_("aborting parsing")); diff --git a/src/render/text/element.cpp b/src/render/text/element.cpp index ac626be4..5f2eb11f 100644 --- a/src/render/text/element.cpp +++ b/src/render/text/element.cpp @@ -198,7 +198,7 @@ struct TextElementsFromString { assert(content.size() == end-start); // use symbol font? if (symbol > 0 && style.symbol_font.valid()) { - te.elements.push_back(intrusive(new SymbolTextElement(content, start, end, style.symbol_font, &ctx))); + te.elements.push_back(make_intrusive(content, start, end, style.symbol_font, &ctx)); } else { // text, possibly mixed with symbols DrawWhat what = soft > 0 ? DRAW_ACTIVE : DRAW_NORMAL; @@ -221,9 +221,9 @@ struct TextElementsFromString { if (text_pos < pos) { // text before it? if (!font) font = makeFont(style); - te.elements.push_back(intrusive(new FontTextElement(content.substr(text_pos, pos-text_pos), start+text_pos, start+pos, font, what, line_break))); + te.elements.push_back(make_intrusive(content.substr(text_pos, pos-text_pos), start+text_pos, start+pos, font, what, line_break)); } - te.elements.push_back(intrusive(new SymbolTextElement(content.substr(pos,n), start+pos, start+pos+n, style.symbol_font, &ctx))); + te.elements.push_back(make_intrusive(content.substr(pos,n), start+pos, start+pos+n, style.symbol_font, &ctx)); text_pos = pos += n; } else { ++pos; @@ -231,10 +231,10 @@ struct TextElementsFromString { } if (text_pos < pos) { if (!font) font = makeFont(style); - te.elements.push_back(intrusive(new FontTextElement(content.substr(text_pos), start+text_pos, end, font, what, line_break))); + te.elements.push_back(make_intrusive(content.substr(text_pos), start+text_pos, end, font, what, line_break)); } } else { - te.elements.push_back(intrusive(new FontTextElement(content, start, end, makeFont(style), what, line_break))); + te.elements.push_back(make_intrusive(content, start, end, makeFont(style), what, line_break)); } } } diff --git a/src/script/context.cpp b/src/script/context.cpp index 169cbbb5..7ec9e57a 100644 --- a/src/script/context.cpp +++ b/src/script/context.cpp @@ -469,9 +469,9 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP& } else if (bt == SCRIPT_NIL) { // a = a; } else if (at == SCRIPT_FUNCTION && bt == SCRIPT_FUNCTION) { - a = intrusive(new ScriptCompose(a, b)); + a = make_intrusive(a, b); } else if (at == SCRIPT_COLLECTION && bt == SCRIPT_COLLECTION) { - a = intrusive(new ScriptConcatCollection(a, b)); + a = make_intrusive(a, b); } else if (at == SCRIPT_INT && bt == SCRIPT_INT) { a = to_script((int)*a + (int)*b); } else if ((at == SCRIPT_INT || at == SCRIPT_DOUBLE) && diff --git a/src/script/dependency.cpp b/src/script/dependency.cpp index e30bfb08..96bcae0d 100644 --- a/src/script/dependency.cpp +++ b/src/script/dependency.cpp @@ -68,13 +68,13 @@ private: // Unify two values from different execution paths void unify(ScriptValueP& a, const ScriptValueP& b) { assert(a && b); - if (a != b) a = intrusive(new DependencyUnion(a,b)); + if (a != b) a = make_intrusive(a,b); } // Unify two values from different execution paths ScriptValueP unified(const ScriptValueP& a, const ScriptValueP& b) { assert(a && b); if (a == b) return a; - else return intrusive(new DependencyUnion(a,b)); + else return make_intrusive(a,b); } /// Behaves like script_nil, but with a name @@ -293,7 +293,7 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script) case I_GET_VAR: { ScriptValueP value = variables[i.data].value; if (!value) { - value = intrusive(new ScriptMissingVariable(variable_to_string((Variable)i.data))); // no errors here + value = make_intrusive(variable_to_string((Variable)i.data)); // no errors here } value->dependencyThis(dep); stack.push_back(value); diff --git a/src/script/functions/basic.cpp b/src/script/functions/basic.cpp index fd9d9516..7c4617c3 100644 --- a/src/script/functions/basic.cpp +++ b/src/script/functions/basic.cpp @@ -100,7 +100,7 @@ SCRIPT_FUNCTION(to_string) { SCRIPT_RETURN(input->toString()); } } catch (const ScriptError& e) { - return intrusive(new ScriptDelayedError(e)); + return make_intrusive(e); } } @@ -715,7 +715,7 @@ SCRIPT_FUNCTION(keyword_usage) { /// Turn a script function into a rule, a.k.a. a delayed closure SCRIPT_FUNCTION(rule) { SCRIPT_PARAM(ScriptValueP, input); - return intrusive(new ScriptRule(input)); + return make_intrusive(input); } // ----------------------------------------------------------------------------- : Init @@ -760,17 +760,17 @@ void init_script_basic_functions(Context& ctx) { ctx.setVariable(_("substring"), script_substring); ctx.setVariable(_("contains"), script_contains); ctx.setVariable(_("format"), script_format); - ctx.setVariable(_("format_rule"), intrusive(new ScriptRule(script_format))); + ctx.setVariable(_("format_rule"), make_intrusive(script_format)); ctx.setVariable(_("curly_quotes"), script_curly_quotes); ctx.setVariable(_("regex_escape"), script_regex_escape); ctx.setVariable(_("sort_text"), script_sort_text); - ctx.setVariable(_("sort_rule"), intrusive(new ScriptRule(script_sort_text))); + ctx.setVariable(_("sort_rule"), make_intrusive(script_sort_text)); // tagged string ctx.setVariable(_("tag_contents"), script_tag_contents); ctx.setVariable(_("remove_tag"), script_remove_tag); ctx.setVariable(_("remove_tags"), script_remove_tags); - ctx.setVariable(_("tag_contents_rule"), intrusive(new ScriptRule(script_tag_contents))); - ctx.setVariable(_("tag_remove_rule"), intrusive(new ScriptRule(script_remove_tag))); + ctx.setVariable(_("tag_contents_rule"), make_intrusive(script_tag_contents)); + ctx.setVariable(_("tag_remove_rule"), make_intrusive(script_remove_tag)); // collection ctx.setVariable(_("position"), script_position_of); ctx.setVariable(_("length"), script_length); @@ -782,6 +782,6 @@ void init_script_basic_functions(Context& ctx) { ctx.setVariable(_("random_select_many"), script_random_select_many); // keyword ctx.setVariable(_("expand_keywords"), script_expand_keywords); - ctx.setVariable(_("expand_keywords_rule"), intrusive(new ScriptRule(script_expand_keywords))); + ctx.setVariable(_("expand_keywords_rule"), make_intrusive(script_expand_keywords)); ctx.setVariable(_("keyword_usage"), script_keyword_usage); } diff --git a/src/script/functions/construction.cpp b/src/script/functions/construction.cpp index 88db1462..41aaf759 100644 --- a/src/script/functions/construction.cpp +++ b/src/script/functions/construction.cpp @@ -22,7 +22,7 @@ SCRIPT_FUNCTION(new_card) { SCRIPT_PARAM(GameP, game); - CardP new_card = intrusive(new Card(*game)); + CardP new_card = make_intrusive(*game); // set field values SCRIPT_PARAM(ScriptValueP, input); ScriptValueP it = input->makeIterator(); diff --git a/src/script/functions/image.cpp b/src/script/functions/image.cpp index bdad8c1d..48e6ee0a 100644 --- a/src/script/functions/image.cpp +++ b/src/script/functions/image.cpp @@ -41,14 +41,14 @@ SCRIPT_FUNCTION(linear_blend) { SCRIPT_PARAM(GeneratedImageP, image2); SCRIPT_PARAM(double, x1); SCRIPT_PARAM(double, y1); SCRIPT_PARAM(double, x2); SCRIPT_PARAM(double, y2); - return intrusive(new LinearBlendImage(image1, image2, x1,y1, x2,y2)); + return make_intrusive(image1, image2, x1,y1, x2,y2); } SCRIPT_FUNCTION(masked_blend) { SCRIPT_PARAM(GeneratedImageP, light); SCRIPT_PARAM(GeneratedImageP, dark); SCRIPT_PARAM(GeneratedImageP, mask); - return intrusive(new MaskedBlendImage(light, dark, mask)); + return make_intrusive(light, dark, mask); } SCRIPT_FUNCTION(combine_blend) { @@ -57,19 +57,19 @@ SCRIPT_FUNCTION(combine_blend) { SCRIPT_PARAM(GeneratedImageP, image2); ImageCombine image_combine; parse_enum(combine, image_combine); - return intrusive(new CombineBlendImage(image1, image2, image_combine)); + return make_intrusive(image1, image2, image_combine); } SCRIPT_FUNCTION(set_mask) { SCRIPT_PARAM(GeneratedImageP, image); SCRIPT_PARAM(GeneratedImageP, mask); - return intrusive(new SetMaskImage(image, mask)); + return make_intrusive(image, mask); } SCRIPT_FUNCTION(set_alpha) { SCRIPT_PARAM_C(GeneratedImageP, input); SCRIPT_PARAM(double, alpha); - return intrusive(new SetAlphaImage(input, alpha)); + return make_intrusive(input, alpha); } SCRIPT_FUNCTION(set_combine) { @@ -77,18 +77,18 @@ SCRIPT_FUNCTION(set_combine) { SCRIPT_PARAM_C(GeneratedImageP, input); ImageCombine image_combine; parse_enum(combine, image_combine); - return intrusive(new SetCombineImage(input, image_combine)); + return make_intrusive(input, image_combine); } SCRIPT_FUNCTION(saturate) { SCRIPT_PARAM_C(GeneratedImageP, input); SCRIPT_PARAM(double, amount); - return intrusive(new SaturateImage(input, amount)); + return make_intrusive(input, amount); } SCRIPT_FUNCTION(invert_image) { SCRIPT_PARAM_C(GeneratedImageP, input); - return intrusive(new InvertImage(input)); + return make_intrusive(input); } SCRIPT_FUNCTION(recolor_image) { @@ -97,17 +97,17 @@ SCRIPT_FUNCTION(recolor_image) { SCRIPT_PARAM(Color, green); SCRIPT_PARAM(Color, blue); SCRIPT_PARAM_DEFAULT(Color, white, *wxWHITE); - return intrusive(new RecolorImage2(input,red,green,blue,white)); + return make_intrusive(input,red,green,blue,white); } else { SCRIPT_PARAM(Color, color); - return intrusive(new RecolorImage(input,color)); + return make_intrusive(input,color); } } SCRIPT_FUNCTION(enlarge) { SCRIPT_PARAM_C(GeneratedImageP, input); SCRIPT_PARAM(double, border_size); - return intrusive(new EnlargeImage(input, border_size)); + return make_intrusive(input, border_size); } SCRIPT_FUNCTION(crop) { @@ -116,23 +116,23 @@ SCRIPT_FUNCTION(crop) { SCRIPT_PARAM(int, height); SCRIPT_PARAM(double, offset_x); SCRIPT_PARAM(double, offset_y); - return intrusive(new CropImage(input, width, height, offset_x, offset_y)); + return make_intrusive(input, width, height, offset_x, offset_y); } SCRIPT_FUNCTION(flip_horizontal) { SCRIPT_PARAM_C(GeneratedImageP, input); - return intrusive(new FlipImageHorizontal(input)); + return make_intrusive(input); } SCRIPT_FUNCTION(flip_vertical) { SCRIPT_PARAM_C(GeneratedImageP, input); - return intrusive(new FlipImageVertical(input)); + return make_intrusive(input); } SCRIPT_FUNCTION(rotate) { SCRIPT_PARAM_C(GeneratedImageP, input); SCRIPT_PARAM(Degrees, angle); - return intrusive(new RotateImage(input,deg_to_rad(angle))); + return make_intrusive(input,deg_to_rad(angle)); } SCRIPT_FUNCTION(drop_shadow) { @@ -142,7 +142,7 @@ SCRIPT_FUNCTION(drop_shadow) { SCRIPT_OPTIONAL_PARAM_(double, alpha); SCRIPT_OPTIONAL_PARAM_(double, blur_radius); SCRIPT_OPTIONAL_PARAM_(Color, color); - return intrusive(new DropShadowImage(input, offset_x, offset_y, alpha, blur_radius, color)); + return make_intrusive(input, offset_x, offset_y, alpha, blur_radius, color); } SCRIPT_FUNCTION(symbol_variation) { @@ -170,7 +170,7 @@ SCRIPT_FUNCTION(symbol_variation) { FOR_EACH(v, style->variations) { if (v->name == variation) { // found it - return intrusive(new SymbolToImage(value, filename, value->last_update, v)); + return make_intrusive(value, filename, value->last_update, v); } } throw ScriptError(_("Variation of symbol not found ('") + variation + _("')")); @@ -183,7 +183,7 @@ SCRIPT_FUNCTION(symbol_variation) { if (fill_type == _("solid") || fill_type.empty()) { SCRIPT_PARAM(Color, fill_color); SCRIPT_PARAM(Color, border_color); - var->filter = intrusive(new SolidFillSymbolFilter(fill_color, border_color)); + var->filter = make_intrusive(fill_color, border_color); } else if (fill_type == _("linear gradient")) { SCRIPT_PARAM(Color, fill_color_1); SCRIPT_PARAM(Color, border_color_1); @@ -193,24 +193,23 @@ SCRIPT_FUNCTION(symbol_variation) { SCRIPT_PARAM(double, center_y); SCRIPT_PARAM(double, end_x); SCRIPT_PARAM(double, end_y); - var->filter = intrusive(new LinearGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2 - ,center_x, center_y, end_x, end_y)); + var->filter = make_intrusive(fill_color_1, border_color_1, fill_color_2, border_color_2, center_x, center_y, end_x, end_y); } else if (fill_type == _("radial gradient")) { SCRIPT_PARAM(Color, fill_color_1); SCRIPT_PARAM(Color, border_color_1); SCRIPT_PARAM(Color, fill_color_2); SCRIPT_PARAM(Color, border_color_2); - var->filter = intrusive(new RadialGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2)); + var->filter = make_intrusive(fill_color_1, border_color_1, fill_color_2, border_color_2); } else { throw ScriptError(_("Unknown fill type for symbol_variation: ") + fill_type); } - return intrusive(new SymbolToImage(value, filename, value ? value->last_update : Age(0), var)); + return make_intrusive(value, filename, value ? value->last_update : Age(0), var); } } SCRIPT_FUNCTION(built_in_image) { SCRIPT_PARAM_C(String, input); - return intrusive(new BuiltInImage(input)); + return make_intrusive(input); } // ----------------------------------------------------------------------------- : Init diff --git a/src/script/functions/regex.cpp b/src/script/functions/regex.cpp index f8603b79..c54a48a4 100644 --- a/src/script/functions/regex.cpp +++ b/src/script/functions/regex.cpp @@ -53,7 +53,7 @@ ScriptRegexP regex_from_script(const ScriptValueP& value) { ScriptRegexP regex = dynamic_pointer_cast(value); if (!regex) { // TODO: introduce some kind of caching? - regex = intrusive(new ScriptRegex(*value)); + regex = make_intrusive(*value); } return regex; } @@ -251,8 +251,8 @@ void init_script_regex_functions(Context& ctx) { ctx.setVariable(_("split_text"), script_split_text); ctx.setVariable(_("match_text"), script_match_text); ctx.setVariable(_("match"), script_match_text); // old name - ctx.setVariable(_("replace_rule"), intrusive(new ScriptRule(script_replace_text))); - ctx.setVariable(_("filter_rule"), intrusive(new ScriptRule(script_filter_text))); - ctx.setVariable(_("break_rule"), intrusive(new ScriptRule(script_break_text))); - ctx.setVariable(_("match_rule"), intrusive(new ScriptRule(script_match_text))); + ctx.setVariable(_("replace_rule"), make_intrusive(script_replace_text)); + ctx.setVariable(_("filter_rule"), make_intrusive(script_filter_text)); + ctx.setVariable(_("break_rule"), make_intrusive(script_break_text)); + ctx.setVariable(_("match_rule"), make_intrusive(script_match_text)); } diff --git a/src/script/functions/util.hpp b/src/script/functions/util.hpp index 3ac9002a..16d5979e 100644 --- a/src/script/functions/util.hpp +++ b/src/script/functions/util.hpp @@ -154,25 +154,25 @@ inline Type from_script(const ScriptValueP& v, Variable var) { #define SCRIPT_RULE_1_C(funname, type1, name1) \ SCRIPT_RULE_1_N(funname, type1, SCRIPT_VAR_ ## name1, name1) /// Utility for defining a script rule with a single named parameter -#define SCRIPT_RULE_1_N(funname, type1, str1, name1) \ - class ScriptRule_##funname: public ScriptValue { \ - public: \ - inline ScriptRule_##funname(const type1& name1) : name1(name1) {} \ - virtual ScriptType type() const { return SCRIPT_FUNCTION; } \ - virtual String typeName() const { return _(#funname)_("_rule"); } \ - protected: \ - virtual ScriptValueP do_eval(Context& ctx, bool) const; \ - private: \ - type1 name1; \ - }; \ - SCRIPT_FUNCTION(funname##_rule) { \ - SCRIPT_PARAM_N(type1, str1, name1); \ - return intrusive(new ScriptRule_##funname(name1)); \ - } \ - SCRIPT_FUNCTION(funname) { \ - SCRIPT_PARAM_N(type1, str1, name1); \ - return ScriptRule_##funname(name1).eval(ctx); \ - } \ +#define SCRIPT_RULE_1_N(funname, type1, str1, name1) \ + class ScriptRule_##funname: public ScriptValue { \ + public: \ + inline ScriptRule_##funname(const type1& name1) : name1(name1) {} \ + virtual ScriptType type() const { return SCRIPT_FUNCTION; } \ + virtual String typeName() const { return _(#funname)_("_rule"); } \ + protected: \ + virtual ScriptValueP do_eval(Context& ctx, bool) const; \ + private: \ + type1 name1; \ + }; \ + SCRIPT_FUNCTION(funname##_rule) { \ + SCRIPT_PARAM_N(type1, str1, name1) \ + return make_intrusive(name1); \ + } \ + SCRIPT_FUNCTION(funname) { \ + SCRIPT_PARAM_N(type1, str1, name1); \ + return ScriptRule_##funname(name1).eval(ctx); \ + } \ ScriptValueP ScriptRule_##funname::do_eval(Context& ctx, bool) const /// Utility for defining a script rule with two parameters @@ -194,30 +194,30 @@ inline Type from_script(const ScriptValueP& v, Variable var) { }) #define SCRIPT_RULE_2_N_AUX(funname, type1, str1, name1, type2, str2, name2, dep, more) \ - class ScriptRule_##funname: public ScriptValue { \ - public: \ - inline ScriptRule_##funname(const type1& name1, const type2& name2) \ - : name1(name1), name2(name2) {} \ - virtual ScriptType type() const { return SCRIPT_FUNCTION; } \ - virtual String typeName() const { return _(#funname)_("_rule"); } \ - dep \ - protected: \ - virtual ScriptValueP do_eval(Context& ctx, bool) const; \ - private: \ - type1 name1; \ - type2 name2; \ - }; \ - SCRIPT_FUNCTION(funname##_rule) { \ - SCRIPT_PARAM_N(type1, str1, name1); \ - SCRIPT_PARAM_N(type2, str2, name2); \ - return intrusive(new ScriptRule_##funname(name1, name2)); \ - } \ - SCRIPT_FUNCTION_AUX(funname, dep) { \ - SCRIPT_PARAM_N(type1, str1, name1); \ - SCRIPT_PARAM_N(type2, str2, name2); \ - return ScriptRule_##funname(name1, name2).eval(ctx); \ - } \ - more \ + class ScriptRule_##funname: public ScriptValue { \ + public: \ + inline ScriptRule_##funname(const type1& name1, const type2& name2) \ + : name1(name1), name2(name2) {} \ + virtual ScriptType type() const { return SCRIPT_FUNCTION; } \ + virtual String typeName() const { return _(#funname)_("_rule"); } \ + dep \ + protected: \ + virtual ScriptValueP do_eval(Context& ctx, bool) const; \ + private: \ + type1 name1; \ + type2 name2; \ + }; \ + SCRIPT_FUNCTION(funname##_rule) { \ + SCRIPT_PARAM_N(type1, str1, name1); \ + SCRIPT_PARAM_N(type2, str2, name2); \ + return make_intrusive(name1, name2); \ + } \ + SCRIPT_FUNCTION_AUX(funname, dep) { \ + SCRIPT_PARAM_N(type1, str1, name1); \ + SCRIPT_PARAM_N(type2, str2, name2); \ + return ScriptRule_##funname(name1, name2).eval(ctx); \ + } \ + more \ ScriptValueP ScriptRule_##funname::do_eval(Context& ctx, bool) const #define SCRIPT_RULE_2_DEPENDENCIES(name) \ diff --git a/src/script/image.cpp b/src/script/image.cpp index f3c281af..5c513d2d 100644 --- a/src/script/image.cpp +++ b/src/script/image.cpp @@ -80,7 +80,7 @@ template <> void Reader::handle(ScriptableImage& s) { s.script.parse(*this, true); } else { // a filename - s.value = intrusive(new PackagedImage(s.script.unparsed)); + s.value = make_intrusive(s.script.unparsed); } } template <> void Writer::handle(const ScriptableImage& s) { diff --git a/src/script/profiler.cpp b/src/script/profiler.cpp index 6482ecea..cc59e6e5 100644 --- a/src/script/profiler.cpp +++ b/src/script/profiler.cpp @@ -61,7 +61,7 @@ void profile_aggregate(FunctionProfile& parent, int level, int max_level, size_t // add to item at idx FunctionProfileP& fpp = parent.children[idx]; if (!fpp) { - fpp = intrusive(new FunctionProfile(p.name)); + fpp = make_intrusive(p.name); } fpp->time_ticks += p.time_ticks; fpp->calls += p.calls; @@ -97,7 +97,7 @@ Profiler::Profiler(Timer& timer, Variable function_name) if ((int)function_name >= 0) { FunctionProfileP& fpp = parent->children[(size_t)function_name << 1 | 1]; if (!fpp) { - fpp = intrusive(new FunctionProfile(variable_to_string(function_name))); + fpp = make_intrusive(variable_to_string(function_name)); } function = fpp.get(); } @@ -111,7 +111,7 @@ Profiler::Profiler(Timer& timer, const Char* function_name) { FunctionProfileP& fpp = parent->children[(size_t)function_name]; if (!fpp) { - fpp = intrusive(new FunctionProfile(function_name)); + fpp = make_intrusive(function_name); } function = fpp.get(); timer.exclude_time(); @@ -124,7 +124,7 @@ Profiler::Profiler(Timer& timer, void* function_object, const String& function_n { FunctionProfileP& fpp = parent->children[(size_t)function_object]; if (!fpp) { - fpp = intrusive(new FunctionProfile(function_name)); + fpp = make_intrusive(function_name); } function = fpp.get(); timer.exclude_time(); diff --git a/src/script/script_manager.cpp b/src/script/script_manager.cpp index 8fc187e9..12357817 100644 --- a/src/script/script_manager.cpp +++ b/src/script/script_manager.cpp @@ -56,7 +56,7 @@ Context& SetScriptContext::getContext(const StyleSheetP& stylesheet) { // NOTE: do not use a smart pointer for the pointer to the set, because the set owns this // which would lead to a reference cycle. init_script_functions(*ctx); - ctx->setVariable(SCRIPT_VAR_set, intrusive(new ScriptObject(&set))); + ctx->setVariable(SCRIPT_VAR_set, make_intrusive>(&set)); ctx->setVariable(SCRIPT_VAR_game, to_script(set.game)); ctx->setVariable(SCRIPT_VAR_stylesheet, to_script(stylesheet)); ctx->setVariable(SCRIPT_VAR_card_style, to_script(&stylesheet->card_style)); diff --git a/src/script/scriptable.cpp b/src/script/scriptable.cpp index 3fc476bb..7c03c743 100644 --- a/src/script/scriptable.cpp +++ b/src/script/scriptable.cpp @@ -76,7 +76,7 @@ void OptionalScript::initDependencies(Context& ctx, const Dependency& dep) const } Script& OptionalScript::getMutableScript() { - if (!script) script = intrusive(new Script()); + if (!script) script = make_intrusive