antiright-devel
[Top][All Lists]
Advanced

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

[Antiright-devel] antiright ACE-desktop/guidl/IDE.gdl gtkshell/ca...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright ACE-desktop/guidl/IDE.gdl gtkshell/ca...
Date: Fri, 11 May 2007 23:28:53 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/05/11 23:28:52

Modified files:
        ACE-desktop/guidl: IDE.gdl 
        gtkshell       : callbacks.c containers.c gtkshell.c gtkshell.h 
                         guidl_options.c guidl_util.c macros.h menu.c 
                         option_options.c pane.c pane.h row.c text.c 
                         text.h 
        libantiright   : macros.h string.c string.h util.c util.h 

Log message:
        Add option -op and guidl option "pane next" to use a pane between
        next and previous widgets.  Use in IDE, between terminals.
        Fixed all warnings.  

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/ACE-desktop/guidl/IDE.gdl?cvsroot=antiright&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/callbacks.c?cvsroot=antiright&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/containers.c?cvsroot=antiright&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.c?cvsroot=antiright&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.h?cvsroot=antiright&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/guidl_options.c?cvsroot=antiright&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/guidl_util.c?cvsroot=antiright&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/macros.h?cvsroot=antiright&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/menu.c?cvsroot=antiright&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/option_options.c?cvsroot=antiright&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/pane.c?cvsroot=antiright&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/pane.h?cvsroot=antiright&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/row.c?cvsroot=antiright&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/text.c?cvsroot=antiright&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/text.h?cvsroot=antiright&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/macros.h?cvsroot=antiright&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/string.c?cvsroot=antiright&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/string.h?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/util.c?cvsroot=antiright&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/util.h?cvsroot=antiright&r1=1.11&r2=1.12

Patches:
Index: ACE-desktop/guidl/IDE.gdl
===================================================================
RCS file: /sources/antiright/antiright/ACE-desktop/guidl/IDE.gdl,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- ACE-desktop/guidl/IDE.gdl   9 May 2007 16:13:49 -0000       1.20
+++ ACE-desktop/guidl/IDE.gdl   11 May 2007 23:28:52 -0000      1.21
@@ -15,7 +15,7 @@
 
 // set up status bar.
 option "update frequency" 10000;
-add "updating label" "echo -n 'Recent: '; ls -t | grep -v o$ | tr '\n' ' ' | 
cut -d ' ' -f-6";
+//add "updating label" "echo -n 'Recent: '; ls -t | grep -v o$ | tr '\n' ' ' | 
cut -d ' ' -f-6";
 
 option "icon size" "small toolbar";
 
@@ -28,9 +28,12 @@
 option "terminal height" 24;
 add "terminal" "vi";
 
+option "pane next";
+
 option "terminal font" "Mono 10";
 option "terminal height" 8;
 add "terminal" "$SHELL";
+
 option "rows" 16;
 
 add "vertical pane" "Work,Utilities";

Index: gtkshell/callbacks.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/callbacks.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- gtkshell/callbacks.c        10 May 2007 00:08:28 -0000      1.25
+++ gtkshell/callbacks.c        11 May 2007 23:28:52 -0000      1.26
@@ -51,13 +51,31 @@
        g_free(feed_command);
 }
 
