Skip to content

Commit

Permalink
Merge pull request #2997 from jkseppan/rule-of-three
Browse files Browse the repository at this point in the history
Disable copying of C++ classes with nontrivial destructors
  • Loading branch information
mdboom committed Apr 21, 2014
2 parents b61e300 + 8d20fb4 commit 96d2e11
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/_backend_agg.h
Expand Up @@ -107,6 +107,11 @@ class BufferRegion : public Py::PythonExtension<BufferRegion>
data = NULL;
}
};

private:
// prevent copying
BufferRegion(const BufferRegion&);
BufferRegion& operator=(const BufferRegion&);
};

class GCAgg
Expand Down Expand Up @@ -284,6 +289,10 @@ class RendererAgg: public Py::PythonExtension<RendererAgg>

private:
void create_alpha_buffers();

// prevent copying
RendererAgg(const RendererAgg&);
RendererAgg& operator=(const RendererAgg&);
};

// the extension module
Expand All @@ -306,6 +315,10 @@ class _backend_agg_module : public Py::ExtensionModule<_backend_agg_module>
private:

Py::Object new_renderer(const Py::Tuple &args, const Py::Dict &kws);

// prevent copying
_backend_agg_module(const _backend_agg_module&);
_backend_agg_module& operator=(const _backend_agg_module&);
};


Expand Down
3 changes: 3 additions & 0 deletions src/_image.h
Expand Up @@ -118,6 +118,9 @@ class Image : public Py::PythonExtension<Image>
static char get_resample__doc__[];
static char set_resample__doc__[];

// prevent copying
Image(const Image&);
Image& operator=(const Image&);
};


Expand Down
18 changes: 17 additions & 1 deletion src/ft2font.h
Expand Up @@ -75,6 +75,10 @@ class FT2Image : public Py::PythonClass<FT2Image>
unsigned long _height;

void resize(long width, long height);

// prevent copying
FT2Image(const FT2Image&);
FT2Image& operator=(const FT2Image&);
};

class Glyph : public Py::PythonClass<Glyph>
Expand All @@ -90,6 +94,10 @@ class Glyph : public Py::PythonClass<Glyph>
size_t glyphInd;
private:
Py::Dict __dict__;

// prevent copying
Glyph(const Glyph&);
Glyph& operator=(const Glyph&);
};

class FT2Font : public Py::PythonClass<FT2Font>
Expand Down Expand Up @@ -172,15 +180,23 @@ class FT2Font : public Py::PythonClass<FT2Font>
static char get_image__doc__[];
static char attach_file__doc__[];
static char get_path__doc__[];

// prevent copying
FT2Font(const FT2Font&);
FT2Font& operator=(const FT2Font&);
};

// the extension module
class ft2font_module : public Py::ExtensionModule<ft2font_module>

{
public:
ft2font_module();
virtual ~ft2font_module();

private:
// prevent copying
ft2font_module(const ft2font_module&);
ft2font_module operator=(const ft2font_module&);
};

#endif
3 changes: 3 additions & 0 deletions src/mplutils.h
Expand Up @@ -45,6 +45,9 @@ class Printf
{
private :
char *buffer;
// prevent copying
Printf(const Printf&);
Printf& operator=(const Printf&);
public :
Printf(const char *, ...);
~Printf();
Expand Down

0 comments on commit 96d2e11

Please sign in to comment.