[pangomm] Use std::vector instead of Glib::ArrayHandle<>.



commit cfac3b9f9126a0e9f29d76df43ff6c23916b02e8
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Mar 17 13:29:29 2017 +0100

    Use std::vector instead of Glib::ArrayHandle<>.
    
    Using Glib::ArrayHandler<>::array_to_vector() and
    Glib::ArrayHandler<>::vector_to_array() instead, and only in the
    implementation instead of in the API.

 pango/src/context.ccg     |    4 ++--
 pango/src/context.hg      |    4 +---
 pango/src/coverage.ccg    |    4 ++--
 pango/src/coverage.hg     |    3 +--
 pango/src/fontface.ccg    |    4 ++--
 pango/src/fontface.hg     |    3 +--
 pango/src/fontfamily.ccg  |    4 ++--
 pango/src/fontfamily.hg   |    3 +--
 pango/src/fontmap.ccg     |    4 ++--
 pango/src/fontmap.hg      |    3 +--
 pango/src/glyphstring.ccg |    8 ++++----
 pango/src/glyphstring.hg  |    4 ++--
 pango/src/language.ccg    |    4 ++--
 pango/src/language.hg     |    3 +--
 pango/src/layout.ccg      |    4 ++--
 pango/src/layout.hg       |    2 +-
 pango/src/layoutline.ccg  |    5 +++--
 pango/src/layoutline.hg   |    3 +--
 pango/src/tabarray.ccg    |    4 ++--
 pango/src/tabarray.hg     |    4 ++--
 20 files changed, 35 insertions(+), 42 deletions(-)
---
diff --git a/pango/src/context.ccg b/pango/src/context.ccg
index 57f7ddd..6650cd0 100644
--- a/pango/src/context.ccg
+++ b/pango/src/context.ccg
@@ -27,14 +27,14 @@
 namespace Pango
 {
 
-Glib::ArrayHandle< Glib::RefPtr<FontFamily> > Context::list_families() const
+std::vector<Glib::RefPtr<FontFamily>> Context::list_families() const
 {
   //Get array:
   PangoFontFamily** pFamilies = nullptr;
   int n_families = 0;
   pango_context_list_families(const_cast<PangoContext*>(gobj()), &pFamilies, &n_families);
   
-  return Glib::ArrayHandle< Glib::RefPtr<FontFamily> >
+  return Glib::ArrayHandler<Glib::RefPtr<FontFamily>>::array_to_vector
       (pFamilies, n_families, Glib::OWNERSHIP_SHALLOW);
 }
 
diff --git a/pango/src/context.hg b/pango/src/context.hg
index d64eb48..ae1d6c3 100644
--- a/pango/src/context.hg
+++ b/pango/src/context.hg
@@ -21,8 +21,6 @@
 
 
 #include <glibmm/object.h>
-#include <glibmm/arrayhandle.h>
-#include <glibmm/listhandle.h>
 #include <pangomm/fontdescription.h>
 #include <pangomm/fontmetrics.h>
 #include <pangomm/fontset.h>
@@ -85,7 +83,7 @@ public:
    * objects you use, e.g. in the default font description of the context.
    * @return An array of Pango::FontFamily objects.
    */
-  Glib::ArrayHandle< Glib::RefPtr<FontFamily> > list_families() const;
+  std::vector<Glib::RefPtr<FontFamily>> list_families() const;
   
   _IGNORE(pango_context_changed)
 
diff --git a/pango/src/coverage.ccg b/pango/src/coverage.ccg
index bd42fbe..a205e2a 100644
--- a/pango/src/coverage.ccg
+++ b/pango/src/coverage.ccg
@@ -24,12 +24,12 @@
 namespace Pango
 {
 
-Glib::ArrayHandle<unsigned char> Coverage::to_bytes() const
+std::vector<unsigned char> Coverage::to_bytes() const
 {
   guchar* bytes = nullptr;
   int n_bytes = 0;
   pango_coverage_to_bytes(const_cast<PangoCoverage*>(gobj()), &bytes, &n_bytes);
-  return Glib::ArrayHandle<unsigned char>(bytes, n_bytes, Glib::OWNERSHIP_SHALLOW);
+  return Glib::ArrayHandler<unsigned char>::array_to_vector(bytes, n_bytes, Glib::OWNERSHIP_SHALLOW);
 }
 
 } /* namespace Pango */
diff --git a/pango/src/coverage.hg b/pango/src/coverage.hg
index 747e8e6..9782e21 100644
--- a/pango/src/coverage.hg
+++ b/pango/src/coverage.hg
@@ -19,7 +19,6 @@
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <glibmm/arrayhandle.h>
 #include <pango/pango-font.h>
 
 _DEFS(pangomm,pango)
@@ -54,7 +53,7 @@ public:
   /** Convert the coverage map into a flat binary format.
    * @return An array of bytes representing the coverage map.
    */
-  Glib::ArrayHandle<unsigned char> to_bytes() const;
+  std::vector<unsigned char> to_bytes() const;
 };
 
 } // namespace Pango