+
+#define MATCH(str) !strncmp(command, str, strlen(str))
+
+static gboolean
+test_special_text_editor_command(struct GSH * gsh, const gchar * command)
+{
+       if(MATCH("Save_As...___"))
+               gsh_editor_save_as(gsh);
+       else if(MATCH("Save___"))
+               gsh_editor_save(gsh);
+       else if(MATCH("Open...___"))
+               gsh_editor_open(gsh);
+       else
+               return FALSE;
+
+       /* A special command match was found.  */
+       return TRUE;
+}
+
 static gboolean
 test_special_command(struct GSHCBData * cb)
 {
        const gchar * command = cb->data;
        struct GSH * gsh = cb->gsh;
 
-#define MATCH(str) !strncmp(command, str, strlen(str))
 
        if(MATCH("Exit__"))
        {       
@@ -66,17 +84,19 @@
                gtk_main_quit();
        }
        else if(MATCH("TERM__"))
-               terminal_feed((gchar *)command, gsh->terminal->widget);
-       else if(MATCH("Save_As...___"))
        {
-               GSH_FIXME();
+               terminal_feed((gchar *)command, gsh->terminal->widget);
        }
-       else if(MATCH("Save___"))
+       else 
        {
-               GSH_FIXME();
-       }
-       else /* No special command found.  */
+               /* Test other special command(s).  */
+               if(!test_special_text_editor_command(gsh, command))
+               {
+                       /* No special command found.  */
                return FALSE;
+               }
+       }
+
        /* Special command handled.  */
        return TRUE;
 }

Index: gtkshell/containers.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/containers.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- gtkshell/containers.c       9 May 2007 20:00:56 -0000       1.17
+++ gtkshell/containers.c       11 May 2007 23:28:52 -0000      1.18
@@ -25,12 +25,11 @@
 static void
 set_scrolled_window_options(struct GSH * gsh)
 {
-       gtk_scrolled_window_set_policy(
-                       GTK_SCROLLED_WINDOW(gsh->widgets.scrolled_window),
-                       GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-       gtk_scrolled_window_set_shadow_type(
-                       GTK_SCROLLED_WINDOW(gsh->widgets.scrolled_window),
-                       GTK_SHADOW_OUT);
+       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(
+               gsh->widgets.scrolled_window), GTK_POLICY_AUTOMATIC, 
+               GTK_POLICY_AUTOMATIC);
+       gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(
+               gsh->widgets.scrolled_window), GTK_SHADOW_OUT);
 }
 
 static void

Index: gtkshell/gtkshell.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- gtkshell/gtkshell.c 10 May 2007 00:08:28 -0000      1.37
+++ gtkshell/gtkshell.c 11 May 2007 23:28:52 -0000      1.38
@@ -65,6 +65,7 @@
 {\
        gsh->widgets.menu_bar=NULL;\
        gsh->widgets.app_frame=NULL;\
+       gsh->widgets.last_managed=NULL;\
 }
 
 #define SETUP_EDITOR_MEMBER_FIELDS(gsh)\

Index: gtkshell/gtkshell.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- gtkshell/gtkshell.h 8 May 2007 20:40:07 -0000       1.44
+++ gtkshell/gtkshell.h 11 May 2007 23:28:52 -0000      1.45
@@ -64,6 +64,7 @@
                GtkWidget * status_bar;
                GtkWidget * app_frame;
                GtkWidget * app_row;
+               GtkWidget * last_managed;
        } widgets;
        struct /* text editor */
        {

Index: gtkshell/guidl_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/guidl_options.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- gtkshell/guidl_options.c    6 May 2007 06:23:36 -0000       1.7
+++ gtkshell/guidl_options.c    11 May 2007 23:28:52 -0000      1.8
@@ -47,6 +47,7 @@
        DEF("update frequency", "-ou");
        DEF("application", "-oa");
        DEF("icon size", "-oi");
+       DEF("pane next", "-op");
 }
 
 GSH_GUIDL_ITEM_FUNC(option, DICT);

Index: gtkshell/guidl_util.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/guidl_util.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- gtkshell/guidl_util.c       11 May 2007 13:29:34 -0000      1.19
+++ gtkshell/guidl_util.c       11 May 2007 23:28:52 -0000      1.20
@@ -29,9 +29,6 @@
 static void
 gsh_delete_GDLEnvironment(struct GDLEnvironment * env)
 {
-#ifdef DEBUG
-       ARPASSERT(env);
-#endif /* DEBUG */
        EDEL(dictionaries);
        EDEL(args);
 }
