mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Instead of the new_intrusive<T>() functions, use intrusive(new T)
This means we no longer need 8 different functions for different numbers of arguments, and non-const references can now also be passed to constructors without problems. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1443 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -21,7 +21,7 @@ DECLARE_TYPEOF_COLLECTION(KeywordModeP);
|
||||
|
||||
AddKeywordAction::AddKeywordAction(Set& set)
|
||||
: KeywordListAction(set)
|
||||
, action(ADD, new_intrusive<Keyword>(), set.keywords)
|
||||
, action(ADD, intrusive(new Keyword()), set.keywords)
|
||||
{
|
||||
Keyword& keyword = *action.steps.front().item;
|
||||
// find default mode
|
||||
@@ -184,7 +184,7 @@ bool KeywordReminderTextValue::checkScript(const ScriptP& script) {
|
||||
const KeywordParam& kwp = *keyword.parameters[i];
|
||||
String param_name = String(_("param")) << (int)(i+1);
|
||||
String param_value = _("<atom-kwpph>") + (kwp.placeholder.empty() ? kwp.name : kwp.placeholder) + _("</atom-kwpph>");
|
||||
ctx.setVariable(param_name, new_intrusive4<KeywordParamValue>(kwp.name, _(""), _(""), param_value));
|
||||
ctx.setVariable(param_name, intrusive(new KeywordParamValue(kwp.name, _(""), _(""), param_value)));
|
||||
}
|
||||
script->eval(ctx);
|
||||
errors.clear();
|
||||
|
||||
@@ -23,7 +23,7 @@ DECLARE_TYPEOF_COLLECTION(int);
|
||||
|
||||
AddCardAction::AddCardAction(Set& set)
|
||||
: CardListAction(set)
|
||||
, action(ADD, new_intrusive1<Card>(*set.game), set.cards)
|
||||
, action(ADD, intrusive(new Card(*set.game)), set.cards)
|
||||
{}
|
||||
|
||||
AddCardAction::AddCardAction(AddingOrRemoving ar, Set& set, const CardP& card)
|
||||
|
||||
@@ -398,7 +398,7 @@ ControlPointRemoveAction::ControlPointRemoveAction(const SymbolShapeP& shape, co
|
||||
FOR_EACH(point, shape->points) {
|
||||
if (to_delete.find(point) != to_delete.end()) {
|
||||
// remove this point
|
||||
removals.push_back(new_intrusive2<SinglePointRemoveAction>(shape, index));
|
||||
removals.push_back(intrusive(new SinglePointRemoveAction(shape, index)));
|
||||
}
|
||||
++index;
|
||||
}
|
||||
@@ -422,7 +422,7 @@ void ControlPointRemoveAction::perform(bool to_undo) {
|
||||
Action* control_point_remove_action(const SymbolShapeP& shape, const set<ControlPointP>& to_delete) {
|
||||
if (shape->points.size() - to_delete.size() < 2) {
|
||||
// TODO : remove part?
|
||||
//new_intrusive<ControlPointRemoveAllAction>(part);
|
||||
//intrusive(new ControlPointRemoveAllAction(part));
|
||||
return 0; // no action
|
||||
} else {
|
||||
return new ControlPointRemoveAction(shape, to_delete);
|
||||
|
||||
@@ -34,7 +34,7 @@ void AddCardsScript::perform(Set& set, vector<CardP>& out) {
|
||||
// is this a new card?
|
||||
if (contains(set.cards,card) || contains(out,card)) {
|
||||
// make copy
|
||||
card = new_intrusive1<Card>(*card);
|
||||
card = intrusive(new Card(*card));
|
||||
}
|
||||
out.push_back(card);
|
||||
}
|
||||
|
||||
+9
-9
@@ -74,15 +74,15 @@ intrusive_ptr<Field> read_new<Field>(Reader& reader) {
|
||||
// there must be a type specified
|
||||
String type;
|
||||
reader.handle(_("type"), type);
|
||||
if (type == _("text")) return new_intrusive<TextField>();
|
||||
else if (type == _("choice")) return new_intrusive<ChoiceField>();
|
||||
else if (type == _("multiple choice")) return new_intrusive<MultipleChoiceField>();
|
||||
else if (type == _("boolean")) return new_intrusive<BooleanField>();
|
||||
else if (type == _("image")) return new_intrusive<ImageField>();
|
||||
else if (type == _("symbol")) return new_intrusive<SymbolField>();
|
||||
else if (type == _("color")) return new_intrusive<ColorField>();
|
||||
else if (type == _("info")) return new_intrusive<InfoField>();
|
||||
else if (type == _("package choice")) return new_intrusive<PackageChoiceField>();
|
||||
if (type == _("text")) return intrusive(new TextField());
|
||||
else if (type == _("choice")) return intrusive(new ChoiceField());
|
||||
else if (type == _("multiple choice")) return intrusive(new MultipleChoiceField());
|
||||
else if (type == _("boolean")) return intrusive(new BooleanField());
|
||||
else if (type == _("image")) return intrusive(new ImageField());
|
||||
else if (type == _("symbol")) return intrusive(new SymbolField());
|
||||
else if (type == _("color")) return intrusive(new ColorField());
|
||||
else if (type == _("info")) return intrusive(new InfoField());
|
||||
else if (type == _("package choice")) return intrusive(new PackageChoiceField());
|
||||
else if (type.empty()) {
|
||||
reader.warning(_ERROR_1_("expected key", _("type")));
|
||||
throw ParseError(_ERROR_("aborting parsing"));
|
||||
|
||||
+4
-4
@@ -266,17 +266,17 @@ inline String type_name(const Value&) {
|
||||
#define IMPLEMENT_FIELD_TYPE(Type, NAME) \
|
||||
StyleP Type ## Field::newStyle(const FieldP& thisP) const { \
|
||||
assert(thisP.get() == this); \
|
||||
return new_intrusive1<Type ## Style>(static_pointer_cast<Type ## Field>(thisP));\
|
||||
return intrusive(new Type ## Style(static_pointer_cast<Type ## Field>(thisP))); \
|
||||
} \
|
||||
ValueP Type ## Field::newValue(const FieldP& thisP) const { \
|
||||
assert(thisP.get() == this); \
|
||||
return new_intrusive1<Type ## Value>(static_pointer_cast<Type ## Field>(thisP));\
|
||||
return intrusive(new Type ## Value(static_pointer_cast<Type ## Field>(thisP))); \
|
||||
} \
|
||||
StyleP Type ## Style::clone() const { \
|
||||
return new_intrusive1<Type ## Style>(*this); \
|
||||
return intrusive(new Type ## Style(*this)); \
|
||||
} \
|
||||
ValueP Type ## Value::clone() const { \
|
||||
return new_intrusive1<Type ## Value>(*this); \
|
||||
return intrusive(new Type ## Value(*this)); \
|
||||
} \
|
||||
String Type ## Field::typeName() const { \
|
||||
return _(NAME); \
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
// ----------------------------------------------------------------------------- : BooleanField
|
||||
|
||||
BooleanField::BooleanField() {
|
||||
choices->choices.push_back(new_intrusive1<Choice>(_("yes")));
|
||||
choices->choices.push_back(new_intrusive1<Choice>(_("no")));
|
||||
choices->choices.push_back(intrusive(new Choice(_("yes"))));
|
||||
choices->choices.push_back(intrusive(new Choice(_("no"))));
|
||||
choices->initIds();
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ BooleanStyle::BooleanStyle(const ChoiceFieldP& field)
|
||||
render_style = RENDER_BOTH;
|
||||
//choice_images[_("yes")] = ScriptableImage(_("buildin_image(\"bool_yes\")"));
|
||||
//choice_images[_("no")] = ScriptableImage(_("buildin_image(\"bool_no\")"));
|
||||
choice_images[_("yes")] = ScriptableImage(new_intrusive1<BuiltInImage>(_("bool_yes")));
|
||||
choice_images[_("no")] = ScriptableImage(new_intrusive1<BuiltInImage>(_("bool_no")));
|
||||
choice_images[_("yes")] = ScriptableImage(intrusive(new BuiltInImage(_("bool_yes"))));
|
||||
choice_images[_("no")] = ScriptableImage(intrusive(new BuiltInImage(_("bool_no"))));
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(BooleanStyle) {
|
||||
|
||||
@@ -48,5 +48,5 @@ void ImageValue::reflect(Writer& tag) {
|
||||
void ImageValue::reflect(GetMember& tag) {}
|
||||
void ImageValue::reflect(GetDefaultMember& tag) {
|
||||
// convert to ScriptImageP for scripting
|
||||
tag.handle( (ScriptValueP)new_intrusive2<ImageValueToImage>(filename, last_update) );
|
||||
tag.handle( (ScriptValueP)intrusive(new ImageValueToImage(filename, last_update)) );
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ void ApprCardDatabase::doRead(wxInputStream& in) {
|
||||
progress_target->onProgress(0.4f * float(i) / cards.size(),
|
||||
String(_("reading card ")) << i << _(" of ") << (int)cards.size());
|
||||
}
|
||||
card = new_intrusive<ApprCardRecord>();
|
||||
card = intrusive(new ApprCardRecord());
|
||||
card->readHead(data);
|
||||
head_pos = in.TellI();
|
||||
in.SeekI(card->data_pos);
|
||||
@@ -753,7 +753,7 @@ bool ApprenticeExportWindow::exportSet() {
|
||||
cardlist.removeSet(set->apprentice_code);
|
||||
// add cards from set
|
||||
FOR_EACH(card, set->cards) {
|
||||
ApprCardRecordP rec = new_intrusive2<ApprCardRecord>(*card, set->apprentice_code);
|
||||
ApprCardRecordP rec = intrusive(new ApprCardRecord(*card, set->apprentice_code));
|
||||
cardlist.cards.push_back(rec);
|
||||
}
|
||||
cardlist.write();
|
||||
|
||||
@@ -187,10 +187,10 @@ SymbolShapeP read_symbol_shape(const ImageData& data) {
|
||||
}
|
||||
|
||||
// add to shape and place a mark
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(
|
||||
shape->points.push_back(intrusive(new ControlPoint(
|
||||
double(x) / data.width,
|
||||
double(y) / data.height
|
||||
));
|
||||
)));
|
||||
if (x > old_x) data(old_x, y) |= MARKED; // mark when moving right -> only mark the top of the shape
|
||||
last_move = (x + y) - (old_x + old_y);
|
||||
old_x = x;
|
||||
|
||||
@@ -30,7 +30,7 @@ class MSE1FileFormat : public FileFormat {
|
||||
};
|
||||
|
||||
FileFormatP mse1_file_format() {
|
||||
return new_intrusive<MSE1FileFormat>();
|
||||
return intrusive(new MSE1FileFormat());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Importing
|
||||
|
||||
@@ -45,5 +45,5 @@ class MSE2FileFormat : public FileFormat {
|
||||
};
|
||||
|
||||
FileFormatP mse2_file_format() {
|
||||
return new_intrusive<MSE2FileFormat>();
|
||||
return intrusive(new MSE2FileFormat());
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class MtgEditorFileFormat : public FileFormat {
|
||||
};
|
||||
|
||||
FileFormatP mtg_editor_file_format() {
|
||||
return new_intrusive<MtgEditorFileFormat>();
|
||||
return intrusive(new MtgEditorFileFormat());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Importing
|
||||
@@ -69,7 +69,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
|
||||
// read file
|
||||
while (!f.Eof()) {
|
||||
// read a line
|
||||
if (!current_card) current_card = new_intrusive1<Card>(*set->game);
|
||||
if (!current_card) current_card = intrusive(new Card(*set->game));
|
||||
String line = file.ReadLine();
|
||||
if (line == _("#SET###########")) { // set.title
|
||||
target = &set->value<TextValue>(_("title")).value;
|
||||
@@ -104,7 +104,7 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
|
||||
set->cards.push_back(current_card);
|
||||
}
|
||||
first = false;
|
||||
current_card = new_intrusive1<Card>(*set->game);
|
||||
current_card = intrusive(new Card(*set->game));
|
||||
target = ¤t_card->value<TextValue>(_("name")).value;
|
||||
} else if (line == _("#DATE##########")) { // date
|
||||
// remember date for generation of illustration filename
|
||||
|
||||
+2
-2
@@ -77,7 +77,7 @@ void Game::validate(Version v) {
|
||||
vector<StatsDimensionP> dims;
|
||||
FOR_EACH(f, card_fields) {
|
||||
if (f->show_statistics) {
|
||||
dims.push_back(new_intrusive1<StatsDimension>(*f));
|
||||
dims.push_back(intrusive(new StatsDimension(*f)));
|
||||
}
|
||||
}
|
||||
statistics_dimensions.insert(statistics_dimensions.begin(), dims.begin(), dims.end()); // push front
|
||||
@@ -86,7 +86,7 @@ void Game::validate(Version v) {
|
||||
{
|
||||
vector<StatsCategoryP> cats;
|
||||
FOR_EACH(dim, statistics_dimensions) {
|
||||
cats.push_back(new_intrusive1<StatsCategory>(dim));
|
||||
cats.push_back(intrusive(new StatsCategory(dim)));
|
||||
}
|
||||
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;
|
||||
wxString fn(wxFileName(p).GetExt());
|
||||
if (fn == _("mse-game")) pack = new_intrusive<Game>();
|
||||
else if (fn == _("mse-style")) pack = new_intrusive<StyleSheet>();
|
||||
else if (fn == _("mse-locale")) pack = new_intrusive<Locale>();
|
||||
else if (fn == _("mse-include")) pack = new_intrusive<IncludePackage>();
|
||||
else if (fn == _("mse-symbol-font")) pack = new_intrusive<SymbolFont>();
|
||||
else if (fn == _("mse-export-template")) pack = new_intrusive<ExportTemplate>();
|
||||
if (fn == _("mse-game")) pack = intrusive(new Game());
|
||||
else if (fn == _("mse-style")) pack = intrusive(new StyleSheet());
|
||||
else if (fn == _("mse-locale")) pack = intrusive(new Locale());
|
||||
else if (fn == _("mse-include")) pack = intrusive(new IncludePackage());
|
||||
else if (fn == _("mse-symbol-font")) pack = intrusive(new SymbolFont());
|
||||
else if (fn == _("mse-export-template")) pack = intrusive(new ExportTemplate());
|
||||
else {
|
||||
throw PackageError(_("Unrecognized package type: '") + fn + _("'\nwhile trying to install: ") + p);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ void Installer::addPackage(Packaged& package) {
|
||||
return; // already added
|
||||
}
|
||||
}
|
||||
packages.push_back(new_intrusive1<PackageDescription>(package));
|
||||
packages.push_back(intrusive(new PackageDescription(package)));
|
||||
// use this as a filename?
|
||||
if (prefered_filename.empty()) {
|
||||
prefered_filename = package.name() + _(".mse-installer");
|
||||
@@ -387,7 +387,7 @@ void merge(InstallablePackages& list1, const InstallablePackages& list2) {
|
||||
void merge(InstallablePackages& installed, const DownloadableInstallerP& installer) {
|
||||
InstallablePackages ips;
|
||||
FOR_EACH(p, installer->packages) {
|
||||
ips.push_back(new_intrusive2<InstallablePackage>(p,installer));
|
||||
ips.push_back(intrusive(new InstallablePackage(p,installer)));
|
||||
}
|
||||
sort(ips);
|
||||
merge(installed, ips);
|
||||
@@ -625,5 +625,5 @@ InstallablePackageP mse_installable_package() {
|
||||
mse_description->position_hint = -100;
|
||||
mse_description->icon = load_resource_image(_("installer_program"));
|
||||
//mse_description->description = _LABEL_("magic set editor package");
|
||||
return new_intrusive2<InstallablePackage>(mse_description, mse_version);
|
||||
return intrusive(new InstallablePackage(mse_description, mse_version));
|
||||
}
|
||||
|
||||
+4
-4
@@ -77,7 +77,7 @@ SubLocaleP find_wildcard(map<String,SubLocaleP>& items, const String& name) {
|
||||
FOR_EACH_CONST(i, items) {
|
||||
if (i.second && match_wildcard(i.first, name)) return i.second;
|
||||
}
|
||||
return new_intrusive<SubLocale>(); // so we don't search again
|
||||
return intrusive(new SubLocale()); // so we don't search again
|
||||
}
|
||||
SubLocaleP find_wildcard_and_set(map<String,SubLocaleP>& items, const String& name) {
|
||||
return items[name] = find_wildcard(items, name);
|
||||
@@ -208,12 +208,12 @@ InputStreamP load_resource_text(const String& name) {
|
||||
char* data = (char *)::LockResource(hData);
|
||||
if ( !data ) throw InternalError(String::Format(_("Resource cannot be locked: %s"), name));
|
||||
int len = ::SizeofResource(wxGetInstance(), hResource);
|
||||
return new_shared2<wxMemoryInputStream>(data, len);
|
||||
return shared(new wxMemoryInputStream(data, len));
|
||||
#else
|
||||
static String path = wxStandardPaths::Get().GetDataDir() + _("/resource/");
|
||||
static String local_path = wxStandardPaths::Get().GetUserDataDir() + _("/resource/");
|
||||
if (wxFileExists(path + name)) return new_shared1<wxFileInputStream>(path + name);
|
||||
else return new_shared1<wxFileInputStream>(local_path + name);
|
||||
if (wxFileExists(path + name)) return shared(new wxFileInputStream(path + name));
|
||||
else return shared(new wxFileInputStream(local_path + name));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -28,13 +28,13 @@ DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA ValueP>);
|
||||
// ----------------------------------------------------------------------------- : Set
|
||||
|
||||
Set::Set()
|
||||
: vcs (new_intrusive<VCS>())
|
||||
: vcs (intrusive(new VCS()))
|
||||
, script_manager(new SetScriptManager(*this))
|
||||
{}
|
||||
|
||||
Set::Set(const GameP& game)
|
||||
: game(game)
|
||||
, vcs (new_intrusive<VCS>())
|
||||
, vcs (intrusive(new VCS()))
|
||||
, script_manager(new SetScriptManager(*this))
|
||||
{
|
||||
data.init(game->set_fields);
|
||||
@@ -43,7 +43,7 @@ Set::Set(const GameP& game)
|
||||
Set::Set(const StyleSheetP& stylesheet)
|
||||
: game(stylesheet->game)
|
||||
, stylesheet(stylesheet)
|
||||
, vcs (new_intrusive<VCS>())
|
||||
, vcs (intrusive(new VCS()))
|
||||
, script_manager(new SetScriptManager(*this))
|
||||
{
|
||||
data.init(game->set_fields);
|
||||
@@ -163,7 +163,7 @@ void Set::validate(Version file_app_version) {
|
||||
}
|
||||
*/ }
|
||||
// we want at least one card
|
||||
if (cards.empty()) cards.push_back(new_intrusive1<Card>(*game));
|
||||
if (cards.empty()) cards.push_back(intrusive(new Card(*game)));
|
||||
// update scripts
|
||||
script_manager->updateAll();
|
||||
}
|
||||
@@ -231,7 +231,7 @@ void Set::reflect_cards<Writer> (Writer& tag) {
|
||||
// ----------------------------------------------------------------------------- : Script utilities
|
||||
|
||||
ScriptValueP make_iterator(const Set& set) {
|
||||
return new_intrusive1<ScriptCollectionIterator<vector<CardP> > >(&set.cards);
|
||||
return intrusive(new ScriptCollectionIterator<vector<CardP> >(&set.cards));
|
||||
}
|
||||
|
||||
void mark_dependency_member(const Set& set, const String& name, const Dependency& dep) {
|
||||
@@ -276,7 +276,7 @@ int Set::positionOfCard(const CardP& card, const ScriptValueP& order_by, const S
|
||||
Profiler prof(t, order_by.get(), _("init order cache"));
|
||||
#endif
|
||||
// 3. initialize order cache
|
||||
order = new_intrusive3<OrderCache<CardP> >(cards, values, filter ? &keep : nullptr);
|
||||
order = intrusive(new OrderCache<CardP>(cards, values, filter ? &keep : nullptr));
|
||||
}
|
||||
return order->find(card);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ void Settings::addRecentFile(const String& filename) {
|
||||
|
||||
GameSettings& Settings::gameSettingsFor(const Game& game) {
|
||||
GameSettingsP& gs = game_settings[game.name()];
|
||||
if (!gs) gs = new_intrusive<GameSettings>();
|
||||
if (!gs) gs = intrusive(new GameSettings);
|
||||
gs->initDefaults(game);
|
||||
return *gs;
|
||||
}
|
||||
@@ -214,7 +214,7 @@ ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field
|
||||
}
|
||||
StyleSheetSettings& Settings::stylesheetSettingsFor(const StyleSheet& stylesheet) {
|
||||
StyleSheetSettingsP& ss = stylesheet_settings[stylesheet.name()];
|
||||
if (!ss) ss = new_intrusive<StyleSheetSettings>();
|
||||
if (!ss) ss = intrusive(new StyleSheetSettings);
|
||||
ss->useDefault(default_stylesheet_settings); // update default settings
|
||||
return *ss;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ void Settings::read() {
|
||||
String filename = settingsFile();
|
||||
if (wxFileExists(filename)) {
|
||||
// settings file not existing is not an error
|
||||
shared_ptr<wxFileInputStream> file = new_shared1<wxFileInputStream>(filename);
|
||||
shared_ptr<wxFileInputStream> file = shared(new wxFileInputStream(filename));
|
||||
if (!file->Ok()) return; // failure is not an error
|
||||
Reader reader(file, nullptr, filename);
|
||||
reader.handle_greedy(*this);
|
||||
@@ -294,6 +294,6 @@ void Settings::read() {
|
||||
}
|
||||
|
||||
void Settings::write() {
|
||||
Writer writer(new_shared1<wxFileOutputStream>(settingsFile()), app_version);
|
||||
Writer writer(shared(new wxFileOutputStream(settingsFile())), app_version);
|
||||
writer.handle(*this);
|
||||
}
|
||||
|
||||
+10
-10
@@ -139,9 +139,9 @@ SymbolPartP read_new<SymbolPart>(Reader& reader) {
|
||||
// there must be a type specified
|
||||
String type;
|
||||
reader.handle(_("type"), type);
|
||||
if (type == _("shape") || type.empty()) return new_intrusive<SymbolShape>();
|
||||
else if (type == _("symmetry")) return new_intrusive<SymbolSymmetry>();
|
||||
else if (type == _("group")) return new_intrusive<SymbolGroup>();
|
||||
if (type == _("shape") || type.empty()) return intrusive(new SymbolShape);
|
||||
else if (type == _("symmetry")) return intrusive(new SymbolSymmetry);
|
||||
else if (type == _("group")) return intrusive(new SymbolGroup);
|
||||
else {
|
||||
throw ParseError(_("Unsupported symbol part type: '") + type + _("'"));
|
||||
}
|
||||
@@ -200,7 +200,7 @@ SymbolPartP SymbolShape::clone() const {
|
||||
SymbolShapeP part(new SymbolShape(*this));
|
||||
// also clone the control points
|
||||
FOR_EACH(p, part->points) {
|
||||
p = new_intrusive1<ControlPoint>(*p);
|
||||
p = intrusive(new ControlPoint(*p));
|
||||
}
|
||||
return part;
|
||||
}
|
||||
@@ -357,18 +357,18 @@ double Symbol::aspectRatio() const {
|
||||
|
||||
// A default symbol part, a square, moved by d
|
||||
SymbolShapeP default_symbol_part(double d) {
|
||||
SymbolShapeP part = new_intrusive<SymbolShape>();
|
||||
part->points.push_back(new_intrusive2<ControlPoint>(d + .2, d + .2));
|
||||
part->points.push_back(new_intrusive2<ControlPoint>(d + .2, d + .8));
|
||||
part->points.push_back(new_intrusive2<ControlPoint>(d + .8, d + .8));
|
||||
part->points.push_back(new_intrusive2<ControlPoint>(d + .8, d + .2));
|
||||
SymbolShapeP part = intrusive(new SymbolShape);
|
||||
part->points.push_back(intrusive(new ControlPoint(d + .2, d + .2)));
|
||||
part->points.push_back(intrusive(new ControlPoint(d + .2, d + .8)));
|
||||
part->points.push_back(intrusive(new ControlPoint(d + .8, d + .8)));
|
||||
part->points.push_back(intrusive(new ControlPoint(d + .8, d + .2)));
|
||||
part->name = _("Square");
|
||||
return part;
|
||||
}
|
||||
|
||||
// A default symbol, a square
|
||||
SymbolP default_symbol() {
|
||||
SymbolP symbol = new_intrusive<Symbol>();
|
||||
SymbolP symbol = intrusive(new Symbol);
|
||||
symbol->parts.push_back(default_symbol_part(0));
|
||||
return symbol;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class AutoReplace : public IntrusivePtrVirtualBase {
|
||||
String match;
|
||||
String replace;
|
||||
|
||||
inline AutoReplaceP clone() const { return new_intrusive1<AutoReplace>(*this); }
|
||||
inline AutoReplaceP clone() const { return intrusive(new AutoReplace(*this)); }
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
@@ -231,7 +231,7 @@ void AutoReplaceWindow::onRemove(wxCommandEvent&) {
|
||||
list->removeSelected();
|
||||
}
|
||||
void AutoReplaceWindow::onAdd(wxCommandEvent&) {
|
||||
list->addItem(new_intrusive<AutoReplace>());
|
||||
list->addItem(intrusive(new AutoReplace()));
|
||||
}
|
||||
void AutoReplaceWindow::onDefault(wxCommandEvent&) {
|
||||
use_auto_replace->SetValue(true);
|
||||
|
||||
+22
-22
@@ -1019,39 +1019,39 @@ void GraphControl::setLayout(GraphType type, bool force) {
|
||||
switch (type) {
|
||||
case GRAPH_TYPE_BAR: {
|
||||
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
||||
combined->add(new_intrusive2<GraphValueAxis>(0, true));
|
||||
combined->add(new_intrusive2<GraphLabelAxis>(0, HORIZONTAL));
|
||||
combined->add(new_intrusive1<BarGraph>(0));
|
||||
combined->add(new_intrusive2<GraphStats>(0, ALIGN_TOP_RIGHT));
|
||||
graph = new_intrusive5<GraphWithMargins>(combined, 23,8,7,20);
|
||||
combined->add(intrusive(new GraphValueAxis(0, true)));
|
||||
combined->add(intrusive(new GraphLabelAxis(0, HORIZONTAL)));
|
||||
combined->add(intrusive(new BarGraph(0)));
|
||||
combined->add(intrusive(new GraphStats(0, ALIGN_TOP_RIGHT)));
|
||||
graph = intrusive(new GraphWithMargins(combined, 23,8,7,20));
|
||||
break;
|
||||
} case GRAPH_TYPE_PIE: {
|
||||
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
||||
combined->add(new_intrusive5<GraphWithMargins>(new_intrusive1<PieGraph>(0), 0,0,120,0));
|
||||
combined->add(new_intrusive3<GraphLegend>(0, ALIGN_TOP_RIGHT, false));
|
||||
graph = new_intrusive5<GraphWithMargins>(combined, 20,20,20,20);
|
||||
combined->add(intrusive(new GraphWithMargins(intrusive(new PieGraph(0)), 0,0,120,0)));
|
||||
combined->add(intrusive(new GraphLegend(0, ALIGN_TOP_RIGHT, false)));
|
||||
graph = intrusive(new GraphWithMargins(combined, 20,20,20,20));
|
||||
break;
|
||||
} case GRAPH_TYPE_STACK: {
|
||||
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
||||
combined->add(new_intrusive2<GraphValueAxis>(0, false));
|
||||
combined->add(new_intrusive2<GraphLabelAxis>(0, HORIZONTAL));
|
||||
combined->add(new_intrusive2<BarGraph2D>(0,1));
|
||||
combined->add(new_intrusive3<GraphLegend>(1, ALIGN_TOP_RIGHT, true));
|
||||
graph = new_intrusive5<GraphWithMargins>(combined, 23,8,7,20);
|
||||
combined->add(intrusive(new GraphValueAxis(0, false)));
|
||||
combined->add(intrusive(new GraphLabelAxis(0, HORIZONTAL)));
|
||||
combined->add(intrusive(new BarGraph2D(0,1)));
|
||||
combined->add(intrusive(new GraphLegend(1, ALIGN_TOP_RIGHT, true)));
|
||||
graph = intrusive(new GraphWithMargins(combined, 23,8,7,20));
|
||||
break;
|
||||
} case GRAPH_TYPE_SCATTER: {
|
||||
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
||||
combined->add(new_intrusive4<GraphLabelAxis>(0, HORIZONTAL, false, DRAW_LINES_MID));
|
||||
combined->add(new_intrusive4<GraphLabelAxis>(1, VERTICAL, false, DRAW_LINES_MID));
|
||||
combined->add(new_intrusive2<ScatterGraph>(0,1));
|
||||
graph = new_intrusive5<GraphWithMargins>(combined, 80,8,7,20);
|
||||
combined->add(intrusive(new GraphLabelAxis(0, HORIZONTAL, false, DRAW_LINES_MID)));
|
||||
combined->add(intrusive(new GraphLabelAxis(1, VERTICAL, false, DRAW_LINES_MID)));
|
||||
combined->add(intrusive(new ScatterGraph(0,1)));
|
||||
graph = intrusive(new GraphWithMargins(combined, 80,8,7,20));
|
||||
break;
|
||||
} case GRAPH_TYPE_SCATTER_PIE: {
|
||||
intrusive_ptr<GraphContainer> combined(new GraphContainer());
|
||||
combined->add(new_intrusive4<GraphLabelAxis>(0, HORIZONTAL, false, DRAW_LINES_MID));
|
||||
combined->add(new_intrusive4<GraphLabelAxis>(1, VERTICAL, false, DRAW_LINES_MID));
|
||||
combined->add(new_intrusive3<ScatterPieGraph>(0,1,2));
|
||||
graph = new_intrusive5<GraphWithMargins>(combined, 80,8,7,20);
|
||||
combined->add(intrusive(new GraphLabelAxis(0, HORIZONTAL, false, DRAW_LINES_MID)));
|
||||
combined->add(intrusive(new GraphLabelAxis(1, VERTICAL, false, DRAW_LINES_MID)));
|
||||
combined->add(intrusive(new ScatterPieGraph(0,1,2)));
|
||||
graph = intrusive(new GraphWithMargins(combined, 80,8,7,20));
|
||||
break;
|
||||
} default:
|
||||
graph = GraphP();
|
||||
@@ -1065,7 +1065,7 @@ GraphType GraphControl::getLayout() const {
|
||||
}
|
||||
|
||||
void GraphControl::setData(const GraphDataPre& data) {
|
||||
setData(new_intrusive1<GraphData>(data));
|
||||
setData(intrusive(new GraphData(data)));
|
||||
}
|
||||
void GraphControl::setData(const GraphDataP& data) {
|
||||
if (graph) {
|
||||
|
||||
@@ -100,7 +100,7 @@ int ImageCardList::OnGetItemImage(long pos) const {
|
||||
return it->second;
|
||||
} else {
|
||||
// request a thumbnail
|
||||
thumbnail_thread.request(new_intrusive2<CardThumbnailRequest>(const_cast<ImageCardList*>(this), val.filename));
|
||||
thumbnail_thread.request(intrusive(new CardThumbnailRequest(const_cast<ImageCardList*>(this), val.filename)));
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
@@ -64,7 +64,7 @@ void TextCtrl::updateSize() {
|
||||
}
|
||||
|
||||
void TextCtrl::setValue(String* value, bool untagged) {
|
||||
setValue(new_intrusive4<FakeTextValue>(getFieldP(), value, true, untagged));
|
||||
setValue(intrusive(new FakeTextValue(getFieldP(), value, true, untagged)));
|
||||
}
|
||||
void TextCtrl::setValue(const FakeTextValueP& value) {
|
||||
value->retrieve();
|
||||
|
||||
@@ -32,7 +32,7 @@ HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set, const Export
|
||||
// init controls
|
||||
list = new PackageList(this, ID_EXPORT_LIST);
|
||||
options = new ExportOptionsEditor(this, wxID_ANY, wxNO_BORDER);
|
||||
options->setSet(new_intrusive1<Set>(set->stylesheet)); // dummy set
|
||||
options->setSet(intrusive(new Set(set->stylesheet))); // dummy set
|
||||
// init sizers
|
||||
wxSizer* s = new wxBoxSizer(wxVERTICAL);
|
||||
s->Add(new wxStaticText(this, wxID_ANY, _LABEL_("html template")), 0, wxALL, 4);
|
||||
|
||||
@@ -91,7 +91,7 @@ void NewSetWindow::OnOK(wxCommandEvent&) {
|
||||
void NewSetWindow::done() {
|
||||
try {
|
||||
StyleSheetP stylesheet = stylesheet_list->getSelection<StyleSheet>();
|
||||
set = new_intrusive1<Set>(stylesheet);
|
||||
set = intrusive(new Set(stylesheet));
|
||||
set->validate();
|
||||
EndModal(wxID_OK);
|
||||
} catch (const Error& e) {
|
||||
|
||||
@@ -227,7 +227,7 @@ void PackageUpdateList::initItems() {
|
||||
ti.setIcon(load_resource_image(_("installer_package")));
|
||||
if (!p->description->icon_url.empty()) {
|
||||
// download icon
|
||||
thumbnail_thread.request(new_intrusive2<PackageIconRequest>(this,&ti));
|
||||
thumbnail_thread.request(intrusive(new PackageIconRequest(this,&ti)));
|
||||
}
|
||||
} else if (ti.position_type == TreeItem::TYPE_LOCALE) { // locale folder
|
||||
ti.setIcon(load_resource_image(_("installer_locales")));
|
||||
|
||||
@@ -214,7 +214,7 @@ PackagesWindow::PackagesWindow(Window* parent, const InstallerP& installer)
|
||||
{
|
||||
init(parent, true);
|
||||
// add installer
|
||||
merge(installable_packages, new_intrusive1<DownloadableInstaller>(installer));
|
||||
merge(installable_packages, intrusive(new DownloadableInstaller(installer)));
|
||||
FOR_EACH(p, installable_packages) p->determineStatus();
|
||||
// mark all packages in the installer for installation
|
||||
FOR_EACH(ip, installable_packages) {
|
||||
@@ -353,7 +353,7 @@ void PackagesWindow::onOk(wxCommandEvent& ev) {
|
||||
os.Write(*is);
|
||||
os.Close();
|
||||
// open installer
|
||||
ip->installer->installer = new_intrusive<Installer>();
|
||||
ip->installer->installer = intrusive(new Installer());
|
||||
ip->installer->installer->open(ip->installer->installer_file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ void TextBufferDC::DoDrawText(const String& str, int x, int y) {
|
||||
if (buffer_text) {
|
||||
double usx,usy;
|
||||
GetUserScale(&usx, &usy);
|
||||
text.push_back( new_intrusive7<TextDraw>(GetFont(), GetTextForeground(), usx, usy, x, y, str) );
|
||||
text.push_back( intrusive(new TextDraw(GetFont(), GetTextForeground(), usx, usy, x, y, str)) );
|
||||
} else {
|
||||
wxMemoryDC::DoDrawText(str,x,y);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ void TextBufferDC::DoDrawRotatedText(const String& str, int x, int y, double ang
|
||||
if (buffer_text) {
|
||||
double usx,usy;
|
||||
GetUserScale(&usx, &usy);
|
||||
text.push_back( new_intrusive8<TextDraw>(GetFont(), GetTextForeground(), usx, usy, x, y, str, angle) );
|
||||
text.push_back( intrusive(new TextDraw(GetFont(), GetTextForeground(), usx, usy, x, y, str, angle)) );
|
||||
} else {
|
||||
wxMemoryDC::DoDrawRotatedText(str,x,y,angle);
|
||||
}
|
||||
@@ -183,7 +183,7 @@ void CardsPrintout::OnPreparePrinting() {
|
||||
int pw_mm, ph_mm;
|
||||
GetPageSizeMM(&pw_mm, &ph_mm);
|
||||
if (!layout) {
|
||||
layout = new_intrusive2<PageLayout>(*set->stylesheet, RealSize(pw_mm, ph_mm));
|
||||
layout = intrusive(new PageLayout(*set->stylesheet, RealSize(pw_mm, ph_mm)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -326,9 +326,9 @@ void KeywordsPanel::onKeywordSelect(KeywordSelectEvent& ev) {
|
||||
if (ev.keyword) {
|
||||
Keyword& kw = *ev.keyword;
|
||||
sp->Show(fixed, kw.fixed);
|
||||
keyword ->setValue(new_intrusive5<KeywordTextValue> (keyword->getFieldP(), &kw, &kw.keyword, !kw.fixed, true));
|
||||
match ->setValue(new_intrusive4<KeywordTextValue> (match->getFieldP(), &kw, &kw.match, !kw.fixed));
|
||||
rules ->setValue(new_intrusive4<KeywordTextValue> (rules->getFieldP(), &kw, &kw.rules, !kw.fixed));
|
||||
keyword ->setValue(intrusive(new KeywordTextValue(keyword->getFieldP(), &kw, &kw.keyword, !kw.fixed, true)));
|
||||
match ->setValue(intrusive(new KeywordTextValue(match->getFieldP(), &kw, &kw.match, !kw.fixed)));
|
||||
rules ->setValue(intrusive(new KeywordTextValue(rules->getFieldP(), &kw, &kw.rules, !kw.fixed)));
|
||||
intrusive_ptr<KeywordReminderTextValue> reminder_value(new KeywordReminderTextValue(*set, reminder->getFieldP(), &kw, !kw.fixed));
|
||||
reminder->setValue(reminder_value);
|
||||
errors->SetLabel(reminder_value->errors);
|
||||
|
||||
@@ -387,14 +387,14 @@ void CustomPackDialog::updateTotals() {
|
||||
}
|
||||
|
||||
void CustomPackDialog::storePack() {
|
||||
edited_pack = new_intrusive<PackType>();
|
||||
edited_pack = intrusive(new PackType());
|
||||
edited_pack->selectable = true;
|
||||
edited_pack->select = SELECT_ALL;
|
||||
edited_pack->name = name->GetValue();
|
||||
FOR_EACH(pick,pickers) {
|
||||
int copies = pick.value->GetValue();
|
||||
if (copies > 0) {
|
||||
edited_pack->items.push_back(new_intrusive2<PackItem>(pick.pack->name, copies));
|
||||
edited_pack->items.push_back(intrusive(new PackItem(pick.pack->name, copies)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -725,10 +725,10 @@ void RandomPackPanel::onCardSelect(CardSelectEvent& ev) {
|
||||
|
||||
void RandomPackPanel::selectionChoices(ExportCardSelectionChoices& out) {
|
||||
if (!isInitialized()) return;
|
||||
out.push_back(new_intrusive2<ExportCardSelectionChoice>(
|
||||
out.push_back(intrusive(new ExportCardSelectionChoice(
|
||||
_BUTTON_("export generated packs"),
|
||||
card_list->getCardsPtr()
|
||||
));
|
||||
)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -470,7 +470,7 @@ void StatsPanel::showCategory(const GraphType* prefer_layout) {
|
||||
// create axes
|
||||
GraphDataPre d;
|
||||
FOR_EACH(dim, dims) {
|
||||
d.axes.push_back(new_intrusive6<GraphAxis>(
|
||||
d.axes.push_back(intrusive(new GraphAxis(
|
||||
dim->name,
|
||||
dim->colors.empty() ? AUTO_COLOR_EVEN : AUTO_COLOR_NO,
|
||||
dim->numeric,
|
||||
@@ -478,7 +478,7 @@ void StatsPanel::showCategory(const GraphType* prefer_layout) {
|
||||
&dim->colors,
|
||||
dim->groups.empty() ? nullptr : &dim->groups
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
// find values for each card
|
||||
for (size_t i = 0 ; i < set->cards.size() ; ++i) {
|
||||
|
||||
@@ -263,7 +263,7 @@ void SetWindow::onChangeSet() {
|
||||
updateTitle();
|
||||
// make sure there is always at least one card
|
||||
// some things need this
|
||||
if (set->cards.empty()) set->cards.push_back(new_intrusive1<Card>(*set->game));
|
||||
if (set->cards.empty()) set->cards.push_back(intrusive(new Card(*set->game)));
|
||||
// all panels view the same set
|
||||
FOR_EACH(p, panels) {
|
||||
p->setSet(set);
|
||||
@@ -337,11 +337,11 @@ void SetWindow::onCardActivate(CardSelectEvent& ev) {
|
||||
}
|
||||
|
||||
void SetWindow::selectionChoices(ExportCardSelectionChoices& out) {
|
||||
out.push_back(new_intrusive1<ExportCardSelectionChoice>(*set)); // entire set
|
||||
out.push_back(intrusive(new ExportCardSelectionChoice(*set))); // entire set
|
||||
FOR_EACH(p, panels) {
|
||||
p->selectionChoices(out);
|
||||
}
|
||||
out.push_back(new_intrusive<ExportCardSelectionChoice>()); // custom
|
||||
out.push_back(intrusive(new ExportCardSelectionChoice())); // custom
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Window events - close
|
||||
|
||||
@@ -186,7 +186,7 @@ void SymbolBasicShapeEditor::makeShape(Vector2D a, Vector2D b, bool constrained,
|
||||
|
||||
// TODO : Move out of this class
|
||||
void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bool constrained) {
|
||||
shape = new_intrusive<SymbolShape>();
|
||||
shape = intrusive(new SymbolShape);
|
||||
// What shape to make?
|
||||
switch (mode) {
|
||||
case ID_SHAPE_CIRCLE: {
|
||||
@@ -199,10 +199,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
|
||||
// a circle has 4 control points, the first is: (x+r, y) db(0, kr) da(0, -kr)
|
||||
// kr is a magic constant
|
||||
const double kr = 0.5522847498f; // = 4/3 * (sqrt(2) - 1)
|
||||
shape->points.push_back(new_intrusive7<ControlPoint>(c.x + r.x, c.y, 0, kr * r.y, 0, -kr * r.y, LOCK_SIZE));
|
||||
shape->points.push_back(new_intrusive7<ControlPoint>(c.x, c.y - r.y, kr * r.x, 0, -kr * r.x, 0, LOCK_SIZE));
|
||||
shape->points.push_back(new_intrusive7<ControlPoint>(c.x - r.x, c.y, 0, -kr * r.y, 0, kr * r.y, LOCK_SIZE));
|
||||
shape->points.push_back(new_intrusive7<ControlPoint>(c.x, c.y + r.y, -kr * r.x, 0, kr * r.x, 0, LOCK_SIZE));
|
||||
shape->points.push_back(intrusive(new ControlPoint(c.x + r.x, c.y, 0, kr * r.y, 0, -kr * r.y, LOCK_SIZE)));
|
||||
shape->points.push_back(intrusive(new ControlPoint(c.x, c.y - r.y, kr * r.x, 0, -kr * r.x, 0, LOCK_SIZE)));
|
||||
shape->points.push_back(intrusive(new ControlPoint(c.x - r.x, c.y, 0, -kr * r.y, 0, kr * r.y, LOCK_SIZE)));
|
||||
shape->points.push_back(intrusive(new ControlPoint(c.x, c.y + r.y, -kr * r.x, 0, kr * r.x, 0, LOCK_SIZE)));
|
||||
break;
|
||||
} case ID_SHAPE_RECTANGLE: {
|
||||
// A rectangle / square
|
||||
@@ -212,10 +212,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
|
||||
shape->name = capitalize(_TYPE_("rectangle"));
|
||||
}
|
||||
// a rectangle just has four corners
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(c.x - r.x, c.y - r.y));
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(c.x + r.x, c.y - r.y));
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(c.x + r.x, c.y + r.y));
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(c.x - r.x, c.y + r.y));
|
||||
shape->points.push_back(intrusive(new ControlPoint(c.x - r.x, c.y - r.y)));
|
||||
shape->points.push_back(intrusive(new ControlPoint(c.x + r.x, c.y - r.y)));
|
||||
shape->points.push_back(intrusive(new ControlPoint(c.x + r.x, c.y + r.y)));
|
||||
shape->points.push_back(intrusive(new ControlPoint(c.x - r.x, c.y + r.y)));
|
||||
break;
|
||||
} default: {
|
||||
// A polygon or star
|
||||
@@ -258,10 +258,10 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
|
||||
// we can generate points
|
||||
for(int i = 0 ; i < n ; ++i) {
|
||||
double theta = alpha * i;
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(
|
||||
shape->points.push_back(intrusive(new ControlPoint(
|
||||
c.x + ra * r.x * sin(theta),
|
||||
y - ra * r.y * cos(theta)
|
||||
));
|
||||
)));
|
||||
}
|
||||
} else {
|
||||
// a star is made using a smaller, inverted polygon at the inside
|
||||
@@ -280,16 +280,16 @@ void SymbolBasicShapeEditor::makeCenteredShape(const Vector2D& c, Vector2D r, bo
|
||||
for(int i = 0 ; i < n ; ++i) {
|
||||
double theta = alpha * i;
|
||||
// from a
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(
|
||||
shape->points.push_back(intrusive(new ControlPoint(
|
||||
c.x + ra * r.x * sin(theta),
|
||||
y - ra * r.y * cos(theta)
|
||||
));
|
||||
)));
|
||||
// from b
|
||||
theta = alpha * (i + 0.5);
|
||||
shape->points.push_back(new_intrusive2<ControlPoint>(
|
||||
shape->points.push_back(intrusive(new ControlPoint(
|
||||
c.x + rb * r.x * sin(theta),
|
||||
y - rb * r.y * cos(theta)
|
||||
));
|
||||
)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
+10
-10
@@ -39,23 +39,23 @@ void SymbolControl::switchEditor(const SymbolEditorBaseP& e) {
|
||||
|
||||
void SymbolControl::onChangeSymbol() {
|
||||
selected_parts.setSymbol(symbol);
|
||||
switchEditor(new_intrusive2<SymbolSelectEditor>(this, false));
|
||||
switchEditor(intrusive(new SymbolSelectEditor(this, false)));
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
void SymbolControl::onModeChange(wxCommandEvent& ev) {
|
||||
switch (ev.GetId()) {
|
||||
case ID_MODE_SELECT:
|
||||
switchEditor(new_intrusive2<SymbolSelectEditor>(this, false));
|
||||
switchEditor(intrusive(new SymbolSelectEditor(this, false)));
|
||||
break;
|
||||
case ID_MODE_ROTATE:
|
||||
switchEditor(new_intrusive2<SymbolSelectEditor>(this, true));
|
||||
switchEditor(intrusive(new SymbolSelectEditor(this, true)));
|
||||
break;
|
||||
case ID_MODE_POINTS:
|
||||
if (selected_parts.size() == 1) {
|
||||
selected_shape = selected_parts.getAShape();
|
||||
if (selected_shape) {
|
||||
switchEditor(new_intrusive2<SymbolPointEditor>(this, selected_shape));
|
||||
switchEditor(intrusive(new SymbolPointEditor(this, selected_shape)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -64,10 +64,10 @@ void SymbolControl::onModeChange(wxCommandEvent& ev) {
|
||||
selected_parts.clear();
|
||||
signalSelectionChange();
|
||||
}
|
||||
switchEditor(new_intrusive1<SymbolBasicShapeEditor>(this));
|
||||
switchEditor(intrusive(new SymbolBasicShapeEditor(this)));
|
||||
break;
|
||||
case ID_MODE_SYMMETRY:
|
||||
switchEditor(new_intrusive2<SymbolSymmetryEditor>(this, selected_parts.getASymmetry()));
|
||||
switchEditor(intrusive(new SymbolSymmetryEditor(this, selected_parts.getASymmetry())));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ void SymbolControl::onUpdateSelection() {
|
||||
}
|
||||
// begin editing another part
|
||||
selected_shape = shape;
|
||||
editor = new_intrusive2<SymbolPointEditor>(this, selected_shape);
|
||||
editor = intrusive(new SymbolPointEditor(this, selected_shape));
|
||||
Refresh(false);
|
||||
}
|
||||
break;
|
||||
@@ -147,17 +147,17 @@ void SymbolControl::onUpdateSelection() {
|
||||
|
||||
void SymbolControl::selectPart(const SymbolPartP& part) {
|
||||
selected_parts.select(part);
|
||||
switchEditor(new_intrusive2<SymbolSelectEditor>(this, false));
|
||||
switchEditor(intrusive(new SymbolSelectEditor(this, false)));
|
||||
signalSelectionChange();
|
||||
}
|
||||
|
||||
void SymbolControl::activatePart(const SymbolPartP& part) {
|
||||
if (part->isSymbolShape()) {
|
||||
selected_parts.select(part);
|
||||
switchEditor(new_intrusive2<SymbolPointEditor>(this, static_pointer_cast<SymbolShape>(part)));
|
||||
switchEditor(intrusive(new SymbolPointEditor(this, static_pointer_cast<SymbolShape>(part))));
|
||||
} else if (part->isSymbolSymmetry()) {
|
||||
selected_parts.select(part);
|
||||
switchEditor(new_intrusive2<SymbolSymmetryEditor>(this, static_pointer_cast<SymbolSymmetry>(part)));
|
||||
switchEditor(intrusive(new SymbolSymmetryEditor(this, static_pointer_cast<SymbolSymmetry>(part))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ void SymbolSelectEditor::onCommand(int id) {
|
||||
control.Refresh(false);
|
||||
} else if (id == ID_EDIT_GROUP && !isEditing()) {
|
||||
// group selection, not when dragging
|
||||
addAction(new GroupSymbolPartsAction(*getSymbol(), control.selected_parts.get(), new_intrusive<SymbolGroup>()));
|
||||
addAction(new GroupSymbolPartsAction(*getSymbol(), control.selected_parts.get(), intrusive(new SymbolGroup())));
|
||||
control.Refresh(false);
|
||||
} else if (id == ID_EDIT_UNGROUP && !isEditing()) {
|
||||
// ungroup selection, not when dragging
|
||||
|
||||
@@ -118,7 +118,7 @@ void SymbolSymmetryEditor::onCommand(int id) {
|
||||
}
|
||||
resetActions();
|
||||
} else if (id == ID_ADD_SYMMETRY) {
|
||||
symmetry = new_intrusive<SymbolSymmetry>();
|
||||
symmetry = intrusive(new SymbolSymmetry());
|
||||
symmetry->kind = SYMMETRY_ROTATION;
|
||||
symmetry->copies = 2;
|
||||
symmetry->center = Vector2D(0.5,0.5);
|
||||
|
||||
@@ -35,7 +35,7 @@ SymbolWindow::SymbolWindow(Window* parent, const String& filename)
|
||||
: performer(nullptr)
|
||||
{
|
||||
// open file
|
||||
Reader reader(new_shared1<wxFileInputStream>(filename), nullptr, filename);
|
||||
Reader reader(shared(new wxFileInputStream(filename)), nullptr, filename);
|
||||
SymbolP symbol;
|
||||
reader.handle_greedy(symbol);
|
||||
init(parent, symbol);
|
||||
@@ -216,7 +216,7 @@ void SymbolWindow::onFileOpen(wxCommandEvent& ev) {
|
||||
String ext = n.GetExt();
|
||||
SymbolP symbol;
|
||||
if (ext.Lower() == _("mse-symbol")) {
|
||||
Reader reader(new_shared1<wxFileInputStream>(name), nullptr, name);
|
||||
Reader reader(shared(new wxFileInputStream(name)), nullptr, name);
|
||||
reader.handle_greedy(symbol);
|
||||
} else {
|
||||
wxBusyCursor busy;
|
||||
@@ -239,7 +239,7 @@ void SymbolWindow::onFileSaveAs(wxCommandEvent& ev) {
|
||||
String name = wxFileSelector(_("Save symbol"),settings.default_set_dir,_(""),_(""),_("Symbol files (*.mse-symbol)|*.mse-symbol"),wxSAVE, this);
|
||||
if (!name.empty()) {
|
||||
settings.default_set_dir = wxPathOnly(name);
|
||||
Writer writer(new_shared1<wxFileOutputStream>(name), file_version_symbol);
|
||||
Writer writer(shared(new wxFileOutputStream(name)), file_version_symbol);
|
||||
writer.handle(control->getSymbol());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,9 +203,9 @@ void DropDownChoiceListBase::generateThumbnailImages() {
|
||||
status = THUMB_OK; // no need to rebuild
|
||||
} else if (img.isReady()) {
|
||||
// request this thumbnail
|
||||
thumbnail_thread.request( new_intrusive4<ChoiceThumbnailRequest>(
|
||||
thumbnail_thread.request( intrusive(new ChoiceThumbnailRequest(
|
||||
&cve, i, status == THUMB_NOT_MADE && !img.local(), img.threadSafe()
|
||||
));
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,5 +116,5 @@ void PackageChoiceValueEditor::change(const String& c) {
|
||||
|
||||
void PackageChoiceValueEditor::initDropDown() {
|
||||
if (drop_down) return;
|
||||
drop_down = new_shared2<DropDownPackageChoiceList>(&editor(), this);
|
||||
drop_down = shared(new DropDownPackageChoiceList(&editor(), this));
|
||||
}
|
||||
|
||||
@@ -1361,7 +1361,7 @@ void TextValueEditor::findWordLists() {
|
||||
throw Error(_ERROR_1_("word list type not found", name));
|
||||
}
|
||||
// add to word_lists
|
||||
word_lists.push_back(new_intrusive3<WordListPos>(pos, end, word_list));
|
||||
word_lists.push_back(intrusive(new WordListPos(pos, end, word_list)));
|
||||
// next
|
||||
pos = str.find(_("<word-list-"), end);
|
||||
}
|
||||
|
||||
@@ -2415,6 +2415,22 @@
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="vcs"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\util\vcs\subversion.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\util\vcs\subversion.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\util\vcs.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\util\vcs.hpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="gfx"
|
||||
|
||||
@@ -71,9 +71,9 @@ intrusive_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader) {
|
||||
// there must be a fill type specified
|
||||
String fill_type;
|
||||
reader.handle(_("fill type"), fill_type);
|
||||
if (fill_type == _("solid")) return new_intrusive<SolidFillSymbolFilter>();
|
||||
else if (fill_type == _("linear gradient")) return new_intrusive<LinearGradientSymbolFilter>();
|
||||
else if (fill_type == _("radial gradient")) return new_intrusive<RadialGradientSymbolFilter>();
|
||||
if (fill_type == _("solid")) return intrusive(new SolidFillSymbolFilter);
|
||||
else if (fill_type == _("linear gradient")) return intrusive(new LinearGradientSymbolFilter);
|
||||
else if (fill_type == _("radial gradient")) return intrusive(new RadialGradientSymbolFilter);
|
||||
else if (fill_type.empty()) {
|
||||
reader.warning(_ERROR_1_("expected key", _("fill type")));
|
||||
throw ParseError(_ERROR_("aborting parsing"));
|
||||
|
||||
@@ -198,7 +198,7 @@ struct TextElementsFromString {
|
||||
assert(content.size() == end-start);
|
||||
// use symbol font?
|
||||
if (symbol > 0 && style.symbol_font.valid()) {
|
||||
te.elements.push_back(new_intrusive5<SymbolTextElement>(content, start, end, style.symbol_font, &ctx));
|
||||
te.elements.push_back(intrusive(new SymbolTextElement(content, start, end, style.symbol_font, &ctx)));
|
||||
} else {
|
||||
// text, possibly mixed with symbols
|
||||
DrawWhat what = soft > 0 ? DRAW_ACTIVE : DRAW_NORMAL;
|
||||
@@ -221,9 +221,9 @@ struct TextElementsFromString {
|
||||
if (text_pos < pos) {
|
||||
// text before it?
|
||||
if (!font) font = makeFont(style);
|
||||
te.elements.push_back(new_intrusive6<FontTextElement>(content.substr(text_pos, pos-text_pos), start+text_pos, start+pos, font, what, line_break));
|
||||
te.elements.push_back(intrusive(new FontTextElement(content.substr(text_pos, pos-text_pos), start+text_pos, start+pos, font, what, line_break)));
|
||||
}
|
||||
te.elements.push_back(new_intrusive5<SymbolTextElement>(content.substr(pos,n), start+pos, start+pos+n, style.symbol_font, &ctx));
|
||||
te.elements.push_back(intrusive(new SymbolTextElement(content.substr(pos,n), start+pos, start+pos+n, style.symbol_font, &ctx)));
|
||||
text_pos = pos += n;
|
||||
} else {
|
||||
++pos;
|
||||
@@ -231,10 +231,10 @@ struct TextElementsFromString {
|
||||
}
|
||||
if (text_pos < pos) {
|
||||
if (!font) font = makeFont(style);
|
||||
te.elements.push_back(new_intrusive6<FontTextElement>(content.substr(text_pos), start+text_pos, end, font, what, line_break));
|
||||
te.elements.push_back(intrusive(new FontTextElement(content.substr(text_pos), start+text_pos, end, font, what, line_break)));
|
||||
}
|
||||
} else {
|
||||
te.elements.push_back(new_intrusive6<FontTextElement>(content, start, end, makeFont(style), what, line_break));
|
||||
te.elements.push_back(intrusive(new FontTextElement(content, start, end, makeFont(style), what, line_break)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,9 +449,9 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP&
|
||||
} else if (bt == SCRIPT_NIL) {
|
||||
// a = a;
|
||||
} else if (at == SCRIPT_FUNCTION && bt == SCRIPT_FUNCTION) {
|
||||
a = new_intrusive2<ScriptCompose>(a, b);
|
||||
a = intrusive(new ScriptCompose(a, b));
|
||||
} else if (at == SCRIPT_COLLECTION && bt == SCRIPT_COLLECTION) {
|
||||
a = new_intrusive2<ScriptConcatCollection>(a, b);
|
||||
a = intrusive(new ScriptConcatCollection(a, b));
|
||||
} else if (at == SCRIPT_INT && bt == SCRIPT_INT) {
|
||||
a = to_script((int)*a + (int)*b);
|
||||
} else if ((at == SCRIPT_INT || at == SCRIPT_DOUBLE) &&
|
||||
|
||||
@@ -68,13 +68,13 @@ class DependencyUnion : public ScriptValue {
|
||||
// Unify two values from different execution paths
|
||||
void unify(ScriptValueP& a, const ScriptValueP& b) {
|
||||
assert(a && b);
|
||||
if (a != b) a = new_intrusive2<DependencyUnion>(a,b);
|
||||
if (a != b) a = intrusive(new DependencyUnion(a,b));
|
||||
}
|
||||
// Unify two values from different execution paths
|
||||
ScriptValueP unified(const ScriptValueP& a, const ScriptValueP& b) {
|
||||
assert(a && b);
|
||||
if (a == b) return a;
|
||||
else return new_intrusive2<DependencyUnion>(a,b);
|
||||
else return intrusive(new DependencyUnion(a,b));
|
||||
}
|
||||
|
||||
/// Behaves like script_nil, but with a name
|
||||
@@ -286,7 +286,7 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script)
|
||||
case I_GET_VAR: {
|
||||
ScriptValueP value = variables[i.data].value;
|
||||
if (!value) {
|
||||
value = new_intrusive1<ScriptMissingVariable>(variable_to_string((Variable)i.data)); // no errors here
|
||||
value = intrusive(new ScriptMissingVariable(variable_to_string((Variable)i.data))); // no errors here
|
||||
}
|
||||
value->dependencyThis(dep);
|
||||
stack.push_back(value);
|
||||
|
||||
@@ -91,7 +91,7 @@ SCRIPT_FUNCTION(to_string) {
|
||||
SCRIPT_RETURN(input->toString());
|
||||
}
|
||||
} catch (const ScriptError& e) {
|
||||
return new_intrusive1<ScriptDelayedError>(e);
|
||||
return intrusive(new ScriptDelayedError(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -649,7 +649,7 @@ SCRIPT_FUNCTION(keyword_usage) {
|
||||
/// Turn a script function into a rule, a.k.a. a delayed closure
|
||||
SCRIPT_FUNCTION(rule) {
|
||||
SCRIPT_PARAM(ScriptValueP, input);
|
||||
return new_intrusive1<ScriptRule>(input);
|
||||
return intrusive(new ScriptRule(input));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Init
|
||||
@@ -680,17 +680,17 @@ void init_script_basic_functions(Context& ctx) {
|
||||
ctx.setVariable(_("substring"), script_substring);
|
||||
ctx.setVariable(_("contains"), script_contains);
|
||||
ctx.setVariable(_("format"), script_format);
|
||||
ctx.setVariable(_("format rule"), new_intrusive1<ScriptRule>(script_format));
|
||||
ctx.setVariable(_("format rule"), intrusive(new ScriptRule(script_format)));
|
||||
ctx.setVariable(_("curly quotes"), script_curly_quotes);
|
||||
ctx.setVariable(_("regex escape"), script_regex_escape);
|
||||
ctx.setVariable(_("sort text"), script_sort_text);
|
||||
ctx.setVariable(_("sort rule"), new_intrusive1<ScriptRule>(script_sort_text));
|
||||
ctx.setVariable(_("sort rule"), intrusive(new ScriptRule(script_sort_text)));
|
||||
// tagged string
|
||||
ctx.setVariable(_("tag contents"), script_tag_contents);
|
||||
ctx.setVariable(_("remove tag"), script_remove_tag);
|
||||
ctx.setVariable(_("remove tags"), script_remove_tags);
|
||||
ctx.setVariable(_("tag contents rule"), new_intrusive1<ScriptRule>(script_tag_contents));
|
||||
ctx.setVariable(_("tag remove rule"), new_intrusive1<ScriptRule>(script_remove_tag));
|
||||
ctx.setVariable(_("tag contents rule"), intrusive(new ScriptRule(script_tag_contents)));
|
||||
ctx.setVariable(_("tag remove rule"), intrusive(new ScriptRule(script_remove_tag)));
|
||||
// collection
|
||||
ctx.setVariable(_("position"), script_position_of);
|
||||
ctx.setVariable(_("length"), script_length);
|
||||
@@ -702,6 +702,6 @@ void init_script_basic_functions(Context& ctx) {
|
||||
ctx.setVariable(_("random select many"), script_random_select_many);
|
||||
// keyword
|
||||
ctx.setVariable(_("expand keywords"), script_expand_keywords);
|
||||
ctx.setVariable(_("expand keywords rule"), new_intrusive1<ScriptRule>(script_expand_keywords));
|
||||
ctx.setVariable(_("expand keywords rule"), intrusive(new ScriptRule(script_expand_keywords)));
|
||||
ctx.setVariable(_("keyword usage"), script_keyword_usage);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
SCRIPT_FUNCTION(new_card) {
|
||||
SCRIPT_PARAM(GameP, game);
|
||||
CardP new_card = new_intrusive1<Card>(*game);
|
||||
CardP new_card = intrusive(new Card(*game));
|
||||
// set field values
|
||||
SCRIPT_PARAM(ScriptValueP, input);
|
||||
ScriptValueP it = input->makeIterator(input);
|
||||
|
||||
@@ -41,14 +41,14 @@ SCRIPT_FUNCTION(linear_blend) {
|
||||
SCRIPT_PARAM(GeneratedImageP, image2);
|
||||
SCRIPT_PARAM(double, x1); SCRIPT_PARAM(double, y1);
|
||||
SCRIPT_PARAM(double, x2); SCRIPT_PARAM(double, y2);
|
||||
return new_intrusive6<LinearBlendImage>(image1, image2, x1,y1, x2,y2);
|
||||
return intrusive(new LinearBlendImage(image1, image2, x1,y1, x2,y2));
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(masked_blend) {
|
||||
SCRIPT_PARAM(GeneratedImageP, light);
|
||||
SCRIPT_PARAM(GeneratedImageP, dark);
|
||||
SCRIPT_PARAM(GeneratedImageP, mask);
|
||||
return new_intrusive3<MaskedBlendImage>(light, dark, mask);
|
||||
return intrusive(new MaskedBlendImage(light, dark, mask));
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(combine_blend) {
|
||||
@@ -57,19 +57,19 @@ SCRIPT_FUNCTION(combine_blend) {
|
||||
SCRIPT_PARAM(GeneratedImageP, image2);
|
||||
ImageCombine image_combine;
|
||||
parse_enum(combine, image_combine);
|
||||
return new_intrusive3<CombineBlendImage>(image1, image2, image_combine);
|
||||
return intrusive(new CombineBlendImage(image1, image2, image_combine));
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(set_mask) {
|
||||
SCRIPT_PARAM(GeneratedImageP, image);
|
||||
SCRIPT_PARAM(GeneratedImageP, mask);
|
||||
return new_intrusive2<SetMaskImage>(image, mask);
|
||||
return intrusive(new SetMaskImage(image, mask));
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(set_alpha) {
|
||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||
SCRIPT_PARAM(double, alpha);
|
||||
return new_intrusive2<SetAlphaImage>(input, alpha);
|
||||
return intrusive(new SetAlphaImage(input, alpha));
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(set_combine) {
|
||||
@@ -77,19 +77,19 @@ SCRIPT_FUNCTION(set_combine) {
|
||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||
ImageCombine image_combine;
|
||||
parse_enum(combine, image_combine);
|
||||
return new_intrusive2<SetCombineImage>(input, image_combine);
|
||||
return intrusive(new SetCombineImage(input, image_combine));
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(saturate) {
|
||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||
SCRIPT_PARAM(double, amount);
|
||||
return new_intrusive2<SaturateImage>(input, amount);
|
||||
return intrusive(new SaturateImage(input, amount));
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(enlarge) {
|
||||
SCRIPT_PARAM_C(GeneratedImageP, input);
|
||||
SCRIPT_PARAM_N(double, _("border size"), border_size);
|
||||
return new_intrusive2<EnlargeImage>(input, border_size);
|
||||
return intrusive(new EnlargeImage(input, border_size));
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(crop) {
|
||||
@@ -98,7 +98,7 @@ SCRIPT_FUNCTION(crop) {
|
||||
SCRIPT_PARAM_N(int, _("height"), height);
|
||||
SCRIPT_PARAM_N(double, _("offset x"), offset_x);
|
||||
SCRIPT_PARAM_N(double, _("offset y"), offset_y);
|
||||
return new_intrusive5<CropImage>(input, width, height, offset_x, offset_y);
|
||||
return intrusive(new CropImage(input, width, height, offset_x, offset_y));
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(drop_shadow) {
|
||||
@@ -108,7 +108,7 @@ SCRIPT_FUNCTION(drop_shadow) {
|
||||
SCRIPT_OPTIONAL_PARAM_N_(double, _("alpha"), alpha);
|
||||
SCRIPT_OPTIONAL_PARAM_N_(double, _("blur radius"), blur_radius);
|
||||
SCRIPT_OPTIONAL_PARAM_N_(Color, _("color"), color);
|
||||
return new_intrusive6<DropShadowImage>(input, offset_x, offset_y, alpha, blur_radius, color);
|
||||
return intrusive(new DropShadowImage(input, offset_x, offset_y, alpha, blur_radius, color));
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(symbol_variation) {
|
||||
@@ -136,7 +136,7 @@ SCRIPT_FUNCTION(symbol_variation) {
|
||||
FOR_EACH(v, style->variations) {
|
||||
if (v->name == variation) {
|
||||
// found it
|
||||
return new_intrusive4<SymbolToImage>(value, filename, value->last_update, v);
|
||||
return intrusive(new SymbolToImage(value, filename, value->last_update, v));
|
||||
}
|
||||
}
|
||||
throw ScriptError(_("Variation of symbol not found ('") + variation + _("')"));
|
||||
@@ -149,7 +149,7 @@ SCRIPT_FUNCTION(symbol_variation) {
|
||||
if (fill_type == _("solid") || fill_type.empty()) {
|
||||
SCRIPT_PARAM_N(Color, _("fill color"), fill_color);
|
||||
SCRIPT_PARAM_N(Color, _("border color"), border_color);
|
||||
var->filter = new_intrusive2<SolidFillSymbolFilter>(fill_color, border_color);
|
||||
var->filter = intrusive(new SolidFillSymbolFilter(fill_color, border_color));
|
||||
} else if (fill_type == _("linear gradient")) {
|
||||
SCRIPT_PARAM_N(Color, _("fill color 1"), fill_color_1);
|
||||
SCRIPT_PARAM_N(Color, _("border color 1"), border_color_1);
|
||||
@@ -159,24 +159,24 @@ SCRIPT_FUNCTION(symbol_variation) {
|
||||
SCRIPT_PARAM_N(double, _("center y"), center_y);
|
||||
SCRIPT_PARAM_N(double, _("end x"), end_x);
|
||||
SCRIPT_PARAM_N(double, _("end y"), end_y);
|
||||
var->filter = new_intrusive8<LinearGradientSymbolFilter>(fill_color_1, border_color_1, fill_color_2, border_color_2
|
||||
,center_x, center_y, end_x, end_y);
|
||||
var->filter = intrusive(new LinearGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2
|
||||
,center_x, center_y, end_x, end_y));
|
||||
} else if (fill_type == _("radial gradient")) {
|
||||
SCRIPT_PARAM_N(Color, _("fill color 1"), fill_color_1);
|
||||
SCRIPT_PARAM_N(Color, _("border color 1"), border_color_1);
|
||||
SCRIPT_PARAM_N(Color, _("fill color 2"), fill_color_2);
|
||||
SCRIPT_PARAM_N(Color, _("border color 2"), border_color_2);
|
||||
var->filter = new_intrusive4<RadialGradientSymbolFilter>(fill_color_1, border_color_1, fill_color_2, border_color_2);
|
||||
var->filter = intrusive(new RadialGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2));
|
||||
} else {
|
||||
throw ScriptError(_("Unknown fill type for symbol_variation: ") + fill_type);
|
||||
}
|
||||
return new_intrusive4<SymbolToImage>(value, filename, value ? value->last_update : Age(0), var);
|
||||
return intrusive(new SymbolToImage(value, filename, value ? value->last_update : Age(0), var));
|
||||
}
|
||||
}
|
||||
|
||||
SCRIPT_FUNCTION(built_in_image) {
|
||||
SCRIPT_PARAM_C(String, input);
|
||||
return new_intrusive1<BuiltInImage>(input);
|
||||
return intrusive(new BuiltInImage(input));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Init
|
||||
|
||||
@@ -53,7 +53,7 @@ ScriptRegexP regex_from_script(const ScriptValueP& value) {
|
||||
ScriptRegexP regex = dynamic_pointer_cast<ScriptRegex>(value);
|
||||
if (!regex) {
|
||||
// TODO: introduce some kind of caching?
|
||||
regex = new_intrusive1<ScriptRegex>(*value);
|
||||
regex = intrusive(new ScriptRegex(*value));
|
||||
}
|
||||
return regex;
|
||||
}
|
||||
@@ -250,8 +250,8 @@ void init_script_regex_functions(Context& ctx) {
|
||||
ctx.setVariable(_("break text"), script_break_text);
|
||||
ctx.setVariable(_("split text"), script_split_text);
|
||||
ctx.setVariable(_("match"), script_match);
|
||||
ctx.setVariable(_("replace rule"), new_intrusive1<ScriptRule>(script_replace));
|
||||
ctx.setVariable(_("filter rule"), new_intrusive1<ScriptRule>(script_filter_text));
|
||||
ctx.setVariable(_("break rule"), new_intrusive1<ScriptRule>(script_break_text));
|
||||
ctx.setVariable(_("match rule"), new_intrusive1<ScriptRule>(script_match));
|
||||
ctx.setVariable(_("replace rule"), intrusive(new ScriptRule(script_replace)));
|
||||
ctx.setVariable(_("filter rule"), intrusive(new ScriptRule(script_filter_text)));
|
||||
ctx.setVariable(_("break rule"), intrusive(new ScriptRule(script_break_text)));
|
||||
ctx.setVariable(_("match rule"), intrusive(new ScriptRule(script_match)));
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ inline Type from_script(const ScriptValueP& v, Variable var) {
|
||||
}; \
|
||||
SCRIPT_FUNCTION(funname##_rule) { \
|
||||
SCRIPT_PARAM_N(type1, str1, name1); \
|
||||
return new_intrusive1<ScriptRule_##funname>(name1); \
|
||||
return intrusive(new ScriptRule_##funname(name1)); \
|
||||
} \
|
||||
SCRIPT_FUNCTION(funname) { \
|
||||
SCRIPT_PARAM_N(type1, str1, name1); \
|
||||
@@ -210,7 +210,7 @@ inline Type from_script(const ScriptValueP& v, Variable var) {
|
||||
SCRIPT_FUNCTION(funname##_rule) { \
|
||||
SCRIPT_PARAM_N(type1, str1, name1); \
|
||||
SCRIPT_PARAM_N(type2, str2, name2); \
|
||||
return new_intrusive2<ScriptRule_##funname>(name1, name2); \
|
||||
return intrusive(new ScriptRule_##funname(name1, name2)); \
|
||||
} \
|
||||
SCRIPT_FUNCTION_AUX(funname, dep) { \
|
||||
SCRIPT_PARAM_N(type1, str1, name1); \
|
||||
|
||||
@@ -80,7 +80,7 @@ template <> void Reader::handle(ScriptableImage& s) {
|
||||
s.script.parse(*this, true);
|
||||
} else {
|
||||
// a filename
|
||||
s.value = new_intrusive1<PackagedImage>(s.script.unparsed);
|
||||
s.value = intrusive(new PackagedImage(s.script.unparsed));
|
||||
}
|
||||
}
|
||||
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
|
||||
FunctionProfileP& fpp = parent.children[idx];
|
||||
if (!fpp) {
|
||||
fpp = new_intrusive1<FunctionProfile>(p.name);
|
||||
fpp = intrusive(new FunctionProfile(p.name));
|
||||
}
|
||||
fpp->time_ticks += p.time_ticks;
|
||||
fpp->calls += p.calls;
|
||||
@@ -97,7 +97,7 @@ Profiler::Profiler(Timer& timer, Variable function_name)
|
||||
if ((int)function_name >= 0) {
|
||||
FunctionProfileP& fpp = parent->children[(size_t)function_name << 1 | 1];
|
||||
if (!fpp) {
|
||||
fpp = new_intrusive1<FunctionProfile>(variable_to_string(function_name));
|
||||
fpp = intrusive(new FunctionProfile(variable_to_string(function_name)));
|
||||
}
|
||||
function = fpp.get();
|
||||
}
|
||||
@@ -111,7 +111,7 @@ Profiler::Profiler(Timer& timer, const Char* function_name)
|
||||
{
|
||||
FunctionProfileP& fpp = parent->children[(size_t)function_name];
|
||||
if (!fpp) {
|
||||
fpp = new_intrusive1<FunctionProfile>(function_name);
|
||||
fpp = intrusive(new FunctionProfile(function_name));
|
||||
}
|
||||
function = fpp.get();
|
||||
timer.exclude_time();
|
||||
@@ -124,7 +124,7 @@ Profiler::Profiler(Timer& timer, void* function_object, const String& function_n
|
||||
{
|
||||
FunctionProfileP& fpp = parent->children[(size_t)function_object];
|
||||
if (!fpp) {
|
||||
fpp = new_intrusive1<FunctionProfile>(function_name);
|
||||
fpp = intrusive(new FunctionProfile(function_name));
|
||||
}
|
||||
function = fpp.get();
|
||||
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
|
||||
// which would lead to a reference cycle.
|
||||
init_script_functions(*ctx);
|
||||
ctx->setVariable(SCRIPT_VAR_set, new_intrusive1<ScriptObject<Set*> >(&set));
|
||||
ctx->setVariable(SCRIPT_VAR_set, intrusive(new ScriptObject<Set*>(&set)));
|
||||
ctx->setVariable(SCRIPT_VAR_game, to_script(set.game));
|
||||
ctx->setVariable(SCRIPT_VAR_stylesheet, to_script(stylesheet));
|
||||
ctx->setVariable(SCRIPT_VAR_card_style, to_script(&stylesheet->card_style));
|
||||
|
||||
@@ -78,7 +78,7 @@ void OptionalScript::initDependencies(Context& ctx, const Dependency& dep) const
|
||||
}
|
||||
|
||||
Script& OptionalScript::getMutableScript() {
|
||||
if (!script) script = new_intrusive<Script>();
|
||||
if (!script) script = intrusive(new Script());
|
||||
return *script;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,10 +95,10 @@ class ScriptDelayedError : public ScriptValue {
|
||||
};
|
||||
|
||||
inline ScriptValueP delay_error(const String& m) {
|
||||
return new_intrusive1<ScriptDelayedError>(ScriptError(m));
|
||||
return intrusive(new ScriptDelayedError(ScriptError(m)));
|
||||
}
|
||||
inline ScriptValueP delay_error(const ScriptError& error) {
|
||||
return new_intrusive1<ScriptDelayedError>(error);
|
||||
return intrusive(new ScriptDelayedError(error));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Iterators
|
||||
@@ -160,7 +160,7 @@ class ScriptCollection : public ScriptCollectionBase {
|
||||
}
|
||||
}
|
||||
virtual ScriptValueP makeIterator(const ScriptValueP& thisP) const {
|
||||
return new_intrusive1<ScriptCollectionIterator<Collection> >(value);
|
||||
return intrusive(new ScriptCollectionIterator<Collection>(value));
|
||||
}
|
||||
virtual int itemCount() const { return (int)value->size(); }
|
||||
/// Collections can be compared by comparing pointers
|
||||
@@ -401,13 +401,13 @@ inline ScriptValueP to_script(long v) { return to_script((int) v); }
|
||||
ScriptValueP to_script(wxDateTime v);
|
||||
inline ScriptValueP to_script(bool v) { return v ? script_true : script_false; }
|
||||
template <typename T>
|
||||
inline ScriptValueP to_script(const vector<T>* v) { return new_intrusive1<ScriptCollection<vector<T> > >(v); }
|
||||
inline ScriptValueP to_script(const vector<T>* v) { return intrusive(new ScriptCollection<vector<T> >(v)); }
|
||||
template <typename K, typename V>
|
||||
inline ScriptValueP to_script(const map<K,V>* v) { return new_intrusive1<ScriptMap<map<K,V> > >(v); }
|
||||
inline ScriptValueP to_script(const map<K,V>* v) { return intrusive(new ScriptMap<map<K,V> >(v)); }
|
||||
template <typename K, typename V>
|
||||
inline ScriptValueP to_script(const IndexMap<K,V>* v) { return new_intrusive1<ScriptMap<IndexMap<K,V> > >(v); }
|
||||
inline ScriptValueP to_script(const IndexMap<K,V>* v) { return intrusive(new ScriptMap<IndexMap<K,V> >(v)); }
|
||||
template <typename T>
|
||||
inline ScriptValueP to_script(const intrusive_ptr<T>& v) { return new_intrusive1<ScriptObject<intrusive_ptr<T> > >(v); }
|
||||
inline ScriptValueP to_script(const intrusive_ptr<T>& v) { return intrusive(new ScriptObject<intrusive_ptr<T> >(v)); }
|
||||
template <typename T>
|
||||
inline ScriptValueP to_script(const Defaultable<T>& v) { return to_script(v()); }
|
||||
|
||||
|
||||
+17
-17
@@ -111,10 +111,10 @@ ScriptDelayedError::operator bool() const { throw error; }
|
||||
ScriptDelayedError::operator AColor() const { throw error; }
|
||||
int ScriptDelayedError::itemCount() const { throw error; }
|
||||
CompareWhat ScriptDelayedError::compareAs(String&, void const*&) const { throw error; }
|
||||
ScriptValueP ScriptDelayedError::getMember(const String&) const { return new_intrusive1<ScriptDelayedError>(error); }
|
||||
ScriptValueP ScriptDelayedError::dependencyMember(const String&, const Dependency&) const { return new_intrusive1<ScriptDelayedError>(error); }
|
||||
ScriptValueP ScriptDelayedError::do_eval(Context&, bool) const { return new_intrusive1<ScriptDelayedError>(error); }
|
||||
ScriptValueP ScriptDelayedError::dependencies(Context&, const Dependency&) const { return new_intrusive1<ScriptDelayedError>(error); }
|
||||
ScriptValueP ScriptDelayedError::getMember(const String&) const { return intrusive(new ScriptDelayedError(error)); }
|
||||
ScriptValueP ScriptDelayedError::dependencyMember(const String&, const Dependency&) const { return intrusive(new ScriptDelayedError(error)); }
|
||||
ScriptValueP ScriptDelayedError::do_eval(Context&, bool) const { return intrusive(new ScriptDelayedError(error)); }
|
||||
ScriptValueP ScriptDelayedError::dependencies(Context&, const Dependency&) const { return intrusive(new ScriptDelayedError(error)); }
|
||||
ScriptValueP ScriptDelayedError::makeIterator(const ScriptValueP& thisP) const { return thisP; }
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ class ScriptRangeIterator : public ScriptIterator {
|
||||
};
|
||||
|
||||
ScriptValueP rangeIterator(int start, int end) {
|
||||
return new_intrusive2<ScriptRangeIterator>(start, end);
|
||||
return intrusive(new ScriptRangeIterator(start, end));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Integers
|
||||
@@ -190,7 +190,7 @@ ScriptValueP to_script(int v) {
|
||||
destroy_value); // deallocation function
|
||||
#endif
|
||||
#else
|
||||
return new_intrusive1<ScriptInt>(v);
|
||||
return intrusive(new ScriptInt(v));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ class ScriptDouble : public ScriptValue {
|
||||
};
|
||||
|
||||
ScriptValueP to_script(double v) {
|
||||
return new_intrusive1<ScriptDouble>(v);
|
||||
return intrusive(new ScriptDouble(v));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : String type
|
||||
@@ -286,9 +286,9 @@ class ScriptString : public ScriptValue {
|
||||
}
|
||||
virtual GeneratedImageP toImage(const ScriptValueP&) const {
|
||||
if (value.empty()) {
|
||||
return new_intrusive<BlankImage>();
|
||||
return intrusive(new BlankImage());
|
||||
} else {
|
||||
return new_intrusive1<PackagedImage>(value);
|
||||
return intrusive(new PackagedImage(value));
|
||||
}
|
||||
}
|
||||
virtual int itemCount() const { return (int)value.size(); }
|
||||
@@ -306,7 +306,7 @@ class ScriptString : public ScriptValue {
|
||||
};
|
||||
|
||||
ScriptValueP to_script(const String& v) {
|
||||
return new_intrusive1<ScriptString>(v);
|
||||
return intrusive(new ScriptString(v));
|
||||
}
|
||||
|
||||
|
||||
@@ -328,10 +328,10 @@ class ScriptAColor : public ScriptValue {
|
||||
};
|
||||
|
||||
ScriptValueP to_script(Color v) {
|
||||
return new_intrusive1<ScriptAColor>(v);
|
||||
return intrusive(new ScriptAColor(v));
|
||||
}
|
||||
ScriptValueP to_script(AColor v) {
|
||||
return new_intrusive1<ScriptAColor>(v);
|
||||
return intrusive(new ScriptAColor(v));
|
||||
}
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ class ScriptDateTime : public ScriptValue {
|
||||
};
|
||||
|
||||
ScriptValueP to_script(wxDateTime v) {
|
||||
return new_intrusive1<ScriptDateTime>(v);
|
||||
return intrusive(new ScriptDateTime(v));
|
||||
}
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ class ScriptNil : public ScriptValue {
|
||||
virtual operator int() const { return 0; }
|
||||
virtual operator bool() const { return false; }
|
||||
virtual GeneratedImageP toImage(const ScriptValueP&) const {
|
||||
return new_intrusive<BlankImage>();
|
||||
return intrusive(new BlankImage());
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -443,9 +443,9 @@ ScriptValueP ScriptCustomCollection::getIndex(int index) const {
|
||||
}
|
||||
}
|
||||
ScriptValueP ScriptCustomCollection::makeIterator(const ScriptValueP& thisP) const {
|
||||
return new_intrusive1<ScriptCustomCollectionIterator>(
|
||||
return intrusive(new ScriptCustomCollectionIterator(
|
||||
static_pointer_cast<ScriptCustomCollection>(thisP)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Concat collection
|
||||
@@ -489,7 +489,7 @@ ScriptValueP ScriptConcatCollection::getIndex(int index) const {
|
||||
}
|
||||
}
|
||||
ScriptValueP ScriptConcatCollection::makeIterator(const ScriptValueP& thisP) const {
|
||||
return new_intrusive2<ScriptConcatCollectionIterator>(a->makeIterator(a), b->makeIterator(b));
|
||||
return intrusive(new ScriptConcatCollectionIterator(a->makeIterator(a), b->makeIterator(b)));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : 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) {
|
||||
intrusive_ptr<DelayedIndexMapsData<Key,Value> >& item = data[name];
|
||||
if (!item) { // no item, make a new one
|
||||
item = new_intrusive<DelayedIndexMapsData<Key,Value> >();
|
||||
item = intrusive(new DelayedIndexMapsData<Key,Value>);
|
||||
item->read_data.init(init_with);
|
||||
} else if (!item->unread_data.empty()) { // not read, read now
|
||||
item->read_data.init(init_with);
|
||||
Reader reader(new_shared1<wxStringInputStream>(item->unread_data), nullptr, _("delayed data for ") + name);
|
||||
Reader reader(shared(new wxStringInputStream(item->unread_data)), nullptr, _("delayed data for ") + name);
|
||||
reader.handle_greedy(item->read_data);
|
||||
item->unread_data.clear();
|
||||
}
|
||||
|
||||
@@ -212,16 +212,16 @@ InputStreamP Package::openIn(const String& file) {
|
||||
InputStreamP stream;
|
||||
if (it->second.wasWritten()) {
|
||||
// written to this file, open the temp file
|
||||
stream = new_shared1<BufferedFileInputStream>(it->second.tempName);
|
||||
stream = shared(new BufferedFileInputStream(it->second.tempName));
|
||||
} else if (wxFileExists(filename+_("/")+file)) {
|
||||
// a file in directory package
|
||||
stream = new_shared1<BufferedFileInputStream>(filename+_("/")+file);
|
||||
stream = shared(new BufferedFileInputStream(filename+_("/")+file));
|
||||
} else if (wxFileExists(filename) && it->second.zipEntry) {
|
||||
// a file in a zip archive
|
||||
// somebody in wx thought seeking was no longer needed, it now only works with the 'compatability constructor'
|
||||
stream = new_shared2<wxZipInputStream>(filename, it->second.zipEntry->GetInternalName());
|
||||
stream = shared(new wxZipInputStream(filename, it->second.zipEntry->GetInternalName()));
|
||||
//stream = static_pointer_cast<wxZipInputStream>(
|
||||
// new_shared2<ZipFileInputStream>(filename, it->second.zipEntry));
|
||||
// shared(new ZipFileInputStream(filename, it->second.zipEntry)));
|
||||
} else {
|
||||
// shouldn't happen, packaged changed by someone else since opening it
|
||||
throw FileNotFoundError(file, filename);
|
||||
@@ -234,7 +234,7 @@ InputStreamP Package::openIn(const String& file) {
|
||||
}
|
||||
|
||||
OutputStreamP Package::openOut(const String& file) {
|
||||
return new_shared1<wxFileOutputStream>(nameOut(file));
|
||||
return shared(new wxFileOutputStream(nameOut(file)));
|
||||
}
|
||||
|
||||
String Package::nameOut(const String& file) {
|
||||
@@ -308,7 +308,7 @@ InputStreamP Package::openAbsoluteFile(const String& name) {
|
||||
size_t pos = name.find_first_of(_('\1'));
|
||||
if (pos == String::npos) {
|
||||
// temp or dir file
|
||||
shared_ptr<wxFileInputStream> f = new_shared1<wxFileInputStream>(name);
|
||||
shared_ptr<wxFileInputStream> f = shared(new wxFileInputStream(name));
|
||||
if (!f->IsOk()) throw FileNotFoundError(_("<unknown>"), name);
|
||||
return f;
|
||||
} else {
|
||||
|
||||
@@ -138,7 +138,7 @@ class Package : public IntrusivePtrVirtualBase {
|
||||
|
||||
protected:
|
||||
// TODO: I dislike putting this here very much. There ought to be a better way.
|
||||
virtual VCSP getVCS() { return new_intrusive<VCS>(); }
|
||||
virtual VCSP getVCS() { return intrusive(new VCS()); }
|
||||
|
||||
/// true if this is a zip file, false if a directory (updated on open/save)
|
||||
bool isZipfile() { return zipfile; }
|
||||
|
||||
@@ -65,12 +65,12 @@ PackagedP PackageManager::openAny(const String& name_, bool just_header) {
|
||||
if (!p) {
|
||||
// load with the right type, based on extension
|
||||
wxFileName fn(filename);
|
||||
if (fn.GetExt() == _("mse-game")) p = new_intrusive<Game>();
|
||||
else if (fn.GetExt() == _("mse-style")) p = new_intrusive<StyleSheet>();
|
||||
else if (fn.GetExt() == _("mse-locale")) p = new_intrusive<Locale>();
|
||||
else if (fn.GetExt() == _("mse-include")) p = new_intrusive<IncludePackage>();
|
||||
else if (fn.GetExt() == _("mse-symbol-font")) p = new_intrusive<SymbolFont>();
|
||||
else if (fn.GetExt() == _("mse-export-template")) p = new_intrusive<ExportTemplate>();
|
||||
if (fn.GetExt() == _("mse-game")) p = intrusive(new Game);
|
||||
else if (fn.GetExt() == _("mse-style")) p = intrusive(new StyleSheet);
|
||||
else if (fn.GetExt() == _("mse-locale")) p = intrusive(new Locale);
|
||||
else if (fn.GetExt() == _("mse-include")) p = intrusive(new IncludePackage);
|
||||
else if (fn.GetExt() == _("mse-symbol-font")) p = intrusive(new SymbolFont);
|
||||
else if (fn.GetExt() == _("mse-export-template")) p = intrusive(new ExportTemplate);
|
||||
else {
|
||||
throw PackageError(_("Unrecognized package type: '") + fn.GetExt() + _("'\nwhile trying to open: ") + name);
|
||||
}
|
||||
@@ -273,7 +273,7 @@ void PackageDirectory::installedPackages(vector<InstallablePackageP>& packages_o
|
||||
PackageVersionP ver(new PackageVersion(
|
||||
is_local ? PackageVersion::STATUS_LOCAL : PackageVersion::STATUS_GLOBAL));
|
||||
ver->check_status(*pack);
|
||||
packages_out.push_back(new_intrusive2<InstallablePackage>(new_intrusive1<PackageDescription>(*pack), ver));
|
||||
packages_out.push_back(intrusive(new InstallablePackage(intrusive(new PackageDescription(*pack)), ver)));
|
||||
} catch (const Error&) {}
|
||||
++it2;
|
||||
} else if ((*it1)->name < *it2) {
|
||||
@@ -285,7 +285,7 @@ void PackageDirectory::installedPackages(vector<InstallablePackageP>& packages_o
|
||||
try {
|
||||
PackagedP pack = package_manager.openAny(*it2, true);
|
||||
(*it1)->check_status(*pack);
|
||||
packages_out.push_back(new_intrusive2<InstallablePackage>(new_intrusive1<PackageDescription>(*pack), *it1));
|
||||
packages_out.push_back(intrusive(new InstallablePackage(intrusive(new PackageDescription(*pack)), *it1)));
|
||||
} catch (const Error&) { db_changed = true; }
|
||||
++it1, ++it2;
|
||||
}
|
||||
@@ -339,7 +339,7 @@ void PackageDirectory::loadDatabase() {
|
||||
String filename = databaseFile();
|
||||
if (wxFileExists(filename)) {
|
||||
// packages file not existing is not an error
|
||||
shared_ptr<wxFileInputStream> file = new_shared1<wxFileInputStream>(filename);
|
||||
shared_ptr<wxFileInputStream> file = shared(new wxFileInputStream(filename));
|
||||
if (!file->Ok()) return; // failure is not an error
|
||||
Reader reader(file, nullptr, filename);
|
||||
reader.handle_greedy(*this);
|
||||
@@ -348,7 +348,7 @@ void PackageDirectory::loadDatabase() {
|
||||
}
|
||||
|
||||
void PackageDirectory::saveDatabase() {
|
||||
Writer writer(new_shared1<wxFileOutputStream>(databaseFile()), app_version);
|
||||
Writer writer(shared(new wxFileOutputStream(databaseFile())), app_version);
|
||||
writer.handle(*this);
|
||||
}
|
||||
String PackageDirectory::databaseFile() {
|
||||
|
||||
@@ -200,7 +200,7 @@ class Reader {
|
||||
*/
|
||||
template <typename T>
|
||||
intrusive_ptr<T> read_new(Reader& reader) {
|
||||
return new_intrusive<T>();
|
||||
return intrusive(new T());
|
||||
}
|
||||
|
||||
/// Update the 'index' member of a value for use by IndexMap
|
||||
|
||||
+16
-60
@@ -38,6 +38,15 @@ using namespace boost;
|
||||
|
||||
// ----------------------------------------------------------------------------- : Creating
|
||||
|
||||
/// Wrap a newly allocated pointer in an shared_ptr
|
||||
/** Usage:
|
||||
* return shared(new T(stuff)));
|
||||
*/
|
||||
template <typename T>
|
||||
inline shared_ptr<T> shared(T* ptr) {
|
||||
return shared_ptr<T>(ptr);
|
||||
}
|
||||
|
||||
/// Allocate a new shared-pointed object
|
||||
template <typename T>
|
||||
inline shared_ptr<T> new_shared() {
|
||||
@@ -98,58 +107,15 @@ inline shared_ptr<T> new_shared9(const A0& a0, const A1& a1, const A2& a2, const
|
||||
class Type; \
|
||||
typedef intrusive_ptr<Type> Type##P;
|
||||
|
||||
|
||||
/// Allocate a new intrusive-pointed object
|
||||
/// Wrap a newly allocated pointer in an intrusive_ptr
|
||||
/** Usage:
|
||||
* return intrusive(new T(stuff)));
|
||||
*/
|
||||
template <typename T>
|
||||
inline intrusive_ptr<T> new_intrusive() {
|
||||
return intrusive_ptr<T>(new T());
|
||||
inline intrusive_ptr<T> intrusive(T* ptr) {
|
||||
return intrusive_ptr<T>(ptr);
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given one argument to pass to the ctor of T
|
||||
template <typename T, typename A0>
|
||||
inline intrusive_ptr<T> new_intrusive1(const A0& a0) {
|
||||
return intrusive_ptr<T>(new T(a0));
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given two arguments to pass to the ctor of T
|
||||
template <typename T, typename A0, typename A1>
|
||||
inline intrusive_ptr<T> new_intrusive2(const A0& a0, const A1& a1) {
|
||||
return intrusive_ptr<T>(new T(a0, a1));
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given three arguments to pass to the ctor of T
|
||||
template <typename T, typename A0, typename A1, typename A2>
|
||||
inline intrusive_ptr<T> new_intrusive3(const A0& a0, const A1& a1, const A2& a2) {
|
||||
return intrusive_ptr<T>(new T(a0, a1, a2));
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given four arguments to pass to the ctor of T
|
||||
template <typename T, typename A0, typename A1, typename A2, typename A3>
|
||||
inline intrusive_ptr<T> new_intrusive4(const A0& a0, const A1& a1, const A2& a2, const A3& a3) {
|
||||
return intrusive_ptr<T>(new T(a0, a1, a2, a3));
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given five arguments to pass to the ctor of T
|
||||
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4>
|
||||
inline intrusive_ptr<T> new_intrusive5(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4) {
|
||||
return intrusive_ptr<T>(new T(a0, a1, a2, a3, a4));
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given six arguments to pass to the ctor of T
|
||||
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
inline intrusive_ptr<T> new_intrusive6(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) {
|
||||
return intrusive_ptr<T>(new T(a0, a1, a2, a3, a4, a5));
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given seven arguments to pass to the ctor of T
|
||||
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
||||
inline intrusive_ptr<T> new_intrusive7(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) {
|
||||
return intrusive_ptr<T>(new T(a0, a1, a2, a3, a4, a5, a6));
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given eight arguments to pass to the ctor of T
|
||||
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
|
||||
inline intrusive_ptr<T> new_intrusive8(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7) {
|
||||
return intrusive_ptr<T>(new T(a0, a1, a2, a3, a4, a5, a6, a7));
|
||||
}
|
||||
/// Allocate a new intrusive-pointed object, given nine arguments to pass to the ctor of T
|
||||
template <typename T, typename A0, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
|
||||
inline intrusive_ptr<T> new_intrusive9(const A0& a0, const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) {
|
||||
return intrusive_ptr<T>(new T(a0, a1, a2, a3, a4, a5, a6, a7, a8));
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Intrusive pointer base
|
||||
|
||||
template <typename T> class IntrusivePtrBase;
|
||||
@@ -215,16 +181,6 @@ inline shared_ptr<T> new_shared9(const A0& a0, const A1& a1, const A2& a2, const
|
||||
#else
|
||||
#define DECLARE_POINTER_TYPE DECLARE_SHARED_POINTER_TYPE
|
||||
#define intrusive_ptr shared_ptr
|
||||
#define new_intrusive new_shared
|
||||
#define new_intrusive1 new_shared1
|
||||
#define new_intrusive2 new_shared2
|
||||
#define new_intrusive3 new_shared3
|
||||
#define new_intrusive4 new_shared4
|
||||
#define new_intrusive5 new_shared5
|
||||
#define new_intrusive6 new_shared6
|
||||
#define new_intrusive7 new_shared7
|
||||
#define new_intrusive8 new_shared8
|
||||
#define new_intrusive9 new_shared9
|
||||
|
||||
template <typename T> class IntrusivePtrBase {};
|
||||
|
||||
|
||||
+2
-2
@@ -17,8 +17,8 @@ VCSP read_new<VCS>(Reader& reader) {
|
||||
// there must be a type specified
|
||||
String type;
|
||||
reader.handle(_("type"), type);
|
||||
if (type == _("none")) return new_intrusive<VCS>();
|
||||
else if (type == _("subversion")) return new_intrusive<SubversionVCS>();
|
||||
if (type == _("none")) return intrusive(new VCS);
|
||||
else if (type == _("subversion")) return intrusive(new SubversionVCS);
|
||||
else if (type.empty()) {
|
||||
reader.warning(_ERROR_1_("expected key", _("version control system")));
|
||||
throw ParseError(_ERROR_("aborting parsing"));
|
||||
|
||||
+25
-45
@@ -11,25 +11,29 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : SVN File Manipulation
|
||||
|
||||
bool run_svn(const Char** arguments) {
|
||||
switch (wxExecute(const_cast<Char**>(arguments), wxEXEC_SYNC)) { // Yuck, const_cast
|
||||
// Success
|
||||
case 0:
|
||||
return true;
|
||||
// Couldn't run SVN
|
||||
case -1:
|
||||
handle_error(String(_("Can't run SVN.")));
|
||||
return false;
|
||||
// SVN error
|
||||
default:
|
||||
handle_error(String(_("SVN encountered an error")));
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SubversionVCS::addFile(const wxFileName& filename)
|
||||
{
|
||||
String name = filename.GetFullPath();
|
||||
const Char* name_c[] = {_("svn"), _("add"), name.c_str(), nullptr};
|
||||
switch (wxExecute(const_cast<Char**>(name_c), wxEXEC_SYNC)) // Yuck, const_cast
|
||||
{
|
||||
// Success
|
||||
case 0:
|
||||
return;
|
||||
// Couldn't run SVN
|
||||
case -1:
|
||||
handle_error(String(_("Can't run SVN.")));
|
||||
VCS::addFile(filename);
|
||||
return;
|
||||
// SVN error
|
||||
default:
|
||||
handle_error(String(_("SVN encountered an error")));
|
||||
VCS::addFile(filename);
|
||||
return;
|
||||
if (!run_svn(name_c)) {
|
||||
VCS::addFile(filename);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,21 +41,8 @@ void SubversionVCS::moveFile(const wxFileName& source, const wxFileName& dest)
|
||||
{
|
||||
String source_name = source.GetFullPath(), dest_name = dest.GetFullPath();
|
||||
const Char* name_c[] = {_("svn"), _("mv"), source_name.c_str(), dest_name.c_str(), nullptr};
|
||||
switch (wxExecute(const_cast<Char**>(name_c), wxEXEC_SYNC)) // Once again, yuck
|
||||
{
|
||||
// Success
|
||||
case 0:
|
||||
return;
|
||||
// Couldn't run SVN
|
||||
case -1:
|
||||
handle_error(String(_("Can't run SVN.")));
|
||||
VCS::moveFile(source, dest);
|
||||
return;
|
||||
// SVN error
|
||||
default:
|
||||
handle_error(String(_("SVN encountered an error")));
|
||||
VCS::moveFile(source, dest);
|
||||
return;
|
||||
if (!run_svn(name_c)) {
|
||||
VCS::moveFile(source, dest);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,22 +51,10 @@ void SubversionVCS::removeFile(const wxFileName& filename)
|
||||
String name = filename.GetFullPath();
|
||||
const Char* name_c[] = {_("svn"), _("rm"), name.c_str(), nullptr};
|
||||
handle_warning(String(name_c[0]) + name_c[1] + name_c[2]);
|
||||
// TODO: do we really need to remove the file before calling "svn remove"?
|
||||
VCS::removeFile(filename);
|
||||
switch (wxExecute(const_cast<Char**>(name_c), wxEXEC_SYNC)) // Once again, yuck
|
||||
{
|
||||
// Success
|
||||
case 0:
|
||||
return;
|
||||
// Couldn't run SVN
|
||||
case -1:
|
||||
handle_error(String(_("Can't run SVN.")));
|
||||
VCS::removeFile(filename);
|
||||
return;
|
||||
// SVN error
|
||||
default:
|
||||
handle_error(String(_("SVN encountered an error")));
|
||||
VCS::removeFile(filename);
|
||||
return;
|
||||
if (!run_svn(name_c)) {
|
||||
VCS::removeFile(filename);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,4 +64,5 @@ IMPLEMENT_REFLECTION(SubversionVCS) {
|
||||
REFLECT(type);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : SubversionVCS
|
||||
|
||||
class SubversionVCS : public VCS
|
||||
{
|
||||
class SubversionVCS : public VCS {
|
||||
public:
|
||||
virtual void addFile (const wxFileName& filename);
|
||||
virtual void moveFile (const wxFileName& source, const wxFileName& destination);
|
||||
|
||||
Reference in New Issue
Block a user