diff --git a/pango/src/fontface.ccg b/pango/src/fontface.ccg
index fd5c436..5e70276 100644
--- a/pango/src/fontface.ccg
+++ b/pango/src/fontface.ccg
@@ -23,13 +23,13 @@
 namespace Pango
 {
 
-Glib::ArrayHandle<int> FontFace::list_sizes() const
+std::vector<int> FontFace::list_sizes() const
 {
   int* sizes = nullptr;
   int n_sizes = 0;
   pango_font_face_list_sizes(const_cast<PangoFontFace*>(gobj()), &sizes, &n_sizes);
 
-  return Glib::ArrayHandle<int>(sizes, n_sizes, Glib::OWNERSHIP_SHALLOW); //The ArrayHandle will free the 
array.
+  return Glib::ArrayHandler<int>::array_to_vector(sizes, n_sizes, Glib::OWNERSHIP_SHALLOW); //The 
ArrayHandle will free the array.
 }
 
 } //namespace Pango
diff --git a/pango/src/fontface.hg b/pango/src/fontface.hg
index e52340b..ebe6925 100644
--- a/pango/src/fontface.hg
+++ b/pango/src/fontface.hg
@@ -22,7 +22,6 @@
 
 #include <pangomm/fontdescription.h>
 #include <glibmm/object.h>
-#include <glibmm/arrayhandle.h>
 #include <pango/pango-font.h>
 
 _DEFS(pangomm,pango)
@@ -45,7 +44,7 @@ public:
    * For scalable fonts this returns an empty array. 
    * The sizes returned are in Pango units and are sorted in ascending order.
    */
-  Glib::ArrayHandle<int> list_sizes() const;
+  std::vector<int> list_sizes() const;
   _IGNORE(pango_font_face_list_sizes)
 
   _WRAP_METHOD(bool is_synthesized() const, pango_font_face_is_synthesized)
diff --git a/pango/src/fontfamily.ccg b/pango/src/fontfamily.ccg
index 4bb7b06..2c68b1f 100644
--- a/pango/src/fontfamily.ccg
+++ b/pango/src/fontfamily.ccg
@@ -23,14 +23,14 @@
 namespace Pango
 {
 
-Glib::ArrayHandle< Glib::RefPtr<FontFace> > FontFamily::list_faces() const
+std::vector<Glib::RefPtr<FontFace>> FontFamily::list_faces() const
 {
   //Get the array:
   PangoFontFace** pFontFaces = nullptr;
   int n_fonts = 0;
   pango_font_family_list_faces(const_cast<PangoFontFamily*>(gobj()), &pFontFaces, &n_fonts);
 
-  return Glib::ArrayHandle<Glib::RefPtr <FontFace> > (pFontFaces, n_fonts, Glib::OWNERSHIP_SHALLOW);
+  return Glib::ArrayHandler<Glib::RefPtr<FontFace>>::array_to_vector(pFontFaces, n_fonts, 
Glib::OWNERSHIP_SHALLOW);
 }
 
 } /* namespace Pango */
diff --git a/pango/src/fontfamily.hg b/pango/src/fontfamily.hg
index c428a5f..91d68ea 100644
--- a/pango/src/fontfamily.hg
+++ b/pango/src/fontfamily.hg
@@ -21,7 +21,6 @@
 
 
 #include <glibmm/object.h>
-#include <glibmm/arrayhandle.h>
 #include <pangomm/fontface.h>
 #include <pango/pango-font.h>
 
@@ -44,7 +43,7 @@ public:
    * The faces in a family share a common design, but differ in slant, weight, width and other aspects.
    * @return an array of pointers to Pango::FontFace objects.
    */
-  Glib::ArrayHandle< Glib::RefPtr<FontFace> > list_faces() const;
+  std::vector<Glib::RefPtr<FontFace>> list_faces() const;
 
   _WRAP_METHOD(Glib::ustring get_name() const, pango_font_family_get_name)
   _WRAP_METHOD(bool is_monospace() const, pango_font_family_is_monospace)
