mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 21:47:00 -04:00
Use make_intrusive/make_shared for smart pointer construction.
This commit is contained in:
@@ -65,7 +65,7 @@ void CLISetInterface::setExportInfoCwd() {
|
|||||||
// write to the current directory
|
// write to the current directory
|
||||||
ei.directory_relative = ei.directory_absolute = wxGetCwd();
|
ei.directory_relative = ei.directory_absolute = wxGetCwd();
|
||||||
// read from the current directory
|
// read from the current directory
|
||||||
ei.export_template = intrusive(new Package());
|
ei.export_template = make_intrusive<Package>();
|
||||||
ei.export_template->open(ei.directory_absolute, true);
|
ei.export_template->open(ei.directory_absolute, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ DECLARE_TYPEOF_COLLECTION(KeywordModeP);
|
|||||||
|
|
||||||
AddKeywordAction::AddKeywordAction(Set& set)
|
AddKeywordAction::AddKeywordAction(Set& set)
|
||||||
: KeywordListAction(set)
|
: KeywordListAction(set)
|
||||||
, action(ADD, intrusive(new Keyword()), set.keywords)
|
, action(ADD, make_intrusive<Keyword>(), set.keywords)
|
||||||
{
|
{
|
||||||
Keyword& keyword = *action.steps.front().item;
|
Keyword& keyword = *action.steps.front().item;
|
||||||
// find default mode
|
// find default mode
|
||||||
@@ -185,7 +185,7 @@ bool KeywordReminderTextValue::checkScript(const ScriptP& script) {
|
|||||||
const KeywordParam& kwp = *keyword.parameters[i];
|
const KeywordParam& kwp = *keyword.parameters[i];
|
||||||
String param_name = String(_("param")) << (int)(i+1);
|
String param_name = String(_("param")) << (int)(i+1);
|
||||||
String param_value = _("<atom-kwpph>") + (kwp.placeholder.empty() ? kwp.name : kwp.placeholder) + _("</atom-kwpph>");
|
String param_value = _("<atom-kwpph>") + (kwp.placeholder.empty() ? kwp.name : kwp.placeholder) + _("</atom-kwpph>");
|
||||||
ctx.setVariable(param_name, intrusive(new KeywordParamValue(kwp.name, _(""), _(""), param_value)));
|
ctx.setVariable(param_name, make_intrusive<KeywordParamValue>(kwp.name, _(""), _(""), param_value));
|
||||||
}
|
}
|
||||||
script->eval(ctx);
|
script->eval(ctx);
|
||||||
errors.clear();
|
errors.clear();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ DECLARE_TYPEOF_COLLECTION(int);
|
|||||||
|
|
||||||
AddCardAction::AddCardAction(Set& set)
|
AddCardAction::AddCardAction(Set& set)
|
||||||
: CardListAction(set)
|
: CardListAction(set)
|
||||||
, action(ADD, intrusive(new Card(*set.game)), set.cards)
|
, action(ADD, make_intrusive<Card>(*set.game), set.cards)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
AddCardAction::AddCardAction(AddingOrRemoving ar, Set& set, const CardP& card)
|
AddCardAction::AddCardAction(AddingOrRemoving ar, Set& set, const CardP& card)
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ ControlPointRemoveAction::ControlPointRemoveAction(const SymbolShapeP& shape, co
|
|||||||
FOR_EACH(point, shape->points) {
|
FOR_EACH(point, shape->points) {
|
||||||
if (to_delete.find(point) != to_delete.end()) {
|
if (to_delete.find(point) != to_delete.end()) {
|
||||||
// remove this point
|
// remove this point
|
||||||
removals.push_back(intrusive(new SinglePointRemoveAction(shape, index)));
|
removals.push_back(make_intrusive<SinglePointRemoveAction>(shape, index));
|
||||||
}
|
}
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
@@ -422,7 +422,7 @@ void ControlPointRemoveAction::perform(bool to_undo) {
|
|||||||
Action* control_point_remove_action(const SymbolShapeP& shape, const set<ControlPointP>& to_delete) {
|
Action* control_point_remove_action(const SymbolShapeP& shape, const set<ControlPointP>& to_delete) {
|
||||||
if (shape->points.size() - to_delete.size() < 2) {
|
if (shape->points.size() - to_delete.size() < 2) {
|
||||||
// TODO : remove part?
|
// TODO : remove part?
|
||||||
//intrusive(new ControlPointRemoveAllAction(part));
|
//make_intrusive<ControlPointRemoveAllAction>(part);
|
||||||
return 0; // no action
|
return 0; // no action
|
||||||
} else {
|
} else {
|
||||||
return new ControlPointRemoveAction(shape, to_delete);
|
return new ControlPointRemoveAction(shape, to_delete);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ void AddCardsScript::perform(Set& set, vector<CardP>& out) {
|
|||||||
// is this a new card?
|
// is this a new card?
|
||||||
if (contains(set.cards,card) || contains(out,card)) {
|
if (contains(set.cards,card) || contains(out,card)) {
|
||||||
// make copy
|
// make copy
|
||||||
card = intrusive(new Card(*card));
|
card = make_intrusive<Card>(*card);
|
||||||
}
|
}
|
||||||
out.push_back(card);
|
out.push_back(card);
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-9
@@ -76,15 +76,15 @@ intrusive_ptr<Field> read_new<Field>(Reader& reader) {
|
|||||||
// there must be a type specified
|
// there must be a type specified
|
||||||
String type;
|
String type;
|
||||||
reader.handle(_("type"), type);
|
reader.handle(_("type"), type);
|
||||||
if (type == _("text")) return intrusive(new TextField());
|
if (type == _("text")) return make_intrusive<TextField>();
|
||||||
else if (type == _("choice")) return intrusive(new ChoiceField());
|
else if (type == _("choice")) return make_intrusive<ChoiceField>();
|
||||||
else if (type == _("multiple choice")) return intrusive(new MultipleChoiceField());
|
else if (type == _("multiple choice")) return make_intrusive<MultipleChoiceField>();
|
||||||
else if (type == _("boolean")) return intrusive(new BooleanField());
|
else if (type == _("boolean")) return make_intrusive<BooleanField>();
|
||||||
else if (type == _("image")) return intrusive(new ImageField());
|
else if (type == _("image")) return make_intrusive<ImageField>();
|
||||||
else if (type == _("symbol")) return intrusive(new SymbolField());
|
else if (type == _("symbol")) return make_intrusive<SymbolField>();
|
||||||
else if (type == _("color")) return intrusive(new ColorField());
|
else if (type == _("color")) return make_intrusive<ColorField>();
|
||||||
else if (type == _("info")) return intrusive(new InfoField());
|
else if (type == _("info")) return make_intrusive<InfoField>();
|
||||||
else if (type == _("package choice")) return intrusive(new PackageChoiceField());
|
else if (type == _("package choice")) return make_intrusive<PackageChoiceField>();
|
||||||
else if (type.empty()) {
|
else if (type.empty()) {
|
||||||
reader.warning(_ERROR_1_("expected key", _("type")));
|
reader.warning(_ERROR_1_("expected key", _("type")));
|
||||||
throw ParseError(_ERROR_("aborting parsing"));
|
throw ParseError(_ERROR_("aborting parsing"));
|
||||||
|
|||||||
+17
-17
@@ -265,23 +265,23 @@ inline String type_name(const Value&) {
|
|||||||
virtual String typeName() const
|
virtual String typeName() const
|
||||||
|
|
||||||
// implement newStyle and newValue
|
// implement newStyle and newValue
|
||||||
#define IMPLEMENT_FIELD_TYPE(Type, NAME) \
|
#define IMPLEMENT_FIELD_TYPE(Type, NAME) \
|
||||||
StyleP Type ## Field::newStyle(const FieldP& thisP) const { \
|
StyleP Type ## Field::newStyle(const FieldP& thisP) const { \
|
||||||
assert(thisP.get() == this); \
|
assert(thisP.get() == this); \
|
||||||
return intrusive(new Type ## Style(static_pointer_cast<Type ## Field>(thisP))); \
|
return make_intrusive<Type ## Style>(static_pointer_cast<Type ## Field>(thisP)); \
|
||||||
} \
|
} \
|
||||||
ValueP Type ## Field::newValue(const FieldP& thisP) const { \
|
ValueP Type ## Field::newValue(const FieldP& thisP) const { \
|
||||||
assert(thisP.get() == this); \
|
assert(thisP.get() == this); \
|
||||||
return intrusive(new Type ## Value(static_pointer_cast<Type ## Field>(thisP))); \
|
return make_intrusive<Type ## Value>(static_pointer_cast<Type ## Field>(thisP)); \
|
||||||
} \
|
} \
|
||||||
StyleP Type ## Style::clone() const { \
|
StyleP Type ## Style::clone() const { \
|
||||||
return intrusive(new Type ## Style(*this)); \
|
return make_intrusive<Type ## Style>(*this); \
|
||||||
} \
|
} \
|
||||||
ValueP Type ## Value::clone() const { \
|
ValueP Type ## Value::clone() const { \
|
||||||
return intrusive(new Type ## Value(*this)); \
|
return make_intrusive<Type ## Value>(*this); \
|
||||||
} \
|
} \
|
||||||
String Type ## Field::typeName() const { \
|
String Type ## Field::typeName() const { \
|
||||||
return _(NAME); \
|
return _(NAME); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DECLARE_STYLE_TYPE(Type) \
|
#define DECLARE_STYLE_TYPE(Type) \
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
// ----------------------------------------------------------------------------- : BooleanField
|
// ----------------------------------------------------------------------------- : BooleanField
|
||||||
|
|
||||||
BooleanField::BooleanField() {
|
BooleanField::BooleanField() {
|
||||||
choices->choices.push_back(intrusive(new Choice(_("yes"))));
|
choices->choices.push_back(make_intrusive<Choice>(_("yes")));
|
||||||
choices->choices.push_back(intrusive(new Choice(_("no"))));
|
choices->choices.push_back(make_intrusive<Choice>(_("no")));
|
||||||
choices->initIds();
|
choices->initIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,10 +32,8 @@ BooleanStyle::BooleanStyle(const ChoiceFieldP& field)
|
|||||||
: ChoiceStyle(field)
|
: ChoiceStyle(field)
|
||||||
{
|
{
|
||||||
render_style = RENDER_BOTH;
|
render_style = RENDER_BOTH;
|
||||||
//choice_images[_("yes")] = ScriptableImage(_("buildin_image(\"bool_yes\")"));
|
choice_images[_("yes")] = ScriptableImage(make_intrusive<BuiltInImage>(_("bool_yes")));
|
||||||
//choice_images[_("no")] = ScriptableImage(_("buildin_image(\"bool_no\")"));
|
choice_images[_("no")] = ScriptableImage(make_intrusive<BuiltInImage>(_("bool_no")));
|
||||||
choice_images[_("yes")] = ScriptableImage(intrusive(new BuiltInImage(_("bool_yes"))));
|
|
||||||
choice_images[_("no")] = ScriptableImage(intrusive(new BuiltInImage(_("bool_no"))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_REFLECTION(BooleanStyle) {
|
IMPLEMENT_REFLECTION(BooleanStyle) {
|
||||||
|
|||||||
@@ -48,5 +48,5 @@ void ImageValue::reflect(Writer& tag) {
|
|||||||
void ImageValue::reflect(GetMember& tag) {}
|
void ImageValue::reflect(GetMember& tag) {}
|
||||||
void ImageValue::reflect(GetDefaultMember& tag) {
|
void ImageValue::reflect(GetDefaultMember& tag) {
|
||||||
// convert to ScriptImageP for scripting
|
// convert to ScriptImageP for scripting
|
||||||
tag.handle( (ScriptValueP)intrusive(new ImageValueToImage(filename, last_update)) );
|
tag.handle( (ScriptValueP)make_intrusive<ImageValueToImage>(filename, last_update) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -538,7 +538,7 @@ void ApprCardDatabase::doRead(wxInputStream& in) {
|
|||||||
progress_target->onProgress(0.4f * float(i) / cards.size(),
|
progress_target->onProgress(0.4f * float(i) / cards.size(),
|
||||||
String(_("reading card ")) << i << _(" of ") << (int)cards.size());
|
String(_("reading card ")) << i << _(" of ") << (int)cards.size());
|
||||||
}
|
}
|
||||||
card = intrusive(new ApprCardRecord());
|
card = make_intrusive<ApprCardRecord>();
|
||||||
card->readHead(data);
|
card->readHead(data);
|
||||||
head_pos = in.TellI();
|
head_pos = in.TellI();
|
||||||
in.SeekI(card->data_pos);
|
in.SeekI(card->data_pos);
|
||||||
@@ -753,7 +753,7 @@ bool ApprenticeExportWindow::exportSet() {
|
|||||||
cardlist.removeSet(set->apprentice_code);
|
cardlist.removeSet(set->apprentice_code);
|
||||||
// add cards from set
|
// add cards from set
|
||||||
FOR_EACH(card, set->cards) {
|
FOR_EACH(card, set->cards) {
|
||||||
ApprCardRecordP rec = intrusive(new ApprCardRecord(*card, set->apprentice_code));
|
ApprCardRecordP rec = make_intrusive<ApprCardRecord>(*card, set->apprentice_code);
|
||||||
cardlist.cards.push_back(rec);
|
cardlist.cards.push_back(rec);
|
||||||
}
|
}
|
||||||
cardlist.write();
|
cardlist.write();
|
||||||
|
|||||||
@@ -10,9 +10,6 @@
|
|||||||
#include <data/format/formats.hpp>
|
#include <data/format/formats.hpp>
|
||||||
#include <data/set.hpp>
|
#include <data/set.hpp>
|
||||||
|
|
||||||
DECLARE_POINTER_TYPE(FileFormat);
|
|
||||||
DECLARE_TYPEOF_COLLECTION(FileFormatP);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Formats
|
// ----------------------------------------------------------------------------- : Formats
|
||||||
|
|
||||||
// All supported file 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) {
|
void export_set(Set& set, const String& filename, size_t format_index, bool is_copy) {
|
||||||
FileFormatP format = file_formats.at(format_index);
|
FileFormat& format = *file_formats.at(format_index);
|
||||||
if (!format->canExport(*set.game)) {
|
if (!format.canExport(*set.game)) {
|
||||||
throw InternalError(_("File format doesn't apply to set"));
|
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) {
|
SetP import_set(String name) {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
class Game;
|
class Game;
|
||||||
DECLARE_POINTER_TYPE(Set);
|
DECLARE_POINTER_TYPE(Set);
|
||||||
DECLARE_POINTER_TYPE(Card);
|
DECLARE_POINTER_TYPE(Card);
|
||||||
DECLARE_POINTER_TYPE(FileFormat);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : FileFormat
|
// ----------------------------------------------------------------------------- : FileFormat
|
||||||
|
|
||||||
@@ -47,6 +46,8 @@ class FileFormat : public IntrusivePtrVirtualBase {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using FileFormatP = unique_ptr<FileFormat>;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Formats
|
// ----------------------------------------------------------------------------- : Formats
|
||||||
|
|
||||||
/// Initialize the list of file formats
|
/// Initialize the list of file formats
|
||||||
|
|||||||
@@ -187,10 +187,10 @@ SymbolShapeP read_symbol_shape(const ImageData& data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add to shape and place a mark
|
// add to shape and place a mark
|
||||||
shape->points.push_back(intrusive(new ControlPoint(
|
shape->points.push_back(make_intrusive<ControlPoint>(
|
||||||
double(x) / data.width,
|
double(x) / data.width,
|
||||||
double(y) / data.height
|
double(y) / data.height
|
||||||
)));
|
));
|
||||||
if (x > old_x) data(old_x, y) |= MARKED; // mark when moving right -> only mark the top of the shape
|
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);
|
last_move = (x + y) - (old_x + old_y);
|
||||||
old_x = x;
|
old_x = x;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class MSE1FileFormat : public FileFormat {
|
|||||||
};
|
};
|
||||||
|
|
||||||
FileFormatP mse1_file_format() {
|
FileFormatP mse1_file_format() {
|
||||||
return intrusive(new MSE1FileFormat());
|
return make_unique<MSE1FileFormat>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Importing
|
// ----------------------------------------------------------------------------- : Importing
|
||||||
|
|||||||
@@ -45,5 +45,5 @@ class MSE2FileFormat : public FileFormat {
|
|||||||
};
|
};
|
||||||
|
|
||||||
FileFormatP mse2_file_format() {
|
FileFormatP mse2_file_format() {
|
||||||
return intrusive(new MSE2FileFormat());
|
return make_unique<MSE2FileFormat>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class MtgEditorFileFormat : public FileFormat {
|
|||||||
};
|
};
|
||||||
|
|
||||||
FileFormatP mtg_editor_file_format() {
|
FileFormatP mtg_editor_file_format() {
|
||||||
return intrusive(new MtgEditorFileFormat());
|
return make_unique<MtgEditorFileFormat>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Importing
|
// ----------------------------------------------------------------------------- : Importing
|
||||||
@@ -69,7 +69,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
|
|||||||
// read file
|
// read file
|
||||||
while (!f.Eof()) {
|
while (!f.Eof()) {
|
||||||
// read a line
|
// read a line
|
||||||
if (!current_card) current_card = intrusive(new Card(*set->game));
|
if (!current_card) current_card = make_intrusive<Card>(*set->game);
|
||||||
String line = file.ReadLine();
|
String line = file.ReadLine();
|
||||||
if (line == _("#SET###########")) { // set.title
|
if (line == _("#SET###########")) { // set.title
|
||||||
target = &set->value<TextValue>(_("title")).value;
|
target = &set->value<TextValue>(_("title")).value;
|
||||||
@@ -104,7 +104,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
|
|||||||
set->cards.push_back(current_card);
|
set->cards.push_back(current_card);
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
current_card = intrusive(new Card(*set->game));
|
current_card = make_intrusive<Card>(*set->game);
|
||||||
target = ¤t_card->value<TextValue>(_("name")).value;
|
target = ¤t_card->value<TextValue>(_("name")).value;
|
||||||
} else if (line == _("#DATE##########")) { // date
|
} else if (line == _("#DATE##########")) { // date
|
||||||
// remember date for generation of illustration filename
|
// remember date for generation of illustration filename
|
||||||
|
|||||||
+2
-2
@@ -73,7 +73,7 @@ void Game::validate(Version v) {
|
|||||||
vector<StatsDimensionP> dims;
|
vector<StatsDimensionP> dims;
|
||||||
FOR_EACH(f, card_fields) {
|
FOR_EACH(f, card_fields) {
|
||||||
if (f->show_statistics) {
|
if (f->show_statistics) {
|
||||||
dims.push_back(intrusive(new StatsDimension(*f)));
|
dims.push_back(make_intrusive<StatsDimension>(*f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
statistics_dimensions.insert(statistics_dimensions.begin(), dims.begin(), dims.end()); // push front
|
statistics_dimensions.insert(statistics_dimensions.begin(), dims.begin(), dims.end()); // push front
|
||||||
@@ -82,7 +82,7 @@ void Game::validate(Version v) {
|
|||||||
{
|
{
|
||||||
vector<StatsCategoryP> cats;
|
vector<StatsCategoryP> cats;
|
||||||
FOR_EACH(dim, statistics_dimensions) {
|
FOR_EACH(dim, statistics_dimensions) {
|
||||||
cats.push_back(intrusive(new StatsCategory(dim)));
|
cats.push_back(make_intrusive<StatsCategory>(dim));
|
||||||
}
|
}
|
||||||
statistics_categories.insert(statistics_categories.begin(), cats.begin(), cats.end()); // push front
|
statistics_categories.insert(statistics_categories.begin(), cats.begin(), cats.end()); // push front
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,12 +105,12 @@ void Installer::install(bool local, bool check_dependencies) {
|
|||||||
}
|
}
|
||||||
PackagedP pack;
|
PackagedP pack;
|
||||||
wxString fn(wxFileName(p).GetExt());
|
wxString fn(wxFileName(p).GetExt());
|
||||||
if (fn == _("mse-game")) pack = intrusive(new Game());
|
if (fn == _("mse-game")) pack = make_intrusive<Game>();
|
||||||
else if (fn == _("mse-style")) pack = intrusive(new StyleSheet());
|
else if (fn == _("mse-style")) pack = make_intrusive<StyleSheet>();
|
||||||
else if (fn == _("mse-locale")) pack = intrusive(new Locale());
|
else if (fn == _("mse-locale")) pack = make_intrusive<Locale>();
|
||||||
else if (fn == _("mse-include")) pack = intrusive(new IncludePackage());
|
else if (fn == _("mse-include")) pack = make_intrusive<IncludePackage>();
|
||||||
else if (fn == _("mse-symbol-font")) pack = intrusive(new SymbolFont());
|
else if (fn == _("mse-symbol-font")) pack = make_intrusive<SymbolFont>();
|
||||||
else if (fn == _("mse-export-template")) pack = intrusive(new ExportTemplate());
|
else if (fn == _("mse-export-template")) pack = make_intrusive<ExportTemplate>();
|
||||||
else {
|
else {
|
||||||
throw PackageError(_("Unrecognized package type: '") + fn + _("'\nwhile trying to install: ") + p);
|
throw PackageError(_("Unrecognized package type: '") + fn + _("'\nwhile trying to install: ") + p);
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ void Installer::addPackage(Packaged& package) {
|
|||||||
return; // already added
|
return; // already added
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
packages.push_back(intrusive(new PackageDescription(package)));
|
packages.push_back(make_intrusive<PackageDescription>(package));
|
||||||
// use this as a filename?
|
// use this as a filename?
|
||||||
if (prefered_filename.empty()) {
|
if (prefered_filename.empty()) {
|
||||||
prefered_filename = package.name() + _(".mse-installer");
|
prefered_filename = package.name() + _(".mse-installer");
|
||||||
@@ -387,7 +387,7 @@ void merge(InstallablePackages& list1, const InstallablePackages& list2) {
|
|||||||
void merge(InstallablePackages& installed, const DownloadableInstallerP& installer) {
|
void merge(InstallablePackages& installed, const DownloadableInstallerP& installer) {
|
||||||
InstallablePackages ips;
|
InstallablePackages ips;
|
||||||
FOR_EACH(p, installer->packages) {
|
FOR_EACH(p, installer->packages) {
|
||||||
ips.push_back(intrusive(new InstallablePackage(p,installer)));
|
ips.push_back(make_intrusive<InstallablePackage>(p,installer));
|
||||||
}
|
}
|
||||||
sort(ips);
|
sort(ips);
|
||||||
merge(installed, ips);
|
merge(installed, ips);
|
||||||
@@ -625,5 +625,5 @@ InstallablePackageP mse_installable_package() {
|
|||||||
mse_description->position_hint = -100;
|
mse_description->position_hint = -100;
|
||||||
mse_description->icon = load_resource_image(_("installer_program"));
|
mse_description->icon = load_resource_image(_("installer_program"));
|
||||||
//mse_description->description = _LABEL_("magic set editor package");
|
//mse_description->description = _LABEL_("magic set editor package");
|
||||||
return intrusive(new InstallablePackage(mse_description, mse_version));
|
return make_intrusive<InstallablePackage>(mse_description, mse_version);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -77,7 +77,7 @@ SubLocaleP find_wildcard(map<String,SubLocaleP>& items, const String& name) {
|
|||||||
FOR_EACH_CONST(i, items) {
|
FOR_EACH_CONST(i, items) {
|
||||||
if (i.second && match_wildcard(i.first, name)) return i.second;
|
if (i.second && match_wildcard(i.first, name)) return i.second;
|
||||||
}
|
}
|
||||||
return intrusive(new SubLocale()); // so we don't search again
|
return make_intrusive<SubLocale>(); // so we don't search again
|
||||||
}
|
}
|
||||||
SubLocaleP find_wildcard_and_set(map<String,SubLocaleP>& items, const String& name) {
|
SubLocaleP find_wildcard_and_set(map<String,SubLocaleP>& items, const String& name) {
|
||||||
return items[name] = find_wildcard(items, name);
|
return items[name] = find_wildcard(items, name);
|
||||||
|
|||||||
+6
-6
@@ -29,13 +29,13 @@ DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA ValueP>);
|
|||||||
// ----------------------------------------------------------------------------- : Set
|
// ----------------------------------------------------------------------------- : Set
|
||||||
|
|
||||||
Set::Set()
|
Set::Set()
|
||||||
: vcs (intrusive(new VCS()))
|
: vcs (make_intrusive<VCS>())
|
||||||
, script_manager(new SetScriptManager(*this))
|
, script_manager(new SetScriptManager(*this))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Set::Set(const GameP& game)
|
Set::Set(const GameP& game)
|
||||||
: game(game)
|
: game(game)
|
||||||
, vcs (intrusive(new VCS()))
|
, vcs (make_intrusive<VCS>())
|
||||||
, script_manager(new SetScriptManager(*this))
|
, script_manager(new SetScriptManager(*this))
|
||||||
{
|
{
|
||||||
data.init(game->set_fields);
|
data.init(game->set_fields);
|
||||||
@@ -44,7 +44,7 @@ Set::Set(const GameP& game)
|
|||||||
Set::Set(const StyleSheetP& stylesheet)
|
Set::Set(const StyleSheetP& stylesheet)
|
||||||
: game(stylesheet->game)
|
: game(stylesheet->game)
|
||||||
, stylesheet(stylesheet)
|
, stylesheet(stylesheet)
|
||||||
, vcs (intrusive(new VCS()))
|
, vcs (make_intrusive<VCS>())
|
||||||
, script_manager(new SetScriptManager(*this))
|
, script_manager(new SetScriptManager(*this))
|
||||||
{
|
{
|
||||||
data.init(game->set_fields);
|
data.init(game->set_fields);
|
||||||
@@ -164,7 +164,7 @@ void Set::validate(Version file_app_version) {
|
|||||||
}
|
}
|
||||||
*/ }
|
*/ }
|
||||||
// we want at least one card
|
// we want at least one card
|
||||||
if (cards.empty()) cards.push_back(intrusive(new Card(*game)));
|
if (cards.empty()) cards.push_back(make_intrusive<Card>(*game));
|
||||||
// update scripts
|
// update scripts
|
||||||
script_manager->updateAll();
|
script_manager->updateAll();
|
||||||
}
|
}
|
||||||
@@ -234,7 +234,7 @@ void Set::reflect_cards<Writer> (Writer& tag) {
|
|||||||
// ----------------------------------------------------------------------------- : Script utilities
|
// ----------------------------------------------------------------------------- : Script utilities
|
||||||
|
|
||||||
ScriptValueP make_iterator(const Set& set) {
|
ScriptValueP make_iterator(const Set& set) {
|
||||||
return intrusive(new ScriptCollectionIterator<vector<CardP> >(&set.cards));
|
return make_intrusive<ScriptCollectionIterator<vector<CardP>>>(&set.cards);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mark_dependency_member(const Set& set, const String& name, const Dependency& dep) {
|
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"));
|
Profiler prof(t, order_by.get(), _("init order cache"));
|
||||||
#endif
|
#endif
|
||||||
// 3. initialize order cache
|
// 3. initialize order cache
|
||||||
order = intrusive(new OrderCache<CardP>(cards, values, filter ? &keep : nullptr));
|
order = make_intrusive<OrderCache<CardP>>(cards, values, filter ? &keep : nullptr);
|
||||||
}
|
}
|
||||||
return order->find(card);
|
return order->find(card);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ void Settings::addRecentFile(const String& filename) {
|
|||||||
|
|
||||||
GameSettings& Settings::gameSettingsFor(const Game& game) {
|
GameSettings& Settings::gameSettingsFor(const Game& game) {
|
||||||
GameSettingsP& gs = game_settings[game.name()];
|
GameSettingsP& gs = game_settings[game.name()];
|
||||||
if (!gs) gs = intrusive(new GameSettings);
|
if (!gs) gs = make_intrusive<GameSettings>();
|
||||||
gs->initDefaults(game);
|
gs->initDefaults(game);
|
||||||
return *gs;
|
return *gs;
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field
|
|||||||
}
|
}
|
||||||
StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet) {
|
StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet) {
|
||||||
StyleSheetSettingsP& ss = stylesheet_settings[stylesheet.name()];
|
StyleSheetSettingsP& ss = stylesheet_settings[stylesheet.name()];
|
||||||
if (!ss) ss = intrusive(new StyleSheetSettings);
|
if (!ss) ss = make_intrusive<StyleSheetSettings>();
|
||||||
ss->useDefault(default_stylesheet_settings); // update default settings
|
ss->useDefault(default_stylesheet_settings); // update default settings
|
||||||
return *ss;
|
return *ss;
|
||||||
}
|
}
|
||||||
@@ -295,7 +295,7 @@ void Settings::read() {
|
|||||||
String filename = settingsFile();
|
String filename = settingsFile();
|
||||||
if (wxFileExists(filename)) {
|
if (wxFileExists(filename)) {
|
||||||
// settings file not existing is not an error
|
// settings file not existing is not an error
|
||||||
shared_ptr<wxFileInputStream> file = shared(new wxFileInputStream(filename));
|
shared_ptr<wxFileInputStream> file = make_shared<wxFileInputStream>(filename);
|
||||||
if (!file->Ok()) return; // failure is not an error
|
if (!file->Ok()) return; // failure is not an error
|
||||||
Reader reader(file, nullptr, filename);
|
Reader reader(file, nullptr, filename);
|
||||||
reader.handle_greedy(*this);
|
reader.handle_greedy(*this);
|
||||||
@@ -303,6 +303,6 @@ void Settings::read() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Settings::write() {
|
void Settings::write() {
|
||||||
Writer writer(shared(new wxFileOutputStream(settingsFile())), app_version);
|
Writer writer(make_shared<wxFileOutputStream>(settingsFile()), app_version);
|
||||||
writer.handle(*this);
|
writer.handle(*this);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -139,9 +139,9 @@ SymbolPartP read_new<SymbolPart>(Reader& reader) {
|
|||||||
// there must be a type specified
|
// there must be a type specified
|
||||||
String type;
|
String type;
|
||||||
reader.handle(_("type"), type);
|
reader.handle(_("type"), type);
|
||||||
if (type == _("shape") || type.empty()) return intrusive(new SymbolShape);
|
if (type == _("shape") || type.empty()) return make_intrusive<SymbolShape>();
|
||||||
else if (type == _("symmetry")) return intrusive(new SymbolSymmetry);
|
else if (type == _("symmetry")) return make_intrusive<SymbolSymmetry>();
|
||||||
else if (type == _("group")) return intrusive(new SymbolGroup);
|
else if (type == _("group")) return make_intrusive<SymbolGroup>();
|
||||||
else {
|
else {
|
||||||
throw ParseError(_("Unsupported symbol part type: '") + type + _("'"));
|
throw ParseError(_("Unsupported symbol part type: '") + type + _("'"));
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ SymbolPartP SymbolShape::clone() const {
|
|||||||
SymbolShapeP part(new SymbolShape(*this));
|
SymbolShapeP part(new SymbolShape(*this));
|
||||||
// also clone the control points
|
// also clone the control points
|
||||||
FOR_EACH(p, part->points) {
|
FOR_EACH(p, part->points) {
|
||||||
p = intrusive(new ControlPoint(*p));
|
p = make_intrusive<ControlPoint>(*p);
|
||||||
}
|
}
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
@@ -357,18 +357,18 @@ double Symbol::aspectRatio() const {
|
|||||||
|
|
||||||
// A default symbol part, a square, moved by d
|
// A default symbol part, a square, moved by d
|
||||||
SymbolShapeP default_symbol_part(double d) {
|
SymbolShapeP default_symbol_part(double d) {
|
||||||
SymbolShapeP part = intrusive(new SymbolShape);
|
SymbolShapeP part = make_intrusive<SymbolShape>();
|
||||||
part->points.push_back(intrusive(new ControlPoint(d + .2, d + .2)));
|
part->points.push_back(make_intrusive<ControlPoint>(d + .2, d + .2));
|
||||||
part->points.push_back(intrusive(new ControlPoint(d + .2, d + .8)));
|
part->points.push_back(make_intrusive<ControlPoint>(d + .2, d + .8));
|
||||||
part->points.push_back(intrusive(new ControlPoint(d + .8, d + .8)));
|
part->points.push_back(make_intrusive<ControlPoint>(d + .8, d + .8));
|
||||||
part->points.push_back(intrusive(new ControlPoint(d + .8, d + .2)));
|
part->points.push_back(make_intrusive<ControlPoint>(d + .8, d + .2));
|
||||||
part->name = _("Square");
|
part->name = _("Square");
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A default symbol, a square
|
// A default symbol, a square
|
||||||
SymbolP default_symbol() {
|
SymbolP default_symbol() {
|
||||||
SymbolP symbol = intrusive(new Symbol);
|
auto symbol = make_intrusive<Symbol>();
|
||||||
symbol->parts.push_back(default_symbol_part(0));
|
symbol->parts.push_back(default_symbol_part(0));
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class AutoReplace : public IntrusivePtrVirtualBase {
|
|||||||
String match;
|
String match;
|
||||||
String replace;
|
String replace;
|
||||||
|
|
||||||
inline AutoReplaceP clone() const { return intrusive(new AutoReplace(*this)); }
|
inline AutoReplaceP clone() const { return make_intrusive<AutoReplace>(*this); }
|
||||||
|
|
||||||
DECLARE_REFLECTION();
|
DECLARE_REFLECTION();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ void AutoReplaceWindow::onRemove(wxCommandEvent&) {
|
|||||||
list->removeSelected();
|
list->removeSelected();
|
||||||
}
|
}
|
||||||
void AutoReplaceWindow::onAdd(wxCommandEvent&) {
|
void AutoReplaceWindow::onAdd(wxCommandEvent&) {
|
||||||
list->addItem(intrusive(new AutoReplace()));
|
list->addItem(make_intrusive<AutoReplace>());
|
||||||
}
|
}
|
||||||
void AutoReplaceWindow::onDefault(wxCommandEvent&) {
|
void AutoReplaceWindow::onDefault(wxCommandEvent&) {
|
||||||
use_auto_replace->SetValue(true);
|
use_auto_replace->SetValue(true);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class FilterCtrl : public wxControl {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
intrusive_ptr<Filter<T> > getFilter() const {
|
intrusive_ptr<Filter<T> > getFilter() const {
|
||||||
if (hasFilter()) {
|
if (hasFilter()) {
|
||||||
return intrusive(new QuickFilter<T>(getFilterString()));
|
return make_intrusive<QuickFilter<T>>(getFilterString());
|
||||||
} else {
|
} else {
|
||||||
return intrusive_ptr<Filter<T> >();
|
return intrusive_ptr<Filter<T> >();
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-22
@@ -1039,39 +1039,39 @@ void GraphControl::setLayout(GraphType type, bool force) {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case GRAPH_TYPE_BAR: {
|
case GRAPH_TYPE_BAR: {
|
||||||
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
||||||
combined->add(intrusive(new GraphValueAxis(0, true)));
|
combined->add(make_intrusive<GraphValueAxis>(0, true));
|
||||||
combined->add(intrusive(new GraphLabelAxis(0, HORIZONTAL)));
|
combined->add(make_intrusive<GraphLabelAxis>(0, HORIZONTAL));
|
||||||
combined->add(intrusive(new BarGraph(0)));
|
combined->add(make_intrusive<BarGraph>(0));
|
||||||
combined->add(intrusive(new GraphStats(0, ALIGN_TOP_RIGHT)));
|
combined->add(make_intrusive<GraphStats>(0, ALIGN_TOP_RIGHT));
|
||||||
graph = intrusive(new GraphWithMargins(combined, 23,8,7,20));
|
graph = make_intrusive<GraphWithMargins>(combined, 23,8,7,20);
|
||||||
break;
|
break;
|
||||||
} case GRAPH_TYPE_PIE: {
|
} case GRAPH_TYPE_PIE: {
|
||||||
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
||||||
combined->add(intrusive(new GraphWithMargins(intrusive(new PieGraph(0)), 0,0,120,0)));
|
combined->add(make_intrusive<GraphWithMargins>(make_intrusive<PieGraph>(0), 0,0,120,0));
|
||||||
combined->add(intrusive(new GraphLegend(0, ALIGN_TOP_RIGHT, false)));
|
combined->add(make_intrusive<GraphLegend>(0, ALIGN_TOP_RIGHT, false));
|
||||||
graph = intrusive(new GraphWithMargins(combined, 20,20,20,20));
|
graph = make_intrusive<GraphWithMargins>(combined, 20,20,20,20);
|
||||||
break;
|
break;
|
||||||
} case GRAPH_TYPE_STACK: {
|
} case GRAPH_TYPE_STACK: {
|
||||||
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
||||||
combined->add(intrusive(new GraphValueAxis(0, false)));
|
combined->add(make_intrusive<GraphValueAxis>(0, false));
|
||||||
combined->add(intrusive(new GraphLabelAxis(0, HORIZONTAL)));
|
combined->add(make_intrusive<GraphLabelAxis>(0, HORIZONTAL));
|
||||||
combined->add(intrusive(new BarGraph2D(0,1)));
|
combined->add(make_intrusive<BarGraph2D>(0,1));
|
||||||
combined->add(intrusive(new GraphLegend(1, ALIGN_TOP_RIGHT, true)));
|
combined->add(make_intrusive<GraphLegend>(1, ALIGN_TOP_RIGHT, true));
|
||||||
graph = intrusive(new GraphWithMargins(combined, 23,8,7,20));
|
graph = make_intrusive<GraphWithMargins>(combined, 23,8,7,20);
|
||||||
break;
|
break;
|
||||||
} case GRAPH_TYPE_SCATTER: {
|
} case GRAPH_TYPE_SCATTER: {
|
||||||
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
||||||
combined->add(intrusive(new GraphLabelAxis(0, HORIZONTAL, false, DRAW_LINES_MID)));
|
combined->add(make_intrusive<GraphLabelAxis>(0, HORIZONTAL, false, DRAW_LINES_MID));
|
||||||
combined->add(intrusive(new GraphLabelAxis(1, VERTICAL, false, DRAW_LINES_MID)));
|
combined->add(make_intrusive<GraphLabelAxis>(1, VERTICAL, false, DRAW_LINES_MID));
|
||||||
combined->add(intrusive(new ScatterGraph(0,1)));
|
combined->add(make_intrusive<ScatterGraph>(0,1));
|
||||||
graph = intrusive(new GraphWithMargins(combined, 80,8,7,20));
|
graph = make_intrusive<GraphWithMargins>(combined, 80,8,7,20);
|
||||||
break;
|
break;
|
||||||
} case GRAPH_TYPE_SCATTER_PIE: {
|
} case GRAPH_TYPE_SCATTER_PIE: {
|
||||||
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
||||||
combined->add(intrusive(new GraphLabelAxis(0, HORIZONTAL, false, DRAW_LINES_MID)));
|
combined->add(make_intrusive<GraphLabelAxis>(0, HORIZONTAL, false, DRAW_LINES_MID));
|
||||||
combined->add(intrusive(new GraphLabelAxis(1, VERTICAL, false, DRAW_LINES_MID)));
|
combined->add(make_intrusive<GraphLabelAxis>(1, VERTICAL, false, DRAW_LINES_MID));
|
||||||
combined->add(intrusive(new ScatterPieGraph(0,1,2)));
|
combined->add(make_intrusive<ScatterPieGraph>(0,1,2));
|
||||||
graph = intrusive(new GraphWithMargins(combined, 80,8,7,20));
|
graph = make_intrusive<GraphWithMargins>(combined, 80,8,7,20);
|
||||||
break;
|
break;
|
||||||
} default:
|
} default:
|
||||||
graph = GraphP();
|
graph = GraphP();
|
||||||
@@ -1085,7 +1085,7 @@ GraphType GraphControl::getLayout() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GraphControl::setData(const GraphDataPre& data) {
|
void GraphControl::setData(const GraphDataPre& data) {
|
||||||
setData(intrusive(new GraphData(data)));
|
setData(make_intrusive<GraphData>(data));
|
||||||
}
|
}
|
||||||
void GraphControl::setData(const GraphDataP& data) {
|
void GraphControl::setData(const GraphDataP& data) {
|
||||||
if (graph) {
|
if (graph) {
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ int ImageCardList::OnGetItemImage(long pos) const {
|
|||||||
return it->second;
|
return it->second;
|
||||||
} else {
|
} else {
|
||||||
// request a thumbnail
|
// request a thumbnail
|
||||||
thumbnail_thread.request(intrusive(new CardThumbnailRequest(const_cast<ImageCardList*>(this), val.filename)));
|
thumbnail_thread.request(make_intrusive<CardThumbnailRequest>(const_cast<ImageCardList*>(this), val.filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ void TextCtrl::updateSize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TextCtrl::setValue(String* value, bool untagged) {
|
void TextCtrl::setValue(String* value, bool untagged) {
|
||||||
setValue(intrusive(new FakeTextValue(getFieldP(), value, true, untagged)));
|
setValue(make_intrusive<FakeTextValue>(getFieldP(), value, true, untagged));
|
||||||
}
|
}
|
||||||
void TextCtrl::setValue(const FakeTextValueP& value) {
|
void TextCtrl::setValue(const FakeTextValueP& value) {
|
||||||
value->retrieve();
|
value->retrieve();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set, const Export
|
|||||||
// init controls
|
// init controls
|
||||||
list = new PackageList(this, ID_EXPORT_LIST);
|
list = new PackageList(this, ID_EXPORT_LIST);
|
||||||
options = new ExportOptionsEditor(this, wxID_ANY, wxNO_BORDER);
|
options = new ExportOptionsEditor(this, wxID_ANY, wxNO_BORDER);
|
||||||
options->setSet(intrusive(new Set(set->stylesheet))); // dummy set
|
options->setSet(make_intrusive<Set>(set->stylesheet)); // dummy set
|
||||||
// init sizers
|
// init sizers
|
||||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||||
s->Add(new wxStaticText(this, wxID_ANY, _LABEL_("html template")), 0, wxALL, 4);
|
s->Add(new wxStaticText(this, wxID_ANY, _LABEL_("html template")), 0, wxALL, 4);
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void NewSetWindow::done() {
|
|||||||
try {
|
try {
|
||||||
if (!stylesheet_list->hasSelection()) return;
|
if (!stylesheet_list->hasSelection()) return;
|
||||||
StyleSheetP stylesheet = stylesheet_list->getSelection<StyleSheet>();
|
StyleSheetP stylesheet = stylesheet_list->getSelection<StyleSheet>();
|
||||||
set = intrusive(new Set(stylesheet));
|
set = make_intrusive<Set>(stylesheet);
|
||||||
set->validate();
|
set->validate();
|
||||||
EndModal(wxID_OK);
|
EndModal(wxID_OK);
|
||||||
} catch (const Error& e) {
|
} catch (const Error& e) {
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ void PackageUpdateList::initItems() {
|
|||||||
ti.setIcon(load_resource_image(_("installer_package")));
|
ti.setIcon(load_resource_image(_("installer_package")));
|
||||||
if (!p->description->icon_url.empty()) {
|
if (!p->description->icon_url.empty()) {
|
||||||
// download icon
|
// download icon
|
||||||
thumbnail_thread.request(intrusive(new PackageIconRequest(this,&ti)));
|
thumbnail_thread.request(make_intrusive<PackageIconRequest>(this,&ti));
|
||||||
}
|
}
|
||||||
} else if (ti.position_type == TreeItem::TYPE_LOCALE) { // locale folder
|
} else if (ti.position_type == TreeItem::TYPE_LOCALE) { // locale folder
|
||||||
ti.setIcon(load_resource_image(_("installer_locales")));
|
ti.setIcon(load_resource_image(_("installer_locales")));
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ PackagesWindow::PackagesWindow(Window* parent, const InstallerP& installer)
|
|||||||
{
|
{
|
||||||
init(parent, true);
|
init(parent, true);
|
||||||
// add installer
|
// add installer
|
||||||
merge(installable_packages, intrusive(new DownloadableInstaller(installer)));
|
merge(installable_packages, make_intrusive<DownloadableInstaller>(installer));
|
||||||
FOR_EACH(p, installable_packages) p->determineStatus();
|
FOR_EACH(p, installable_packages) p->determineStatus();
|
||||||
// mark all packages in the installer for installation
|
// mark all packages in the installer for installation
|
||||||
FOR_EACH(ip, installable_packages) {
|
FOR_EACH(ip, installable_packages) {
|
||||||
@@ -353,7 +353,7 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
|
|||||||
os.Write(*is);
|
os.Write(*is);
|
||||||
os.Close();
|
os.Close();
|
||||||
// open installer
|
// open installer
|
||||||
ip->installer->installer = intrusive(new Installer());
|
ip->installer->installer = make_intrusive<Installer>();
|
||||||
ip->installer->installer->open(ip->installer->installer_file);
|
ip->installer->installer->open(ip->installer->installer_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ PrintJobP make_print_job(Window* parent, const SetP& set, const ExportCardSelect
|
|||||||
return PrintJobP(); // cancel
|
return PrintJobP(); // cancel
|
||||||
} else {
|
} else {
|
||||||
// make print job
|
// make print job
|
||||||
PrintJobP job = intrusive(new PrintJob(set));
|
PrintJobP job = make_intrusive<PrintJob>(set);
|
||||||
job->layout_type = settings.print_layout = space->GetValue() ? LAYOUT_EQUAL_SPACE : LAYOUT_NO_SPACE;
|
job->layout_type = settings.print_layout = space->GetValue() ? LAYOUT_EQUAL_SPACE : LAYOUT_NO_SPACE;
|
||||||
job->cards = wnd.getSelection();
|
job->cards = wnd.getSelection();
|
||||||
return job;
|
return job;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class MessageCtrl : public wxScrolledWindow {
|
|||||||
Refresh(false);
|
Refresh(false);
|
||||||
}
|
}
|
||||||
void add_message(MessageType type, String const& text, bool joined_to_previous = 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<ConsoleMessage>(type,text,joined_to_previous));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool have_selection() const {
|
bool have_selection() const {
|
||||||
@@ -499,7 +499,7 @@ void ConsolePanel::exec(String const& command) {
|
|||||||
ScriptValueP result = ctx.eval(*script,false);
|
ScriptValueP result = ctx.eval(*script,false);
|
||||||
get_pending_errors();
|
get_pending_errors();
|
||||||
// show result
|
// show result
|
||||||
ConsoleMessageP message = intrusive(new ConsoleMessage(MESSAGE_OUTPUT));
|
ConsoleMessageP message = make_intrusive<ConsoleMessage>(MESSAGE_OUTPUT);
|
||||||
message->joined_to_previous = true;
|
message->joined_to_previous = true;
|
||||||
message->value = result;
|
message->value = result;
|
||||||
// type of result
|
// type of result
|
||||||
|
|||||||
@@ -344,9 +344,9 @@ void KeywordsPanel::onKeywordSelect(KeywordSelectEvent& ev) {
|
|||||||
if (ev.keyword) {
|
if (ev.keyword) {
|
||||||
Keyword& kw = *ev.keyword;
|
Keyword& kw = *ev.keyword;
|
||||||
sp->Show(fixed, kw.fixed);
|
sp->Show(fixed, kw.fixed);
|
||||||
keyword ->setValue(intrusive(new KeywordTextValue(keyword->getFieldP(), &kw, &kw.keyword, !kw.fixed, true)));
|
keyword ->setValue(make_intrusive<KeywordTextValue>(keyword->getFieldP(), &kw, &kw.keyword, !kw.fixed, true));
|
||||||
match ->setValue(intrusive(new KeywordTextValue(match->getFieldP(), &kw, &kw.match, !kw.fixed)));
|
match ->setValue(make_intrusive<KeywordTextValue>(match->getFieldP(), &kw, &kw.match, !kw.fixed));
|
||||||
rules ->setValue(intrusive(new KeywordTextValue(rules->getFieldP(), &kw, &kw.rules, !kw.fixed)));
|
rules ->setValue(make_intrusive<KeywordTextValue>(rules->getFieldP(), &kw, &kw.rules, !kw.fixed));
|
||||||
intrusive_ptr<KeywordReminderTextValue> reminder_value(new KeywordReminderTextValue(*set, reminder->getFieldP(), &kw, !kw.fixed));
|
intrusive_ptr<KeywordReminderTextValue> reminder_value(new KeywordReminderTextValue(*set, reminder->getFieldP(), &kw, !kw.fixed));
|
||||||
reminder->setValue(reminder_value);
|
reminder->setValue(reminder_value);
|
||||||
errors->SetLabel(reminder_value->errors);
|
errors->SetLabel(reminder_value->errors);
|
||||||
|
|||||||
@@ -326,14 +326,14 @@ void CustomPackDialog::updateTotals() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CustomPackDialog::storePack() {
|
void CustomPackDialog::storePack() {
|
||||||
edited_pack = intrusive(new PackType());
|
edited_pack = make_intrusive<PackType>();
|
||||||
edited_pack->selectable = true;
|
edited_pack->selectable = true;
|
||||||
edited_pack->select = SELECT_ALL;
|
edited_pack->select = SELECT_ALL;
|
||||||
edited_pack->name = name->GetValue();
|
edited_pack->name = name->GetValue();
|
||||||
FOR_EACH(pick,pickers) {
|
FOR_EACH(pick,pickers) {
|
||||||
int copies = pick.value->GetValue();
|
int copies = pick.value->GetValue();
|
||||||
if (copies > 0) {
|
if (copies > 0) {
|
||||||
edited_pack->items.push_back(intrusive(new PackItem(pick.pack->name, copies)));
|
edited_pack->items.push_back(make_intrusive<PackItem>(pick.pack->name, copies));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -632,10 +632,10 @@ void RandomPackPanel::onCardSelect(CardSelectEvent& ev) {
|
|||||||
|
|
||||||
void RandomPackPanel::selectionChoices(ExportCardSelectionChoices& out) {
|
void RandomPackPanel::selectionChoices(ExportCardSelectionChoices& out) {
|
||||||
if (!isInitialized()) return;
|
if (!isInitialized()) return;
|
||||||
out.push_back(intrusive(new ExportCardSelectionChoice(
|
out.push_back(make_intrusive<ExportCardSelectionChoice>(
|
||||||
_BUTTON_("export generated packs"),
|
_BUTTON_("export generated packs"),
|
||||||
card_list->getCardsPtr()
|
card_list->getCardsPtr()
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ void StatsPanel::showCategory(const GraphType* prefer_layout) {
|
|||||||
// create axes
|
// create axes
|
||||||
GraphDataPre d;
|
GraphDataPre d;
|
||||||
FOR_EACH(dim, dims) {
|
FOR_EACH(dim, dims) {
|
||||||
d.axes.push_back(intrusive(new GraphAxis(
|
d.axes.push_back(make_intrusive<GraphAxis>(
|
||||||
dim->name,
|
dim->name,
|
||||||
dim->colors.empty() ? AUTO_COLOR_EVEN : AUTO_COLOR_NO,
|
dim->colors.empty() ? AUTO_COLOR_EVEN : AUTO_COLOR_NO,
|
||||||
dim->numeric,
|
dim->numeric,
|
||||||
@@ -480,7 +480,7 @@ void StatsPanel::showCategory(const GraphType* prefer_layout) {
|
|||||||
&dim->colors,
|
&dim->colors,
|
||||||
dim->groups.empty() ? nullptr : &dim->groups
|
dim->groups.empty() ? nullptr : &dim->groups
|
||||||
)
|
)
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
// find values for each card
|
// find values for each card
|
||||||
for (size_t i = 0 ; i < set->cards.size() ; ++i) {
|
for (size_t i = 0 ; i < set->cards.size() ; ++i) {
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ void SetWindow::onChangeSet() {
|
|||||||
updateTitle();
|
updateTitle();
|
||||||
// make sure there is always at least one card
|
// make sure there is always at least one card
|
||||||
// some things need this
|
// 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<Card>(*set->game));
|
||||||
// all panels view the same set
|
// all panels view the same set
|
||||||
FOR_EACH(p, panels) {
|
FOR_EACH(p, panels) {
|
||||||
p->setSet(set);
|
p->setSet(set);
|
||||||
@@ -383,11 +383,11 @@ void SetWindow::onCardActivate(CardSelectEvent& ev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetWindow::selectionChoices(ExportCardSelectionChoices& out) {
|
void SetWindow::selectionChoices(ExportCardSelectionChoices& out) {
|
||||||
out.push_back(intrusive(new ExportCardSelectionChoice(*set))); // entire set
|
out.push_back(make_intrusive<ExportCardSelectionChoice>(*set)); // entire set
|
||||||
FOR_EACH(p, panels) {
|
FOR_EACH(p, panels) {
|
||||||
p->selectionChoices(out);
|
p->selectionChoices(out);
|
||||||
}
|
}
|
||||||
out.push_back(intrusive(new ExportCardSelectionChoice())); // custom
|
out.push_back(make_intrusive<ExportCardSelectionChoice>()); // custom
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Window events - close
|
// ----------------------------------------------------------------------------- : Window events - close
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ void SymbolBasicShapeEditor::makeShape(Vector2D a, Vector2D b, bool constrained,
|
|||||||
|
|
||||||
// TODO : Move out of this class
|
// TODO : Move out of this class
|
||||||
void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bool constrained) {
|
void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bool constrained) {
|
||||||
shape = intrusive(new SymbolShape);
|
shape = make_intrusive<SymbolShape>();
|
||||||
// What shape to make?
|
// What shape to make?
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case ID_SHAPE_CIRCLE: {
|
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)
|
// a circle has 4 control points, the first is: (x+r, y) db(0, kr) da(0, -kr)
|
||||||
// kr is a magic constant
|
// kr is a magic constant
|
||||||
const double kr = 0.5522847498f; // = 4/3 * (sqrt(2) - 1)
|
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(make_intrusive<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<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(make_intrusive<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<ControlPoint>(c.x, c.y + r.y, -kr * r.x, 0, kr * r.x, 0, LOCK_SIZE));
|
||||||
break;
|
break;
|
||||||
} case ID_SHAPE_RECTANGLE: {
|
} case ID_SHAPE_RECTANGLE: {
|
||||||
// A rectangle / square
|
// A rectangle / square
|
||||||
@@ -212,10 +212,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
|
|||||||
shape->name = capitalize(_TYPE_("rectangle"));
|
shape->name = capitalize(_TYPE_("rectangle"));
|
||||||
}
|
}
|
||||||
// a rectangle just has four corners
|
// 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(make_intrusive<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<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<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<ControlPoint>(c.x - r.x, c.y + r.y));
|
||||||
break;
|
break;
|
||||||
} default: {
|
} default: {
|
||||||
// A polygon or star
|
// A polygon or star
|
||||||
@@ -258,10 +258,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
|
|||||||
// we can generate points
|
// we can generate points
|
||||||
for(int i = 0 ; i < n ; ++i) {
|
for(int i = 0 ; i < n ; ++i) {
|
||||||
double theta = alpha * i;
|
double theta = alpha * i;
|
||||||
shape->points.push_back(intrusive(new ControlPoint(
|
shape->points.push_back(make_intrusive<ControlPoint>(
|
||||||
c.x + ra * r.x * sin(theta),
|
c.x + ra * r.x * sin(theta),
|
||||||
y - ra * r.y * cos(theta)
|
y - ra * r.y * cos(theta)
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// a star is made using a smaller, inverted polygon at the inside
|
// 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) {
|
for(int i = 0 ; i < n ; ++i) {
|
||||||
double theta = alpha * i;
|
double theta = alpha * i;
|
||||||
// from a
|
// from a
|
||||||
shape->points.push_back(intrusive(new ControlPoint(
|
shape->points.push_back(make_intrusive<ControlPoint>(
|
||||||
c.x + ra * r.x * sin(theta),
|
c.x + ra * r.x * sin(theta),
|
||||||
y - ra * r.y * cos(theta)
|
y - ra * r.y * cos(theta)
|
||||||
)));
|
));
|
||||||
// from b
|
// from b
|
||||||
theta = alpha * (i + 0.5);
|
theta = alpha * (i + 0.5);
|
||||||
shape->points.push_back(intrusive(new ControlPoint(
|
shape->points.push_back(make_intrusive<ControlPoint>(
|
||||||
c.x + rb * r.x * sin(theta),
|
c.x + rb * r.x * sin(theta),
|
||||||
y - rb * r.y * cos(theta)
|
y - rb * r.y * cos(theta)
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
+10
-10
@@ -39,23 +39,23 @@ void SymbolControl::switchEditor(const SymbolEditorBaseP& e) {
|
|||||||
|
|
||||||
void SymbolControl::onChangeSymbol() {
|
void SymbolControl::onChangeSymbol() {
|
||||||
selected_parts.setSymbol(symbol);
|
selected_parts.setSymbol(symbol);
|
||||||
switchEditor(intrusive(new SymbolSelectEditor(this, false)));
|
switchEditor(make_intrusive<SymbolSelectEditor>(this, false));
|
||||||
Refresh(false);
|
Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolControl::onModeChange(wxCommandEvent& ev) {
|
void SymbolControl::onModeChange(wxCommandEvent& ev) {
|
||||||
switch (ev.GetId()) {
|
switch (ev.GetId()) {
|
||||||
case ID_MODE_SELECT:
|
case ID_MODE_SELECT:
|
||||||
switchEditor(intrusive(new SymbolSelectEditor(this, false)));
|
switchEditor(make_intrusive<SymbolSelectEditor>(this, false));
|
||||||
break;
|
break;
|
||||||
case ID_MODE_ROTATE:
|
case ID_MODE_ROTATE:
|
||||||
switchEditor(intrusive(new SymbolSelectEditor(this, true)));
|
switchEditor(make_intrusive<SymbolSelectEditor>(this, true));
|
||||||
break;
|
break;
|
||||||
case ID_MODE_POINTS:
|
case ID_MODE_POINTS:
|
||||||
if (selected_parts.size() == 1) {
|
if (selected_parts.size() == 1) {
|
||||||
selected_shape = selected_parts.getAShape();
|
selected_shape = selected_parts.getAShape();
|
||||||
if (selected_shape) {
|
if (selected_shape) {
|
||||||
switchEditor(intrusive(new SymbolPointEditor(this, selected_shape)));
|
switchEditor(make_intrusive<SymbolPointEditor>(this, selected_shape));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -64,10 +64,10 @@ void SymbolControl::onModeChange(wxCommandEvent& ev) {
|
|||||||
selected_parts.clear();
|
selected_parts.clear();
|
||||||
signalSelectionChange();
|
signalSelectionChange();
|
||||||
}
|
}
|
||||||
switchEditor(intrusive(new SymbolBasicShapeEditor(this)));
|
switchEditor(make_intrusive<SymbolBasicShapeEditor>(this));
|
||||||
break;
|
break;
|
||||||
case ID_MODE_SYMMETRY:
|
case ID_MODE_SYMMETRY:
|
||||||
switchEditor(intrusive(new SymbolSymmetryEditor(this, selected_parts.getASymmetry())));
|
switchEditor(make_intrusive<SymbolSymmetryEditor>(this, selected_parts.getASymmetry()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ void SymbolControl::onUpdateSelection() {
|
|||||||
}
|
}
|
||||||
// begin editing another part
|
// begin editing another part
|
||||||
selected_shape = shape;
|
selected_shape = shape;
|
||||||
editor = intrusive(new SymbolPointEditor(this, selected_shape));
|
editor = make_intrusive<SymbolPointEditor>(this, selected_shape);
|
||||||
Refresh(false);
|
Refresh(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -147,17 +147,17 @@ void SymbolControl::onUpdateSelection() {
|
|||||||
|
|
||||||
void SymbolControl::selectPart(const SymbolPartP& part) {
|
void SymbolControl::selectPart(const SymbolPartP& part) {
|
||||||
selected_parts.select(part);
|
selected_parts.select(part);
|
||||||
switchEditor(intrusive(new SymbolSelectEditor(this, false)));
|
switchEditor(make_intrusive<SymbolSelectEditor>(this, false));
|
||||||
signalSelectionChange();
|
signalSelectionChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolControl::activatePart(const SymbolPartP& part) {
|
void SymbolControl::activatePart(const SymbolPartP& part) {
|
||||||
if (part->isSymbolShape()) {
|
if (part->isSymbolShape()) {
|
||||||
selected_parts.select(part);
|
selected_parts.select(part);
|
||||||
switchEditor(intrusive(new SymbolPointEditor(this, static_pointer_cast<SymbolShape>(part))));
|
switchEditor(make_intrusive<SymbolPointEditor>(this, static_pointer_cast<SymbolShape>(part)));
|
||||||
} else if (part->isSymbolSymmetry()) {
|
} else if (part->isSymbolSymmetry()) {
|
||||||
selected_parts.select(part);
|
selected_parts.select(part);
|
||||||
switchEditor(intrusive(new SymbolSymmetryEditor(this, static_pointer_cast<SymbolSymmetry>(part))));
|
switchEditor(make_intrusive<SymbolSymmetryEditor>(this, static_pointer_cast<SymbolSymmetry>(part)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ void SymbolSelectEditor::onCommand(int id) {
|
|||||||
control.Refresh(false);
|
control.Refresh(false);
|
||||||
} else if (id == ID_EDIT_GROUP && !isEditing()) {
|
} else if (id == ID_EDIT_GROUP && !isEditing()) {
|
||||||
// group selection, not when dragging
|
// 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<SymbolGroup>()));
|
||||||
control.Refresh(false);
|
control.Refresh(false);
|
||||||
} else if (id == ID_EDIT_UNGROUP && !isEditing()) {
|
} else if (id == ID_EDIT_UNGROUP && !isEditing()) {
|
||||||
// ungroup selection, not when dragging
|
// ungroup selection, not when dragging
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ void SymbolSymmetryEditor::onCommand(int id) {
|
|||||||
}
|
}
|
||||||
resetActions();
|
resetActions();
|
||||||
} else if (id == ID_ADD_SYMMETRY) {
|
} else if (id == ID_ADD_SYMMETRY) {
|
||||||
symmetry = intrusive(new SymbolSymmetry());
|
symmetry = make_intrusive<SymbolSymmetry>();
|
||||||
symmetry->kind = SYMMETRY_ROTATION;
|
symmetry->kind = SYMMETRY_ROTATION;
|
||||||
symmetry->copies = 2;
|
symmetry->copies = 2;
|
||||||
symmetry->center = Vector2D(0.5,0.5);
|
symmetry->center = Vector2D(0.5,0.5);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ SymbolWindow::SymbolWindow(Window* parent, const String& filename)
|
|||||||
: performer(nullptr)
|
: performer(nullptr)
|
||||||
{
|
{
|
||||||
// open file
|
// open file
|
||||||
Reader reader(shared(new wxFileInputStream(filename)), nullptr, filename);
|
Reader reader(make_shared<wxFileInputStream>(filename), nullptr, filename);
|
||||||
SymbolP symbol;
|
SymbolP symbol;
|
||||||
reader.handle_greedy(symbol);
|
reader.handle_greedy(symbol);
|
||||||
init(parent, symbol);
|
init(parent, symbol);
|
||||||
@@ -217,7 +217,7 @@ void SymbolWindow::onFileOpen(wxCommandEvent& ev) {
|
|||||||
String ext = n.GetExt();
|
String ext = n.GetExt();
|
||||||
SymbolP symbol;
|
SymbolP symbol;
|
||||||
if (ext.Lower() == _("mse-symbol")) {
|
if (ext.Lower() == _("mse-symbol")) {
|
||||||
Reader reader(shared(new wxFileInputStream(name)), nullptr, name);
|
Reader reader(make_shared<wxFileInputStream>(name), nullptr, name);
|
||||||
reader.handle_greedy(symbol);
|
reader.handle_greedy(symbol);
|
||||||
} else {
|
} else {
|
||||||
wxBusyCursor busy;
|
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);
|
String name = wxFileSelector(_("Save symbol"),settings.default_set_dir,_(""),_(""),_("Symbol files (*.mse-symbol)|*.mse-symbol"),wxFD_SAVE, this);
|
||||||
if (!name.empty()) {
|
if (!name.empty()) {
|
||||||
settings.default_set_dir = wxPathOnly(name);
|
settings.default_set_dir = wxPathOnly(name);
|
||||||
Writer writer(shared(new wxFileOutputStream(name)), file_version_symbol);
|
Writer writer(make_shared<wxFileOutputStream>(name), file_version_symbol);
|
||||||
writer.handle(control->getSymbol());
|
writer.handle(control->getSymbol());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,9 +203,9 @@ void DropDownChoiceListBase::generateThumbnailImages() {
|
|||||||
status = THUMB_OK; // no need to rebuild
|
status = THUMB_OK; // no need to rebuild
|
||||||
} else if (img.isReady()) {
|
} else if (img.isReady()) {
|
||||||
// request this thumbnail
|
// request this thumbnail
|
||||||
thumbnail_thread.request( intrusive(new ChoiceThumbnailRequest(
|
thumbnail_thread.request(make_intrusive<ChoiceThumbnailRequest>(
|
||||||
&cve, i, status == THUMB_NOT_MADE && !img.local(), img.threadSafe()
|
&cve, i, status == THUMB_NOT_MADE && !img.local(), img.threadSafe()
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,5 +116,5 @@ void PackageChoiceValueEditor::change(const String& c) {
|
|||||||
|
|
||||||
void PackageChoiceValueEditor::initDropDown() {
|
void PackageChoiceValueEditor::initDropDown() {
|
||||||
if (drop_down) return;
|
if (drop_down) return;
|
||||||
drop_down = shared(new DropDownPackageChoiceList(&editor(), this));
|
drop_down = make_shared<DropDownPackageChoiceList>(&editor(), this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1367,7 +1367,7 @@ void TextValueEditor::findWordLists() {
|
|||||||
throw Error(_ERROR_1_("word list type not found", name));
|
throw Error(_ERROR_1_("word list type not found", name));
|
||||||
}
|
}
|
||||||
// add to word_lists
|
// add to word_lists
|
||||||
word_lists.push_back(intrusive(new WordListPos(pos, end, word_list)));
|
word_lists.push_back(make_intrusive<WordListPos>(pos, end, word_list));
|
||||||
// next
|
// next
|
||||||
pos = str.find(_("<word-list-"), end);
|
pos = str.find(_("<word-list-"), end);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ intrusive_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader) {
|
|||||||
// there must be a fill type specified
|
// there must be a fill type specified
|
||||||
String fill_type;
|
String fill_type;
|
||||||
reader.handle(_("fill_type"), fill_type);
|
reader.handle(_("fill_type"), fill_type);
|
||||||
if (fill_type == _("solid")) return intrusive(new SolidFillSymbolFilter);
|
if (fill_type == _("solid")) return make_intrusive<SolidFillSymbolFilter>();
|
||||||
else if (fill_type == _("linear gradient")) return intrusive(new LinearGradientSymbolFilter);
|
else if (fill_type == _("linear gradient")) return make_intrusive<LinearGradientSymbolFilter>();
|
||||||
else if (fill_type == _("radial gradient")) return intrusive(new RadialGradientSymbolFilter);
|
else if (fill_type == _("radial gradient")) return make_intrusive<RadialGradientSymbolFilter>();
|
||||||
else if (fill_type.empty()) {
|
else if (fill_type.empty()) {
|
||||||
reader.warning(_ERROR_1_("expected key", _("fill type")));
|
reader.warning(_ERROR_1_("expected key", _("fill type")));
|
||||||
throw ParseError(_ERROR_("aborting parsing"));
|
throw ParseError(_ERROR_("aborting parsing"));
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ struct TextElementsFromString {
|
|||||||
assert(content.size() == end-start);
|
assert(content.size() == end-start);
|
||||||
// use symbol font?
|
// use symbol font?
|
||||||
if (symbol > 0 && style.symbol_font.valid()) {
|
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<SymbolTextElement>(content, start, end, style.symbol_font, &ctx));
|
||||||
} else {
|
} else {
|
||||||
// text, possibly mixed with symbols
|
// text, possibly mixed with symbols
|
||||||
DrawWhat what = soft > 0 ? DRAW_ACTIVE : DRAW_NORMAL;
|
DrawWhat what = soft > 0 ? DRAW_ACTIVE : DRAW_NORMAL;
|
||||||
@@ -221,9 +221,9 @@ struct TextElementsFromString {
|
|||||||
if (text_pos < pos) {
|
if (text_pos < pos) {
|
||||||
// text before it?
|
// text before it?
|
||||||
if (!font) font = makeFont(style);
|
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<FontTextElement>(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<SymbolTextElement>(content.substr(pos,n), start+pos, start+pos+n, style.symbol_font, &ctx));
|
||||||
text_pos = pos += n;
|
text_pos = pos += n;
|
||||||
} else {
|
} else {
|
||||||
++pos;
|
++pos;
|
||||||
@@ -231,10 +231,10 @@ struct TextElementsFromString {
|
|||||||
}
|
}
|
||||||
if (text_pos < pos) {
|
if (text_pos < pos) {
|
||||||
if (!font) font = makeFont(style);
|
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<FontTextElement>(content.substr(text_pos), start+text_pos, end, font, what, line_break));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
te.elements.push_back(intrusive(new FontTextElement(content, start, end, makeFont(style), what, line_break)));
|
te.elements.push_back(make_intrusive<FontTextElement>(content, start, end, makeFont(style), what, line_break));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -469,9 +469,9 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP&
|
|||||||
} else if (bt == SCRIPT_NIL) {
|
} else if (bt == SCRIPT_NIL) {
|
||||||
// a = a;
|
// a = a;
|
||||||
} else if (at == SCRIPT_FUNCTION && bt == SCRIPT_FUNCTION) {
|
} else if (at == SCRIPT_FUNCTION && bt == SCRIPT_FUNCTION) {
|
||||||
a = intrusive(new ScriptCompose(a, b));
|
a = make_intrusive<ScriptCompose>(a, b);
|
||||||
} else if (at == SCRIPT_COLLECTION && bt == SCRIPT_COLLECTION) {
|
} else if (at == SCRIPT_COLLECTION && bt == SCRIPT_COLLECTION) {
|
||||||
a = intrusive(new ScriptConcatCollection(a, b));
|
a = make_intrusive<ScriptConcatCollection>(a, b);
|
||||||
} else if (at == SCRIPT_INT && bt == SCRIPT_INT) {
|
} else if (at == SCRIPT_INT && bt == SCRIPT_INT) {
|
||||||
a = to_script((int)*a + (int)*b);
|
a = to_script((int)*a + (int)*b);
|
||||||
} else if ((at == SCRIPT_INT || at == SCRIPT_DOUBLE) &&
|
} else if ((at == SCRIPT_INT || at == SCRIPT_DOUBLE) &&
|
||||||
|
|||||||
@@ -68,13 +68,13 @@ private:
|
|||||||
// Unify two values from different execution paths
|
// Unify two values from different execution paths
|
||||||
void unify(ScriptValueP& a, const ScriptValueP& b) {
|
void unify(ScriptValueP& a, const ScriptValueP& b) {
|
||||||
assert(a && b);
|
assert(a && b);
|
||||||
if (a != b) a = intrusive(new DependencyUnion(a,b));
|
if (a != b) a = make_intrusive<DependencyUnion>(a,b);
|
||||||
}
|
}
|
||||||
// Unify two values from different execution paths
|
// Unify two values from different execution paths
|
||||||
ScriptValueP unified(const ScriptValueP& a, const ScriptValueP& b) {
|
ScriptValueP unified(const ScriptValueP& a, const ScriptValueP& b) {
|
||||||
assert(a && b);
|
assert(a && b);
|
||||||
if (a == b) return a;
|
if (a == b) return a;
|
||||||
else return intrusive(new DependencyUnion(a,b));
|
else return make_intrusive<DependencyUnion>(a,b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Behaves like script_nil, but with a name
|
/// 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: {
|
case I_GET_VAR: {
|
||||||
ScriptValueP value = variables[i.data].value;
|
ScriptValueP value = variables[i.data].value;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
value = intrusive(new ScriptMissingVariable(variable_to_string((Variable)i.data))); // no errors here
|
value = make_intrusive<ScriptMissingVariable>(variable_to_string((Variable)i.data)); // no errors here
|
||||||
}
|
}
|
||||||
value->dependencyThis(dep);
|
value->dependencyThis(dep);
|
||||||
stack.push_back(value);
|
stack.push_back(value);
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ SCRIPT_FUNCTION(to_string) {
|
|||||||
SCRIPT_RETURN(input->toString());
|
SCRIPT_RETURN(input->toString());
|
||||||
}
|
}
|
||||||
} catch (const ScriptError& e) {
|
} catch (const ScriptError& e) {
|
||||||
return intrusive(new ScriptDelayedError(e));
|
return make_intrusive<ScriptDelayedError>(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -715,7 +715,7 @@ SCRIPT_FUNCTION(keyword_usage) {
|
|||||||
/// Turn a script function into a rule, a.k.a. a delayed closure
|
/// Turn a script function into a rule, a.k.a. a delayed closure
|
||||||
SCRIPT_FUNCTION(rule) {
|
SCRIPT_FUNCTION(rule) {
|
||||||
SCRIPT_PARAM(ScriptValueP, input);
|
SCRIPT_PARAM(ScriptValueP, input);
|
||||||
return intrusive(new ScriptRule(input));
|
return make_intrusive<ScriptRule>(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Init
|
// ----------------------------------------------------------------------------- : Init
|
||||||
@@ -760,17 +760,17 @@ void init_script_basic_functions(Context& ctx) {
|
|||||||
ctx.setVariable(_("substring"), script_substring);
|
ctx.setVariable(_("substring"), script_substring);
|
||||||
ctx.setVariable(_("contains"), script_contains);
|
ctx.setVariable(_("contains"), script_contains);
|
||||||
ctx.setVariable(_("format"), script_format);
|
ctx.setVariable(_("format"), script_format);
|
||||||
ctx.setVariable(_("format_rule"), intrusive(new ScriptRule(script_format)));
|
ctx.setVariable(_("format_rule"), make_intrusive<ScriptRule>(script_format));
|
||||||
ctx.setVariable(_("curly_quotes"), script_curly_quotes);
|
ctx.setVariable(_("curly_quotes"), script_curly_quotes);
|
||||||
ctx.setVariable(_("regex_escape"), script_regex_escape);
|
ctx.setVariable(_("regex_escape"), script_regex_escape);
|
||||||
ctx.setVariable(_("sort_text"), script_sort_text);
|
ctx.setVariable(_("sort_text"), script_sort_text);
|
||||||
ctx.setVariable(_("sort_rule"), intrusive(new ScriptRule(script_sort_text)));
|
ctx.setVariable(_("sort_rule"), make_intrusive<ScriptRule>(script_sort_text));
|
||||||
// tagged string
|
// tagged string
|
||||||
ctx.setVariable(_("tag_contents"), script_tag_contents);
|
ctx.setVariable(_("tag_contents"), script_tag_contents);
|
||||||
ctx.setVariable(_("remove_tag"), script_remove_tag);
|
ctx.setVariable(_("remove_tag"), script_remove_tag);
|
||||||
ctx.setVariable(_("remove_tags"), script_remove_tags);
|
ctx.setVariable(_("remove_tags"), script_remove_tags);
|
||||||
ctx.setVariable(_("tag_contents_rule"), intrusive(new ScriptRule(script_tag_contents)));
|
ctx.setVariable(_("tag_contents_rule"), make_intrusive<ScriptRule>(script_tag_contents));
|
||||||
ctx.setVariable(_("tag_remove_rule"), intrusive(new ScriptRule(script_remove_tag)));
|
ctx.setVariable(_("tag_remove_rule"), make_intrusive<ScriptRule>(script_remove_tag));
|
||||||
// collection
|
// collection
|
||||||
ctx.setVariable(_("position"), script_position_of);
|
ctx.setVariable(_("position"), script_position_of);
|
||||||
ctx.setVariable(_("length"), script_length);
|
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);
|
ctx.setVariable(_("random_select_many"), script_random_select_many);
|
||||||
// keyword
|
// keyword
|
||||||
ctx.setVariable(_("expand_keywords"), script_expand_keywords);
|
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<ScriptRule>(script_expand_keywords));
|
||||||
ctx.setVariable(_("keyword_usage"), script_keyword_usage);
|
ctx.setVariable(_("keyword_usage"), script_keyword_usage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
SCRIPT_FUNCTION(new_card) {
|
SCRIPT_FUNCTION(new_card) {
|
||||||
SCRIPT_PARAM(GameP, game);
|
SCRIPT_PARAM(GameP, game);
|
||||||
CardP new_card = intrusive(new Card(*game));
|
CardP new_card = make_intrusive<Card>(*game);
|
||||||
// set field values
|
// set field values
|
||||||
SCRIPT_PARAM(ScriptValueP, input);
|
SCRIPT_PARAM(ScriptValueP, input);
|
||||||
ScriptValueP it = input->makeIterator();
|
ScriptValueP it = input->makeIterator();
|
||||||
|
|||||||
@@ -41,14 +41,14 @@ SCRIPT_FUNCTION(linear_blend) {
|
|||||||
SCRIPT_PARAM(GeneratedImageP, image2);
|
SCRIPT_PARAM(GeneratedImageP, image2);
|
||||||
SCRIPT_PARAM(double, x1); SCRIPT_PARAM(double, y1);
|
SCRIPT_PARAM(double, x1); SCRIPT_PARAM(double, y1);
|
||||||
SCRIPT_PARAM(double, x2); SCRIPT_PARAM(double, y2);
|
SCRIPT_PARAM(double, x2); SCRIPT_PARAM(double, y2);
|
||||||
return intrusive(new LinearBlendImage(image1, image2, x1,y1, x2,y2));
|
return make_intrusive<LinearBlendImage>(image1, image2, x1,y1, x2,y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(masked_blend) {
|
SCRIPT_FUNCTION(masked_blend) {
|
||||||
SCRIPT_PARAM(GeneratedImageP, light);
|
SCRIPT_PARAM(GeneratedImageP, light);
|
||||||
SCRIPT_PARAM(GeneratedImageP, dark);
|
SCRIPT_PARAM(GeneratedImageP, dark);
|
||||||
SCRIPT_PARAM(GeneratedImageP, mask);
|
SCRIPT_PARAM(GeneratedImageP, mask);
|
||||||
return intrusive(new MaskedBlendImage(light, dark, mask));
|
return make_intrusive<MaskedBlendImage>(light, dark, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(combine_blend) {
|
SCRIPT_FUNCTION(combine_blend) {
|
||||||
@@ -57,19 +57,19 @@ SCRIPT_FUNCTION(combine_blend) {
|
|||||||
SCRIPT_PARAM(GeneratedImageP, image2);
|
SCRIPT_PARAM(GeneratedImageP, image2);
|
||||||
ImageCombine image_combine;
|
ImageCombine image_combine;
|
||||||
parse_enum(combine, image_combine);
|
parse_enum(combine, image_combine);
|
||||||
return intrusive(new CombineBlendImage(image1, image2, image_combine));
|
return make_intrusive<CombineBlendImage>(image1, image2, image_combine);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(set_mask) {
|
SCRIPT_FUNCTION(set_mask) {
|
||||||
SCRIPT_PARAM(GeneratedImageP, image);
|
SCRIPT_PARAM(GeneratedImageP, image);
|
||||||
SCRIPT_PARAM(GeneratedImageP, mask);
|
SCRIPT_PARAM(GeneratedImageP, mask);
|
||||||
return intrusive(new SetMaskImage(image, mask));
|
return make_intrusive<SetMaskImage>(image, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(set_alpha) {
|
SCRIPT_FUNCTION(set_alpha) {
|
||||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||||
SCRIPT_PARAM(double, alpha);
|
SCRIPT_PARAM(double, alpha);
|
||||||
return intrusive(new SetAlphaImage(input, alpha));
|
return make_intrusive<SetAlphaImage>(input, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(set_combine) {
|
SCRIPT_FUNCTION(set_combine) {
|
||||||
@@ -77,18 +77,18 @@ SCRIPT_FUNCTION(set_combine) {
|
|||||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||||
ImageCombine image_combine;
|
ImageCombine image_combine;
|
||||||
parse_enum(combine, image_combine);
|
parse_enum(combine, image_combine);
|
||||||
return intrusive(new SetCombineImage(input, image_combine));
|
return make_intrusive<SetCombineImage>(input, image_combine);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(saturate) {
|
SCRIPT_FUNCTION(saturate) {
|
||||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||||
SCRIPT_PARAM(double, amount);
|
SCRIPT_PARAM(double, amount);
|
||||||
return intrusive(new SaturateImage(input, amount));
|
return make_intrusive<SaturateImage>(input, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(invert_image) {
|
SCRIPT_FUNCTION(invert_image) {
|
||||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||||
return intrusive(new InvertImage(input));
|
return make_intrusive<InvertImage>(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(recolor_image) {
|
SCRIPT_FUNCTION(recolor_image) {
|
||||||
@@ -97,17 +97,17 @@ SCRIPT_FUNCTION(recolor_image) {
|
|||||||
SCRIPT_PARAM(Color, green);
|
SCRIPT_PARAM(Color, green);
|
||||||
SCRIPT_PARAM(Color, blue);
|
SCRIPT_PARAM(Color, blue);
|
||||||
SCRIPT_PARAM_DEFAULT(Color, white, *wxWHITE);
|
SCRIPT_PARAM_DEFAULT(Color, white, *wxWHITE);
|
||||||
return intrusive(new RecolorImage2(input,red,green,blue,white));
|
return make_intrusive<RecolorImage2>(input,red,green,blue,white);
|
||||||
} else {
|
} else {
|
||||||
SCRIPT_PARAM(Color, color);
|
SCRIPT_PARAM(Color, color);
|
||||||
return intrusive(new RecolorImage(input,color));
|
return make_intrusive<RecolorImage>(input,color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(enlarge) {
|
SCRIPT_FUNCTION(enlarge) {
|
||||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||||
SCRIPT_PARAM(double, border_size);
|
SCRIPT_PARAM(double, border_size);
|
||||||
return intrusive(new EnlargeImage(input, border_size));
|
return make_intrusive<EnlargeImage>(input, border_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(crop) {
|
SCRIPT_FUNCTION(crop) {
|
||||||
@@ -116,23 +116,23 @@ SCRIPT_FUNCTION(crop) {
|
|||||||
SCRIPT_PARAM(int, height);
|
SCRIPT_PARAM(int, height);
|
||||||
SCRIPT_PARAM(double, offset_x);
|
SCRIPT_PARAM(double, offset_x);
|
||||||
SCRIPT_PARAM(double, offset_y);
|
SCRIPT_PARAM(double, offset_y);
|
||||||
return intrusive(new CropImage(input, width, height, offset_x, offset_y));
|
return make_intrusive<CropImage>(input, width, height, offset_x, offset_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(flip_horizontal) {
|
SCRIPT_FUNCTION(flip_horizontal) {
|
||||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||||
return intrusive(new FlipImageHorizontal(input));
|
return make_intrusive<FlipImageHorizontal>(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(flip_vertical) {
|
SCRIPT_FUNCTION(flip_vertical) {
|
||||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||||
return intrusive(new FlipImageVertical(input));
|
return make_intrusive<FlipImageVertical>(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(rotate) {
|
SCRIPT_FUNCTION(rotate) {
|
||||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||||
SCRIPT_PARAM(Degrees, angle);
|
SCRIPT_PARAM(Degrees, angle);
|
||||||
return intrusive(new RotateImage(input,deg_to_rad(angle)));
|
return make_intrusive<RotateImage>(input,deg_to_rad(angle));
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(drop_shadow) {
|
SCRIPT_FUNCTION(drop_shadow) {
|
||||||
@@ -142,7 +142,7 @@ SCRIPT_FUNCTION(drop_shadow) {
|
|||||||
SCRIPT_OPTIONAL_PARAM_(double, alpha);
|
SCRIPT_OPTIONAL_PARAM_(double, alpha);
|
||||||
SCRIPT_OPTIONAL_PARAM_(double, blur_radius);
|
SCRIPT_OPTIONAL_PARAM_(double, blur_radius);
|
||||||
SCRIPT_OPTIONAL_PARAM_(Color, color);
|
SCRIPT_OPTIONAL_PARAM_(Color, color);
|
||||||
return intrusive(new DropShadowImage(input, offset_x, offset_y, alpha, blur_radius, color));
|
return make_intrusive<DropShadowImage>(input, offset_x, offset_y, alpha, blur_radius, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(symbol_variation) {
|
SCRIPT_FUNCTION(symbol_variation) {
|
||||||
@@ -170,7 +170,7 @@ SCRIPT_FUNCTION(symbol_variation) {
|
|||||||
FOR_EACH(v, style->variations) {
|
FOR_EACH(v, style->variations) {
|
||||||
if (v->name == variation) {
|
if (v->name == variation) {
|
||||||
// found it
|
// found it
|
||||||
return intrusive(new SymbolToImage(value, filename, value->last_update, v));
|
return make_intrusive<SymbolToImage>(value, filename, value->last_update, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw ScriptError(_("Variation of symbol not found ('") + variation + _("')"));
|
throw ScriptError(_("Variation of symbol not found ('") + variation + _("')"));
|
||||||
@@ -183,7 +183,7 @@ SCRIPT_FUNCTION(symbol_variation) {
|
|||||||
if (fill_type == _("solid") || fill_type.empty()) {
|
if (fill_type == _("solid") || fill_type.empty()) {
|
||||||
SCRIPT_PARAM(Color, fill_color);
|
SCRIPT_PARAM(Color, fill_color);
|
||||||
SCRIPT_PARAM(Color, border_color);
|
SCRIPT_PARAM(Color, border_color);
|
||||||
var->filter = intrusive(new SolidFillSymbolFilter(fill_color, border_color));
|
var->filter = make_intrusive<SolidFillSymbolFilter>(fill_color, border_color);
|
||||||
} else if (fill_type == _("linear gradient")) {
|
} else if (fill_type == _("linear gradient")) {
|
||||||
SCRIPT_PARAM(Color, fill_color_1);
|
SCRIPT_PARAM(Color, fill_color_1);
|
||||||
SCRIPT_PARAM(Color, border_color_1);
|
SCRIPT_PARAM(Color, border_color_1);
|
||||||
@@ -193,24 +193,23 @@ SCRIPT_FUNCTION(symbol_variation) {
|
|||||||
SCRIPT_PARAM(double, center_y);
|
SCRIPT_PARAM(double, center_y);
|
||||||
SCRIPT_PARAM(double, end_x);
|
SCRIPT_PARAM(double, end_x);
|
||||||
SCRIPT_PARAM(double, end_y);
|
SCRIPT_PARAM(double, end_y);
|
||||||
var->filter = intrusive(new LinearGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2
|
var->filter = make_intrusive<LinearGradientSymbolFilter>(fill_color_1, border_color_1, fill_color_2, border_color_2, center_x, center_y, end_x, end_y);
|
||||||
,center_x, center_y, end_x, end_y));
|
|
||||||
} else if (fill_type == _("radial gradient")) {
|
} else if (fill_type == _("radial gradient")) {
|
||||||
SCRIPT_PARAM(Color, fill_color_1);
|
SCRIPT_PARAM(Color, fill_color_1);
|
||||||
SCRIPT_PARAM(Color, border_color_1);
|
SCRIPT_PARAM(Color, border_color_1);
|
||||||
SCRIPT_PARAM(Color, fill_color_2);
|
SCRIPT_PARAM(Color, fill_color_2);
|
||||||
SCRIPT_PARAM(Color, border_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<RadialGradientSymbolFilter>(fill_color_1, border_color_1, fill_color_2, border_color_2);
|
||||||
} else {
|
} else {
|
||||||
throw ScriptError(_("Unknown fill type for symbol_variation: ") + fill_type);
|
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<SymbolToImage>(value, filename, value ? value->last_update : Age(0), var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SCRIPT_FUNCTION(built_in_image) {
|
SCRIPT_FUNCTION(built_in_image) {
|
||||||
SCRIPT_PARAM_C(String, input);
|
SCRIPT_PARAM_C(String, input);
|
||||||
return intrusive(new BuiltInImage(input));
|
return make_intrusive<BuiltInImage>(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Init
|
// ----------------------------------------------------------------------------- : Init
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ ScriptRegexP regex_from_script(const ScriptValueP& value) {
|
|||||||
ScriptRegexP regex = dynamic_pointer_cast<ScriptRegex>(value);
|
ScriptRegexP regex = dynamic_pointer_cast<ScriptRegex>(value);
|
||||||
if (!regex) {
|
if (!regex) {
|
||||||
// TODO: introduce some kind of caching?
|
// TODO: introduce some kind of caching?
|
||||||
regex = intrusive(new ScriptRegex(*value));
|
regex = make_intrusive<ScriptRegex>(*value);
|
||||||
}
|
}
|
||||||
return regex;
|
return regex;
|
||||||
}
|
}
|
||||||
@@ -251,8 +251,8 @@ void init_script_regex_functions(Context& ctx) {
|
|||||||
ctx.setVariable(_("split_text"), script_split_text);
|
ctx.setVariable(_("split_text"), script_split_text);
|
||||||
ctx.setVariable(_("match_text"), script_match_text);
|
ctx.setVariable(_("match_text"), script_match_text);
|
||||||
ctx.setVariable(_("match"), script_match_text); // old name
|
ctx.setVariable(_("match"), script_match_text); // old name
|
||||||
ctx.setVariable(_("replace_rule"), intrusive(new ScriptRule(script_replace_text)));
|
ctx.setVariable(_("replace_rule"), make_intrusive<ScriptRule>(script_replace_text));
|
||||||
ctx.setVariable(_("filter_rule"), intrusive(new ScriptRule(script_filter_text)));
|
ctx.setVariable(_("filter_rule"), make_intrusive<ScriptRule>(script_filter_text));
|
||||||
ctx.setVariable(_("break_rule"), intrusive(new ScriptRule(script_break_text)));
|
ctx.setVariable(_("break_rule"), make_intrusive<ScriptRule>(script_break_text));
|
||||||
ctx.setVariable(_("match_rule"), intrusive(new ScriptRule(script_match_text)));
|
ctx.setVariable(_("match_rule"), make_intrusive<ScriptRule>(script_match_text));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,25 +154,25 @@ inline Type from_script(const ScriptValueP& v, Variable var) {
|
|||||||
#define SCRIPT_RULE_1_C(funname, type1, name1) \
|
#define SCRIPT_RULE_1_C(funname, type1, name1) \
|
||||||
SCRIPT_RULE_1_N(funname, type1, SCRIPT_VAR_ ## name1, name1)
|
SCRIPT_RULE_1_N(funname, type1, SCRIPT_VAR_ ## name1, name1)
|
||||||
/// Utility for defining a script rule with a single named parameter
|
/// Utility for defining a script rule with a single named parameter
|
||||||
#define SCRIPT_RULE_1_N(funname, type1, str1, name1) \
|
#define SCRIPT_RULE_1_N(funname, type1, str1, name1) \
|
||||||
class ScriptRule_##funname: public ScriptValue { \
|
class ScriptRule_##funname: public ScriptValue { \
|
||||||
public: \
|
public: \
|
||||||
inline ScriptRule_##funname(const type1& name1) : name1(name1) {} \
|
inline ScriptRule_##funname(const type1& name1) : name1(name1) {} \
|
||||||
virtual ScriptType type() const { return SCRIPT_FUNCTION; } \
|
virtual ScriptType type() const { return SCRIPT_FUNCTION; } \
|
||||||
virtual String typeName() const { return _(#funname)_("_rule"); } \
|
virtual String typeName() const { return _(#funname)_("_rule"); } \
|
||||||
protected: \
|
protected: \
|
||||||
virtual ScriptValueP do_eval(Context& ctx, bool) const; \
|
virtual ScriptValueP do_eval(Context& ctx, bool) const; \
|
||||||
private: \
|
private: \
|
||||||
type1 name1; \
|
type1 name1; \
|
||||||
}; \
|
}; \
|
||||||
SCRIPT_FUNCTION(funname##_rule) { \
|
SCRIPT_FUNCTION(funname##_rule) { \
|
||||||
SCRIPT_PARAM_N(type1, str1, name1); \
|
SCRIPT_PARAM_N(type1, str1, name1) \
|
||||||
return intrusive(new ScriptRule_##funname(name1)); \
|
return make_intrusive<ScriptRule_##funname>(name1); \
|
||||||
} \
|
} \
|
||||||
SCRIPT_FUNCTION(funname) { \
|
SCRIPT_FUNCTION(funname) { \
|
||||||
SCRIPT_PARAM_N(type1, str1, name1); \
|
SCRIPT_PARAM_N(type1, str1, name1); \
|
||||||
return ScriptRule_##funname(name1).eval(ctx); \
|
return ScriptRule_##funname(name1).eval(ctx); \
|
||||||
} \
|
} \
|
||||||
ScriptValueP ScriptRule_##funname::do_eval(Context& ctx, bool) const
|
ScriptValueP ScriptRule_##funname::do_eval(Context& ctx, bool) const
|
||||||
|
|
||||||
/// Utility for defining a script rule with two parameters
|
/// 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) \
|
#define SCRIPT_RULE_2_N_AUX(funname, type1, str1, name1, type2, str2, name2, dep, more) \
|
||||||
class ScriptRule_##funname: public ScriptValue { \
|
class ScriptRule_##funname: public ScriptValue { \
|
||||||
public: \
|
public: \
|
||||||
inline ScriptRule_##funname(const type1& name1, const type2& name2) \
|
inline ScriptRule_##funname(const type1& name1, const type2& name2) \
|
||||||
: name1(name1), name2(name2) {} \
|
: name1(name1), name2(name2) {} \
|
||||||
virtual ScriptType type() const { return SCRIPT_FUNCTION; } \
|
virtual ScriptType type() const { return SCRIPT_FUNCTION; } \
|
||||||
virtual String typeName() const { return _(#funname)_("_rule"); } \
|
virtual String typeName() const { return _(#funname)_("_rule"); } \
|
||||||
dep \
|
dep \
|
||||||
protected: \
|
protected: \
|
||||||
virtual ScriptValueP do_eval(Context& ctx, bool) const; \
|
virtual ScriptValueP do_eval(Context& ctx, bool) const; \
|
||||||
private: \
|
private: \
|
||||||
type1 name1; \
|
type1 name1; \
|
||||||
type2 name2; \
|
type2 name2; \
|
||||||
}; \
|
}; \
|
||||||
SCRIPT_FUNCTION(funname##_rule) { \
|
SCRIPT_FUNCTION(funname##_rule) { \
|
||||||
SCRIPT_PARAM_N(type1, str1, name1); \
|
SCRIPT_PARAM_N(type1, str1, name1); \
|
||||||
SCRIPT_PARAM_N(type2, str2, name2); \
|
SCRIPT_PARAM_N(type2, str2, name2); \
|
||||||
return intrusive(new ScriptRule_##funname(name1, name2)); \
|
return make_intrusive<ScriptRule_##funname>(name1, name2); \
|
||||||
} \
|
} \
|
||||||
SCRIPT_FUNCTION_AUX(funname, dep) { \
|
SCRIPT_FUNCTION_AUX(funname, dep) { \
|
||||||
SCRIPT_PARAM_N(type1, str1, name1); \
|
SCRIPT_PARAM_N(type1, str1, name1); \
|
||||||
SCRIPT_PARAM_N(type2, str2, name2); \
|
SCRIPT_PARAM_N(type2, str2, name2); \
|
||||||
return ScriptRule_##funname(name1, name2).eval(ctx); \
|
return ScriptRule_##funname(name1, name2).eval(ctx); \
|
||||||
} \
|
} \
|
||||||
more \
|
more \
|
||||||
ScriptValueP ScriptRule_##funname::do_eval(Context& ctx, bool) const
|
ScriptValueP ScriptRule_##funname::do_eval(Context& ctx, bool) const
|
||||||
|
|
||||||
#define SCRIPT_RULE_2_DEPENDENCIES(name) \
|
#define SCRIPT_RULE_2_DEPENDENCIES(name) \
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ template <> void Reader::handle(ScriptableImage& s) {
|
|||||||
s.script.parse(*this, true);
|
s.script.parse(*this, true);
|
||||||
} else {
|
} else {
|
||||||
// a filename
|
// a filename
|
||||||
s.value = intrusive(new PackagedImage(s.script.unparsed));
|
s.value = make_intrusive<PackagedImage>(s.script.unparsed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template <> void Writer::handle(const ScriptableImage& s) {
|
template <> void Writer::handle(const ScriptableImage& s) {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ void profile_aggregate(FunctionProfile& parent, int level, int max_level, size_t
|
|||||||
// add to item at idx
|
// add to item at idx
|
||||||
FunctionProfileP& fpp = parent.children[idx];
|
FunctionProfileP& fpp = parent.children[idx];
|
||||||
if (!fpp) {
|
if (!fpp) {
|
||||||
fpp = intrusive(new FunctionProfile(p.name));
|
fpp = make_intrusive<FunctionProfile>(p.name);
|
||||||
}
|
}
|
||||||
fpp->time_ticks += p.time_ticks;
|
fpp->time_ticks += p.time_ticks;
|
||||||
fpp->calls += p.calls;
|
fpp->calls += p.calls;
|
||||||
@@ -97,7 +97,7 @@ Profiler::Profiler(Timer& timer, Variable function_name)
|
|||||||
if ((int)function_name >= 0) {
|
if ((int)function_name >= 0) {
|
||||||
FunctionProfileP& fpp = parent->children[(size_t)function_name << 1 | 1];
|
FunctionProfileP& fpp = parent->children[(size_t)function_name << 1 | 1];
|
||||||
if (!fpp) {
|
if (!fpp) {
|
||||||
fpp = intrusive(new FunctionProfile(variable_to_string(function_name)));
|
fpp = make_intrusive<FunctionProfile>(variable_to_string(function_name));
|
||||||
}
|
}
|
||||||
function = fpp.get();
|
function = fpp.get();
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ Profiler::Profiler(Timer& timer, const Char* function_name)
|
|||||||
{
|
{
|
||||||
FunctionProfileP& fpp = parent->children[(size_t)function_name];
|
FunctionProfileP& fpp = parent->children[(size_t)function_name];
|
||||||
if (!fpp) {
|
if (!fpp) {
|
||||||
fpp = intrusive(new FunctionProfile(function_name));
|
fpp = make_intrusive<FunctionProfile>(function_name);
|
||||||
}
|
}
|
||||||
function = fpp.get();
|
function = fpp.get();
|
||||||
timer.exclude_time();
|
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];
|
FunctionProfileP& fpp = parent->children[(size_t)function_object];
|
||||||
if (!fpp) {
|
if (!fpp) {
|
||||||
fpp = intrusive(new FunctionProfile(function_name));
|
fpp = make_intrusive<FunctionProfile>(function_name);
|
||||||
}
|
}
|
||||||
function = fpp.get();
|
function = fpp.get();
|
||||||
timer.exclude_time();
|
timer.exclude_time();
|
||||||
|
|||||||
@@ -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
|
// 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.
|
// which would lead to a reference cycle.
|
||||||
init_script_functions(*ctx);
|
init_script_functions(*ctx);
|
||||||
ctx->setVariable(SCRIPT_VAR_set, intrusive(new ScriptObject<Set*>(&set)));
|
ctx->setVariable(SCRIPT_VAR_set, make_intrusive<ScriptObject<Set*>>(&set));
|
||||||
ctx->setVariable(SCRIPT_VAR_game, to_script(set.game));
|
ctx->setVariable(SCRIPT_VAR_game, to_script(set.game));
|
||||||
ctx->setVariable(SCRIPT_VAR_stylesheet, to_script(stylesheet));
|
ctx->setVariable(SCRIPT_VAR_stylesheet, to_script(stylesheet));
|
||||||
ctx->setVariable(SCRIPT_VAR_card_style, to_script(&stylesheet->card_style));
|
ctx->setVariable(SCRIPT_VAR_card_style, to_script(&stylesheet->card_style));
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ void OptionalScript::initDependencies(Context& ctx, const Dependency& dep) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
Script& OptionalScript::getMutableScript() {
|
Script& OptionalScript::getMutableScript() {
|
||||||
if (!script) script = intrusive(new Script());
|
if (!script) script = make_intrusive<Script>();
|
||||||
return *script;
|
return *script;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,10 +95,10 @@ class ScriptDelayedError : public ScriptValue {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline ScriptValueP delay_error(const String& m) {
|
inline ScriptValueP delay_error(const String& m) {
|
||||||
return intrusive(new ScriptDelayedError(ScriptError(m)));
|
return make_intrusive<ScriptDelayedError>(ScriptError(m));
|
||||||
}
|
}
|
||||||
inline ScriptValueP delay_error(const ScriptError& error) {
|
inline ScriptValueP delay_error(const ScriptError& error) {
|
||||||
return intrusive(new ScriptDelayedError(error));
|
return make_intrusive<ScriptDelayedError>(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Iterators
|
// ----------------------------------------------------------------------------- : Iterators
|
||||||
@@ -160,7 +160,7 @@ class ScriptCollection : public ScriptCollectionBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual ScriptValueP makeIterator(const ScriptValueP& thisP) const {
|
virtual ScriptValueP makeIterator(const ScriptValueP& thisP) const {
|
||||||
return intrusive(new ScriptCollectionIterator<Collection>(value));
|
return make_intrusive<ScriptCollectionIterator<Collection>>(value);
|
||||||
}
|
}
|
||||||
virtual int itemCount() const { return (int)value->size(); }
|
virtual int itemCount() const { return (int)value->size(); }
|
||||||
/// Collections can be compared by comparing pointers
|
/// Collections can be compared by comparing pointers
|
||||||
@@ -402,13 +402,13 @@ inline ScriptValueP to_script(long v) { return to_script((int) v); }
|
|||||||
ScriptValueP to_script(wxDateTime v);
|
ScriptValueP to_script(wxDateTime v);
|
||||||
inline ScriptValueP to_script(bool v) { return v ? script_true : script_false; }
|
inline ScriptValueP to_script(bool v) { return v ? script_true : script_false; }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline ScriptValueP to_script(const vector<T>* v) { return intrusive(new ScriptCollection<vector<T> >(v)); }
|
inline ScriptValueP to_script(const vector<T>* v) { return make_intrusive<ScriptCollection<vector<T>>>(v); }
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline ScriptValueP to_script(const map<K,V>* v) { return intrusive(new ScriptMap<map<K,V> >(v)); }
|
inline ScriptValueP to_script(const map<K,V>* v) { return make_intrusive<ScriptMap<map<K,V>>>(v); }
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline ScriptValueP to_script(const IndexMap<K,V>* v) { return intrusive(new ScriptMap<IndexMap<K,V> >(v)); }
|
inline ScriptValueP to_script(const IndexMap<K,V>* v) { return make_intrusive<ScriptMap<IndexMap<K,V>>>(v); }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline ScriptValueP to_script(const intrusive_ptr<T>& v) { return intrusive(new ScriptObject<intrusive_ptr<T> >(v)); }
|
inline ScriptValueP to_script(const intrusive_ptr<T>& v) { return make_intrusive<ScriptObject<intrusive_ptr<T>>>(v); }
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline ScriptValueP to_script(const Defaultable<T>& v) { return to_script(v()); }
|
inline ScriptValueP to_script(const Defaultable<T>& v) { return to_script(v()); }
|
||||||
|
|
||||||
|
|||||||
+16
-16
@@ -111,11 +111,11 @@ ScriptDelayedError::operator bool() const { throw error; }
|
|||||||
ScriptDelayedError::operator Color() const { throw error; }
|
ScriptDelayedError::operator Color() const { throw error; }
|
||||||
int ScriptDelayedError::itemCount() const { throw error; }
|
int ScriptDelayedError::itemCount() const { throw error; }
|
||||||
CompareWhat ScriptDelayedError::compareAs(String&, void const*&) const { throw error; }
|
CompareWhat ScriptDelayedError::compareAs(String&, void const*&) const { throw error; }
|
||||||
ScriptValueP ScriptDelayedError::getMember(const String&) const { return intrusive(new ScriptDelayedError(error)); }
|
ScriptValueP ScriptDelayedError::getMember(const String&) const { return make_intrusive<ScriptDelayedError>(error); }
|
||||||
ScriptValueP ScriptDelayedError::dependencyMember(const String&, const Dependency&) const { return intrusive(new ScriptDelayedError(error)); }
|
ScriptValueP ScriptDelayedError::dependencyMember(const String&, const Dependency&) const { return make_intrusive<ScriptDelayedError>(error); }
|
||||||
ScriptValueP ScriptDelayedError::do_eval(Context&, bool) const { return intrusive(new ScriptDelayedError(error)); }
|
ScriptValueP ScriptDelayedError::do_eval(Context&, bool) const { return make_intrusive<ScriptDelayedError>(error); }
|
||||||
ScriptValueP ScriptDelayedError::dependencies(Context&, const Dependency&) const { return intrusive(new ScriptDelayedError(error)); }
|
ScriptValueP ScriptDelayedError::dependencies(Context&, const Dependency&) const { return make_intrusive<ScriptDelayedError>(error); }
|
||||||
ScriptValueP ScriptDelayedError::makeIterator(const ScriptValueP& thisP) const { return thisP ? thisP : intrusive(new ScriptDelayedError(error)); }
|
ScriptValueP ScriptDelayedError::makeIterator(const ScriptValueP& thisP) const { return thisP ? thisP : make_intrusive<ScriptDelayedError>(error); }
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Iterators
|
// ----------------------------------------------------------------------------- : Iterators
|
||||||
@@ -144,7 +144,7 @@ class ScriptRangeIterator : public ScriptIterator {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ScriptValueP rangeIterator(int start, int end) {
|
ScriptValueP rangeIterator(int start, int end) {
|
||||||
return intrusive(new ScriptRangeIterator(start, end));
|
return make_intrusive<ScriptRangeIterator>(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Integers
|
// ----------------------------------------------------------------------------- : Integers
|
||||||
@@ -190,7 +190,7 @@ ScriptValueP to_script(int v) {
|
|||||||
destroy_value); // deallocation function
|
destroy_value); // deallocation function
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
return intrusive(new ScriptInt(v));
|
return make_intrusive<ScriptInt>(v);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ class ScriptDouble : public ScriptValue {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ScriptValueP to_script(double v) {
|
ScriptValueP to_script(double v) {
|
||||||
return intrusive(new ScriptDouble(v));
|
return make_intrusive<ScriptDouble>(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : String type
|
// ----------------------------------------------------------------------------- : String type
|
||||||
@@ -287,9 +287,9 @@ class ScriptString : public ScriptValue {
|
|||||||
}
|
}
|
||||||
virtual GeneratedImageP toImage(const ScriptValueP&) const {
|
virtual GeneratedImageP toImage(const ScriptValueP&) const {
|
||||||
if (value.empty()) {
|
if (value.empty()) {
|
||||||
return intrusive(new BlankImage());
|
return make_intrusive<BlankImage>();
|
||||||
} else {
|
} else {
|
||||||
return intrusive(new PackagedImage(value));
|
return make_intrusive<PackagedImage>(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual int itemCount() const { return (int)value.size(); }
|
virtual int itemCount() const { return (int)value.size(); }
|
||||||
@@ -307,7 +307,7 @@ class ScriptString : public ScriptValue {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ScriptValueP to_script(const String& v) {
|
ScriptValueP to_script(const String& v) {
|
||||||
return intrusive(new ScriptString(v));
|
return make_intrusive<ScriptString>(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -329,7 +329,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
ScriptValueP to_script(Color v) {
|
ScriptValueP to_script(Color v) {
|
||||||
return intrusive(new ScriptColor(v));
|
return make_intrusive<ScriptColor>(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ class ScriptDateTime : public ScriptValue {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ScriptValueP to_script(wxDateTime v) {
|
ScriptValueP to_script(wxDateTime v) {
|
||||||
return intrusive(new ScriptDateTime(v));
|
return make_intrusive<ScriptDateTime>(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ public:
|
|||||||
operator bool() const override { return false; }
|
operator bool() const override { return false; }
|
||||||
operator Color() const override { return wxTransparentColour; }
|
operator Color() const override { return wxTransparentColour; }
|
||||||
GeneratedImageP toImage(const ScriptValueP&) const {
|
GeneratedImageP toImage(const ScriptValueP&) const {
|
||||||
return intrusive(new BlankImage());
|
return make_intrusive<BlankImage>();
|
||||||
}
|
}
|
||||||
String toCode() const override {
|
String toCode() const override {
|
||||||
return "nil";
|
return "nil";
|
||||||
@@ -440,7 +440,7 @@ ScriptValueP ScriptCustomCollection::getIndex(int index) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ScriptValueP ScriptCustomCollection::makeIterator(const ScriptValueP& thisP) const {
|
ScriptValueP ScriptCustomCollection::makeIterator(const ScriptValueP& thisP) const {
|
||||||
return intrusive(new ScriptCustomCollectionIterator(this, thisP));
|
return make_intrusive<ScriptCustomCollectionIterator>(this, thisP);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Concat collection
|
// ----------------------------------------------------------------------------- : Concat collection
|
||||||
@@ -484,7 +484,7 @@ ScriptValueP ScriptConcatCollection::getIndex(int index) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ScriptValueP ScriptConcatCollection::makeIterator(const ScriptValueP& thisP) const {
|
ScriptValueP ScriptConcatCollection::makeIterator(const ScriptValueP& thisP) const {
|
||||||
return intrusive(new ScriptConcatCollectionIterator(a->makeIterator(a), b->makeIterator(b)));
|
return make_intrusive<ScriptConcatCollectionIterator>(a->makeIterator(a), b->makeIterator(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Default arguments / closure
|
// ----------------------------------------------------------------------------- : Default arguments / closure
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ template <typename Key, typename Value>
|
|||||||
IndexMap<Key,Value>& DelayedIndexMaps<Key,Value>::get(const String& name, const vector<Key>& init_with) {
|
IndexMap<Key,Value>& DelayedIndexMaps<Key,Value>::get(const String& name, const vector<Key>& init_with) {
|
||||||
intrusive_ptr<DelayedIndexMapsData<Key,Value> >& item = data[name];
|
intrusive_ptr<DelayedIndexMapsData<Key,Value> >& item = data[name];
|
||||||
if (!item) { // no item, make a new one
|
if (!item) { // no item, make a new one
|
||||||
item = intrusive(new DelayedIndexMapsData<Key,Value>);
|
item = make_intrusive<DelayedIndexMapsData<Key,Value>>();
|
||||||
item->read_data.init(init_with);
|
item->read_data.init(init_with);
|
||||||
} else if (!item->unread_data.empty()) { // not read, read now
|
} else if (!item->unread_data.empty()) { // not read, read now
|
||||||
item->read_data.init(init_with);
|
item->read_data.init(init_with);
|
||||||
Reader reader(shared(new wxStringInputStream(item->unread_data)), nullptr, _("delayed data for ") + name);
|
Reader reader(make_shared<wxStringInputStream>(item->unread_data), nullptr, _("delayed data for ") + name);
|
||||||
reader.handle_greedy(item->read_data);
|
reader.handle_greedy(item->read_data);
|
||||||
item->unread_data.clear();
|
item->unread_data.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,13 +203,13 @@ InputStreamP Package::openIn(const String& file) {
|
|||||||
InputStreamP stream;
|
InputStreamP stream;
|
||||||
if (it != files.end() && it->second.wasWritten()) {
|
if (it != files.end() && it->second.wasWritten()) {
|
||||||
// written to this file, open the temp file
|
// written to this file, open the temp file
|
||||||
stream = shared(new BufferedFileInputStream(it->second.tempName));
|
stream = make_shared<BufferedFileInputStream>(it->second.tempName);
|
||||||
} else if (wxFileExists(filename+_("/")+file)) {
|
} else if (wxFileExists(filename+_("/")+file)) {
|
||||||
// a file in directory package
|
// a file in directory package
|
||||||
stream = shared(new BufferedFileInputStream(filename+_("/")+file));
|
stream = make_shared<BufferedFileInputStream>(filename+_("/")+file);
|
||||||
} else if (wxFileExists(filename) && it != files.end() && it->second.zipEntry) {
|
} else if (wxFileExists(filename) && it != files.end() && it->second.zipEntry) {
|
||||||
// a file in a zip archive
|
// a file in a zip archive
|
||||||
stream = static_pointer_cast<wxZipInputStream>(shared(new ZipFileInputStream(filename, it->second.zipEntry)));
|
stream = static_pointer_cast<wxZipInputStream>(make_shared<ZipFileInputStream>(filename, it->second.zipEntry));
|
||||||
} else {
|
} else {
|
||||||
// shouldn't happen, packaged changed by someone else since opening it
|
// shouldn't happen, packaged changed by someone else since opening it
|
||||||
throw FileNotFoundError(file, filename);
|
throw FileNotFoundError(file, filename);
|
||||||
@@ -222,7 +222,7 @@ InputStreamP Package::openIn(const String& file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OutputStreamP Package::openOut(const String& file) {
|
OutputStreamP Package::openOut(const String& file) {
|
||||||
return shared(new wxFileOutputStream(nameOut(file)));
|
return make_shared<wxFileOutputStream>(nameOut(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
String Package::nameOut(const String& file) {
|
String Package::nameOut(const String& file) {
|
||||||
@@ -296,7 +296,7 @@ InputStreamP Package::openAbsoluteFile(const String& name) {
|
|||||||
size_t pos = name.find_first_of(_('\1'));
|
size_t pos = name.find_first_of(_('\1'));
|
||||||
if (pos == String::npos) {
|
if (pos == String::npos) {
|
||||||
// temp or dir file
|
// temp or dir file
|
||||||
shared_ptr<wxFileInputStream> f = shared(new wxFileInputStream(name));
|
shared_ptr<wxFileInputStream> f = make_shared<wxFileInputStream>(name);
|
||||||
if (!f->IsOk()) throw FileNotFoundError(_("<unknown>"), name);
|
if (!f->IsOk()) throw FileNotFoundError(_("<unknown>"), name);
|
||||||
return f;
|
return f;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -65,12 +65,12 @@ PackagedP PackageManager::openAny(const String& name_, bool just_header) {
|
|||||||
if (!p) {
|
if (!p) {
|
||||||
// load with the right type, based on extension
|
// load with the right type, based on extension
|
||||||
wxFileName fn(filename);
|
wxFileName fn(filename);
|
||||||
if (fn.GetExt() == _("mse-game")) p = intrusive(new Game);
|
if (fn.GetExt() == _("mse-game")) p = make_intrusive<Game>();
|
||||||
else if (fn.GetExt() == _("mse-style")) p = intrusive(new StyleSheet);
|
else if (fn.GetExt() == _("mse-style")) p = make_intrusive<StyleSheet>();
|
||||||
else if (fn.GetExt() == _("mse-locale")) p = intrusive(new Locale);
|
else if (fn.GetExt() == _("mse-locale")) p = make_intrusive<Locale>();
|
||||||
else if (fn.GetExt() == _("mse-include")) p = intrusive(new IncludePackage);
|
else if (fn.GetExt() == _("mse-include")) p = make_intrusive<IncludePackage>();
|
||||||
else if (fn.GetExt() == _("mse-symbol-font")) p = intrusive(new SymbolFont);
|
else if (fn.GetExt() == _("mse-symbol-font")) p = make_intrusive<SymbolFont>();
|
||||||
else if (fn.GetExt() == _("mse-export-template")) p = intrusive(new ExportTemplate);
|
else if (fn.GetExt() == _("mse-export-template")) p = make_intrusive<ExportTemplate>();
|
||||||
else {
|
else {
|
||||||
throw PackageError(_("Unrecognized package type: '") + fn.GetExt() + _("'\nwhile trying to open: ") + name);
|
throw PackageError(_("Unrecognized package type: '") + fn.GetExt() + _("'\nwhile trying to open: ") + name);
|
||||||
}
|
}
|
||||||
@@ -273,7 +273,7 @@ void PackageDirectory::installedPackages(vector<InstallablePackageP>& packages_o
|
|||||||
PackageVersionP ver(new PackageVersion(
|
PackageVersionP ver(new PackageVersion(
|
||||||
is_local ? PackageVersion::STATUS_LOCAL : PackageVersion::STATUS_GLOBAL));
|
is_local ? PackageVersion::STATUS_LOCAL : PackageVersion::STATUS_GLOBAL));
|
||||||
ver->check_status(*pack);
|
ver->check_status(*pack);
|
||||||
packages_out.push_back(intrusive(new InstallablePackage(intrusive(new PackageDescription(*pack)), ver)));
|
packages_out.push_back(make_intrusive<InstallablePackage>(make_intrusive<PackageDescription>(*pack), ver));
|
||||||
} catch (const Error&) {}
|
} catch (const Error&) {}
|
||||||
++it2;
|
++it2;
|
||||||
} else if ((*it1)->name < *it2) {
|
} else if ((*it1)->name < *it2) {
|
||||||
@@ -285,7 +285,7 @@ void PackageDirectory::installedPackages(vector<InstallablePackageP>& packages_o
|
|||||||
try {
|
try {
|
||||||
PackagedP pack = package_manager.openAny(*it2, true);
|
PackagedP pack = package_manager.openAny(*it2, true);
|
||||||
(*it1)->check_status(*pack);
|
(*it1)->check_status(*pack);
|
||||||
packages_out.push_back(intrusive(new InstallablePackage(intrusive(new PackageDescription(*pack)), *it1)));
|
packages_out.push_back(make_intrusive<InstallablePackage>(make_intrusive<PackageDescription>(*pack), *it1));
|
||||||
} catch (const Error&) { db_changed = true; }
|
} catch (const Error&) { db_changed = true; }
|
||||||
++it1, ++it2;
|
++it1, ++it2;
|
||||||
}
|
}
|
||||||
@@ -339,7 +339,7 @@ void PackageDirectory::loadDatabase() {
|
|||||||
String filename = databaseFile();
|
String filename = databaseFile();
|
||||||
if (wxFileExists(filename)) {
|
if (wxFileExists(filename)) {
|
||||||
// packages file not existing is not an error
|
// packages file not existing is not an error
|
||||||
shared_ptr<wxFileInputStream> file = shared(new wxFileInputStream(filename));
|
shared_ptr<wxFileInputStream> file = make_shared<wxFileInputStream>(filename);
|
||||||
if (!file->Ok()) return; // failure is not an error
|
if (!file->Ok()) return; // failure is not an error
|
||||||
Reader reader(file, nullptr, filename);
|
Reader reader(file, nullptr, filename);
|
||||||
reader.handle_greedy(*this);
|
reader.handle_greedy(*this);
|
||||||
@@ -348,7 +348,7 @@ void PackageDirectory::loadDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PackageDirectory::saveDatabase() {
|
void PackageDirectory::saveDatabase() {
|
||||||
Writer writer(shared(new wxFileOutputStream(databaseFile())), app_version);
|
Writer writer(make_shared<wxFileOutputStream>(databaseFile()), app_version);
|
||||||
writer.handle(*this);
|
writer.handle(*this);
|
||||||
}
|
}
|
||||||
String PackageDirectory::databaseFile() {
|
String PackageDirectory::databaseFile() {
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ class Reader {
|
|||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
intrusive_ptr<T> read_new(Reader& reader) {
|
intrusive_ptr<T> read_new(Reader& reader) {
|
||||||
return intrusive(new T());
|
return make_intrusive<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update the 'index' member of a value for use by IndexMap
|
/// Update the 'index' member of a value for use by IndexMap
|
||||||
|
|||||||
+7
-18
@@ -33,29 +33,18 @@ template <typename T> using scoped_ptr = unique_ptr<T>;
|
|||||||
class Type; \
|
class Type; \
|
||||||
typedef shared_ptr<Type> Type##P;
|
typedef shared_ptr<Type> Type##P;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Creating
|
|
||||||
|
|
||||||
/// Wrap a newly allocated pointer in an shared_ptr
|
|
||||||
/** Usage:
|
|
||||||
* return shared(new T(stuff)));
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
//[[deprecated("use make_shared")]]
|
|
||||||
inline shared_ptr<T> shared(T* ptr) {
|
|
||||||
return shared_ptr<T>(ptr);
|
|
||||||
}
|
|
||||||
template <typename T>
|
|
||||||
//[[deprecated("use make_shared")]]
|
|
||||||
inline shared_ptr<T> intrusive(T* ptr) {
|
|
||||||
return shared_ptr<T>(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Intrusive pointers
|
// ----------------------------------------------------------------------------- : Intrusive pointers
|
||||||
|
|
||||||
#define DECLARE_POINTER_TYPE DECLARE_SHARED_POINTER_TYPE
|
#define DECLARE_POINTER_TYPE DECLARE_SHARED_POINTER_TYPE
|
||||||
#define intrusive_ptr shared_ptr
|
|
||||||
|
|
||||||
template <typename T> class IntrusivePtrBase {};
|
template <typename T> class IntrusivePtrBase {};
|
||||||
|
template <typename T> using intrusive_ptr = shared_ptr<T>;
|
||||||
|
|
||||||
|
/// Allocate an object of type T and store it in a new intrusive_ptr, similar to std::make_shared
|
||||||
|
template <typename T, class... Args>
|
||||||
|
inline intrusive_ptr<T> make_intrusive(Args&&... args) {
|
||||||
|
return std::make_shared<T>(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
/// IntrusivePtrBase with a virtual destructor
|
/// IntrusivePtrBase with a virtual destructor
|
||||||
class IntrusivePtrVirtualBase : public IntrusivePtrBase<IntrusivePtrVirtualBase> {
|
class IntrusivePtrVirtualBase : public IntrusivePtrBase<IntrusivePtrVirtualBase> {
|
||||||
|
|||||||
+2
-2
@@ -17,8 +17,8 @@ VCSP read_new<VCS>(Reader& reader) {
|
|||||||
// there must be a type specified
|
// there must be a type specified
|
||||||
String type;
|
String type;
|
||||||
reader.handle(_("type"), type);
|
reader.handle(_("type"), type);
|
||||||
if (type == _("none")) return intrusive(new VCS);
|
if (type == _("none")) return make_intrusive<VCS>();
|
||||||
else if (type == _("subversion")) return intrusive(new SubversionVCS);
|
else if (type == _("subversion")) return make_intrusive<SubversionVCS>();
|
||||||
else if (type.empty()) {
|
else if (type.empty()) {
|
||||||
reader.warning(_ERROR_1_("expected key", _("version control system")));
|
reader.warning(_ERROR_1_("expected key", _("version control system")));
|
||||||
throw ParseError(_ERROR_("aborting parsing"));
|
throw ParseError(_ERROR_("aborting parsing"));
|
||||||
|
|||||||
Reference in New Issue
Block a user