diff --git a/src/data/action/keyword.cpp b/src/data/action/keyword.cpp index d1937d85..f45e694a 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, new_intrusive(), set.keywords) + , action(ADD, intrusive(new Keyword()), set.keywords) { Keyword& keyword = *action.steps.front().item; // find default mode @@ -184,7 +184,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, new_intrusive4(kwp.name, _(""), _(""), param_value)); + ctx.setVariable(param_name, intrusive(new KeywordParamValue(kwp.name, _(""), _(""), param_value))); } script->eval(ctx); errors.clear(); diff --git a/src/data/action/set.cpp b/src/data/action/set.cpp index 2a79b8a4..86399b9e 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, new_intrusive1(*set.game), set.cards) + , action(ADD, intrusive(new Card(*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 a8d85c37..52847d9a 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(new_intrusive2(shape, index)); + removals.push_back(intrusive(new SinglePointRemoveAction(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? - //new_intrusive(part); + //intrusive(new ControlPointRemoveAllAction(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 4450714b..bbcaea54 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 = new_intrusive1(*card); + card = intrusive(new Card(*card)); } out.push_back(card); } diff --git a/src/data/field.cpp b/src/data/field.cpp index 1e16046a..e456397b 100644 --- a/src/data/field.cpp +++ b/src/data/field.cpp @@ -74,15 +74,15 @@ intrusive_ptr read_new(Reader& reader) { // there must be a type specified String type; reader.handle(_("type"), type); - if (type == _("text")) return new_intrusive(); - else if (type == _("choice")) return new_intrusive(); - else if (type == _("multiple choice")) return new_intrusive(); - else if (type == _("boolean")) return new_intrusive(); - else if (type == _("image")) return new_intrusive(); - else if (type == _("symbol")) return new_intrusive(); - else if (type == _("color")) return new_intrusive(); - else if (type == _("info")) return new_intrusive(); - else if (type == _("package choice")) return new_intrusive(); + 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()); 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 25c58e8f..6ed7714a 100644 --- a/src/data/field.hpp +++ b/src/data/field.hpp @@ -266,17 +266,17 @@ inline String type_name(const Value&) { #define IMPLEMENT_FIELD_TYPE(Type, NAME) \ StyleP Type ## Field::newStyle(const FieldP& thisP) const { \ assert(thisP.get() == this); \ - return new_intrusive1(static_pointer_cast(thisP));\ + return intrusive(new Type ## Style(static_pointer_cast(thisP))); \ } \ ValueP Type ## Field::newValue(const FieldP& thisP) const { \ assert(thisP.get() == this); \ - return new_intrusive1(static_pointer_cast(thisP));\ + return intrusive(new Type ## Value(static_pointer_cast(thisP))); \ } \ StyleP Type ## Style::clone() const { \ - return new_intrusive1(*this); \ + return intrusive(new Type ## Style(*this)); \ } \ ValueP Type ## Value::clone() const { \ - return new_intrusive1(*this); \ + return intrusive(new Type ## Value(*this)); \ } \ String Type ## Field::typeName() const { \ return _(NAME); \ diff --git a/src/data/field/boolean.cpp b/src/data/field/boolean.cpp index eb1d1349..332a7402 100644 --- a/src/data/field/boolean.cpp +++ b/src/data/field/boolean.cpp @@ -12,8 +12,8 @@ // ----------------------------------------------------------------------------- : BooleanField BooleanField::BooleanField() { - choices->choices.push_back(new_intrusive1(_("yes"))); - choices->choices.push_back(new_intrusive1(_("no"))); + choices->choices.push_back(intrusive(new Choice(_("yes")))); + choices->choices.push_back(intrusive(new Choice(_("no")))); choices->initIds(); } @@ -34,8 +34,8 @@ BooleanStyle::BooleanStyle(const ChoiceFieldP& 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(new_intrusive1(_("bool_yes"))); - choice_images[_("no")] = ScriptableImage(new_intrusive1(_("bool_no"))); + choice_images[_("yes")] = ScriptableImage(intrusive(new BuiltInImage(_("bool_yes")))); + choice_images[_("no")] = ScriptableImage(intrusive(new BuiltInImage(_("bool_no")))); } IMPLEMENT_REFLECTION(BooleanStyle) { diff --git a/src/data/field/image.cpp b/src/data/field/image.cpp index 7c389651..54cdb0db 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)new_intrusive2(filename, last_update) ); + tag.handle( (ScriptValueP)intrusive(new ImageValueToImage(filename, last_update)) ); } diff --git a/src/data/format/apprentice.cpp b/src/data/format/apprentice.cpp index 6ebafa68..da08780e 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 = new_intrusive(); + card = intrusive(new ApprCardRecord()); 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 = new_intrusive2(*card, set->apprentice_code); + ApprCardRecordP rec = intrusive(new ApprCardRecord(*card, set->apprentice_code)); cardlist.cards.push_back(rec); } cardlist.write(); diff --git a/src/data/format/image_to_symbol.cpp b/src/data/format/image_to_symbol.cpp index c5a7c8fd..6d4d38a0 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(new_intrusive2( + shape->points.push_back(intrusive(new ControlPoint( 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 186e6eef..60c49e32 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 new_intrusive(); + return intrusive(new MSE1FileFormat()); } // ----------------------------------------------------------------------------- : Importing diff --git a/src/data/format/mse2.cpp b/src/data/format/mse2.cpp index 2e0866af..80779660 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 new_intrusive(); + return intrusive(new MSE2FileFormat()); } diff --git a/src/data/format/mtg_editor.cpp b/src/data/format/mtg_editor.cpp index 9b7ae63c..c40b34cb 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 new_intrusive(); + return intrusive(new MtgEditorFileFormat()); } // ----------------------------------------------------------------------------- : Importing @@ -69,7 +69,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) { // read file while (!f.Eof()) { // read a line - if (!current_card) current_card = new_intrusive1(*set->game); + if (!current_card) current_card = intrusive(new Card(*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 = new_intrusive1(*set->game); + current_card = intrusive(new Card(*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 5eb3be86..522683c7 100644 --- a/src/data/game.cpp +++ b/src/data/game.cpp @@ -77,7 +77,7 @@ void Game::validate(Version v) { vector dims; FOR_EACH(f, card_fields) { if (f->show_statistics) { - dims.push_back(new_intrusive1(*f)); + dims.push_back(intrusive(new StatsDimension(*f))); } } statistics_dimensions.insert(statistics_dimensions.begin(), dims.begin(), dims.end()); // push front @@ -86,7 +86,7 @@ void Game::validate(Version v) { { vector cats; FOR_EACH(dim, statistics_dimensions) { - cats.push_back(new_intrusive1(dim)); + cats.push_back(intrusive(new StatsCategory(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 37927327..cc98dc2e 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 = new_intrusive(); - else if (fn == _("mse-style")) pack = new_intrusive(); - else if (fn == _("mse-locale")) pack = new_intrusive(); - else if (fn == _("mse-include")) pack = new_intrusive(); - else if (fn == _("mse-symbol-font")) pack = new_intrusive(); - else if (fn == _("mse-export-template")) pack = new_intrusive(); + 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()); 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(new_intrusive1(package)); + packages.push_back(intrusive(new PackageDescription(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(new_intrusive2(p,installer)); + ips.push_back(intrusive(new InstallablePackage(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 new_intrusive2(mse_description, mse_version); + return intrusive(new InstallablePackage(mse_description, mse_version)); } diff --git a/src/data/locale.cpp b/src/data/locale.cpp index 96e9f968..7a846fb1 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 new_intrusive(); // so we don't search again + return intrusive(new SubLocale()); // so we don't search again } SubLocaleP find_wildcard_and_set(map& items, const String& name) { return items[name] = find_wildcard(items, name); @@ -208,12 +208,12 @@ InputStreamP load_resource_text(const String& name) { char* data = (char *)::LockResource(hData); if ( !data ) throw InternalError(String::Format(_("Resource cannot be locked: %s"), name)); int len = ::SizeofResource(wxGetInstance(), hResource); - return new_shared2(data, len); + return shared(new wxMemoryInputStream(data, len)); #else static String path = wxStandardPaths::Get().GetDataDir() + _("/resource/"); static String local_path = wxStandardPaths::Get().GetUserDataDir() + _("/resource/"); - if (wxFileExists(path + name)) return new_shared1(path + name); - else return new_shared1(local_path + name); + if (wxFileExists(path + name)) return shared(new wxFileInputStream(path + name)); + else return shared(new wxFileInputStream(local_path + name)); #endif } diff --git a/src/data/set.cpp b/src/data/set.cpp index 5950571a..28fcbbf4 100644 --- a/src/data/set.cpp +++ b/src/data/set.cpp @@ -28,13 +28,13 @@ DECLARE_TYPEOF_NO_REV(IndexMap); // ----------------------------------------------------------------------------- : Set Set::Set() - : vcs (new_intrusive()) + : vcs (intrusive(new VCS())) , script_manager(new SetScriptManager(*this)) {} Set::Set(const GameP& game) : game(game) - , vcs (new_intrusive()) + , vcs (intrusive(new VCS())) , script_manager(new SetScriptManager(*this)) { data.init(game->set_fields); @@ -43,7 +43,7 @@ Set::Set(const GameP& game) Set::Set(const StyleSheetP& stylesheet) : game(stylesheet->game) , stylesheet(stylesheet) - , vcs (new_intrusive()) + , vcs (intrusive(new VCS())) , script_manager(new SetScriptManager(*this)) { data.init(game->set_fields); @@ -163,7 +163,7 @@ void Set::validate(Version file_app_version) { } */ } // we want at least one card - if (cards.empty()) cards.push_back(new_intrusive1(*game)); + if (cards.empty()) cards.push_back(intrusive(new Card(*game))); // update scripts script_manager->updateAll(); } @@ -231,7 +231,7 @@ void Set::reflect_cards (Writer& tag) { // ----------------------------------------------------------------------------- : Script utilities ScriptValueP make_iterator(const Set& set) { - return new_intrusive1 > >(&set.cards); + return intrusive(new ScriptCollectionIterator >(&set.cards)); } void mark_dependency_member(const Set& set, const String& name, const Dependency& dep) { @@ -276,7 +276,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 = new_intrusive3 >(cards, values, filter ? &keep : nullptr); + order = intrusive(new OrderCache(cards, values, filter ? &keep : nullptr)); } return order->find(card); } diff --git a/src/data/settings.cpp b/src/data/settings.cpp index 0c0016a4..4fdcdcb7 100644 --- a/src/data/settings.cpp +++ b/src/data/settings.cpp @@ -195,7 +195,7 @@ void Settings::addRecentFile(const String& filename) { GameSettings& Settings::gameSettingsFor(const Game& game) { GameSettingsP& gs = game_settings[game.name()]; - if (!gs) gs = new_intrusive(); + if (!gs) gs = intrusive(new GameSettings); gs->initDefaults(game); return *gs; } @@ -214,7 +214,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 = new_intrusive(); + if (!ss) ss = intrusive(new StyleSheetSettings); ss->useDefault(default_stylesheet_settings); // update default settings return *ss; } @@ -286,7 +286,7 @@ void Settings::read() { String filename = settingsFile(); if (wxFileExists(filename)) { // settings file not existing is not an error - shared_ptr file = new_shared1(filename); + shared_ptr file = shared(new wxFileInputStream(filename)); if (!file->Ok()) return; // failure is not an error Reader reader(file, nullptr, filename); reader.handle_greedy(*this); @@ -294,6 +294,6 @@ void Settings::read() { } void Settings::write() { - Writer writer(new_shared1(settingsFile()), app_version); + Writer writer(shared(new wxFileOutputStream(settingsFile())), app_version); writer.handle(*this); } diff --git a/src/data/symbol.cpp b/src/data/symbol.cpp index 064742df..5af5be33 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 new_intrusive(); - else if (type == _("symmetry")) return new_intrusive(); - else if (type == _("group")) return new_intrusive(); + 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); 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 = new_intrusive1(*p); + p = intrusive(new ControlPoint(*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 = new_intrusive(); - part->points.push_back(new_intrusive2(d + .2, d + .2)); - part->points.push_back(new_intrusive2(d + .2, d + .8)); - part->points.push_back(new_intrusive2(d + .8, d + .8)); - part->points.push_back(new_intrusive2(d + .8, d + .2)); + 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))); part->name = _("Square"); return part; } // A default symbol, a square SymbolP default_symbol() { - SymbolP symbol = new_intrusive(); + SymbolP symbol = intrusive(new Symbol); 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 767f9bc2..b9d837c9 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 new_intrusive1(*this); } + inline AutoReplaceP clone() const { return intrusive(new AutoReplace(*this)); } DECLARE_REFLECTION(); }; diff --git a/src/gui/auto_replace_window.cpp b/src/gui/auto_replace_window.cpp index 88d2b391..bca4b6d8 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(new_intrusive()); + list->addItem(intrusive(new AutoReplace())); } void AutoReplaceWindow::onDefault(wxCommandEvent&) { use_auto_replace->SetValue(true); diff --git a/src/gui/control/graph.cpp b/src/gui/control/graph.cpp index 205726ae..115057a5 100644 --- a/src/gui/control/graph.cpp +++ b/src/gui/control/graph.cpp @@ -1019,39 +1019,39 @@ void GraphControl::setLayout(GraphType type, bool force) { switch (type) { case GRAPH_TYPE_BAR: { intrusive_ptr combined(new GraphContainer()); - combined->add(new_intrusive2(0, true)); - combined->add(new_intrusive2(0, HORIZONTAL)); - combined->add(new_intrusive1(0)); - combined->add(new_intrusive2(0, ALIGN_TOP_RIGHT)); - graph = new_intrusive5(combined, 23,8,7,20); + 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)); break; } case GRAPH_TYPE_PIE: { intrusive_ptr combined(new GraphContainer()); - combined->add(new_intrusive5(new_intrusive1(0), 0,0,120,0)); - combined->add(new_intrusive3(0, ALIGN_TOP_RIGHT, false)); - graph = new_intrusive5(combined, 20,20,20,20); + 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)); break; } case GRAPH_TYPE_STACK: { intrusive_ptr combined(new GraphContainer()); - combined->add(new_intrusive2(0, false)); - combined->add(new_intrusive2(0, HORIZONTAL)); - combined->add(new_intrusive2(0,1)); - combined->add(new_intrusive3(1, ALIGN_TOP_RIGHT, true)); - graph = new_intrusive5(combined, 23,8,7,20); + 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)); break; } case GRAPH_TYPE_SCATTER: { intrusive_ptr combined(new GraphContainer()); - combined->add(new_intrusive4(0, HORIZONTAL, false, DRAW_LINES_MID)); - combined->add(new_intrusive4(1, VERTICAL, false, DRAW_LINES_MID)); - combined->add(new_intrusive2(0,1)); - graph = new_intrusive5(combined, 80,8,7,20); + 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)); break; } case GRAPH_TYPE_SCATTER_PIE: { intrusive_ptr combined(new GraphContainer()); - combined->add(new_intrusive4(0, HORIZONTAL, false, DRAW_LINES_MID)); - combined->add(new_intrusive4(1, VERTICAL, false, DRAW_LINES_MID)); - combined->add(new_intrusive3(0,1,2)); - graph = new_intrusive5(combined, 80,8,7,20); + 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)); break; } default: graph = GraphP(); @@ -1065,7 +1065,7 @@ GraphType GraphControl::getLayout() const { } void GraphControl::setData(const GraphDataPre& data) { - setData(new_intrusive1(data)); + setData(intrusive(new GraphData(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 5a651d02..4449e3dd 100644 --- a/src/gui/control/image_card_list.cpp +++ b/src/gui/control/image_card_list.cpp @@ -100,7 +100,7 @@ int ImageCardList::OnGetItemImage(long pos) const { return it->second; } else { // request a thumbnail - thumbnail_thread.request(new_intrusive2(const_cast(this), val.filename)); + thumbnail_thread.request(intrusive(new CardThumbnailRequest(const_cast(this), val.filename))); } } return -1; diff --git a/src/gui/control/text_ctrl.cpp b/src/gui/control/text_ctrl.cpp index 80ff2857..7573cea4 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(new_intrusive4(getFieldP(), value, true, untagged)); + setValue(intrusive(new FakeTextValue(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 be7f565b..91248500 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(new_intrusive1(set->stylesheet)); // dummy set + options->setSet(intrusive(new Set(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 1c6fdec2..0463c3e9 100644 --- a/src/gui/new_window.cpp +++ b/src/gui/new_window.cpp @@ -91,7 +91,7 @@ void NewSetWindow::OnOK(wxCommandEvent&) { void NewSetWindow::done() { try { StyleSheetP stylesheet = stylesheet_list->getSelection(); - set = new_intrusive1(stylesheet); + set = intrusive(new Set(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 8c0c7690..ea69d273 100644 --- a/src/gui/package_update_list.cpp +++ b/src/gui/package_update_list.cpp @@ -227,7 +227,7 @@ void PackageUpdateList::initItems() { ti.setIcon(load_resource_image(_("installer_package"))); if (!p->description->icon_url.empty()) { // download icon - thumbnail_thread.request(new_intrusive2(this,&ti)); + thumbnail_thread.request(intrusive(new PackageIconRequest(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 e90f5f59..c9ef6af3 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, new_intrusive1(installer)); + merge(installable_packages, intrusive(new DownloadableInstaller(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 = new_intrusive(); + ip->installer->installer = intrusive(new Installer()); ip->installer->installer->open(ip->installer->installer_file); } } diff --git a/src/gui/print_window.cpp b/src/gui/print_window.cpp index 08e11451..d5b50d8f 100644 --- a/src/gui/print_window.cpp +++ b/src/gui/print_window.cpp @@ -78,7 +78,7 @@ void TextBufferDC::DoDrawText(const String& str, int x, int y) { if (buffer_text) { double usx,usy; GetUserScale(&usx, &usy); - text.push_back( new_intrusive7(GetFont(), GetTextForeground(), usx, usy, x, y, str) ); + text.push_back( intrusive(new TextDraw(GetFont(), GetTextForeground(), usx, usy, x, y, str)) ); } else { wxMemoryDC::DoDrawText(str,x,y); } @@ -87,7 +87,7 @@ void TextBufferDC::DoDrawRotatedText(const String& str, int x, int y, double ang if (buffer_text) { double usx,usy; GetUserScale(&usx, &usy); - text.push_back( new_intrusive8(GetFont(), GetTextForeground(), usx, usy, x, y, str, angle) ); + text.push_back( intrusive(new TextDraw(GetFont(), GetTextForeground(), usx, usy, x, y, str, angle)) ); } else { wxMemoryDC::DoDrawRotatedText(str,x,y,angle); } @@ -183,7 +183,7 @@ void CardsPrintout::OnPreparePrinting() { int pw_mm, ph_mm; GetPageSizeMM(&pw_mm, &ph_mm); if (!layout) { - layout = new_intrusive2(*set->stylesheet, RealSize(pw_mm, ph_mm)); + layout = intrusive(new PageLayout(*set->stylesheet, RealSize(pw_mm, ph_mm))); } } diff --git a/src/gui/set/keywords_panel.cpp b/src/gui/set/keywords_panel.cpp index 42864cfa..9e31e8ee 100644 --- a/src/gui/set/keywords_panel.cpp +++ b/src/gui/set/keywords_panel.cpp @@ -326,9 +326,9 @@ void KeywordsPanel::onKeywordSelect(KeywordSelectEvent& ev) { if (ev.keyword) { Keyword& kw = *ev.keyword; sp->Show(fixed, kw.fixed); - keyword ->setValue(new_intrusive5 (keyword->getFieldP(), &kw, &kw.keyword, !kw.fixed, true)); - match ->setValue(new_intrusive4 (match->getFieldP(), &kw, &kw.match, !kw.fixed)); - rules ->setValue(new_intrusive4 (rules->getFieldP(), &kw, &kw.rules, !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))); 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 48fcad76..743a1935 100644 --- a/src/gui/set/random_pack_panel.cpp +++ b/src/gui/set/random_pack_panel.cpp @@ -387,14 +387,14 @@ void CustomPackDialog::updateTotals() { } void CustomPackDialog::storePack() { - edited_pack = new_intrusive(); + edited_pack = intrusive(new PackType()); 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(new_intrusive2(pick.pack->name, copies)); + edited_pack->items.push_back(intrusive(new PackItem(pick.pack->name, copies))); } } } @@ -725,10 +725,10 @@ void RandomPackPanel::onCardSelect(CardSelectEvent& ev) { void RandomPackPanel::selectionChoices(ExportCardSelectionChoices& out) { if (!isInitialized()) return; - out.push_back(new_intrusive2( + out.push_back(intrusive(new ExportCardSelectionChoice( _BUTTON_("export generated packs"), card_list->getCardsPtr() - )); + ))); } diff --git a/src/gui/set/stats_panel.cpp b/src/gui/set/stats_panel.cpp index 798de64c..481e5b3b 100644 --- a/src/gui/set/stats_panel.cpp +++ b/src/gui/set/stats_panel.cpp @@ -470,7 +470,7 @@ void StatsPanel::showCategory(const GraphType* prefer_layout) { // create axes GraphDataPre d; FOR_EACH(dim, dims) { - d.axes.push_back(new_intrusive6( + d.axes.push_back(intrusive(new GraphAxis( dim->name, dim->colors.empty() ? AUTO_COLOR_EVEN : AUTO_COLOR_NO, dim->numeric, @@ -478,7 +478,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 7091a4ea..b4dc3065 100644 --- a/src/gui/set/window.cpp +++ b/src/gui/set/window.cpp @@ -263,7 +263,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(new_intrusive1(*set->game)); + if (set->cards.empty()) set->cards.push_back(intrusive(new Card(*set->game))); // all panels view the same set FOR_EACH(p, panels) { p->setSet(set); @@ -337,11 +337,11 @@ void SetWindow::onCardActivate(CardSelectEvent& ev) { } void SetWindow::selectionChoices(ExportCardSelectionChoices& out) { - out.push_back(new_intrusive1(*set)); // entire set + out.push_back(intrusive(new ExportCardSelectionChoice(*set))); // entire set FOR_EACH(p, panels) { p->selectionChoices(out); } - out.push_back(new_intrusive()); // custom + out.push_back(intrusive(new ExportCardSelectionChoice())); // custom } // ----------------------------------------------------------------------------- : Window events - close diff --git a/src/gui/symbol/basic_shape_editor.cpp b/src/gui/symbol/basic_shape_editor.cpp index 5ec8502e..3691c13d 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 = new_intrusive(); + shape = intrusive(new SymbolShape); // 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(new_intrusive7(c.x + r.x, c.y, 0, kr * r.y, 0, -kr * r.y, LOCK_SIZE)); - shape->points.push_back(new_intrusive7(c.x, c.y - r.y, kr * r.x, 0, -kr * r.x, 0, LOCK_SIZE)); - shape->points.push_back(new_intrusive7(c.x - r.x, c.y, 0, -kr * r.y, 0, kr * r.y, LOCK_SIZE)); - shape->points.push_back(new_intrusive7(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(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))); 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(new_intrusive2(c.x - r.x, c.y - r.y)); - shape->points.push_back(new_intrusive2(c.x + r.x, c.y - r.y)); - shape->points.push_back(new_intrusive2(c.x + r.x, c.y + r.y)); - shape->points.push_back(new_intrusive2(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(intrusive(new ControlPoint(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(new_intrusive2( + shape->points.push_back(intrusive(new ControlPoint( 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(new_intrusive2( + shape->points.push_back(intrusive(new ControlPoint( c.x + ra * r.x * sin(theta), y - ra * r.y * cos(theta) - )); + ))); // from b theta = alpha * (i + 0.5); - shape->points.push_back(new_intrusive2( + shape->points.push_back(intrusive(new ControlPoint( 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 955ea284..6d81b89b 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(new_intrusive2(this, false)); + switchEditor(intrusive(new SymbolSelectEditor(this, false))); Refresh(false); } void SymbolControl::onModeChange(wxCommandEvent& ev) { switch (ev.GetId()) { case ID_MODE_SELECT: - switchEditor(new_intrusive2(this, false)); + switchEditor(intrusive(new SymbolSelectEditor(this, false))); break; case ID_MODE_ROTATE: - switchEditor(new_intrusive2(this, true)); + switchEditor(intrusive(new SymbolSelectEditor(this, true))); break; case ID_MODE_POINTS: if (selected_parts.size() == 1) { selected_shape = selected_parts.getAShape(); if (selected_shape) { - switchEditor(new_intrusive2(this, selected_shape)); + switchEditor(intrusive(new SymbolPointEditor(this, selected_shape))); } } break; @@ -64,10 +64,10 @@ void SymbolControl::onModeChange(wxCommandEvent& ev) { selected_parts.clear(); signalSelectionChange(); } - switchEditor(new_intrusive1(this)); + switchEditor(intrusive(new SymbolBasicShapeEditor(this))); break; case ID_MODE_SYMMETRY: - switchEditor(new_intrusive2(this, selected_parts.getASymmetry())); + switchEditor(intrusive(new SymbolSymmetryEditor(this, selected_parts.getASymmetry()))); break; } } @@ -110,7 +110,7 @@ void SymbolControl::onUpdateSelection() { } // begin editing another part selected_shape = shape; - editor = new_intrusive2(this, selected_shape); + editor = intrusive(new SymbolPointEditor(this, selected_shape)); Refresh(false); } break; @@ -147,17 +147,17 @@ void SymbolControl::onUpdateSelection() { void SymbolControl::selectPart(const SymbolPartP& part) { selected_parts.select(part); - switchEditor(new_intrusive2(this, false)); + switchEditor(intrusive(new SymbolSelectEditor(this, false))); signalSelectionChange(); } void SymbolControl::activatePart(const SymbolPartP& part) { if (part->isSymbolShape()) { selected_parts.select(part); - switchEditor(new_intrusive2(this, static_pointer_cast(part))); + switchEditor(intrusive(new SymbolPointEditor(this, static_pointer_cast(part)))); } else if (part->isSymbolSymmetry()) { selected_parts.select(part); - switchEditor(new_intrusive2(this, static_pointer_cast(part))); + switchEditor(intrusive(new SymbolSymmetryEditor(this, static_pointer_cast(part)))); } } diff --git a/src/gui/symbol/select_editor.cpp b/src/gui/symbol/select_editor.cpp index 0708d761..34019b73 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(), new_intrusive())); + addAction(new GroupSymbolPartsAction(*getSymbol(), control.selected_parts.get(), intrusive(new SymbolGroup()))); 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 b08abab9..0d9bfa15 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 = new_intrusive(); + symmetry = intrusive(new SymbolSymmetry()); 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 5439a2b6..fbaf6fd2 100644 --- a/src/gui/symbol/window.cpp +++ b/src/gui/symbol/window.cpp @@ -35,7 +35,7 @@ SymbolWindow::SymbolWindow(Window* parent, const String& filename) : performer(nullptr) { // open file - Reader reader(new_shared1(filename), nullptr, filename); + Reader reader(shared(new wxFileInputStream(filename)), nullptr, filename); SymbolP symbol; reader.handle_greedy(symbol); init(parent, symbol); @@ -216,7 +216,7 @@ void SymbolWindow::onFileOpen(wxCommandEvent& ev) { String ext = n.GetExt(); SymbolP symbol; if (ext.Lower() == _("mse-symbol")) { - Reader reader(new_shared1(name), nullptr, name); + Reader reader(shared(new wxFileInputStream(name)), nullptr, name); reader.handle_greedy(symbol); } else { wxBusyCursor busy; @@ -239,7 +239,7 @@ void SymbolWindow::onFileSaveAs(wxCommandEvent& ev) { String name = wxFileSelector(_("Save symbol"),settings.default_set_dir,_(""),_(""),_("Symbol files (*.mse-symbol)|*.mse-symbol"),wxSAVE, this); if (!name.empty()) { settings.default_set_dir = wxPathOnly(name); - Writer writer(new_shared1(name), file_version_symbol); + Writer writer(shared(new wxFileOutputStream(name)), file_version_symbol); writer.handle(control->getSymbol()); } } diff --git a/src/gui/value/choice.cpp b/src/gui/value/choice.cpp index 16b7a2e9..2995e2fc 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( new_intrusive4( + thumbnail_thread.request( intrusive(new ChoiceThumbnailRequest( &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 6a277f5e..b8a3cf6e 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 = new_shared2(&editor(), this); + drop_down = shared(new DropDownPackageChoiceList(&editor(), this)); } diff --git a/src/gui/value/text.cpp b/src/gui/value/text.cpp index a8d55752..4319dff4 100644 --- a/src/gui/value/text.cpp +++ b/src/gui/value/text.cpp @@ -1361,7 +1361,7 @@ void TextValueEditor::findWordLists() { throw Error(_ERROR_1_("word list type not found", name)); } // add to word_lists - word_lists.push_back(new_intrusive3(pos, end, word_list)); + word_lists.push_back(intrusive(new WordListPos(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 new_intrusive(); - else if (fill_type == _("linear gradient")) return new_intrusive(); - else if (fill_type == _("radial gradient")) return new_intrusive(); + 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); 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 24d7f4c2..2a8c9a37 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(new_intrusive5(content, start, end, style.symbol_font, &ctx)); + te.elements.push_back(intrusive(new SymbolTextElement(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(new_intrusive6(content.substr(text_pos, pos-text_pos), start+text_pos, start+pos, font, what, line_break)); + 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(new_intrusive5(content.substr(pos,n), start+pos, start+pos+n, style.symbol_font, &ctx)); + te.elements.push_back(intrusive(new SymbolTextElement(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(new_intrusive6(content.substr(text_pos), start+text_pos, end, font, what, line_break)); + te.elements.push_back(intrusive(new FontTextElement(content.substr(text_pos), start+text_pos, end, font, what, line_break))); } } else { - te.elements.push_back(new_intrusive6(content, start, end, makeFont(style), what, line_break)); + te.elements.push_back(intrusive(new FontTextElement(content, start, end, makeFont(style), what, line_break))); } } } diff --git a/src/script/context.cpp b/src/script/context.cpp index 9cbdce97..54f4f7d9 100644 --- a/src/script/context.cpp +++ b/src/script/context.cpp @@ -449,9 +449,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 = new_intrusive2(a, b); + a = intrusive(new ScriptCompose(a, b)); } else if (at == SCRIPT_COLLECTION && bt == SCRIPT_COLLECTION) { - a = new_intrusive2(a, b); + a = intrusive(new ScriptConcatCollection(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 b74b2590..2a4b04d5 100644 --- a/src/script/dependency.cpp +++ b/src/script/dependency.cpp @@ -68,13 +68,13 @@ class DependencyUnion : public ScriptValue { // Unify two values from different execution paths void unify(ScriptValueP& a, const ScriptValueP& b) { assert(a && b); - if (a != b) a = new_intrusive2(a,b); + if (a != b) a = intrusive(new DependencyUnion(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 new_intrusive2(a,b); + else return intrusive(new DependencyUnion(a,b)); } /// Behaves like script_nil, but with a name @@ -286,7 +286,7 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script) case I_GET_VAR: { ScriptValueP value = variables[i.data].value; if (!value) { - value = new_intrusive1(variable_to_string((Variable)i.data)); // no errors here + value = intrusive(new ScriptMissingVariable(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 25ca8856..ae9c5533 100644 --- a/src/script/functions/basic.cpp +++ b/src/script/functions/basic.cpp @@ -91,7 +91,7 @@ SCRIPT_FUNCTION(to_string) { SCRIPT_RETURN(input->toString()); } } catch (const ScriptError& e) { - return new_intrusive1(e); + return intrusive(new ScriptDelayedError(e)); } } @@ -649,7 +649,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 new_intrusive1(input); + return intrusive(new ScriptRule(input)); } // ----------------------------------------------------------------------------- : Init @@ -680,17 +680,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"), new_intrusive1(script_format)); + ctx.setVariable(_("format rule"), intrusive(new ScriptRule(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"), new_intrusive1(script_sort_text)); + ctx.setVariable(_("sort rule"), intrusive(new ScriptRule(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"), new_intrusive1(script_tag_contents)); - ctx.setVariable(_("tag remove rule"), new_intrusive1(script_remove_tag)); + ctx.setVariable(_("tag contents rule"), intrusive(new ScriptRule(script_tag_contents))); + ctx.setVariable(_("tag remove rule"), intrusive(new ScriptRule(script_remove_tag))); // collection ctx.setVariable(_("position"), script_position_of); ctx.setVariable(_("length"), script_length); @@ -702,6 +702,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"), new_intrusive1(script_expand_keywords)); + ctx.setVariable(_("expand keywords rule"), intrusive(new ScriptRule(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 bbe67c71..c53a1549 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 = new_intrusive1(*game); + CardP new_card = intrusive(new Card(*game)); // set field values SCRIPT_PARAM(ScriptValueP, input); ScriptValueP it = input->makeIterator(input); diff --git a/src/script/functions/image.cpp b/src/script/functions/image.cpp index d75743a1..09590ee0 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 new_intrusive6(image1, image2, x1,y1, x2,y2); + return intrusive(new LinearBlendImage(image1, image2, x1,y1, x2,y2)); } SCRIPT_FUNCTION(masked_blend) { SCRIPT_PARAM(GeneratedImageP, light); SCRIPT_PARAM(GeneratedImageP, dark); SCRIPT_PARAM(GeneratedImageP, mask); - return new_intrusive3(light, dark, mask); + return intrusive(new MaskedBlendImage(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 new_intrusive3(image1, image2, image_combine); + return intrusive(new CombineBlendImage(image1, image2, image_combine)); } SCRIPT_FUNCTION(set_mask) { SCRIPT_PARAM(GeneratedImageP, image); SCRIPT_PARAM(GeneratedImageP, mask); - return new_intrusive2(image, mask); + return intrusive(new SetMaskImage(image, mask)); } SCRIPT_FUNCTION(set_alpha) { SCRIPT_PARAM_C(GeneratedImageP, input); SCRIPT_PARAM(double, alpha); - return new_intrusive2(input, alpha); + return intrusive(new SetAlphaImage(input, alpha)); } SCRIPT_FUNCTION(set_combine) { @@ -77,19 +77,19 @@ SCRIPT_FUNCTION(set_combine) { SCRIPT_PARAM_C(GeneratedImageP, input); ImageCombine image_combine; parse_enum(combine, image_combine); - return new_intrusive2(input, image_combine); + return intrusive(new SetCombineImage(input, image_combine)); } SCRIPT_FUNCTION(saturate) { SCRIPT_PARAM_C(GeneratedImageP, input); SCRIPT_PARAM(double, amount); - return new_intrusive2(input, amount); + return intrusive(new SaturateImage(input, amount)); } SCRIPT_FUNCTION(enlarge) { SCRIPT_PARAM_C(GeneratedImageP, input); SCRIPT_PARAM_N(double, _("border size"), border_size); - return new_intrusive2(input, border_size); + return intrusive(new EnlargeImage(input, border_size)); } SCRIPT_FUNCTION(crop) { @@ -98,7 +98,7 @@ SCRIPT_FUNCTION(crop) { SCRIPT_PARAM_N(int, _("height"), height); SCRIPT_PARAM_N(double, _("offset x"), offset_x); SCRIPT_PARAM_N(double, _("offset y"), offset_y); - return new_intrusive5(input, width, height, offset_x, offset_y); + return intrusive(new CropImage(input, width, height, offset_x, offset_y)); } SCRIPT_FUNCTION(drop_shadow) { @@ -108,7 +108,7 @@ SCRIPT_FUNCTION(drop_shadow) { SCRIPT_OPTIONAL_PARAM_N_(double, _("alpha"), alpha); SCRIPT_OPTIONAL_PARAM_N_(double, _("blur radius"), blur_radius); SCRIPT_OPTIONAL_PARAM_N_(Color, _("color"), color); - return new_intrusive6(input, offset_x, offset_y, alpha, blur_radius, color); + return intrusive(new DropShadowImage(input, offset_x, offset_y, alpha, blur_radius, color)); } SCRIPT_FUNCTION(symbol_variation) { @@ -136,7 +136,7 @@ SCRIPT_FUNCTION(symbol_variation) { FOR_EACH(v, style->variations) { if (v->name == variation) { // found it - return new_intrusive4(value, filename, value->last_update, v); + return intrusive(new SymbolToImage(value, filename, value->last_update, v)); } } throw ScriptError(_("Variation of symbol not found ('") + variation + _("')")); @@ -149,7 +149,7 @@ SCRIPT_FUNCTION(symbol_variation) { if (fill_type == _("solid") || fill_type.empty()) { SCRIPT_PARAM_N(Color, _("fill color"), fill_color); SCRIPT_PARAM_N(Color, _("border color"), border_color); - var->filter = new_intrusive2(fill_color, border_color); + var->filter = intrusive(new SolidFillSymbolFilter(fill_color, border_color)); } else if (fill_type == _("linear gradient")) { SCRIPT_PARAM_N(Color, _("fill color 1"), fill_color_1); SCRIPT_PARAM_N(Color, _("border color 1"), border_color_1); @@ -159,24 +159,24 @@ SCRIPT_FUNCTION(symbol_variation) { SCRIPT_PARAM_N(double, _("center y"), center_y); SCRIPT_PARAM_N(double, _("end x"), end_x); SCRIPT_PARAM_N(double, _("end y"), end_y); - var->filter = new_intrusive8(fill_color_1, border_color_1, fill_color_2, border_color_2 - ,center_x, center_y, end_x, 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)); } else if (fill_type == _("radial gradient")) { SCRIPT_PARAM_N(Color, _("fill color 1"), fill_color_1); SCRIPT_PARAM_N(Color, _("border color 1"), border_color_1); SCRIPT_PARAM_N(Color, _("fill color 2"), fill_color_2); SCRIPT_PARAM_N(Color, _("border color 2"), border_color_2); - var->filter = new_intrusive4(fill_color_1, border_color_1, fill_color_2, border_color_2); + var->filter = intrusive(new RadialGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2)); } else { throw ScriptError(_("Unknown fill type for symbol_variation: ") + fill_type); } - return new_intrusive4(value, filename, value ? value->last_update : Age(0), var); + return intrusive(new SymbolToImage(value, filename, value ? value->last_update : Age(0), var)); } } SCRIPT_FUNCTION(built_in_image) { SCRIPT_PARAM_C(String, input); - return new_intrusive1(input); + return intrusive(new BuiltInImage(input)); } // ----------------------------------------------------------------------------- : Init diff --git a/src/script/functions/regex.cpp b/src/script/functions/regex.cpp index 9d85c2da..eac5ccc1 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 = new_intrusive1(*value); + regex = intrusive(new ScriptRegex(*value)); } return regex; } @@ -250,8 +250,8 @@ void init_script_regex_functions(Context& ctx) { ctx.setVariable(_("break text"), script_break_text); ctx.setVariable(_("split text"), script_split_text); ctx.setVariable(_("match"), script_match); - ctx.setVariable(_("replace rule"), new_intrusive1(script_replace)); - ctx.setVariable(_("filter rule"), new_intrusive1(script_filter_text)); - ctx.setVariable(_("break rule"), new_intrusive1(script_break_text)); - ctx.setVariable(_("match rule"), new_intrusive1(script_match)); + ctx.setVariable(_("replace rule"), intrusive(new ScriptRule(script_replace))); + 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))); } diff --git a/src/script/functions/util.hpp b/src/script/functions/util.hpp index eec728dc..f2fc5b4e 100644 --- a/src/script/functions/util.hpp +++ b/src/script/functions/util.hpp @@ -167,7 +167,7 @@ inline Type from_script(const ScriptValueP& v, Variable var) { }; \ SCRIPT_FUNCTION(funname##_rule) { \ SCRIPT_PARAM_N(type1, str1, name1); \ - return new_intrusive1(name1); \ + return intrusive(new ScriptRule_##funname(name1)); \ } \ SCRIPT_FUNCTION(funname) { \ SCRIPT_PARAM_N(type1, str1, name1); \ @@ -210,7 +210,7 @@ inline Type from_script(const ScriptValueP& v, Variable var) { SCRIPT_FUNCTION(funname##_rule) { \ SCRIPT_PARAM_N(type1, str1, name1); \ SCRIPT_PARAM_N(type2, str2, name2); \ - return new_intrusive2(name1, name2); \ + return intrusive(new ScriptRule_##funname(name1, name2)); \ } \ SCRIPT_FUNCTION_AUX(funname, dep) { \ SCRIPT_PARAM_N(type1, str1, name1); \ diff --git a/src/script/image.cpp b/src/script/image.cpp index 45bb95d8..44fce34b 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 = new_intrusive1(s.script.unparsed); + s.value = intrusive(new PackagedImage(s.script.unparsed)); } } template <> void Writer::handle(const ScriptableImage& s) { diff --git a/src/script/profiler.cpp b/src/script/profiler.cpp index a597f7c7..ec614804 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 = new_intrusive1(p.name); + fpp = intrusive(new FunctionProfile(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 = new_intrusive1(variable_to_string(function_name)); + fpp = intrusive(new FunctionProfile(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 = new_intrusive1(function_name); + fpp = intrusive(new FunctionProfile(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 = new_intrusive1(function_name); + fpp = intrusive(new FunctionProfile(function_name)); } function = fpp.get(); timer.exclude_time(); diff --git a/src/script/script_manager.cpp b/src/script/script_manager.cpp index b25af18b..2c4cb154 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, new_intrusive1 >(&set)); + ctx->setVariable(SCRIPT_VAR_set, intrusive(new ScriptObject(&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 4060c992..6819828e 100644 --- a/src/script/scriptable.cpp +++ b/src/script/scriptable.cpp @@ -78,7 +78,7 @@ void OptionalScript::initDependencies(Context& ctx, const Dependency& dep) const } Script& OptionalScript::getMutableScript() { - if (!script) script = new_intrusive