Move SharedPtr to base namespace

This commit is contained in:
David Capello 2015-04-01 12:35:18 -03:00
parent 27c7f31175
commit 3d63e0e1b4
32 changed files with 70 additions and 65 deletions

View File

@ -91,7 +91,7 @@ private:
for (ConvolutionMatrixStock::iterator it = m_stock.begin(), end = m_stock.end();
it != end; ++it) {
SharedPtr<ConvolutionMatrix> matrix = *it;
base::SharedPtr<ConvolutionMatrix> matrix = *it;
ListItem* listitem = new ListItem(matrix->getName());
m_stockListBox->addChild(listitem);
}
@ -125,7 +125,7 @@ private:
void onMatrixChange()
{
Widget* selected = m_stockListBox->getSelectedChild();
SharedPtr<ConvolutionMatrix> matrix = m_stock.getByName(selected->getText().c_str());
base::SharedPtr<ConvolutionMatrix> matrix = m_stock.getByName(selected->getText().c_str());
Target newTarget = matrix->getDefaultTarget();
m_filter.setMatrix(matrix);
@ -172,7 +172,7 @@ void ConvolutionMatrixCommand::onExecute(Context* context)
ConvolutionMatrixStock m_stock;
// Get last used (selected) matrix
SharedPtr<ConvolutionMatrix> matrix =
base::SharedPtr<ConvolutionMatrix> matrix =
m_stock.getByName(get_config_string(ConfigSection, "Selected", ""));
// Create the filter and setup initial settings

View File

@ -31,13 +31,13 @@ ConvolutionMatrixStock::~ConvolutionMatrixStock()
cleanStock();
}
SharedPtr<ConvolutionMatrix> ConvolutionMatrixStock::getByName(const char* name)
base::SharedPtr<ConvolutionMatrix> ConvolutionMatrixStock::getByName(const char* name)
{
for (const_iterator it = begin(), end = this->end(); it != end; ++it) {
if (std::strcmp((*it)->getName(), name) == 0)
return *it;
}
return SharedPtr<ConvolutionMatrix>(0);
return base::SharedPtr<ConvolutionMatrix>(0);
}
void ConvolutionMatrixStock::reloadStock()
@ -57,7 +57,7 @@ void ConvolutionMatrixStock::reloadStock()
"convmatr.def", NULL };
char *s, buf[256], leavings[4096];
int i, x, y, w, h, div, bias;
SharedPtr<ConvolutionMatrix> matrix;
base::SharedPtr<ConvolutionMatrix> matrix;
std::string name;
cleanStock();

View File