diff --git a/pango/src/fontmap.ccg b/pango/src/fontmap.ccg
index 0fedf36..65ce514 100644
--- a/pango/src/fontmap.ccg
+++ b/pango/src/fontmap.ccg
@@ -26,14 +26,14 @@
 namespace Pango
 {
 
-Glib::ArrayHandle< Glib::RefPtr<FontFamily> > FontMap::list_families() const
+std::vector<Glib::RefPtr<FontFamily>> FontMap::list_families() const
 {
   //Get the array:
   PangoFontFamily** pFamilies = nullptr;
   int n_families = 0;
   pango_font_map_list_families(const_cast<PangoFontMap*>(gobj()), &pFamilies, &n_families);
 
-  return Glib::ArrayHandle< Glib::RefPtr<FontFamily> >
+  return Glib::ArrayHandler<Glib::RefPtr<FontFamily>>::array_to_vector
       (pFamilies, n_families, Glib::OWNERSHIP_SHALLOW);
 }
 
diff --git a/pango/src/fontmap.hg b/pango/src/fontmap.hg
index 2234661..e73b7e6 100644
--- a/pango/src/fontmap.hg
+++ b/pango/src/fontmap.hg
@@ -21,7 +21,6 @@
 
 
 #include <glibmm/object.h>
-#include <glibmm/arrayhandle.h>
 #include <pangomm/font.h>
 #include <pangomm/fontset.h>
 #include <pangomm/fontfamily.h>
@@ -51,7 +50,7 @@ public:
   /** List all families for the fontmap.
    * @return an array of pointers to Pango::FontFamily objects.
    */
-  Glib::ArrayHandle< Glib::RefPtr<FontFamily> > list_families() const;
+  std::vector<Glib::RefPtr<FontFamily>> list_families() const;
 
   _WRAP_METHOD(guint get_serial() const, pango_font_map_get_serial)
 
diff --git a/pango/src/glyphstring.ccg b/pango/src/glyphstring.ccg
index 7a17e86..9b055f9 100644
--- a/pango/src/glyphstring.ccg
+++ b/pango/src/glyphstring.ccg
@@ -61,11 +61,11 @@ Rectangle GlyphString::get_logical_extents(int start, int end, const Glib::RefPt
   return logical_rect;
 }
 
-Glib::ArrayHandle<int> GlyphString::get_logical_widths(const Glib::ustring& text, int embedding_level) const
+std::vector<int> GlyphString::get_logical_widths(const Glib::ustring& text, int embedding_level) const
 {
   int* logical_widths = g_new(int, text.length());
   pango_glyph_string_get_logical_widths(const_cast<PangoGlyphString*>(gobj()), text.c_str(), text.bytes(), 
embedding_level, logical_widths);
-  return Glib::ArrayHandle<int>(logical_widths, text.length(), Glib::OWNERSHIP_SHALLOW);
+  return Glib::ArrayHandler<int>::array_to_vector(logical_widths, text.length(), Glib::OWNERSHIP_SHALLOW);
 }
 
 int GlyphString::index_to_x(const Glib::ustring& text, const Analysis& analysis, int index, bool trailing) 
const
@@ -82,9 +82,9 @@ void GlyphString::x_to_index(const Glib::ustring& text, const Analysis& analysis
   trailing = trailing_temp;
 }
 
-Glib::ArrayHandle<GlyphInfo> GlyphString::get_glyphs() const
+std::vector<GlyphInfo> GlyphString::get_glyphs() const
 {
-  return Glib::ArrayHandle<GlyphInfo>(reinterpret_cast<GlyphInfo*>(gobj()->glyphs), gobj()->num_glyphs, 
Glib::OWNERSHIP_NONE);
+  return Glib::ArrayHandler<GlyphInfo>::array_to_vector(reinterpret_cast<GlyphInfo*>(gobj()->glyphs), 
gobj()->num_glyphs, Glib::OWNERSHIP_NONE);
 }
 
 } //namespace Pango
diff --git a/pango/src/glyphstring.hg b/pango/src/glyphstring.hg
index ee72699..9cdd149 100644
--- a/pango/src/glyphstring.hg
+++ b/pango/src/glyphstring.hg
@@ -92,7 +92,7 @@ public:
    * @param embedding_level The embedding level of the string.
    * @return An array of integers representing the resulting character widths.
    */
