[PATCH] removed WidgetList, name_func_link_t and related function

2009-06-17 Thread Perrin Alexandre
Hi!

jd could you check this patch? I compiled/run awesome with it without
any problems but I'm not confident with this patch since I don't know
the awesome codebase well.

It remove the WidgetList, name_func_link_t and related function and use
tokenize.gperf instead.

Cheers,
Alexandre Perrin.
From bd1923b5981023f748e1741b5bd69ada887e753b Mon Sep 17 00:00:00 2001
From: Perrin kAworu Alexandre kaworu(a)kaworu,ch
Date: Wed, 17 Jun 2009 15:57:10 +0200
Subject: [PATCH] removed WidgetList, name_func_link_t and related function

use tokenize.gperf instead.

Signed-off-by: Perrin kAworu Alexandre kaworu(a)kaworu,ch
---
 CMakeLists.txt   |   13 +
 build-utils/widgetgen.sh |   18 --
 common/tokenize.gperf|5 +
 common/util.c|   39 ---
 common/util.h|   10 --
 widget.c |   26 +++---
 6 files changed, 29 insertions(+), 82 deletions(-)
 delete mode 100755 build-utils/widgetgen.sh

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b4af79c..4075c17 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -99,16 +99,6 @@ target_link_libraries(${PROJECT_AWE_NAME}
 ${AWESOME_REQUIRED_LIBRARIES}
 ${AWESOME_OPTIONAL_LIBRARIES})
 
-# {{{ Generated sources
-add_custom_command(
-COMMAND ${SOURCE_DIR}/build-utils/widgetgen.sh
-ARGS ${BUILD_DIR}/widgetgen.h
-OUTPUT  ${BUILD_DIR}/widgetgen.h
-WORKING_DIRECTORY ${SOURCE_DIR}
-DEPENDS ${SOURCE_DIR}/widget.h
-COMMENT Generating widgetgen.h
-VERBATIM)
-
 # atoms
 file(MAKE_DIRECTORY ${BUILD_DIR}/common)
 add_custom_command(
@@ -149,8 +139,7 @@ add_custom_command(
 COMMENT Generating common/tokenize.c)
 
 add_custom_target(generated_sources
-DEPENDS ${BUILD_DIR}/widgetgen.h
-${BUILD_DIR}/common/atoms-intern.h
+DEPENDS ${BUILD_DIR}/common/atoms-intern.h
 ${BUILD_DIR}/common/atoms-extern.h
 ${BUILD_DIR}/common/tokenize.c
 ${BUILD_DIR}/common/tokenize.h)
diff --git a/build-utils/widgetgen.sh b/build-utils/widgetgen.sh
deleted file mode 100755
index ae71b0b..000
--- a/build-utils/widgetgen.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-top_srcdir=${1-.}
-echo /* This file is autogenerated by `basename $0` */
-echo
-echo const name_func_link_t WidgetList[] =
-echo {
-for file in ${top_srcdir}/widget.h
-do
-echo /* $file */
-grep '^widget_constructor_t ' $file | cut -d' ' -f2 | cut -d\; -f1 | while read widget
-do
-shortname=`echo $widget | cut -d_ -f2`
-echo {\$shortname\, sizeof(\$shortname\) - 1, $widget},
-done
-done
-
-echo {NULL, 0, NULL}
-echo };
diff --git a/common/tokenize.gperf b/common/tokenize.gperf
index c1313df..8713fdd 100644
--- a/common/tokenize.gperf
+++ b/common/tokenize.gperf
@@ -37,6 +37,7 @@ font_height
 fullscreen
 gap
 geometry
+graph
 group_id
 grow
 height
@@ -45,6 +46,7 @@ icon
 icon_name
 id
 image
+imagebox
 instance
 key
 key_press
@@ -79,6 +81,7 @@ plot_data_add
 plot_properties_set
 position
 press
+progressbar
 release
 resize
 right
@@ -94,7 +97,9 @@ south
 start
 sticky
 system
+systray
 text
+textbox
 ticks_count
 ticks_gap
 titlebar
diff --git a/common/util.c b/common/util.c
index 3c89e51..ed339d4 100644
--- a/common/util.c
+++ b/common/util.c
@@ -57,45 +57,6 @@ _warn(int line, const char *fct, const char *fmt, ...)
 fprintf(stderr, \n);
 }
 
-/** Lookup for a function pointer from its name
- * in the given name_func_link_t list.
- * \param funcname Function name.
- * \param len The function name length.
- * \param list Function and name link list.
- * \return Function pointer.
- */
-void *
-name_func_lookup(const char *funcname, size_t len, const name_func_link_t *list)
-{
-int i;
-
-if(funcname  list)
-for(i = 0; list[i].name; i++)
-if(len == list[i].len  !a_strcmp(funcname, list[i].name))
-return list[i].func;
-
-return NULL;
-}
-
-/** Lookup for a function name from its pointer
- * in the given name_func_link_t list.
- * \param funcp Function pointer.
- * \param list Function and name link list.
- * \return Name of the function.
- */
-const char *
-name_func_rlookup(void * funcp, const name_func_link_t *list)
-{
-int i;
-
-if(funcp  list)
-for(i = 0; list[i].name; i++)
-if(funcp == list[i].func)
-return list[i].name;
-
-return NULL;
-}
-
 /** Get a position type from a string.
  * \param pos The position.
  * \param len The string length, -1 if unknown.
diff --git a/common/util.h b/common/util.h
index 6d2c23c..794b929 100644
--- a/common/util.h
+++ b/common/util.h
@@ -52,14 +52,6 @@ typedef enum
 Left
 } position_t;
 
-/** Link a name to a function */
-typedef struct
-{
-const char *name;
-size_t len;
-void *func;
-} name_func_link_t;
-
 /** \brief replace \c NULL strings with emtpy strings */
 #define NONULL(x)   (x ? x : )
 
@@ -348,8

Re: [PATCH] removed WidgetList, name_func_link_t and related function

2009-06-17 Thread Julien Danjou
At 1245247677 time_t, Perrin Alexandre wrote:
 jd could you check this patch? I compiled/run awesome with it without
 any problems but I'm not confident with this patch since I don't know
 the awesome codebase well.
 
 It remove the WidgetList, name_func_link_t and related function and use
 tokenize.gperf instead.

Good work, merged.

Thanks!

Cheers,
-- 
Julien Danjou
// ᐰ jul...@danjou.info   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
// Trust me.


signature.asc
Description: Digital signature