@@ -47,7 +44,7 @@
        if(switches)
        {
 #ifdef DEBUG
-       ARPASSERT(gsh);
+       ARPASSERT(env);
 #endif /* DEBUG */
                APPEND_ARG(env, switches);
                if(argument)

Index: gtkshell/macros.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/macros.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- gtkshell/macros.h   9 May 2007 16:13:49 -0000       1.8
+++ gtkshell/macros.h   11 May 2007 23:28:52 -0000      1.9
@@ -35,6 +35,7 @@
 #define GSH_NO_EXPAND          256
 #define GSH_GUIDL_NO_DUMMY     512
 #define GSH_APP_MODE           1024
+#define GSH_PANE_NEXT          2048
 typedef guint Bitmask;
 
 #define GSH_FLAG(flag) ((gsh->bflags & flag) == flag)

Index: gtkshell/menu.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/menu.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- gtkshell/menu.c     10 May 2007 00:08:28 -0000      1.11
+++ gtkshell/menu.c     11 May 2007 23:28:52 -0000      1.12
@@ -104,7 +104,7 @@
 
 #define MANAGE_MENU_BAR(gsh) \
        GSH_FLAG(GSH_APP_MODE) ?  setup_app_mode(gsh)\
-               : gsh_manage(gsh, gsh->widgets.menu_bar);
+               : $(gsh, manage, gsh->widgets.menu_bar);
 
 static GtkWidget *
 add_menu_bar(struct GSH * gsh)

Index: gtkshell/option_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/option_options.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- gtkshell/option_options.c   6 May 2007 06:23:36 -0000       1.26
+++ gtkshell/option_options.c   11 May 2007 23:28:52 -0000      1.27
@@ -129,6 +129,10 @@
                set_no_decorations(gsh);
                break;
 
+       case 'p': /* Pane next widget with previous.  */
+               GSH_SET(GSH_PANE_NEXT);
+               break;
+
        case 'r': /* Set number of rows per column.  */
                GSH_COUNT(argc, counter);
                gsh->rows->total=(unsigned int)atoi(argv[(*counter)]);

Index: gtkshell/pane.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/pane.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- gtkshell/pane.c     10 May 2007 00:08:28 -0000      1.1
+++ gtkshell/pane.c     11 May 2007 23:28:52 -0000      1.2
@@ -73,3 +73,23 @@
        /* PAIR freed here.  */
        setup_second_pane_half(gsh, pair, pane);
 }
+
+void
+gsh_pane_previous(struct GSH * gsh, GtkWidget * target)
+{
+       GtkWidget * pane;
+       GtkWidget * prev_frame;
+
+       pane=gtk_vpaned_new();
+       prev_frame = gtk_frame_new(NULL);
+#ifdef DEBUG
+       ARPASSERT(gsh->widgets.last_managed);
+#endif /* DEBUG */
+       reparent(gsh->widgets.last_managed, gsh->rows->v, prev_frame);
+       gtk_paned_add1(GTK_PANED(pane), prev_frame);
+       gtk_paned_add2(GTK_PANED(pane), target);
+       gtk_widget_show(prev_frame);
+       gtk_widget_show(target);
+       GSH_UNSET(GSH_PANE_NEXT);
+       $(gsh, manage, pane);
+}

Index: gtkshell/pane.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/pane.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- gtkshell/pane.h     10 May 2007 00:08:28 -0000      1.1
+++ gtkshell/pane.h     11 May 2007 23:28:52 -0000      1.2
@@ -28,4 +28,7 @@
 void
 gsh_setup_hpaned(struct GSH * gsh, const gchar * label_pair);
 
+void
+gsh_pane_previous(struct GSH * gsh, GtkWidget * target);
+
 #endif /* not GSH_PANE_H */

Index: gtkshell/row.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/row.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- gtkshell/row.c      9 May 2007 20:00:56 -0000       1.21
+++ gtkshell/row.c      11 May 2007 23:28:52 -0000      1.22
@@ -80,6 +80,7 @@
 {
        gtk_widget_show(widget);
        gsh->rows->current++;
+       gsh->widgets.last_managed=widget;
 }
 
 static gboolean
