[uniquemm] We are now using gmmproc to wrap Unique::Message.



commit 3e46a2a1f765be2c9ab31537a63e8a4a12c4b0c1
Author: Fabien Parent <parent f gmail com>
Date:   Tue Apr 27 21:12:43 2010 +0200

    We are now using gmmproc to wrap Unique::Message.

 codegen/m4/convert_unique.m4                  |   21 +++--
 examples/unique.cc                            |    2 +-
 unique/src/app.hg                             |    3 +-
 unique/src/backend.hg                         |    2 +-
 unique/src/filelist.am                        |    3 +-
 unique/src/message.ccg                        |   27 ++++++
 unique/{uniquemm/message.h => src/message.hg} |   86 +++++---------------
 unique/uniquemm/filelist.am                   |    4 +-
 unique/uniquemm/message.cc                    |  109 -------------------------
 9 files changed, 68 insertions(+), 189 deletions(-)
---
diff --git a/codegen/m4/convert_unique.m4 b/codegen/m4/convert_unique.m4
index d54a142..34295a3 100644
--- a/codegen/m4/convert_unique.m4
+++ b/codegen/m4/convert_unique.m4
@@ -1,14 +1,19 @@
 dnl Copyright (c) 2009  Fabien Parent <parent f gmail com>
 dnl This file is part of libuniquemm.
 