-  Glib::ArrayHandle<int> get_logical_widths(const Glib::ustring& text, int embedding_level) const;
+  std::vector<int> get_logical_widths(const Glib::ustring& text, int embedding_level) const;
 
   /** Converts from character position to x position.
    * (X position is measured from the left edge of the run). Character positions are computed by dividing up 
each cluster into equal portions.
@@ -120,7 +120,7 @@ public:
   /** Gharacter positions are computed by dividing up each cluster into equal portions.
    * @return An array of Pango::GlyphInfo objects.
    */
-  Glib::ArrayHandle<GlyphInfo> get_glyphs() const;
+  std::vector<GlyphInfo> get_glyphs() const;
 
   //TODO: 
   //void        pango_cairo_glyph_string_path   (cairo_t *cr,
diff --git a/pango/src/language.ccg b/pango/src/language.ccg
index 5e443fe..8ef2034 100644
--- a/pango/src/language.ccg
+++ b/pango/src/language.ccg
@@ -62,11 +62,11 @@ Glib::ustring Language::get_string() const
     return Glib::ustring();
 }
 
-Glib::ArrayHandle<Script> Language::get_scripts() const
+std::vector<Script> Language::get_scripts() const
 {
   int num_scripts = 0;
   const auto* carray = pango_language_get_scripts(const_cast<PangoLanguage*>(gobj()), &num_scripts);
-  return Glib::ArrayHandle<Script>((const Script*)carray, num_scripts, Glib::OWNERSHIP_NONE);
+  return Glib::ArrayHandler<Script>::array_to_vector((const Script*)carray, num_scripts, 
Glib::OWNERSHIP_NONE);
 }
 
 
diff --git a/pango/src/language.hg b/pango/src/language.hg
index cf3d180..8b07c60 100644
--- a/pango/src/language.hg
+++ b/pango/src/language.hg
@@ -16,7 +16,6 @@
  */
 
 #include <glibmm/value.h>
-#include <glibmm/arrayhandle.h>
 #include <pango/pango-attributes.h>
 
 _DEFS(pangomm,pango)
@@ -70,7 +69,7 @@ public:
    *
    * @newin{2,14}
    */
-  Glib::ArrayHandle<Script> get_scripts() const;
+  std::vector<Script> get_scripts() const;
   _IGNORE(pango_language_get_scripts)
 };
 
diff --git a/pango/src/layout.ccg b/pango/src/layout.ccg
index e2f2153..d07f157 100644
--- a/pango/src/layout.ccg
+++ b/pango/src/layout.ccg
@@ -74,14 +74,14 @@ void Layout::set_markup(const Glib::ustring& markup, gunichar accel_marker, guni
   return pango_layout_set_markup_with_accel(gobj(), markup.c_str(), markup.bytes(), accel_marker, 
&accel_char);
 }
 
-Glib::ArrayHandle<PangoLogAttr> Layout::get_log_attrs() const
+std::vector<PangoLogAttr> Layout::get_log_attrs() const
 {
   //Get array:
   PangoLogAttr* pAttrs = nullptr;
   int n_attrs = 0;
   pango_layout_get_log_attrs(const_cast<PangoLayout*>(gobj()), &pAttrs, &n_attrs);
 
-  return Glib::ArrayHandle<PangoLogAttr>(pAttrs, n_attrs, Glib::OWNERSHIP_SHALLOW);
+  return Glib::ArrayHandler<PangoLogAttr>::array_to_vector(pAttrs, n_attrs, Glib::OWNERSHIP_SHALLOW);
 }
 
 Rectangle Layout::index_to_pos(int index) const
diff --git a/pango/src/layout.hg b/pango/src/layout.hg
index 5eaf919..4274f87 100644
--- a/pango/src/layout.hg
+++ b/pango/src/layout.hg
@@ -163,7 +163,7 @@ public:
   /** Retrieve an array of logical attributes for each character in the layout.
    * @return An array of logical attributes.
    */
