[gnome-mud] line-buffer: Remove marshalling dependency



commit 1aeae40a77fc9d94c3dac810e8d3837a3a5f17c4
Author: Steven Jackson <sj oscode net>
Date:   Fri Apr 28 14:45:10 2017 +0100

    line-buffer: Remove marshalling dependency
    
    This will enable simpler out of tree builds.

 src/mud-connection-view.c |   32 ++++++++++++++------------------
 src/mud-line-buffer.c     |   39 ++++++++++++++++-----------------------
 src/mud-line-buffer.h     |    2 +-
 src/mud-log.c             |    6 ++----
 src/mud-trigger.c         |    4 +---
 5 files changed, 34 insertions(+), 49 deletions(-)
---
diff --git a/src/mud-connection-view.c b/src/mud-connection-view.c
index c11881d..39ff5dd 100644
--- a/src/mud-connection-view.c
+++ b/src/mud-connection-view.c
@@ -134,11 +134,9 @@ static void mud_connection_view_profile_changed_cb(MudProfile *profile,
                                                    MudConnectionView *view);
 static void mud_connection_view_line_added_cb(MudLineBuffer *buffer,
                                               MudLineBufferLine *line,
-                                              guint length,
                                               MudConnectionView *view);
 static void mud_connection_view_partial_line_cb(MudLineBuffer *buffer,
-                                                const gchar *line,
-                                                guint length,
+                                                const GString *line,
                                                 MudConnectionView *view);
 
 
@@ -1169,7 +1167,6 @@ mud_connection_view_popup(MudConnectionView *view, GdkEventButton *event)
 static void
 mud_connection_view_line_added_cb(MudLineBuffer *buffer,
                                   MudLineBufferLine *line,
-                                  guint length,
                                   MudConnectionView *view)
 {
 #ifdef ENABLE_GST
@@ -1203,8 +1200,8 @@ mud_connection_view_line_added_cb(MudLineBuffer *buffer,
         if(g_str_equal(view->priv->current_output, "main"))
         {
             vte_terminal_feed(view->terminal,
-                              line->line,
-                              length);
+                              line->line->str,
+                              line->line->len);
 
             mud_window_toggle_tab_icon(view->window, view);
         }
@@ -1215,12 +1212,12 @@ mud_connection_view_line_added_cb(MudLineBuffer *buffer,
                         view->priv->current_output);
 
             if(sub)
-                mud_subwindow_feed(sub, line->line, length);
+                mud_subwindow_feed(sub, line->line->str, line->line->len);
             else
             {
                 vte_terminal_feed(view->terminal,
-                                  line->line,
-                                  length);
+                                  line->line->str,
+                                  line->line->len);
 
                 mud_window_toggle_tab_icon(view->window, view);
             }
@@ -1234,13 +1231,12 @@ mud_connection_view_line_added_cb(MudLineBuffer *buffer,
     }
 
     if(view->logging)
-        mud_log_write_hook(view->log, line->line, length);
+        mud_log_write_hook(view->log, line->line->str, line->line->len);
 }
 
 static void
 mud_connection_view_partial_line_cb(MudLineBuffer *buffer,
-                                    const gchar *line,
-                                    guint length,
+                                    const GString *line,
                                     MudConnectionView *view)
 {
     //TODO:  Pass through trigger and script code.
@@ -1252,8 +1248,8 @@ mud_connection_view_partial_line_cb(MudLineBuffer *buffer,
         if(g_str_equal(view->priv->current_output, "main"))
         {
             vte_terminal_feed(view->terminal,
-                    line,
-                    length);
+                    line->str,
+                    line->len);
 
             mud_window_toggle_tab_icon(view->window, view);
         }
@@ -1264,12 +1260,12 @@ mud_connection_view_partial_line_cb(MudLineBuffer *buffer,
                         view->priv->current_output);
 
             if(sub)
-                mud_subwindow_feed(sub, line, length);
+                mud_subwindow_feed(sub, line->str, line->len);
             else
             {
                 vte_terminal_feed(view->terminal,
-                        line,
-                        length);
+                        line->str,
+                        line->len);
 
                 mud_window_toggle_tab_icon(view->window, view);
             }
@@ -1279,7 +1275,7 @@ mud_connection_view_partial_line_cb(MudLineBuffer *buffer,
     }
 
     if(view->logging)
-        mud_log_write_hook(view->log, line, length);
+        mud_log_write_hook(view->log, line->str, line->len);
 }
 
 static void
diff --git a/src/mud-line-buffer.c b/src/mud-line-buffer.c
index 4dc9419..83026c1 100644
--- a/src/mud-line-buffer.c
+++ b/src/mud-line-buffer.c
@@ -127,11 +127,10 @@ mud_line_buffer_class_init (MudLineBufferClass *klass)
                      0,
                      NULL,
                      NULL,
-                     gnome_mud_cclosure_VOID__POINTER_UINT,
+                     g_cclosure_marshal_VOID__POINTER,
                      G_TYPE_NONE,
-                     2,
-                     G_TYPE_POINTER,
-                     G_TYPE_UINT);
+                     1,
+                     G_TYPE_POINTER);
 
     mud_line_buffer_signal[LINE_REMOVED] =
         g_signal_newv("line-removed",
@@ -152,11 +151,10 @@ mud_line_buffer_class_init (MudLineBufferClass *klass)
                       0,
                       NULL,
                       NULL,
-                      gnome_mud_cclosure_VOID__STRING_UINT,
+                      g_cclosure_marshal_VOID__POINTER,
                       G_TYPE_NONE,
-                      2,
-                      G_TYPE_STRING,
-                      G_TYPE_UINT);
+                      1,
+                      G_TYPE_POINTER);
 }
 
 static void
