[pangomm] Layout::get_lines(): Use std::vector instead of Glib::SListHandle<>.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pangomm] Layout::get_lines(): Use std::vector instead of Glib::SListHandle<>.
- Date: Fri, 17 Mar 2017 12:35:18 +0000 (UTC)
commit 57d8bceba336e972a4967db6872a373eac1833b9
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Mar 17 13:20:30 2017 +0100
Layout::get_lines(): Use std::vector instead of Glib::SListHandle<>.
Using Glib::SListHandler<>::slist_to_vector() and
Glib::SListHandler<>::vector_to_slist() instead, and only in the
implementation instead of in the API.
pango/src/item.hg | 1 -
pango/src/layout.ccg | 19 +++++++++++++++++++
pango/src/layout.hg | 13 ++++++++-----
pango/src/layoutline.hg | 21 ---------------------
tools/m4/convert_pango.m4 | 4 ----
5 files changed, 27 insertions(+), 31 deletions(-)
---
diff --git a/pango/src/item.hg b/pango/src/item.hg
index 7d0893b..191ed88 100644
--- a/pango/src/item.hg
+++ b/pango/src/item.hg
@@ -17,7 +17,6 @@
#include <pangomm/attributes.h>
#include <pangomm/language.h>
-#include <glibmm/listhandle.h>
#include <pango/pango-item.h>
_DEFS(pangomm,pango)
diff --git a/pango/src/layout.ccg b/pango/src/layout.ccg
index dd99deb..e2f2153 100644
--- a/pango/src/layout.ccg
+++ b/pango/src/layout.ccg
@@ -25,6 +25,25 @@
namespace Pango
{
+namespace {
+
+struct LayoutLineTraits
+{
+ typedef Glib::RefPtr<LayoutLine> CppType;
+ typedef PangoLayoutLine * CType;
+ typedef PangoLayoutLine * CTypeNonConst;
+
+ static CType to_c_type (const CppType& ptr) { return Glib::unwrap(ptr); }
+ static CType to_c_type (CType ptr) { return ptr; }
+ static CppType to_cpp_type (CType ptr) { return Glib::wrap(ptr, true); }
+ static void release_c_type (CType ptr) { pango_layout_line_unref(ptr); }
+};
+
+using SListHandler_LayoutLine = Glib::SListHandler<Glib::RefPtr<LayoutLine>, LayoutLineTraits>;
+using SListHandler_ConstLayoutLine = Glib::SListHandler<Glib::RefPtr<const LayoutLine>, LayoutLineTraits>;
+
+} // anonymous namespace
+
Layout::Layout(const Glib::RefPtr<Context>& context)
:
Glib::Object(G_OBJECT(pango_layout_new(context->gobj())))
diff --git a/pango/src/layout.hg b/pango/src/layout.hg
index e80cc7c..5eaf919 100644
--- a/pango/src/layout.hg
+++ b/pango/src/layout.hg
@@ -227,15 +227,18 @@ public:
_WRAP_METHOD(int get_baseline() const, pango_layout_get_baseline)
_WRAP_METHOD(int get_line_count() const, pango_layout_get_line_count)
-
+
//Note that the const version uses a different (faster) C function:
_WRAP_METHOD(Glib::RefPtr<LayoutLine> get_line(int line), pango_layout_get_line, refreturn)
- _WRAP_METHOD(Glib::RefPtr<const LayoutLine> get_line(int line) const, pango_layout_get_line_readonly,
refreturn)
+ _WRAP_METHOD(Glib::RefPtr<const LayoutLine> get_line(int line) const, pango_layout_get_line_readonly,
refreturn)
+
+#m4
_CONVERSION(`GSList*',`std::vector<Glib::RefPtr<LayoutLine>>',`SListHandler_LayoutLine::slist_to_vector($3,
Glib::OWNERSHIP_SHALLOW)',)
+#m4 _CONVERSION(`GSList*',`std::vector<Glib::RefPtr<const
LayoutLine>>',`SListHandler_ConstLayoutLine::slist_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
//Note that the const version uses a different (faster) C function:
- _WRAP_METHOD(SListHandle_LayoutLine get_lines(), pango_layout_get_lines)
- _WRAP_METHOD(SListHandle_ConstLayoutLine get_lines() const, pango_layout_get_lines_readonly)
-
+ _WRAP_METHOD(std::vector<Glib::RefPtr<LayoutLine>> get_lines(), pango_layout_get_lines)
+ _WRAP_METHOD(std::vector<Glib::RefPtr<const LayoutLine>> get_lines() const,
pango_layout_get_lines_readonly)
+
_DEPRECATE_IFDEF_START
/** Gets an iterator to iterate over the visual extents of the layout.
* @param iter Location to store the iterator.
diff --git a/pango/src/layoutline.hg b/pango/src/layoutline.hg
index 770fb81..3585662 100644
--- a/pango/src/layoutline.hg
+++ b/pango/src/layoutline.hg
@@ -128,24 +128,3 @@ Glib::RefPtr<Pango::LayoutLine> wrap(PangoLayoutLine* object, bool take_copy /*
} // namespace Glib
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
-
-namespace Pango
-{
-
-struct LayoutLineTraits
-{
- typedef Glib::RefPtr<LayoutLine> CppType;
- typedef PangoLayoutLine * CType;
- typedef PangoLayoutLine * CTypeNonConst;
-
- static CType to_c_type (const CppType& ptr) { return Glib::unwrap(ptr); }
- static CType to_c_type (CType ptr) { return ptr; }
- static CppType to_cpp_type (CType ptr) { return Glib::wrap(ptr, true); }
- static void release_c_type (CType ptr) { pango_layout_line_unref(ptr); }
-};
-
-typedef Glib::SListHandle< Glib::RefPtr<LayoutLine>, LayoutLineTraits > SListHandle_LayoutLine;
-typedef Glib::SListHandle< Glib::RefPtr<const LayoutLine>, LayoutLineTraits > SListHandle_ConstLayoutLine;
-
-} // namespace Pango
-
diff --git a/tools/m4/convert_pango.m4 b/tools/m4/convert_pango.m4
index a1b72d1..6edf6d5 100644
--- a/tools/m4/convert_pango.m4
+++ b/tools/m4/convert_pango.m4
@@ -161,10 +161,6 @@ _CONVERSION(`const Matrix&',`const PangoMatrix*',`&($3)')
#_CONVERSION(`const PangoMatrix*',`Matrix',`($3) ? *($3) : PANGO_MATRIX_INIT')
#_CONVERSION(`const Matrix&',`PangoMatrix*',`const_cast<PangoMatrix*>(&($3))')
-define(`__FL2H_SHALLOW',`$`'2($`'3, Glib::OWNERSHIP_SHALLOW)')
-_CONVERSION(`GSList*',`SListHandle_LayoutLine',__FL2H_SHALLOW)
-_CONVERSION(`GSList*',`SListHandle_ConstLayoutLine',__FL2H_SHALLOW)
-
_CONVERSION(`PangoFontMap*',`Glib::RefPtr<Pango::FontMap>',`Glib::wrap($3)')
_CONVERSION(`const Cairo::FontOptions&',`const cairo_font_options_t*',`($3).cobj()')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]