-  Glib::ArrayHandle<LogAttr> get_log_attrs() const;
+  std::vector<LogAttr> get_log_attrs() const;
 
   /** Convert from an index within the layout to the onscreen position corresponding to the grapheme at that 
index, which is represented as rectangle.
    * Note that @a x in the returned rectangle is always the leading edge of the grapheme
diff --git a/pango/src/layoutline.ccg b/pango/src/layoutline.ccg
index 1ed387b..60c32b6 100644
--- a/pango/src/layoutline.ccg
+++ b/pango/src/layoutline.ccg
@@ -60,12 +60,13 @@ int LayoutLine::index_to_x(int index, bool trailing) const
   return x_pos;
 }
 
-Glib::ArrayHandle<std::pair<int,int> > LayoutLine::get_x_ranges(int start_index, int end_index) const
+std::vector<std::pair<int,int> > LayoutLine::get_x_ranges(int start_index, int end_index) const
 {
+  //TODO: This reinterpret_cast<> is scary. There should at least be a comment explaining it.
   int* ranges = nullptr;
   int n_ranges = 0;
   pango_layout_line_get_x_ranges(const_cast<PangoLayoutLine*>(gobj()), start_index, end_index, &ranges, 
&n_ranges);
-  return Glib::ArrayHandle<std::pair<int,int> >(reinterpret_cast<std::pair<int,int>*>(ranges), n_ranges, 
Glib::OWNERSHIP_SHALLOW);
+  return 
Glib::ArrayHandler<std::pair<int,int>>::array_to_vector(reinterpret_cast<std::pair<int,int>*>(ranges), 
n_ranges, Glib::OWNERSHIP_SHALLOW);
 }
 
 void LayoutLine::show_in_cairo_context(const Cairo::RefPtr<Cairo::Context>& context)
diff --git a/pango/src/layoutline.hg b/pango/src/layoutline.hg
index 3585662..646b09d 100644
--- a/pango/src/layoutline.hg
+++ b/pango/src/layoutline.hg
@@ -21,7 +21,6 @@
 
 #include <pangomm/rectangle.h>
 #include <cairomm/context.h>
-#include <glibmm/arrayhandle.h>
 #include <pango/pango-layout.h>
 
 _DEFS(pangomm,pango)
@@ -67,7 +66,7 @@ public:
    * Otherwise, it will end at the trailing edge of the last character.
    * @return An array of ranges represented by pairs of integers marking the start and end pixel coordinates 
of the ranges.
    */
-  Glib::ArrayHandle<std::pair<int,int> > get_x_ranges(int start_index, int end_index) const;
+  std::vector<std::pair<int,int> > get_x_ranges(int start_index, int end_index) const;
 
   _WRAP_METHOD(void get_extents(Rectangle& ink_rect, Rectangle& logical_rect) const, 
pango_layout_line_get_extents)
 
diff --git a/pango/src/tabarray.ccg b/pango/src/tabarray.ccg
index bf22aa0..3dc0f1e 100644
--- a/pango/src/tabarray.ccg
+++ b/pango/src/tabarray.ccg
@@ -38,7 +38,7 @@ std::pair<TabAlign,int> TabArray::get_tab(int tab_index) const
   return std::pair<TabAlign,int>(alignment, location);
 }
 
-Glib::ArrayHandle< std::pair<TabAlign,int> > TabArray::get_tabs() const
+std::vector<std::pair<TabAlign,int>> TabArray::get_tabs() const
 {
   typedef std::pair<TabAlign,int> PairType;
 
@@ -69,7 +69,7 @@ Glib::ArrayHandle< std::pair<TabAlign,int> > TabArray::get_tabs() const
     g_free(pLocations);
   }
 
-  return Glib::ArrayHandle<PairType>(pair_buffer, size, Glib::OWNERSHIP_SHALLOW);
+  return Glib::ArrayHandler<PairType>::array_to_vector(pair_buffer, size, Glib::OWNERSHIP_SHALLOW);
 }
 
 } /* namespace Pango */
diff --git a/pango/src/tabarray.hg b/pango/src/tabarray.hg
index dc0fb88..e9b852a 100644
--- a/pango/src/tabarray.hg
+++ b/pango/src/tabarray.hg
@@ -47,12 +47,12 @@ public:
   /** Gets the alignment and position of a tab stop.
    * @return An std::pair<TabAlign, int>. The first element represents the tab stop alignment, the second 
one is the tab position.
    */
-  std::pair<TabAlign,int> get_tab(int tab_index) const;
+  std::pair<TabAlign, int> get_tab(int tab_index) const;
 
   /** Gets an array of std::pairs containing the tab stop alignments and tab positions.
    * @return An array of std::pair<TabAlign, int>. The first element in each pair represents the tab stop 
alignment, the second one is the tab position.
    */
-  Glib::ArrayHandle< std::pair<TabAlign,int> > get_tabs() const;
+  std::vector<std::pair<TabAlign, int>> get_tabs() const;
 
   _WRAP_METHOD(bool get_positions_in_pixels() const, pango_tab_array_get_positions_in_pixels)
 };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]