Mercurial > hg > octave-nkf
changeset 12244:0db2f792972e release-3-4-x
eliminate some -Weffc++ warnings
author | Pascal Dupuis <Pascal.Dupuis@uclouvain.be> |
---|---|
date | Wed, 26 Jan 2011 05:20:33 -0500 |
parents | 02d4a18617e3 |
children | 8b3d4d791988 |
files | src/ChangeLog src/gl-render.cc src/graphics.cc src/graphics.h.in |
diffstat | 4 files changed, 97 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,24 @@ +2011-01-26 John W. Eaton <jwe@octave.org> + +2011-01-26 Pascal Dupuis <Pascal.Dupuis@worldonline.be> + John W. Eaton <jwe@octave.org> + + * graphics.h.in (scaler::scaler (const std::string&)): New constructor. + (graphics_handle::operator++, graphics_hanlde::operator--): + Implement as recommended by Effective C++. + + * graphics.h.in (class base_property, class array_property, + class children_property, class property, class graphics_xform, + class graphics_event): Explicitelly iniatialize + all data members in constructor initialisation list. + * gl-render.cc (class patch_tesselator): Likewise + * graphics.cc (class radio_values, class gh_manager), + (class callback_event, class set_event): Likewise. + + * graphics.h.in (class base_graphics_property): Disallow copying. + * graphics.cc (class function_event): Likewise. + (function_event::function_event (void)): Delete implementation. + 2011-01-25 Rik <octave@nomad.inbox5.com> * DLD-FUNCTIONS/config-module.awk: Use automake variable for
--- a/src/gl-render.cc +++ b/src/gl-render.cc @@ -416,7 +416,8 @@ patch_tesselator (opengl_renderer *r, int cmode, int lmode, int idx = 0) : opengl_tesselator (), renderer (r), color_mode (cmode), light_mode (lmode), index (idx), - first (true) { } + first (true), tmp_vdata () + { } protected: void begin (GLenum type)
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -803,6 +803,7 @@ } radio_values::radio_values (const std::string& opt_string) + : default_val (), possible_vals () { size_t beg = 0; size_t len = opt_string.length (); @@ -5518,7 +5519,8 @@ // scalar values for the first argument. gh_manager::gh_manager (void) : handle_map (), handle_free_list (), - next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0)) + next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0)), + figure_list (), graphics_lock (), event_queue (), callback_objects () { handle_map[0] = graphics_object (new root_figure ()); @@ -5613,7 +5615,9 @@ private: callback_event (void) - : base_graphics_event () { } + : base_graphics_event (), handle (), + callback_name (), callback_data () + { } private: graphics_handle handle; @@ -5635,12 +5639,19 @@ } private: - function_event (void) - : base_graphics_event () { } - -private: + graphics_event::event_fcn function; + void* function_data; + + // function_event objects must be created with at least a function. + function_event (void); + + // No copying! + + function_event (const function_event &); + + function_event & operator = (const function_event &); }; class @@ -5661,7 +5672,10 @@ private: set_event (void) - : base_graphics_event () { } + : base_graphics_event (), + // FIXME: it it private in order not to be used ? + handle (), property_name (), property_value () + { } private: graphics_handle handle;
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -83,30 +83,32 @@ return ok () ? octave_value (val) : octave_value (Matrix ()); } - graphics_handle operator ++ (void) + // Prefix increment/decrement operators. + graphics_handle& operator ++ (void) { ++val; return *this; } - graphics_handle operator ++ (int) - { - graphics_handle h = *this; - ++val; - return h; - } - - graphics_handle operator -- (void) + graphics_handle& operator -- (void) { --val; return *this; } - graphics_handle operator -- (int) + // Postfix increment/decrement operators. + const graphics_handle operator ++ (int) { - graphics_handle h = *this; - --val; - return h; + graphics_handle old_value = *this; + ++(*this); + return old_value; + } + + const graphics_handle operator -- (int) + { + graphics_handle old_value = *this; + --(*this); + return old_value; } bool ok (void) const { return ! xisnan (val); } @@ -254,6 +256,12 @@ scaler (const scaler& s) : rep (s.rep->clone()) { } + scaler (const std::string& s) + : rep (s == "log" + ? new log_scaler () + : (s == "linear" ? new lin_scaler () : new base_scaler ())) + { } + ~scaler (void) { delete rep; } Matrix scale (const Matrix& m) const @@ -318,13 +326,18 @@ friend class property; public: - base_property (void) : id (-1), count (1) { } + base_property (void) + : id (-1), count (1), name (), parent (), hidden (), listeners () + { } base_property (const std::string& s, const graphics_handle& h) - : id (-1), count (1), name (s), parent (h), hidden (false) { } + : id (-1), count (1), name (s), parent (h), hidden (false), listeners () + { } base_property (const base_property& p) - : id (-1), count (1), name (p.name), parent (p.parent), hidden (p.hidden) { } + : id (-1), count (1), name (p.name), parent (p.parent), + hidden (p.hidden), listeners () + { } virtual ~base_property (void) { } @@ -498,7 +511,7 @@ string_array_property (const std::string& s, const graphics_handle& h, const std::string& val = "", const char& sep = '|', const desired_enum& typ = string_t) - : base_property (s, h), desired_type (typ), separator (sep) + : base_property (s, h), desired_type (typ), separator (sep), str () { size_t pos = 0; @@ -521,7 +534,7 @@ string_array_property (const std::string& s, const graphics_handle& h, const Cell& c, const char& sep = '|', const desired_enum& typ = string_t) - : base_property (s, h), desired_type (typ), separator (sep) + : base_property (s, h), desired_type (typ), separator (sep), str () { if (c.is_cellstr ()) { @@ -1081,14 +1094,17 @@ { public: array_property (void) - : base_property ("", graphics_handle ()), data (Matrix ()) + : base_property ("", graphics_handle ()), data (Matrix ()), + xmin (), xmax (), xminp (), type_constraints (), size_constraints () { get_data_limits (); } array_property (const std::string& nm, const graphics_handle& h, const octave_value& m) - : base_property (nm, h), data (m) + : base_property (nm, h), data (m), + xmin (), xmax (), xminp (), type_constraints (), size_constraints () + { get_data_limits (); } @@ -1098,7 +1114,9 @@ // copy constraints. array_property (const array_property& p) : base_property (p), data (p.data), - xmin (p.xmin), xmax (p.xmax), xminp (p.xminp) { } + xmin (p.xmin), xmax (p.xmax), xminp (p.xminp), + type_constraints (), size_constraints () + { } octave_value get (void) const { return data; } @@ -1373,20 +1391,20 @@ { public: children_property (void) - : base_property ("", graphics_handle ()) + : base_property ("", graphics_handle ()), children_list () { do_init_children (Matrix ()); } children_property (const std::string& nm, const graphics_handle& h, const Matrix &val) - : base_property (nm, h) + : base_property (nm, h), children_list () { do_init_children (val); } children_property (const children_property& p) - : base_property (p) + : base_property (p), children_list () { do_init_children (p.children_list); } @@ -1604,9 +1622,8 @@ property (base_property *bp, bool persist = false) : rep (bp) { if (persist) rep->count++; } - property (const property& p) + property (const property& p) : rep (p.rep) { - rep = p.rep; rep->count++; } @@ -2188,8 +2205,6 @@ base_graphics_object (void) : count (1) { } - base_graphics_object (const base_graphics_object&) { } - virtual ~base_graphics_object (void) { } virtual void mark_modified (void) @@ -2403,6 +2418,12 @@ protected: // A reference count. int count; + + // No copying! + + base_graphics_object (const base_graphics_object&); + + base_graphics_object& operator = (const base_graphics_object&); }; class OCTINTERP_API graphics_object @@ -2413,9 +2434,8 @@ graphics_object (base_graphics_object *new_rep) : rep (new_rep) { } - graphics_object (const graphics_object& obj) + graphics_object (const graphics_object& obj) : rep (obj.rep) { - rep = obj.rep; rep->count++; } @@ -2958,9 +2978,9 @@ { public: graphics_xform (void) - : xform (xform_eye ()), xform_inv (xform_eye ()), zlim (1, 2, 0.0) + : xform (xform_eye ()), xform_inv (xform_eye ()), + sx ("linear"), sy ("linear"), sz ("linear"), zlim (1, 2, 0.0) { - sx = sy = sz = "linear"; zlim(1) = 1.0; } @@ -4204,9 +4224,8 @@ graphics_event (void) : rep (0) { } - graphics_event (const graphics_event& e) + graphics_event (const graphics_event& e) : rep (e.rep) { - rep = e.rep; rep->count++; }