@ -23,8 +23,8 @@ namespace app {
// A container of all convolution matrices in the convmatr.def file.
class ConvolutionMatrixStock {
public:
typedef std::vector<SharedPtr<ConvolutionMatrix> >::iterator iterator;
typedef std::vector<SharedPtr<ConvolutionMatrix> >::const_iterator const_iterator;
typedef std::vector<base::SharedPtr<ConvolutionMatrix> >::iterator iterator;
typedef std::vector<base::SharedPtr<ConvolutionMatrix> >::const_iterator const_iterator;
ConvolutionMatrixStock();
virtual ~ConvolutionMatrixStock();
@ -34,13 +34,13 @@ namespace app {
const_iterator begin() const { return m_matrices.begin(); }
const_iterator end() const { return m_matrices.end(); }
SharedPtr<ConvolutionMatrix> getByName(const char* name);
base::SharedPtr<ConvolutionMatrix> getByName(const char* name);
void reloadStock();
void cleanStock();
private:
std::vector<SharedPtr<ConvolutionMatrix> > m_matrices;
std::vector<base::SharedPtr<ConvolutionMatrix> > m_matrices;
};
} // namespace app

View File

@ -203,7 +203,7 @@ void Document::impossibleToBackToSavedState()
//////////////////////////////////////////////////////////////////////
// Loaded options from file
void Document::setFormatOptions(const SharedPtr<FormatOptions>& format_options)
void Document::setFormatOptions(const base::SharedPtr<FormatOptions>& format_options)
{
m_format_options = format_options;
}

View File

@ -103,8 +103,8 @@ namespace app {
//////////////////////////////////////////////////////////////////////
// Loaded options from file
void setFormatOptions(const SharedPtr<FormatOptions>& format_options);
SharedPtr<FormatOptions> getFormatOptions() { return m_format_options; }
void setFormatOptions(const base::SharedPtr<FormatOptions>& format_options);
base::SharedPtr<FormatOptions> getFormatOptions() { return m_format_options; }
//////////////////////////////////////////////////////////////////////
// Boundaries
@ -203,7 +203,7 @@ namespace app {
int m_read_locks;
// Data to save the file in the same format that it was loaded
SharedPtr<FormatOptions> m_format_options;
base::SharedPtr<FormatOptions> m_format_options;
// Extra cel used to draw extra stuff (e.g. editor's pen preview, pixels in movement, etc.)
Cel* m_extraCel;

View File

@ -69,7 +69,7 @@ private:
gfx::Rect m_inTextureBounds;
};
typedef SharedPtr<SampleBounds> SampleBoundsPtr;
typedef base::SharedPtr<SampleBounds> SampleBoundsPtr;
class DocumentExporter::Sample {
public:

View File

@ -693,7 +693,7 @@ bool BmpFormat::onLoad(FileOp *fop)
// Setup the file-data.
if (fop->seq.format_options == NULL) {
SharedPtr<BmpOptions> bmp_options(new BmpOptions());
base::SharedPtr<BmpOptions> bmp_options(new BmpOptions());
bmp_options->format = format;
bmp_options->compression = infoheader.biCompression;

View File

@ -419,7 +419,7 @@ FileOp* fop_to_save_document(Context* context, Document* document, const char* f
// Configure output format?
if (fop->format->support(FILE_SUPPORT_GET_FORMAT_OPTIONS)) {
SharedPtr<FormatOptions> format_options = fop->format->getFormatOptions(fop);
base::SharedPtr<FormatOptions> format_options = fop->format->getFormatOptions(fop);
// Does the user cancelled the operation?
if (format_options == NULL) {
@ -696,7 +696,7 @@ void fop_post_load(FileOp* fop)
if (fop->document->sprite()->pixelFormat() == IMAGE_RGB &&
fop->document->sprite()->getPalettes().size() <= 1 &&
fop->document->sprite()->palette(frame_t(0))->isBlack()) {
SharedPtr<Palette> palette
base::SharedPtr<Palette> palette
(render::create_palette_from_rgb(
fop->document->sprite(),
frame_t(0), NULL));
@ -709,7 +709,7 @@ void fop_post_load(FileOp* fop)
fop->document->markAsSaved();
}
void fop_sequence_set_format_options(FileOp* fop, const SharedPtr<FormatOptions>& format_options)
void fop_sequence_set_format_options(FileOp* fop, const base::SharedPtr<FormatOptions>& format_options)
{
ASSERT(fop->seq.format_options == NULL);
fop->seq.format_options = format_options;

View File

@ -94,7 +94,7 @@ namespace app {
bool has_alpha;
LayerImage* layer;
Cel* last_cel;
SharedPtr<FormatOptions> format_options;
base::SharedPtr<FormatOptions> format_options;
} seq;
~FileOp();
@ -132,7 +132,7 @@ namespace app {
// Does extra post-load processing which may require user intervention.
void fop_post_load(FileOp* fop);
void fop_sequence_set_format_options(FileOp* fop, const SharedPtr<FormatOptions>& format_options);
void fop_sequence_set_format_options(FileOp* fop, const base::SharedPtr<FormatOptions>& format_options);
void fop_sequence_set_color(FileOp* fop, int index, int r, int g, int b);
void fop_sequence_get_color(FileOp* fop, int index, int *r, int *g, int *b);
Image* fop_sequence_image(FileOp* fi, PixelFormat pixelFormat, int w, int h);

View File

@ -57,7 +57,7 @@ namespace app {
// Returns extra options for this format. It can return != NULL
// only if flags() returns FILE_SUPPORT_GET_FORMAT_OPTIONS.
SharedPtr<FormatOptions> getFormatOptions(FileOp* fop) {
base::SharedPtr<FormatOptions> getFormatOptions(FileOp* fop) {
return onGetFormatOptions(fop);
}
@ -78,8 +78,8 @@ namespace app {
#endif
virtual void onDestroyData(FileOp* fop) { }
virtual SharedPtr<FormatOptions> onGetFormatOptions(FileOp* fop) {
return SharedPtr<FormatOptions>(0);
virtual base::SharedPtr<FormatOptions> onGetFormatOptions(FileOp* fop) {
return base::SharedPtr<FormatOptions>(0);
}
};

View File

@ -93,7 +93,7 @@ class GifFormat : public FileFormat {
#ifdef ENABLE_SAVE
bool onSave(FileOp* fop) override;
#endif
SharedPtr<FormatOptions> onGetFormatOptions(FileOp* fop) override;
base::SharedPtr<FormatOptions> onGetFormatOptions(FileOp* fop) override;
};
FileFormat* CreateGifFormat()
@ -528,7 +528,7 @@ bool GifFormat::onSave(FileOp* fop)
if (!gif_file)
throw Exception("Error creating GIF file.\n");
SharedPtr<GifOptions> gif_options = fop->seq.format_options;
base::SharedPtr<GifOptions> gif_options = fop->seq.format_options;
Sprite* sprite = fop->document->sprite();
int sprite_w = sprite->width();
int sprite_h = sprite->height();
@ -773,11 +773,11 @@ bool GifFormat::onSave(FileOp* fop)
}
#endif
SharedPtr<FormatOptions> GifFormat::onGetFormatOptions(FileOp* fop)
base::SharedPtr<FormatOptions> GifFormat::onGetFormatOptions(FileOp* fop)
{
SharedPtr<GifOptions> gif_options;
base::SharedPtr<GifOptions> gif_options;
if (fop->document->getFormatOptions() != NULL)
gif_options = SharedPtr<GifOptions>(fop->document->getFormatOptions());
gif_options = base::SharedPtr<GifOptions>(fop->document->getFormatOptions());
if (!gif_options)
gif_options.reset(new GifOptions);
@ -838,7 +838,7 @@ SharedPtr<FormatOptions> GifFormat::onGetFormatOptions(FileOp* fop)
}
catch (std::exception& e) {
Console::showException(e);
return SharedPtr<GifOptions>(0);
return base::SharedPtr<GifOptions>(0);
}
}

View File

@ -302,7 +302,7 @@ TEST_F(GifFormat, OpaqueRgbQuantizationTwoLayers)
pal->setEntry(1, rgba(255, 0, 0, 255));
// Do not modify palettes
doc->setFormatOptions(SharedPtr<FormatOptions>(new GifOptions(GifOptions::NoQuantize)));
doc->setFormatOptions(base::SharedPtr<FormatOptions>(new GifOptions(GifOptions::NoQuantize)));
save_document(&m_ctx, doc);
doc->close();

View File

@ -59,7 +59,7 @@ class JpegFormat : public FileFormat {
bool onSave(FileOp* fop) override;
#endif
SharedPtr<FormatOptions> onGetFormatOptions(FileOp* fop) override;
base::SharedPtr<FormatOptions> onGetFormatOptions(FileOp* fop) override;
};
FileFormat* CreateJpegFormat()
@ -237,7 +237,7 @@ bool JpegFormat::onSave(FileOp* fop)
Image *image = fop->seq.image;
JSAMPARRAY buffer;
JDIMENSION buffer_height;
SharedPtr<JpegOptions> jpeg_options = fop->seq.format_options;
base::SharedPtr<JpegOptions> jpeg_options = fop->seq.format_options;
int c;
// Open the file for write in it.
@ -347,11 +347,11 @@ bool JpegFormat::onSave(FileOp* fop)
#endif
// Shows the JPEG configuration dialog.
SharedPtr<FormatOptions> JpegFormat::onGetFormatOptions(FileOp* fop)
base::SharedPtr<FormatOptions> JpegFormat::onGetFormatOptions(FileOp* fop)
{
SharedPtr<JpegOptions> jpeg_options;
base::SharedPtr<JpegOptions> jpeg_options;
if (fop->document->getFormatOptions() != NULL)
jpeg_options = SharedPtr<JpegOptions>(fop->document->getFormatOptions());
jpeg_options = base::SharedPtr<JpegOptions>(fop->document->getFormatOptions());
if (!jpeg_options)
jpeg_options.reset(new JpegOptions);
@ -385,7 +385,7 @@ SharedPtr<FormatOptions> JpegFormat::onGetFormatOptions(FileOp* fop)
}
catch (std::exception& e) {
Console::showException(e);
return SharedPtr<JpegOptions>(0);
return base::SharedPtr<JpegOptions>(0);
}
}

View File

@ -115,7 +115,7 @@ namespace app {
DISABLE_COPYING(EditorState);
};
typedef SharedPtr<EditorState> EditorStatePtr;
typedef base::SharedPtr<EditorState> EditorStatePtr;
} // namespace app

View File

@ -128,7 +128,7 @@ namespace app {
return a;
}
typedef SharedPtr<PixelsMovement> PixelsMovementPtr;
typedef base::SharedPtr<PixelsMovement> PixelsMovementPtr;
} // namespace app

View File

@ -42,7 +42,7 @@ namespace app {
Bitmaps m_bitmaps;
};
typedef SharedPtr<SkinPart> SkinPartPtr;
typedef base::SharedPtr<SkinPart> SkinPartPtr;
} // namespace skin
} // namespace app

View File

@ -56,7 +56,7 @@ namespace app {
int m_lowerRight;
};
typedef SharedPtr<SkinProperty> SkinPropertyPtr;
typedef base::SharedPtr<SkinProperty> SkinPropertyPtr;
SkinPropertyPtr get_skin_property(ui::Widget* widget);

View File

@ -42,7 +42,7 @@ namespace app {
ISliderBgPainter* m_painter;
};
typedef SharedPtr<SkinSliderProperty> SkinSliderPropertyPtr;
typedef base::SharedPtr<SkinSliderProperty> SkinSliderPropertyPtr;
} // namespace skin
} // namespace app

View File

@ -29,7 +29,7 @@ namespace skin {
skin::Style* m_style;
};
typedef SharedPtr<SkinStyleProperty> SkinStylePropertyPtr;
typedef base::SharedPtr<SkinStyleProperty> SkinStylePropertyPtr;
} // namespace skin
} // namespace app

View File

@ -92,7 +92,7 @@ namespace app {
}
};
typedef SharedPtr<Tab> TabPtr;
typedef base::SharedPtr<Tab> TabPtr;
typedef std::vector<TabPtr> TabsList;
typedef TabsList::iterator TabsListIterator;