@@ -87,11 +88,12 @@
 {
        if(GTK_IS_MENU(container) || GTK_IS_MENU_BAR(container)
           || GTK_IS_MENU_ITEM(container))
+       {
                gtk_menu_shell_append(GTK_MENU_SHELL(container), widget);
+               return TRUE;
+       }
        else
                return FALSE;
-
-       return TRUE;
 }
 
 static void
@@ -124,7 +126,9 @@
 void
 gsh_manage(struct GSH * gsh, GtkWidget *widget)
 {
-       if(TEST_MANAGE_UNEXPANDED(gsh))
+       if(GSH_FLAG(GSH_PANE_NEXT))
+               gsh_pane_previous(gsh, widget);
+       else if(TEST_MANAGE_UNEXPANDED(gsh))
                manage_unexpanded(gsh, widget);
        else
                manage_normal(gsh, widget);

Index: gtkshell/text.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/text.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- gtkshell/text.c     10 May 2007 00:08:28 -0000      1.27
+++ gtkshell/text.c     11 May 2007 23:28:52 -0000      1.28
@@ -70,7 +70,6 @@
        /* Create widget and assign callback.  */
        setup_entry_cb(gsh, entry=gtk_combo_box_entry_new_text(), command);
        APPEND_SAMPLE_ENTRIES(GTK_COMBO_BOX(entry));
-       /* Do not fill remaining container area.  */
        gsh_manage(gsh, entry);
 
        return entry;
@@ -128,3 +127,54 @@
        g_free(text);
        CHECK_GEOMETRY(gsh);
 }
+
+#define TEST_EDITOR_EXISTS(gsh)\
+       if(!gsh->editor.widget)\
+               return;
+       
+
+void
+gsh_editor_save(struct GSH * gsh)
+{
+       TEST_EDITOR_EXISTS(gsh);
+       if(gsh->editor.filename)
+       {
+               gchar * text;
+
+               AR_TEXT_TO_FILE(gsh->editor.filename, text);
+       }
+       else
+               gsh_editor_save_as(gsh);
+}
+
+#define PROMPT_FILENAME() antiright_pipe_read("gtkshell -df")
+
+static void
+get_filename(struct GSH * gsh)
+{
+       if(gsh->editor.filename)
+               g_free(gsh->editor.filename);
+       gsh->editor.filename=PROMPT_FILENAME();
+}
+
+void
+gsh_editor_save_as(struct GSH * gsh)
+{
+       TEST_EDITOR_EXISTS(gsh);
+       get_filename(gsh);
+       gsh_editor_save(gsh);
+}
+
+void
+gsh_editor_open(struct GSH * gsh)
+{
+       gchar * text;
+
+       TEST_EDITOR_EXISTS(gsh);
+       get_filename(gsh);
+       text=antiright_read_named_file(gsh->editor.filename);
+       GSH_TEXT_AREA_SET_TEXT(gsh->editor.widget, text);
+       g_free(text);
+}
+
+

Index: gtkshell/text.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/text.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- gtkshell/text.h     9 May 2007 19:53:37 -0000       1.8
+++ gtkshell/text.h     11 May 2007 23:28:52 -0000      1.9
@@ -40,4 +40,13 @@
 void
 gsh_text_editor(struct GSH * gsh, const gchar *filename);
 
+void
+gsh_editor_save_as(struct GSH * gsh);
+
+void
+gsh_editor_save(struct GSH * gsh);
+
+void
+gsh_editor_open(struct GSH * gsh);
+
 #endif

Index: libantiright/macros.h
===================================================================
RCS file: /sources/antiright/antiright/libantiright/macros.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- libantiright/macros.h       10 May 2007 00:08:28 -0000      1.7
+++ libantiright/macros.h       11 May 2007 23:28:52 -0000      1.8
@@ -83,6 +83,8 @@
 #define ARDELETE(class)\
        $(class, delete)
 
