removed WidgetList, name_func_link_t and related function
use tokenize.gperf instead. Signed-off-by: Perrin "kAworu" Alexandre <kaworu(a)kaworu,ch> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
654bfae6f7
commit
319f2d55bc
|
@ -99,16 +99,6 @@ target_link_libraries(${PROJECT_AWE_NAME}
|
||||||
${AWESOME_REQUIRED_LIBRARIES}
|
${AWESOME_REQUIRED_LIBRARIES}
|
||||||
${AWESOME_OPTIONAL_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
|
# atoms
|
||||||
file(MAKE_DIRECTORY ${BUILD_DIR}/common)
|
file(MAKE_DIRECTORY ${BUILD_DIR}/common)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
@ -149,8 +139,7 @@ add_custom_command(
|
||||||
COMMENT "Generating common/tokenize.c")
|
COMMENT "Generating common/tokenize.c")
|
||||||
|
|
||||||
add_custom_target(generated_sources
|
add_custom_target(generated_sources
|
||||||
DEPENDS ${BUILD_DIR}/widgetgen.h
|
DEPENDS ${BUILD_DIR}/common/atoms-intern.h
|
||||||
${BUILD_DIR}/common/atoms-intern.h
|
|
||||||
${BUILD_DIR}/common/atoms-extern.h
|
${BUILD_DIR}/common/atoms-extern.h
|
||||||
${BUILD_DIR}/common/tokenize.c
|
${BUILD_DIR}/common/tokenize.c
|
||||||
${BUILD_DIR}/common/tokenize.h)
|
${BUILD_DIR}/common/tokenize.h)
|
||||||
|
|
|
@ -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 "};"
|
|
|
@ -37,6 +37,7 @@ font_height
|
||||||
fullscreen
|
fullscreen
|
||||||
gap
|
gap
|
||||||
geometry
|
geometry
|
||||||
|
graph
|
||||||
group_id
|
group_id
|
||||||
grow
|
grow
|
||||||
height
|
height
|
||||||
|
@ -45,6 +46,7 @@ icon
|
||||||
icon_name
|
icon_name
|
||||||
id
|
id
|
||||||
image
|
image
|
||||||
|
imagebox
|
||||||
instance
|
instance
|
||||||
key
|
key
|
||||||
key_press
|
key_press
|
||||||
|
@ -79,6 +81,7 @@ plot_data_add
|
||||||
plot_properties_set
|
plot_properties_set
|
||||||
position
|
position
|
||||||
press
|
press
|
||||||
|
progressbar
|
||||||
release
|
release
|
||||||
resize
|
resize
|
||||||
right
|
right
|
||||||
|
@ -94,7 +97,9 @@ south
|
||||||
start
|
start
|
||||||
sticky
|
sticky
|
||||||
system
|
system
|
||||||
|
systray
|
||||||
text
|
text
|
||||||
|
textbox
|
||||||
ticks_count
|
ticks_count
|
||||||
ticks_gap
|
ticks_gap
|
||||||
titlebar
|
titlebar
|
||||||
|
|
|
@ -57,45 +57,6 @@ _warn(int line, const char *fct, const char *fmt, ...)
|
||||||
fprintf(stderr, "\n");
|
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.
|
/** Get a position type from a string.
|
||||||
* \param pos The position.
|
* \param pos The position.
|
||||||
* \param len The string length, -1 if unknown.
|
* \param len The string length, -1 if unknown.
|
||||||
|
|
|
@ -52,14 +52,6 @@ typedef enum
|
||||||
Left
|
Left
|
||||||
} position_t;
|
} 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 */
|
/** \brief replace \c NULL strings with emtpy strings */
|
||||||
#define NONULL(x) (x ? x : "")
|
#define NONULL(x) (x ? x : "")
|
||||||
|
|
||||||
|
@ -350,8 +342,6 @@ position_t position_fromstr(const char *, ssize_t);
|
||||||
const char * position_tostr(position_t);
|
const char * position_tostr(position_t);
|
||||||
orientation_t orientation_fromstr(const char *, ssize_t);
|
orientation_t orientation_fromstr(const char *, ssize_t);
|
||||||
const char * orientation_tostr(orientation_t);
|
const char * orientation_tostr(orientation_t);
|
||||||
void *name_func_lookup(const char *, size_t, const name_func_link_t *);
|
|
||||||
const char * name_func_rlookup(void *, const name_func_link_t *);
|
|
||||||
void a_exec(const char *);
|
void a_exec(const char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
28
widget.c
28
widget.c
|
@ -32,8 +32,6 @@
|
||||||
#include "common/atoms.h"
|
#include "common/atoms.h"
|
||||||
#include "common/xutil.h"
|
#include "common/xutil.h"
|
||||||
|
|
||||||
#include "widgetgen.h"
|
|
||||||
|
|
||||||
DO_LUA_TOSTRING(widget_t, widget, "widget")
|
DO_LUA_TOSTRING(widget_t, widget, "widget")
|
||||||
|
|
||||||
/** Collect a widget structure.
|
/** Collect a widget structure.
|
||||||
|
@ -353,14 +351,36 @@ luaA_widget_new(lua_State *L)
|
||||||
{
|
{
|
||||||
const char *align, *type;
|
const char *align, *type;
|
||||||
widget_t *w;
|
widget_t *w;
|
||||||
widget_constructor_t *wc;
|
widget_constructor_t *wc = NULL;
|
||||||
|
awesome_token_t token;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
luaA_checktable(L, 2);
|
luaA_checktable(L, 2);
|
||||||
|
|
||||||
type = luaA_getopt_lstring(L, 2, "type", NULL, &len);
|
type = luaA_getopt_lstring(L, 2, "type", NULL, &len);
|
||||||
|
|
||||||
if((wc = name_func_lookup(type, len, WidgetList)))
|
switch((token = a_tokenize(type, len)))
|
||||||
|
{
|
||||||
|
case A_TK_TEXTBOX:
|
||||||
|
wc = widget_textbox;
|
||||||
|
break;
|
||||||
|
case A_TK_PROGRESSBAR:
|
||||||
|
wc = widget_progressbar;
|
||||||
|
break;
|
||||||
|
case A_TK_GRAPH:
|
||||||
|
wc = widget_graph;
|
||||||
|
break;
|
||||||
|
case A_TK_SYSTRAY:
|
||||||
|
wc = widget_systray;
|
||||||
|
break;
|
||||||
|
case A_TK_IMAGEBOX:
|
||||||
|
wc = widget_imagebox;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wc)
|
||||||
{
|
{
|
||||||
w = widget_new(L);
|
w = widget_new(L);
|
||||||
wc(w);
|
wc(w);
|
||||||
|
|
Loading…
Reference in New Issue