-_CONVERSION(`Gtk::Window&',`GtkWindow*',`$3.gobj()')
-_CONVERSION(`GtkWindow*',`Gtk::Window&',`Glib::wrap($3)')
-
-_CONVERSION(`UniqueMessageData*', `MessageData', `MessageData($3, false)')
-_CONVERSION(`UniqueMessageData*', `MessageData*', `&(MessageData($3))')
-_CONVERSION(`MessageData', `UniqueMessageData*', `$3.gobj()')
-_CONVERSION(`MessageData&', `UniqueMessageData*', `$3.gobj()')
-_CONVERSION(`MessageData*', `UniqueMessageData*', `$3->gobj()')
+_CONVERSION(`Gtk::Window&',`GtkWindow*',$3.gobj())
+_CONVERSION(`GtkWindow*',`Gtk::Window&',Glib::wrap($3))
+
+_CONVERSION(`UniqueMessageData*', `MessageData', MessageData($3))
+_CONVERSION(`UniqueMessageData*', `MessageData*', &(MessageData($3)))
+_CONVERSION(`MessageData', `UniqueMessageData*', $3.gobj())
+_CONVERSION(`MessageData&', `UniqueMessageData*', $3.gobj())
+_CONVERSION(`MessageData*', `UniqueMessageData*', $3->gobj())
+
+_CONVERSION(`const Glib::StringArrayHandle&', `gchar**', const_cast<gchar**>($3.data()))
+_CONVERSION(`gchar**', `Glib::StringArrayHandle', Glib::StringArrayHandle($3, Glib::OWNERSHIP_DEEP))
+
+_CONVERSION(`GdkScreen', `Glib::RefPtr<Gdk::Screen>', Glib::wrap($3, true))
 
 _CONV_ENUM(Unique, Response)
 _CONV_ENUM(Unique, Command)
diff --git a/examples/unique.cc b/examples/unique.cc
index cb77faa..07a857b 100644
--- a/examples/unique.cc
+++ b/examples/unique.cc
@@ -38,7 +38,7 @@ Unique::Response on_message_received(int command, Unique::MessageData message_da
 	Glib::ustring message;
 	std::vector<Glib::ustring> uris;
 	
-	std::cout << "Message received from screen: " << message_data.get_screen()->get_number()
+	std::cout //<< "Message received from screen: " << message_data.get_screen()->get_number()
 			  << ", startup-id: " << message_data.get_startup_id()
 			  << ", workspace: " << message_data.get_workspace()
 			  << std::endl;
diff --git a/unique/src/app.hg b/unique/src/app.hg
index 7288c5e..bd70916 100644
--- a/unique/src/app.hg
+++ b/unique/src/app.hg
@@ -29,6 +29,7 @@ namespace Unique
 {
 
 _CC_INCLUDE(unique/uniqueapp.h)
+_CC_INCLUDE(unique/uniqueenumtypes.h)
 
 _WRAP_ENUM(Command, UniqueCommand)
 _WRAP_ENUM(Response, UniqueResponse)
@@ -179,7 +180,7 @@ public:
    * @param timestamp of the command
    * @return response
    */
-  _WRAP_SIGNAL(Unique::Response message_received(int command, MessageData message_data, guint time), "message-received")
+  _WRAP_SIGNAL(Unique::Response message_received(int command, MessageData message_data, guint time), "message-received", no_default_handler)
 };
 
 } // namespace Unique
diff --git a/unique/src/backend.hg b/unique/src/backend.hg
index 8dd7778..0c52e85 100644
--- a/unique/src/backend.hg
+++ b/unique/src/backend.hg
@@ -86,7 +86,7 @@ public:
    * @param time time of the command emission, or 0 for the current time
    * @return a Unique::Response value sent by the running instance
    */
-  _WRAP_METHOD(UniqueResponse send_message(int command, UniqueMessageData* message_data, guint time), unique_backend_send_message)
+  _WRAP_METHOD(Unique::Response send_message(int command, UniqueMessageData* message_data, guint time), unique_backend_send_message)
 };
 
 } // namespace Unique
diff --git a/unique/src/filelist.am b/unique/src/filelist.am
index 9080cf7..17a1d66 100644
--- a/unique/src/filelist.am
+++ b/unique/src/filelist.am
@@ -10,5 +10,6 @@ files_defs =			\
 
 files_hg  = \
 	app.hg \
-	backend.hg
+	backend.hg \
+	message.hg
 files_ccg = $(files_hg:.hg=.ccg)
diff --git a/unique/src/message.ccg b/unique/src/message.ccg
new file mode 100644
index 0000000..f7de2da
--- /dev/null
+++ b/unique/src/message.ccg
@@ -0,0 +1,27 @@
+/* message.cc
+ *
+ * Copyright (C) 2009 Fabien Parent <parent f gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <uniquemm/message.h>
+
+
+namespace Unique
+{
+
+} // namespace Unique
+
diff --git a/unique/uniquemm/message.h b/unique/src/message.hg
similarity index 66%
rename from unique/uniquemm/message.h
rename to unique/src/message.hg
index d6df606..76af3ae 100644
--- a/unique/uniquemm/message.h
+++ b/unique/src/message.hg
@@ -1,12 +1,6 @@
-// -*- c++ -*-
-#ifndef _UNIQUEMM_MESSAGE_H
-#define _UNIQUEMM_MESSAGE_H
-
-/* $Id$ */
-
-/* message.h
+/* message.hg
  *
- * Copyright (C) 2009  Fabien Parent <parent f gmail com>
+ * Copyright (C) 2009 Fabien Parent <parent f gmail com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -23,13 +17,16 @@
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <unique/unique.h>
 #include <glibmm.h>
 #include <gdkmm/screen.h>
 
+_DEFS(uniquemm, unique)
+
 namespace Unique
 {
 
+_CC_INCLUDE(unique/unique.h)
+
 /**
  * Message container for Unique::App
  *
@@ -48,37 +45,9 @@ namespace Unique
  */
 class MessageData
 {
+  _CLASS_BOXEDTYPE(MessageData, UniqueMessageData, unique_message_data_new, unique_message_data_copy, unique_message_data_free)
+
 public:
-  /**
-   * Creates a new Unique::MessageData structure. This structure holds
-   * the message data passed between running instances with
-   * Unique::App::send_message().
-   */
-  MessageData(void);
-  
-  /**
-   * Creates a new Unique::MessageData structure by copying another
-   * Unique::MessageData.
-   *
-   * @param message message data to copy
-   */
-  MessageData(const MessageData& message);
-  
-  /**
-   * Create a new Unique::MessageData structure from a @a
-   * UniqueMessageData*. This structure holds the message data passed
-   * between running instances with Unique::App::send_message().
-   *
-   * @param message UniqueMessageData
-   * @param take_ownership if the Unique::MessageData created is the
-   * owner of the message.
-   */
-  MessageData(UniqueMessageData* message, bool take_ownership = true);
-  
-  /**
-   * Destruct the MessageData
-   */
-  ~MessageData(void);
   
   /**
    * Sets @a data as the payload of @a message_data. Any other data
@@ -91,7 +60,7 @@ public:
    * @param data binary blob to set, or NULL.
    * @param length length of @a data.
    */
-  void set(const guchar* data = NULL, int length = -1);
+  _WRAP_METHOD(void set(const guchar* data = 0, gsize length = -1), unique_message_data_set)
   
   /**
    * Retrieves the raw contents of @a message_data set using set().
@@ -102,7 +71,7 @@ public:
    * @return the contents of the message data or NULL. The returned string
    * is owned by the Unique::MessageData and should never be modified or freed
    */
-  const guchar* get(gsize& length) const;
+  _WRAP_METHOD(const guchar* get(gsize& length) const, unique_message_data_get)
   
   /**
    * Sets @a str as the plain text payload of @a message_data, converting it
@@ -110,17 +79,17 @@ public:
    * used. Use get_text() to retrieve the text.
    *
    * @param str plain text to be set as payload
-   * @param legnth length of the text, or -1
+   * @param length length of the text, or -1
    * @return <tt>true</tt> if the text was successfully converted to UTF-8
    */
-  bool set_text(const Glib::ustring& str, int length = -1);
+  _WRAP_METHOD(bool set_text(const Glib::ustring& str, gssize length = -1), unique_message_data_set_text)
   
   /**
    * Retrieves the text set using set_text().
    *
    * @return an allocated string.
    */
-  Glib::ustring get_text(void) const;
+  _WRAP_METHOD(Glib::ustring get_text() const, unique_message_data_get_text)
   
   /**
    * Converts @a uris to a valid URI list and sets it as payload of @a message_data.
@@ -129,28 +98,28 @@ public:
    * @param uris a list of URIs in a string vector
    * @return <tt>true</tt> if the URIs were successfully converted
    */
-  bool set_uris(const Glib::StringArrayHandle& uris);
+  _WRAP_METHOD(bool set_uris(const Glib::StringArrayHandle& uris), unique_message_data_set_uris)
   
   /**
    * Retrieves a string vector containing the URIs set with set_uris().
    *
    * @return an allocated list of URIs.
    */
-  Glib::StringArrayHandle get_uris(void) const;
+  _WRAP_METHOD(Glib::StringArrayHandle get_uris() const, unique_message_data_get_uris)
   
   /**
    * Sets @a filename as the contents of @a message_data.
    *
    * @param filename a filename
    */
-  void set_filename(const Glib::ustring& filename);
+  _WRAP_METHOD(void set_filename(const Glib::ustring& filename), unique_message_data_set_filename)
   
   /** 
    * Retrieves the filename set with set_filename().
    *
    * @return a newly allocated string containing the filename.
    */
-  Glib::ustring get_filename(void) const;
+  _WRAP_METHOD(Glib::ustring get_filename() const, unique_message_data_get_filename)
   
   /**
    * Returns a pointer to the screen from where the message came.
@@ -159,7 +128,8 @@ public:
    * 
    * @return a Glib::RefPtr<Gdk::Screen>
    */
-  Glib::RefPtr<Gdk::Screen> get_screen(void) const;
+#m4 _CONVERSION(`GdkScreen', `Glib::RefPtr<Gdk::Screen>', Glib::wrap($3, true))
+  _WRAP_METHOD(Glib::RefPtr<Gdk::Screen> get_screen() const, unique_message_data_get_screen)
   
   /**
    * Retrieves the startup notification id set inside message_data.
@@ -167,7 +137,7 @@ public:
    *
    * @return the startup notification id.
    */
-  Glib::ustring get_startup_id(void) const;
+  _WRAP_METHOD(Glib::ustring get_startup_id() const, unique_message_data_get_startup_id)
   
   /**
    * Retrieves the workspace number from where the message came.
@@ -175,22 +145,8 @@ public:
    *
    * @return the workspace number
    */
-  unsigned int get_workspace(void) const;
-  
-  /// Provides access to the underlying C GObject.
-  UniqueMessageData* gobj(void)       { return gobject_; }
-  
-  /// Provides access to the underlying C GObject.
-  UniqueMessageData* gobj(void) const { return gobject_; }
-
-private:
-  UniqueMessageData* gobject_;
-  bool ownership_;
-
+  _WRAP_METHOD(guint get_workspace() const, unique_message_data_get_workspace)
 };
 
 } // namespace Unique
 
-
-#endif /* _UNIQUEMM_MESSAGE_H */
-
diff --git a/unique/uniquemm/filelist.am b/unique/uniquemm/filelist.am
index d7eb1e3..e3aebe5 100644
--- a/unique/uniquemm/filelist.am
+++ b/unique/uniquemm/filelist.am
@@ -3,10 +3,8 @@
 files_built_cc = $(files_hg:.hg=.cc) wrap_init.cc
 files_built_h  = $(files_hg:.hg=.h)
 files_built_ph = $(patsubst %.hg,private/%_p.h,$(files_hg))
-files_extra_cc = \
-	message.cc
+files_extra_cc = 
 files_extra_h  = \
 	wrap_init.h \
-	message.h \
 	version.h
 files_extra_ph =



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