Freeze break request for glibmm API



Hi Release Team,

I'd like to request a break of the API freeze for module glibmm.  The
newly added GRegex wrapper has a couple of methods which don't follow
our usual policy of implementing convenience methods as overloads,
rather than giving them different names as in the original API.  This is
the bug with patch, approved by Murray Cumming:

    http://bugzilla.gnome.org/show_bug.cgi?id=474134

Glib::Regex is completely new API and hardly used by anyone yet.  Since
it'll have to stay ABI compatible after the release I'd like to make it
as clean as possible while we can still change it.  Although existing
code (if any) would be broken by the change, porting to the revised API
amounts a trivial search/replace cycle.

The patch is attached to this mail as well as to the bug report.

Thanks for your time,
--Daniel

2007-09-06  Daniel Elstner  <danielk openismus com>

	* glib/src/regex.{ccg,hg} (Regex): Some cosmetic cleanup.  Also
	replace C-style casts in default argument values with static_cast<>.
	(escape_string): Wrap missing function.
	(match_full): Rename to and add as overloads of match().
	(match_all_full): Rename to and add as overloads of match_all().
	(split_full): Rename to and add as overloads of split().

Index: glib/src/regex.ccg
===================================================================
--- glib/src/regex.ccg	(Revision 441)
+++ glib/src/regex.ccg	(Arbeitskopie)
@@ -21,39 +21,51 @@ namespace Glib
 {
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-Glib::RefPtr<Glib::Regex> Regex::create(const Glib::ustring& pattern, RegexCompileFlags compile_options, RegexMatchFlags match_options)
+Glib::RefPtr<Glib::Regex> Regex::create(const Glib::ustring& pattern,
+                                        RegexCompileFlags compile_options,
+                                        RegexMatchFlags match_options)
 #else
-Glib::RefPtr<Glib::Regex> Regex::create(const Glib::ustring& pattern, RegexCompileFlags compile_options, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error)
-#endif //GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<Glib::Regex> Regex::create(const Glib::ustring& pattern,
+                                        RegexCompileFlags compile_options,
+                                        RegexMatchFlags match_options,
+                                        std::auto_ptr<Glib::Error>& error)
+#endif /* GLIBMM_EXCEPTIONS_ENABLED */
 {
-  GError* gerror = NULL;
-  GRegex* regex = g_regex_new(pattern.c_str(), (GRegexCompileFlags)compile_options, (GRegexMatchFlags)match_options, &gerror);
+  GError* gerror = 0;
+  GRegex* regex  = g_regex_new(pattern.c_str(), (GRegexCompileFlags)compile_options,
+                               (GRegexMatchFlags)match_options, &gerror);
 
-#ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
-    ::Glib::Error::throw_exception(gerror);
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+    Glib::Error::throw_exception(gerror);
 #else
-  if(gerror)
-    error = ::Glib::Error::throw_exception(gerror);
-#endif //GLIBMM_EXCEPTIONS_ENABLED
-
+    error = Glib::Error::throw_exception(gerror);
+#endif
   return Glib::wrap(regex);
 }
 
+// static
+Glib::ustring Regex::escape_string(const Glib::ustring& string)
+{
+  const Glib::ScopedPtr<char> buf (g_regex_escape_string(string.raw().c_str(),
+                                                         string.raw().size()));
+  return Glib::ustring(buf.get());
+}
+
 bool Regex::match(const Glib::ustring& string, RegexMatchFlags match_options)
 {
-  return g_regex_match(gobj(), string.c_str(), ((GRegexMatchFlags)(match_options)), NULL);
+  return g_regex_match(gobj(), string.c_str(), (GRegexMatchFlags)(match_options), 0);
 }
 
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-bool Regex::match_full(const Glib::ustring& string, int start_position, RegexMatchFlags match_options)
+bool Regex::match(const Glib::ustring& string, int start_position, RegexMatchFlags match_options)
 #else