View File

@ -18,7 +18,7 @@
namespace app {
typedef SharedPtr<TiXmlDocument> XmlDocumentRef;
typedef base::SharedPtr<TiXmlDocument> XmlDocumentRef;
XmlDocumentRef open_xml(const std::string& filename);
void save_xml(XmlDocumentRef doc, const std::string& filename);

View File

@ -1,5 +1,5 @@
// Aseprite Base Library
// Copyright (c) 2001-2013 David Capello
// Copyright (c) 2001-2013, 2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -14,8 +14,8 @@
#include <string>
namespace base {
typedef SharedPtr<FILE> FileHandle;
typedef base::SharedPtr<FILE> FileHandle;
FILE* open_file_raw(const std::string& filename, const std::string& mode);
FileHandle open_file(const std::string& filename, const std::string& mode);

View File

@ -8,6 +8,8 @@
#define BASE_SHARED_PTR_H_INCLUDED
#pragma once
namespace base {
// This class counts references for a SharedPtr.
class SharedPtrRefCounterBase
{
@ -253,4 +255,6 @@ bool operator!=(const SharedPtr<T>& ptr1, const SharedPtr<T>& ptr2)
return ptr1.get() != ptr2.get();
}
} // namespace base
#endif

View File

@ -1,5 +1,5 @@
// Aseprite Base Library
// Copyright (c) 2001-2013 David Capello
// Copyright (c) 2001-2013, 2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -8,6 +8,8 @@
#include "base/shared_ptr.h"
using namespace base;
TEST(SharedPtr, IntPtr)
{
SharedPtr<int> a(new int(5));

View File

@ -43,7 +43,7 @@ namespace doc {
int m_opacity; // Opacity level
};
typedef SharedPtr<CelData> CelDataRef;
typedef base::SharedPtr<CelData> CelDataRef;
} // namespace doc

View File

@ -32,7 +32,7 @@ namespace doc {
std::vector<uint8_t> m_buffer;
};
typedef SharedPtr<ImageBuffer> ImageBufferPtr;
typedef base::SharedPtr<ImageBuffer> ImageBufferPtr;
} // namespace doc

View File

@ -1,5 +1,5 @@
// Aseprite Document Library
// Copyright (c) 2001-2014 David Capello
// Copyright (c) 2001-2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -13,7 +13,7 @@
namespace doc {
typedef SharedPtr<Image> ImageRef;
typedef base::SharedPtr<Image> ImageRef;
} // namespace doc

View File

@ -118,7 +118,7 @@ ConvolutionMatrixFilter::ConvolutionMatrixFilter()
{
}
void ConvolutionMatrixFilter::setMatrix(const SharedPtr<ConvolutionMatrix>& matrix)
void ConvolutionMatrixFilter::setMatrix(const base::SharedPtr<ConvolutionMatrix>& matrix)
{
m_matrix = matrix;
m_lines.resize(matrix->getHeight());

View File

@ -23,10 +23,10 @@ namespace filters {
public:
ConvolutionMatrixFilter();
void setMatrix(const SharedPtr<ConvolutionMatrix>& matrix);
void setMatrix(const base::SharedPtr<ConvolutionMatrix>& matrix);
void setTiledMode(TiledMode tiledMode);
SharedPtr<ConvolutionMatrix> getMatrix() { return m_matrix; }
base::SharedPtr<ConvolutionMatrix> getMatrix() { return m_matrix; }
TiledMode getTiledMode() const { return m_tiledMode; }
// Filter implementation
@ -36,7 +36,7 @@ namespace filters {
void applyToIndexed(FilterManager* filterMgr);
private:
SharedPtr<ConvolutionMatrix> m_matrix;
base::SharedPtr<ConvolutionMatrix> m_matrix;
TiledMode m_tiledMode;
std::vector<uint8_t*> m_lines;
};

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2001-2013 David Capello
// Copyright (C) 2001-2013, 2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -14,10 +14,9 @@
namespace ui {
class Alert;
typedef SharedPtr<Alert> AlertPtr;
typedef base::SharedPtr<Alert> AlertPtr;
class Alert : public Window
{
class Alert : public Window {
public:
Alert();

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2001-2014 David Capello
// Copyright (C) 2001-2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -169,7 +169,7 @@ namespace ui {
DISABLE_COPYING(CheckedDrawMode);
};
typedef SharedPtr<Graphics> GraphicsPtr;
typedef base::SharedPtr<Graphics> GraphicsPtr;
} // namespace ui

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2001-2013 David Capello
// Copyright (C) 2001-2013, 2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -28,7 +28,7 @@ namespace ui {
DISABLE_COPYING(Property);
};
typedef SharedPtr<Property> PropertyPtr;
typedef base::SharedPtr<Property> PropertyPtr;
} // namespace ui