diff options
author | Neil <nyamatongwe@gmail.com> | 2017-04-19 17:44:09 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2017-04-19 17:44:09 +1000 |
commit | d9a4e803d7b5e9fde3009052653ec3fdf77c5c09 (patch) | |
tree | 45858426901e942a5f1cd8b1f4a5805902e125c0 | |
parent | c085f3f8458110eca0874343b45b34acc9827631 (diff) | |
download | scintilla-mirror-d9a4e803d7b5e9fde3009052653ec3fdf77c5c09.tar.gz |
Use =delete for unwanted functions.
-rw-r--r-- | cocoa/ScintillaCocoa.h | 7 | ||||
-rw-r--r-- | gtk/ScintillaGTK.h | 7 | ||||
-rw-r--r-- | src/CallTip.h | 6 | ||||
-rw-r--r-- | src/CellBuffer.h | 5 | ||||
-rw-r--r-- | src/EditModel.h | 7 | ||||
-rw-r--r-- | src/Editor.h | 7 | ||||
-rw-r--r-- | src/PositionCache.h | 8 | ||||
-rw-r--r-- | src/RunStyles.h | 4 | ||||
-rw-r--r-- | src/ScintillaBase.h | 7 | ||||
-rw-r--r-- | src/SparseVector.h | 4 | ||||
-rw-r--r-- | src/Style.h | 4 | ||||
-rw-r--r-- | src/ViewStyle.h | 15 | ||||
-rw-r--r-- | src/XPM.h | 6 | ||||
-rw-r--r-- | test/unit/testCharClassify.cxx | 4 | ||||
-rw-r--r-- | win32/PlatWin.cxx | 18 |
15 files changed, 51 insertions, 58 deletions
diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h index 4c9da0f4a..2b19c6609 100644 --- a/cocoa/ScintillaCocoa.h +++ b/cocoa/ScintillaCocoa.h @@ -104,10 +104,6 @@ private: bool enteredSetScrollingSize; - // Private so ScintillaCocoa objects can not be copied - ScintillaCocoa(const ScintillaCocoa &) : ScintillaBase() {} - ScintillaCocoa &operator=(const ScintillaCocoa &) { return * this; } - bool GetPasteboardData(NSPasteboard* board, SelectionText* selectedText); void SetPasteboardData(NSPasteboard* board, const SelectionText& selectedText); int TargetAsUTF8(char *text); @@ -135,6 +131,9 @@ protected: public: ScintillaCocoa(ScintillaView* sciView_, SCIContentView* viewContent, SCIMarginView* viewMargin); + // Deleted so ScintillaCocoa objects can not be copied + ScintillaCocoa(const ScintillaCocoa &) : ScintillaBase() = delete; + ScintillaCocoa &operator=(const ScintillaCocoa &) = delete; ~ScintillaCocoa() override; void Finalise() override; diff --git a/gtk/ScintillaGTK.h b/gtk/ScintillaGTK.h index 37f8dca31..c227d7b77 100644 --- a/gtk/ScintillaGTK.h +++ b/gtk/ScintillaGTK.h @@ -71,12 +71,11 @@ class ScintillaGTK : public ScintillaBase { int accessibilityEnabled; AtkObject *accessible; - // Private so ScintillaGTK objects can not be copied - ScintillaGTK(const ScintillaGTK &); - ScintillaGTK &operator=(const ScintillaGTK &); - public: explicit ScintillaGTK(_ScintillaObject *sci_); + // Deleted so ScintillaGTK objects can not be copied + ScintillaGTK(const ScintillaGTK &) = delete; + ScintillaGTK &operator=(const ScintillaGTK &) = delete; virtual ~ScintillaGTK(); static ScintillaGTK *FromWidget(GtkWidget *widget); static void ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_class, GtkContainerClass *container_class); diff --git a/src/CallTip.h b/src/CallTip.h index 28d815bbd..aec915373 100644 --- a/src/CallTip.h +++ b/src/CallTip.h @@ -27,9 +27,6 @@ class CallTip { bool useStyleCallTip; // if true, STYLE_CALLTIP should be used bool above; // if true, display calltip above text - // Private so CallTip objects can not be copied - CallTip(const CallTip &); - CallTip &operator=(const CallTip &); void DrawChunk(Surface *surface, int &x, const char *s, int posStart, int posEnd, int ytext, PRectangle rcClient, bool highlight, bool draw); @@ -56,6 +53,9 @@ public: int verticalOffset; // pixel offset up or down of the calltip with respect to the line CallTip(); + // Deleted so CallTip objects can not be copied + CallTip(const CallTip &) = delete; + CallTip &operator=(const CallTip &) = delete; ~CallTip(); void PaintCT(Surface *surfaceWindow); diff --git a/src/CellBuffer.h b/src/CellBuffer.h index f0b77e162..c073d5e5e 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -83,11 +83,10 @@ class UndoHistory { void EnsureUndoRoom(); - // Private so UndoHistory objects can not be copied - UndoHistory(const UndoHistory &); - public: UndoHistory(); + // Deleted so UndoHistory objects can not be copied + UndoHistory(const UndoHistory &) = delete; ~UndoHistory(); const char *AppendAction(actionType at, Sci::Position position, const char *data, Sci::Position lengthData, bool &startSequence, bool mayCoalesce=true); diff --git a/src/EditModel.h b/src/EditModel.h index b67eadd3f..e8b031a65 100644 --- a/src/EditModel.h +++ b/src/EditModel.h @@ -24,10 +24,6 @@ public: }; class EditModel { - // Private so EditModel objects can not be copied - explicit EditModel(const EditModel &); - EditModel &operator=(const EditModel &); - public: bool inOverstrike; int xOffset; ///< Horizontal scrolled amount in pixels @@ -57,6 +53,9 @@ public: Document *pdoc; EditModel(); + // Deleted so EditModel objects can not be copied + explicit EditModel(const EditModel &) = delete; + EditModel &operator=(const EditModel &) = delete; virtual ~EditModel(); virtual Sci::Line TopLineOfMain() const = 0; virtual Point GetVisibleOriginInMain() const = 0; diff --git a/src/Editor.h b/src/Editor.h index 976d538ab..4e5e56f5b 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -150,10 +150,6 @@ struct WrapPending { /** */ class Editor : public EditModel, public DocWatcher { - // Private so Editor objects can not be copied - explicit Editor(const Editor &); - Editor &operator=(const Editor &); - protected: // ScintillaBase subclass needs access to much of Editor /** On GTK+, Scintilla is a container widget holding two scroll bars @@ -261,6 +257,9 @@ protected: // ScintillaBase subclass needs access to much of Editor bool convertPastes; Editor(); + // Deleted so Editor objects can not be copied + explicit Editor(const Editor &) = delete; + Editor &operator=(const Editor &) = delete; ~Editor() override; virtual void Initialise() = 0; virtual void Finalise(); diff --git a/src/PositionCache.h b/src/PositionCache.h index 56018c141..f97374cef 100644 --- a/src/PositionCache.h +++ b/src/PositionCache.h @@ -186,8 +186,6 @@ class BreakFinder { EncodingFamily encodingFamily; const SpecialRepresentations *preprs; void Insert(int val); - // Private so BreakFinder objects can not be copied - BreakFinder(const BreakFinder &); public: // If a whole run is longer than lengthStartSubdivision then subdivide // into smaller runs at spaces or punctuation. @@ -196,6 +194,8 @@ public: enum { lengthEachSubdivision = 100 }; BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart_, int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw); + // Deleted so BreakFinder objects can not be copied + BreakFinder(const BreakFinder &) = delete; ~BreakFinder(); TextSegment Next(); bool More() const; @@ -205,10 +205,10 @@ class PositionCache { std::vector<PositionCacheEntry> pces; unsigned int clock; bool allClear; - // Private so PositionCache objects can not be copied - PositionCache(const PositionCache &); public: PositionCache(); + // Deleted so PositionCache objects can not be copied + PositionCache(const PositionCache &) = delete; ~PositionCache(); void Clear(); void SetSize(size_t size_); diff --git a/src/RunStyles.h b/src/RunStyles.h index b096ad800..7c5d85ee2 100644 --- a/src/RunStyles.h +++ b/src/RunStyles.h @@ -23,10 +23,10 @@ private: void RemoveRun(int run); void RemoveRunIfEmpty(int run); void RemoveRunIfSameAsPrevious(int run); - // Private so RunStyles objects can not be copied - RunStyles(const RunStyles &); public: RunStyles(); + // Deleted so RunStyles objects can not be copied + RunStyles(const RunStyles &) = delete; ~RunStyles(); int Length() const; int ValueAt(int position) const; diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h index bf14d3354..2d104b531 100644 --- a/src/ScintillaBase.h +++ b/src/ScintillaBase.h @@ -19,10 +19,6 @@ class LexState; /** */ class ScintillaBase : public Editor { - // Private so ScintillaBase objects can not be copied - explicit ScintillaBase(const ScintillaBase &); - ScintillaBase &operator=(const ScintillaBase &); - protected: /** Enumeration of commands and child windows. */ enum { @@ -58,6 +54,9 @@ protected: #endif ScintillaBase(); + // Deleted so ScintillaBase objects can not be copied + explicit ScintillaBase(const ScintillaBase &) = delete; + ScintillaBase &operator=(const ScintillaBase &) = delete; virtual ~ScintillaBase(); void Initialise() override {} void Finalise() override; diff --git a/src/SparseVector.h b/src/SparseVector.h index 20fa56cca..c81170c4b 100644 --- a/src/SparseVector.h +++ b/src/SparseVector.h @@ -19,8 +19,8 @@ class SparseVector { private: Partitioning *starts; SplitVector<T> *values; - // Private so SparseVector objects can not be copied - SparseVector(const SparseVector &); + // Deleted so SparseVector objects can not be copied + SparseVector(const SparseVector &) = delete; void ClearValue(int partition) { values->SetValueAt(partition, T()); } diff --git a/src/Style.h b/src/Style.h index adf5010c7..c0696a770 100644 --- a/src/Style.h +++ b/src/Style.h @@ -33,10 +33,10 @@ struct FontSpecification { // Just like Font but only has a copy of the FontID so should not delete it class FontAlias : public Font { - // FontAlias objects can not be assigned except for initialization - FontAlias &operator=(const FontAlias &) = delete; public: FontAlias(); + // FontAlias objects can not be assigned except for initialization + FontAlias &operator=(const FontAlias &) = delete; FontAlias(const FontAlias &); virtual ~FontAlias(); void MakeAlias(Font &fontOrigin); diff --git a/src/ViewStyle.h b/src/ViewStyle.h index f08fb777a..95e1ffc2c 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -30,24 +30,23 @@ public: class FontNames { private: std::vector<const char *> names; - +public: + FontNames(); // FontNames objects can not be copied FontNames(const FontNames &) = delete; FontNames &operator=(const FontNames &) = delete; -public: - FontNames(); ~FontNames(); void Clear(); const char *Save(const char *name); }; class FontRealised : public FontMeasurements { - // FontRealised objects can not be copied - FontRealised(const FontRealised &) = delete; - FontRealised &operator=(const FontRealised &) = delete; public: Font font; FontRealised(); + // FontRealised objects can not be copied + FontRealised(const FontRealised &) = delete; + FontRealised &operator=(const FontRealised &) = delete; virtual ~FontRealised(); void Realise(Surface &surface, int zoomLevel, int technology, const FontSpecification &fs); }; @@ -177,6 +176,8 @@ public: ViewStyle(); ViewStyle(const ViewStyle &source); + // Can only be copied through copy constructor which ensures font names initialised correctly + ViewStyle &operator=(const ViewStyle &) = delete; ~ViewStyle(); void CalculateMarginWidthAndMask(); void Init(size_t stylesSize_=256); @@ -212,8 +213,6 @@ private: void CreateAndAddFont(const FontSpecification &fs); FontRealised *Find(const FontSpecification &fs); void FindMaxAscentDescent(); - // Can only be copied through copy constructor which ensures font names initialised correctly - ViewStyle &operator=(const ViewStyle &) = delete; }; #ifdef SCI_NAMESPACE @@ -43,9 +43,6 @@ private: * A translucent image stored as a sequence of RGBA bytes. */ class RGBAImage { - // Deleted so RGBAImage objects can not be copied - RGBAImage(const RGBAImage &) = delete; - RGBAImage &operator=(const RGBAImage &) = delete; int height; int width; float scale; @@ -53,6 +50,9 @@ class RGBAImage { public: RGBAImage(int width_, int height_, float scale_, const unsigned char *pixels_); explicit RGBAImage(const XPM &xpm); + // Deleted so RGBAImage objects can not be copied + RGBAImage(const RGBAImage &) = delete; + RGBAImage &operator=(const RGBAImage &) = delete; virtual ~RGBAImage(); int GetHeight() const { return height; } int GetWidth() const { return width; } diff --git a/test/unit/testCharClassify.cxx b/test/unit/testCharClassify.cxx index 5a66ff80f..b682d8b2d 100644 --- a/test/unit/testCharClassify.cxx +++ b/test/unit/testCharClassify.cxx @@ -14,8 +14,8 @@ // Test CharClassify. class CharClassifyTest { - // Avoid warnings, private so never called. - CharClassifyTest(const CharClassifyTest &); + // Avoid warnings, deleted so never called. + CharClassifyTest(const CharClassifyTest &) = delete; protected: CharClassifyTest() { pcc = new CharClassify(); diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 3b45e5e4b..75d981def 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -457,9 +457,6 @@ void Font::Release() { template<typename T, int lengthStandard> class VarBuffer { T bufferStandard[lengthStandard]; - // Private so VarBuffer objects can not be copied - VarBuffer(const VarBuffer &); - VarBuffer &operator=(const VarBuffer &); public: T *buffer; explicit VarBuffer(size_t length) : buffer(0) { @@ -469,6 +466,9 @@ public: buffer = bufferStandard; } } + // Deleted so VarBuffer objects can not be copied + VarBuffer(const VarBuffer &) = delete; + VarBuffer &operator=(const VarBuffer &) = delete; ~VarBuffer() { if (buffer != bufferStandard) { delete []buffer; @@ -513,11 +513,11 @@ class SurfaceGDI : public Surface { void BrushColor(ColourDesired back); void SetFont(Font &font_); - // Private so SurfaceGDI objects can not be copied - SurfaceGDI(const SurfaceGDI &); - SurfaceGDI &operator=(const SurfaceGDI &); public: SurfaceGDI(); + // Deleted so SurfaceGDI objects can not be copied + SurfaceGDI(const SurfaceGDI &) = delete; + SurfaceGDI &operator=(const SurfaceGDI &) = delete; ~SurfaceGDI() override; void Init(WindowID wid) override; @@ -1071,11 +1071,11 @@ class SurfaceD2D : public Surface { void SetFont(Font &font_); - // Private so SurfaceD2D objects can not be copied - SurfaceD2D(const SurfaceD2D &); - SurfaceD2D &operator=(const SurfaceD2D &); public: SurfaceD2D(); + // Deleted so SurfaceD2D objects can not be copied + SurfaceD2D(const SurfaceD2D &) = delete; + SurfaceD2D &operator=(const SurfaceD2D &) = delete; virtual ~SurfaceD2D() override; void SetScale(); |