-bool Regex::match_full(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error)
+bool Regex::match(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error)
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 {
   GError* gerror = 0;
-  bool retvalue = g_regex_match_full(gobj(), string.c_str(), -1, start_position, ((GRegexMatchFlags)(match_options)), NULL, &(gerror));
+  bool retvalue = g_regex_match_full(gobj(), string.c_str(), -1, start_position, ((GRegexMatchFlags)(match_options)), 0, &(gerror));
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
@@ -66,13 +78,13 @@ bool Regex::match_full(const Glib::ustri
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-bool Regex::match_full(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options)
+bool Regex::match(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options)
 #else
-bool Regex::match_full(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error)
+bool Regex::match(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error)
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 {
   GError* gerror = 0;
-  bool retvalue = g_regex_match_full(gobj(), string.c_str(), string_len, start_position, ((GRegexMatchFlags)(match_options)), NULL, &(gerror));
+  bool retvalue = g_regex_match_full(gobj(), string.c_str(), string_len, start_position, ((GRegexMatchFlags)(match_options)), 0, &(gerror));
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
@@ -87,18 +99,18 @@ bool Regex::match_full(const Glib::ustri
 
 bool Regex::match_all(const Glib::ustring& string, RegexMatchFlags match_options)
 {
-  return g_regex_match_all(gobj(), string.c_str(), ((GRegexMatchFlags)(match_options)), NULL);
+  return g_regex_match_all(gobj(), string.c_str(), ((GRegexMatchFlags)(match_options)), 0);
 }
 
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-bool Regex::match_all_full(const Glib::ustring& string, int start_position, RegexMatchFlags match_options)
+bool Regex::match_all(const Glib::ustring& string, int start_position, RegexMatchFlags match_options)
 #else
-bool Regex::match_all_full(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error)
+bool Regex::match_all(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error)
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 {
   GError* gerror = 0;
-  bool retvalue = g_regex_match_all_full(gobj(), string.c_str(), -1, start_position, ((GRegexMatchFlags)(match_options)), NULL, &(gerror));
+  bool retvalue = g_regex_match_all_full(gobj(), string.c_str(), -1, start_position, ((GRegexMatchFlags)(match_options)), 0, &(gerror));
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
@@ -111,13 +123,13 @@ bool Regex::match_all_full(const Glib::u
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-bool Regex::match_all_full(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options)
+bool Regex::match_all(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options)
 #else
-bool Regex::match_all_full(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error)
+bool Regex::match_all(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error)
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 {
   GError* gerror = 0;
-  bool retvalue = g_regex_match_all_full(gobj(), string.c_str(), string_len, start_position, ((GRegexMatchFlags)(match_options)), NULL, &(gerror));
+  bool retvalue = g_regex_match_all_full(gobj(), string.c_str(), string_len, start_position, ((GRegexMatchFlags)(match_options)), 0, &(gerror));
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
@@ -171,9 +183,9 @@ Glib::ustring Regex::replace_literal(con
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-Glib::StringArrayHandle Regex::split_full(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, int max_tokens) const
+Glib::StringArrayHandle Regex::split(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, int max_tokens) const
 #else
-Glib::StringArrayHandle Regex::split_full(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, int max_tokens, std::auto_ptr<Glib::Error>& error) const
+Glib::StringArrayHandle Regex::split(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, int max_tokens, std::auto_ptr<Glib::Error>& error) const
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 {
   GError* gerror = 0;
@@ -189,6 +201,4 @@ Glib::StringArrayHandle Regex::split_ful
   return retvalue;
 }
 
-
-
-} //namespace Glib
+} // namespace Glib
Index: glib/src/regex.hg
===================================================================
--- glib/src/regex.hg	(Revision 441)
+++ glib/src/regex.hg	(Arbeitskopie)
@@ -21,13 +21,11 @@ _DEFS(glibmm,glib)
 #include <glibmm/ustring.h>
 #include <glibmm/error.h>
 #include <glibmm/arrayhandle.h>
-//#include <glibmm/value.h>
-
 #include <glib/gregex.h>
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 typedef struct _GRegex GRegex;
-#endif //DOXYGEN_SHOULD_SKIP_THIS
+#endif
 
 namespace Glib
 {
@@ -99,87 +97,83 @@ class Regex
 public:
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-   static Glib::RefPtr<Glib::Regex> create(const Glib::ustring& pattern, RegexCompileFlags compile_options = (RegexCompileFlags)0, RegexMatchFlags match_options = (RegexMatchFlags)0);
+  static Glib::RefPtr<Glib::Regex> create(const Glib::ustring& pattern, RegexCompileFlags compile_options = static_cast<RegexCompileFlags>(0), RegexMatchFlags match_options = static_cast<RegexMatchFlags>(0));
 #else
-   static Glib::RefPtr<Glib::Regex> create(const Glib::ustring& pattern, RegexCompileFlags compile_options = (RegexCompileFlags)0, RegexMatchFlags match_options = (RegexMatchFlags)0, std::auto_ptr<Glib::Error>& error)
-#endif //GLIBMM_EXCEPTIONS_ENABLED
+  static Glib::RefPtr<Glib::Regex> create(const Glib::ustring& pattern, RegexCompileFlags compile_options = static_cast<RegexCompileFlags>(0), RegexMatchFlags match_options = static_cast<RegexMatchFlags>(0), std::auto_ptr<Glib::Error>& error);
+#endif /* !GLIBMM_EXCEPTIONS_ENABLED */
   
-
   _WRAP_METHOD(Glib::ustring get_pattern() const, g_regex_get_pattern)
   _WRAP_METHOD(int get_max_backref() const, g_regex_get_max_backref)
   _WRAP_METHOD(int get_capture_count() const, g_regex_get_capture_count)
   _WRAP_METHOD(int get_string_number(const Glib::ustring& name) const, g_regex_get_string_number)
 
-  //TODO: _WRAP_METHOD(static Glib::ustring escape_string(const Glib::ustring& string, gint length) const, g_regex_escape_string)
+  static Glib::ustring escape_string(const Glib::ustring& string);
 
-/* Matching. */
-  _WRAP_METHOD(static bool match_simple(const Glib::ustring& pattern, const Glib::ustring& string, RegexCompileFlags compile_options = (RegexCompileFlags)0, RegexMatchFlags match_options = (RegexMatchFlags)0), g_regex_match_simple)
+  _WRAP_METHOD(static bool match_simple(const Glib::ustring& pattern, const Glib::ustring& string, RegexCompileFlags compile_options = static_cast<RegexCompileFlags>(0), RegexMatchFlags match_options = static_cast<RegexMatchFlags>(0)), g_regex_match_simple)
 
   //TODO: _WRAP_METHOD(bool match(const Glib::ustring& string, RegexMatchFlags match_options = (RegexMatchFlags)0, GMatchInfo **match_info = 0), g_regex_match)
-  bool match(const Glib::ustring& string, RegexMatchFlags match_options = (RegexMatchFlags)0);
+  bool match(const Glib::ustring& string, RegexMatchFlags match_options = static_cast<RegexMatchFlags>(0));
 
   //TODO: Wrap GMatchInfo as an iterator:
   //_WRAP_METHOD(bool match_full(const gchar* string, gssize string_len, int start_position, RegexMatchFlags match_options = (RegexMatchFlags)0, GMatchInfo** match_info = 0), g_regex_match_full, errthrow)
 
-  #ifdef GLIBMM_EXCEPTIONS_ENABLED
-  bool match_full(const Glib::ustring& string, int start_position, RegexMatchFlags match_options);
-  #else
-  bool match_full(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error);
-  #endif //GLIBMM_EXCEPTIONS_ENABLED
-
-  #ifdef GLIBMM_EXCEPTIONS_ENABLED
-  bool match_full(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options);
-  #else
-  bool match_full(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error);
-  #endif //GLIBMM_EXCEPTIONS_ENABLED
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  bool match(const Glib::ustring& string, int start_position, RegexMatchFlags match_options);
+#else
+  bool match(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error);
+#endif /* !GLIBMM_EXCEPTIONS_ENABLED */
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  bool match(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options);
+#else
+  bool match(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error);
+#endif /* !GLIBMM_EXCEPTIONS_ENABLED */
 
   //TODO: _WRAP_METHOD(bool match_all(const Glib::ustring& string, RegexMatchFlags match_options = (RegexMatchFlags)0, GMatchInfo ** match_info = 0), g_regex_match_all)
-  bool match_all(const Glib::ustring& string, RegexMatchFlags match_options = (RegexMatchFlags)0);
+  bool match_all(const Glib::ustring& string, RegexMatchFlags match_options = static_cast<RegexMatchFlags>(0));
 
   //TODO: _WRAP_METHOD(bool match_all_full(const gchar* string, gssize string_len, int start_position, RegexMatchFlags match_options = (RegexMatchFlags)0, GMatchInfo** match_info = 0), g_regex_match_all_full, errthrow)
 
-  #ifdef GLIBMM_EXCEPTIONS_ENABLED
-  bool match_all_full(const Glib::ustring& string, int start_position, RegexMatchFlags match_options);
-  #else
-  bool match_all_full(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error);
-  #endif //GLIBMM_EXCEPTIONS_ENABLED
-
-  #ifdef GLIBMM_EXCEPTIONS_ENABLED
-  bool match_all_full(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options);
-  #else
-  bool match_all_full(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error);
-  #endif //GLIBMM_EXCEPTIONS_ENABLED
-
-
-  #m4 _CONVERSION(`gchar**',`Glib::StringArrayHandle',`Glib::StringArrayHandle($3, Glib::OWNERSHIP_DEEP)')
-
-  _WRAP_METHOD(static Glib::StringArrayHandle split_simple(const Glib::ustring& pattern, const Glib::ustring& string, RegexCompileFlags compile_options = (RegexCompileFlags)0, RegexMatchFlags match_options = (RegexMatchFlags)0), g_regex_split_simple)
-  _WRAP_METHOD(Glib::StringArrayHandle split(const Glib::ustring& string, RegexMatchFlags match_options = (RegexMatchFlags)0), g_regex_split)
-
-  _WRAP_METHOD(Glib::StringArrayHandle split_full(const gchar* string, gssize string_len, int start_position, RegexMatchFlags match_options = (RegexMatchFlags)0, int max_tokens = 0) const, g_regex_split_full, errthrow)
-
-  #ifdef GLIBMM_EXCEPTIONS_ENABLED
-  Glib::StringArrayHandle split_full(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, int max_tokens) const;
-  #else
-  Glib::StringArrayHandle split_full(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, int max_tokens, std::auto_ptr<Glib::Error>& error) const;
-  #endif //GLIBMM_EXCEPTIONS_ENABLED
-
-/* String replacement. */
-  _WRAP_METHOD(Glib::ustring replace(const gchar* string, gssize string_len, int start_position, const Glib::ustring& replacement, RegexMatchFlags match_options = (RegexMatchFlags)0), g_regex_replace, errthrow)
-  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  bool match_all(const Glib::ustring& string, int start_position, RegexMatchFlags match_options);
+#else
+  bool match_all(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error);
+#endif /* !GLIBMM_EXCEPTIONS_ENABLED */
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  bool match_all(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options);
+#else
+  bool match_all(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error);
+#endif /* !GLIBMM_EXCEPTIONS_ENABLED */
+
+#m4 _CONVERSION(`gchar**',`Glib::StringArrayHandle',`Glib::StringArrayHandle($3, Glib::OWNERSHIP_DEEP)')
+
+  _WRAP_METHOD(static Glib::StringArrayHandle split_simple(const Glib::ustring& pattern, const Glib::ustring& string, RegexCompileFlags compile_options = static_cast<RegexCompileFlags>(0), RegexMatchFlags match_options = static_cast<RegexMatchFlags>(0)), g_regex_split_simple)
+  _WRAP_METHOD(Glib::StringArrayHandle split(const Glib::ustring& string, RegexMatchFlags match_options = static_cast<RegexMatchFlags>(0)), g_regex_split)
+
+  _WRAP_METHOD(Glib::StringArrayHandle split(const gchar* string, gssize string_len, int start_position, RegexMatchFlags match_options = static_cast<RegexMatchFlags>(0), int max_tokens = 0) const, g_regex_split_full, errthrow)
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  Glib::StringArrayHandle split(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, int max_tokens) const;
+#else
+  Glib::StringArrayHandle split(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, int max_tokens, std::auto_ptr<Glib::Error>& error) const;
+#endif /* !GLIBMM_EXCEPTIONS_ENABLED */
+
+  _WRAP_METHOD(Glib::ustring replace(const gchar* string, gssize string_len, int start_position, const Glib::ustring& replacement, RegexMatchFlags match_options = static_cast<RegexMatchFlags>(0)), g_regex_replace, errthrow)
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
   Glib::ustring replace(const Glib::ustring& string, int start_position, const Glib::ustring& replacement, RegexMatchFlags match_options);
-  #else
+#else
   Glib::ustring replace(const Glib::ustring& string, int start_position, const Glib::ustring& replacement, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error);
-  #endif //GLIBMM_EXCEPTIONS_ENABLED
+#endif /* !GLIBMM_EXCEPTIONS_ENABLED */
 
-  _WRAP_METHOD(Glib::ustring replace_literal(const gchar *string, gssize string_len, int start_position, const Glib::ustring& replacement, RegexMatchFlags match_options = (RegexMatchFlags)0), g_regex_replace_literal, errthrow)
-  #ifdef GLIBMM_EXCEPTIONS_ENABLED
+  _WRAP_METHOD(Glib::ustring replace_literal(const gchar *string, gssize string_len, int start_position, const Glib::ustring& replacement, RegexMatchFlags match_options = static_cast<RegexMatchFlags>(0)), g_regex_replace_literal, errthrow)
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
   Glib::ustring replace_literal(const Glib::ustring& string, int start_position, const Glib::ustring& replacement, RegexMatchFlags match_options);
-  #else
+#else
   Glib::ustring replace_literal(const Glib::ustring& string, int start_position, const Glib::ustring& replacement, RegexMatchFlags match_options, std::auto_ptr<Glib::Error>& error);
-  #endif //GLIBMM_EXCEPTIONS_ENABLED
+#endif /* !GLIBMM_EXCEPTIONS_ENABLED */
 
-  _WRAP_METHOD(Glib::ustring replace_eval(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options, GRegexEvalCallback   eval,  gpointer user_data), g_regex_replace_eval, errthrow)
+  _WRAP_METHOD(Glib::ustring replace_eval(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options, GRegexEvalCallback eval,  gpointer user_data), g_regex_replace_eval, errthrow)
   _WRAP_METHOD(static bool check_replacement(const Glib::ustring& replacement, gboolean* has_references), g_regex_check_replacement, errthrow)
 
 /* Match info */
@@ -212,6 +206,4 @@ gchar		**g_match_info_fetch_all	(const G
 */
 };
 
-
 } // namespace Glib
-


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