@@ -287,7 +285,7 @@ mud_line_buffer_add_data(MudLineBuffer *self,
 
     for(i = 0; i < data_buffer->len; ++i)
     {
-        line = g_string_append_c(line, data_buffer->str[i]);
+        g_string_append_c(line, data_buffer->str[i]);
 
         if(data_buffer->str[i] == '\n')
         {
@@ -296,7 +294,8 @@ mud_line_buffer_add_data(MudLineBuffer *self,
             ++self->priv->length;
 
             new_line->gag = FALSE;
-            new_line->line = g_strdup(line->str);
+            new_line->line = line;
+            line = g_string_new(NULL);
 
             self->priv->line_buffer =
                 g_list_append(self->priv->line_buffer,
@@ -325,12 +324,7 @@ mud_line_buffer_add_data(MudLineBuffer *self,
             g_signal_emit(self,
                           mud_line_buffer_signal[LINE_ADDED],
                           0,
-                          new_line,
-                          line->len);
-
-            g_string_free(line, TRUE);
-
-            line = g_string_new(NULL);
+                          new_line);
         }
     }
 
@@ -343,8 +337,7 @@ mud_line_buffer_add_data(MudLineBuffer *self,
         g_signal_emit(self,
                       mud_line_buffer_signal[PARTIAL_LINE_RECEIVED],
                       0,
-                      line->str,
-                      line->len);
+                      line);
     }
 
     g_string_free(line, TRUE);
@@ -387,7 +380,7 @@ mud_line_buffer_get_lines(MudLineBuffer *self)
         const MudLineBufferLine *line =
             (MudLineBufferLine *)entry->data;
 
-        lines = g_string_append(lines, line->line);
+        lines = g_string_append(lines, line->line->str);
 
         entry = g_list_next(entry);
     }
@@ -421,7 +414,7 @@ mud_line_buffer_get_lines_and_partial(MudLineBuffer *self)
         const MudLineBufferLine *line =
             (MudLineBufferLine *)entry->data;
 
-        lines = g_string_append(lines, line->line);
+        lines = g_string_append(lines, line->line->str);
 
         entry = g_list_next(entry);
     }
@@ -468,7 +461,7 @@ mud_line_buffer_get_line(MudLineBuffer *self,
     buffer_line = g_list_nth_data(self->priv->line_buffer,
                                   line);
 
-    return buffer_line->line;
+    return buffer_line->line->str;
 }
 
 gchar *
@@ -504,7 +497,7 @@ mud_line_buffer_get_range(MudLineBuffer *self,
         MudLineBufferLine *buffer_line =
             (MudLineBufferLine *)entry->data;
 
-        range = g_string_append(range, buffer_line->line);
+        range = g_string_append(range, buffer_line->line->str);
 
         entry = g_list_next(entry);
     }
@@ -556,7 +549,7 @@ mud_line_buffer_free_line(gpointer value,
 
     if(line)
     {
-        g_free(line->line);
+        g_string_free(line->line, TRUE);
         g_free(line);
     }
 }
diff --git a/src/mud-line-buffer.h b/src/mud-line-buffer.h
index 060d268..a8ba87c 100644
--- a/src/mud-line-buffer.h
+++ b/src/mud-line-buffer.h
@@ -55,7 +55,7 @@ typedef struct MudLineBufferLine
     gboolean gag;
 
     // Line Data
-    gchar *line;
+    GString *line;
 } MudLineBufferLine;
 
 GType           mud_line_buffer_get_type (void);
diff --git a/src/mud-log.c b/src/mud-log.c
index d2b3f3f..0ffb3dd 100644
--- a/src/mud-log.c
+++ b/src/mud-log.c
@@ -128,7 +128,6 @@ static gboolean mud_log_keypress_cb(GtkWidget *widget,
                                     MudLog *self);
 static void mud_log_line_added_cb(MudLineBuffer *buffer,
                                   MudLineBufferLine *line,
-                                  guint length,
                                   MudLog *self);
 
 /* Private Methods */
@@ -587,13 +586,12 @@ mud_log_prev_spin_changed_cb(GtkSpinButton *button,
 static void
 mud_log_line_added_cb(MudLineBuffer *buffer,
                       MudLineBufferLine *line,
-                      guint length,
                       MudLog *self)
 {
     if(!self->priv->done)
     {
-        if(line && length != 0) 
-            mud_log_write(self, line->line, length);
+        if(line && line->line && line->line->len != 0)
+            mud_log_write(self, line->line->str, line->line->len);
 
         if(self->priv->include_next)
         {
diff --git a/src/mud-trigger.c b/src/mud-trigger.c
index 3df1ad8..81fcacc 100644
--- a/src/mud-trigger.c
+++ b/src/mud-trigger.c
@@ -124,7 +124,6 @@ static void mud_trigger_get_property(GObject *object,
 // Callbacks
 static void mud_trigger_line_added_cb(MudLineBuffer *buffer,
                                       MudLineBufferLine *line,
-                                      guint length,
                                       MudTrigger *self);
 
 // Private Methods
@@ -441,7 +440,7 @@ mud_trigger_execute(MudTrigger *self,
                     MudLineBufferLine *line,
                     guint length)
 {
-    gchar *stripped = utils_strip_ansi(line->line);
+    gchar *stripped = utils_strip_ansi(line->line->str);
     guint len = strlen(stripped);
 
     switch(self->priv->type)
@@ -536,7 +535,6 @@ mud_trigger_add_window(MudTrigger *self,
 static void
 mud_trigger_line_added_cb(MudLineBuffer *buffer,
                           MudLineBufferLine *line,
-                          guint length,
                           MudTrigger *self)
 {
     gulong len, max;


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