+#define $$(...) $(this, __VA_ARGS__)
+
 #define ARINHERIT(parent, child, member)\
        child->member=parent->member
 

Index: libantiright/string.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/string.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- libantiright/string.c       27 Apr 2007 21:46:06 -0000      1.10
+++ libantiright/string.c       11 May 2007 23:28:52 -0000      1.11
@@ -22,6 +22,7 @@
 
 #include "library.h"
 
+
 gint
 ar_asprintf(gchar **string, const gchar *format,...)
 {
@@ -31,8 +32,9 @@
        va_start(list, format);
        return_value = g_vasprintf(string, format, list);
        va_end(list);
-
+#ifdef DEBUG
        ARASSERT(return_value != -1);
+#endif /* DEBUG */
 
        return return_value;
 }

Index: libantiright/string.h
===================================================================
RCS file: /sources/antiright/antiright/libantiright/string.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libantiright/string.h       27 Apr 2007 21:46:06 -0000      1.5
+++ libantiright/string.h       11 May 2007 23:28:52 -0000      1.6
@@ -23,6 +23,10 @@
 #ifndef LIBAR_STRING_H
 #define LIBAR_STRING_H
 
+/* Prototype included here, as not defined in glib headers.  */
+gint
+g_vasprintf(gchar ** string, gchar const * format, va_list args);
+
 gint
 ar_asprintf(gchar **string, const gchar *format, ...);
 

Index: libantiright/util.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/util.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- libantiright/util.c 10 May 2007 00:08:28 -0000      1.15
+++ libantiright/util.c 11 May 2007 23:28:52 -0000      1.16
@@ -25,7 +25,6 @@
 gpointer
 xmalloc(size_t size)
 {
-
        /*
         * There is no need to check for success, as g_malloc causes
         * the application to terminate on failure.
@@ -34,3 +33,120 @@
        return (g_malloc(size));
 }
 
+static ARActionFunction
+ar_ARFunctionDictionary_lookup(struct ARFunctionDictionary * dict, 
+       const gchar * key)
+{
+       const gint argc = dict->__data->argc;
+       const gchar ** argv = (const gchar **)dict->__data->argv;
+       gint i;
+
+       for(i = 0; i < argc; i+=2)
+       {
+               if(!strcmp(argv[i], key))
+                       return (ARActionFunction)argv[i+1];
+       }
+
+       return NULL;
+}
+
+static void
+ar_ARFunctionDictionary_exec(struct ARFunctionDictionary * this, 
+       const gchar * key, gint * argc, gchar ** argv)
+{
+       const ARActionFunction definition = $$(lookup, key);
+       if(definition)
+               definition(argc, argv);
+}
+
+static void
+ar_delete_ARFunctionDictionary(struct ARFunctionDictionary * this)
+{
+       ARDELETE(this->__data);
+       g_free(this);
+}
+
+static void
+ar_ARFunctionDictionary_define(struct ARFunctionDictionary * this,
+       const gchar * key, ARActionFunction action)
+{
+       $(this->__data, add, key);
+       $(this->__data, add, (gchar*)action);
+}
+
+static void
+setup_ARFunctionDictionary_methods(struct ARFunctionDictionary * dict)
+{
+       dict->lookup = &ar_ARFunctionDictionary_lookup;
+       dict->exec = &ar_ARFunctionDictionary_exec;
+       dict->define = &ar_ARFunctionDictionary_define;
+       dict->delete = &ar_delete_ARFunctionDictionary;
+}
+
+static void
+setup_ARFunctionDictionary_fields(struct ARFunctionDictionary * this)
+{
+       this->__data=ARNEW(ar, ARArguments);
+}
+
+struct ARFunctionDictionary *
+ar_new_ARFunctionDictionary()
+{
+       struct ARFunctionDictionary * dict;
+
+       dict = xmalloc(sizeof(struct ARFunctionDictionary));
+       setup_ARFunctionDictionary_fields(dict);
+       setup_ARFunctionDictionary_methods(dict);
+
+       return dict;
+}
+
+
+static void
+ar_delete_ARCommandLineParser(struct ARCommandLineParser * parser)
+{
+       g_free(parser);
+}
+
+static void
+ar_ARCommandLineParser_set_args(struct ARCommandLineParser * parser,
+       const struct ARArguments * args)
+{
+       parser->__args=(struct ARArguments *)args;
+}
+
+static void
+ar_ARCommandLineParser_parse(struct ARCommandLineParser * this)
+{
+       struct ARFunctionDictionary * dict = 
+               (struct ARFunctionDictionary *)this->__dict;
+       const gint argc = (const gint)(this->__args->argc);
+       gchar ** argv = this->__args->argv;
+       gint i;
+
+       for(i=0; i < argc; i++)
+       {
+               $(dict, exec, (const gchar *)argv[i], &i, argv);
+       }
+}
+
+static void
+setup_ARCommandLineParser_methods(struct ARCommandLineParser * parser)
+{
+       parser->delete = &ar_delete_ARCommandLineParser;
+       parser->set_args = &ar_ARCommandLineParser_set_args;
+       parser->parse = &ar_ARCommandLineParser_parse;
+}
+
+struct ARCommandLineParser *
+ar_new_ARCommandLineParser(struct ARFunctionDictionary * dictionary)
+{
+       struct ARCommandLineParser * parser;
+
+       parser = xmalloc(sizeof(struct ARCommandLineParser));
+       parser->__dict=dictionary;
+       setup_ARCommandLineParser_methods(parser);
+
+       return parser;
+}
+

Index: libantiright/util.h
===================================================================
RCS file: /sources/antiright/antiright/libantiright/util.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- libantiright/util.h 10 May 2007 00:08:28 -0000      1.11
+++ libantiright/util.h 11 May 2007 23:28:52 -0000      1.12
@@ -23,21 +23,42 @@
 #ifndef LIBAR_UTIL_H
 #define LIBAR_UTIL_H
 
-
-/* Decimal bitmasks for boolean storage.  */
-#define ARB_0 1
-#define ARB_1 2
-#define ARB_2 4
-#define ARB_3 8
-#define ARB_4 16
-#define ARB_5 32
-#define ARB_6 64
-#define ARB_7 128
-#define ARB_8 256
+#define AR_TEXT_TO_FILE(filename, text)\
+       g_file_set_contents(filename, text, strlen(text), NULL)
 
 gpointer
 xmalloc(size_t size);
 
-#define UNUSED(arg) { arg = arg; }
+#define UNUSED(arg) /* undefined. */
+
+typedef void(*ARActionFunction)(gint *, gchar **);
+
+struct ARFunctionDictionary
+{
+       struct ARArguments * __data;
+       void (*define)(struct ARFunctionDictionary *, const gchar *,
+               ARActionFunction);
+       ARActionFunction (*lookup)(struct ARFunctionDictionary *,
+               const gchar *);
+       void (*exec)(struct ARFunctionDictionary *, const gchar *,
+               gint *, gchar **);
+       void (*delete)(struct ARFunctionDictionary *);
+};
+
+struct ARFunctionDictionary *
+ar_new_ARFunctionDictionary();
+
+struct ARCommandLineParser
+{
+       struct ARArguments * __args;
+       struct ARFunctionDictionary * __dict;
+       void (*set_args)(struct ARCommandLineParser *, 
+               const struct ARArguments * args);
+       void (*parse)(struct ARCommandLineParser *);
+       void (*delete)(struct ARCommandLineParser *);
+};
+
+struct ARCommandLineParser *
+ar_new_ARCommandLineParser(struct ARFunctionDictionary * dict);
 
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]