summaryrefslogtreecommitdiff
path: root/Source/DirectFB/tools/mknames.sh
diff options
context:
space:
mode:
Diffstat (limited to 'Source/DirectFB/tools/mknames.sh')
-rwxr-xr-xSource/DirectFB/tools/mknames.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/Source/DirectFB/tools/mknames.sh b/Source/DirectFB/tools/mknames.sh
new file mode 100755
index 0000000..8e4ca2f
--- /dev/null
+++ b/Source/DirectFB/tools/mknames.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+if test -z "$6"; then
+ echo "Usage: $0 <enum> <prefix> <null> <name> <value> <header>"
+ echo "Example: $0 DFBSurfacePixelFormat DSPF UNKNOWN PixelFormat format directfb.h"
+ exit 1
+fi
+
+ENUM=$1
+PREFIX=$2
+NULL=$3
+NAME=$4
+VALUE=$5
+HEADER=$6
+
+
+cat << EOF
+
+
+struct DFB${NAME}Name {
+ ${ENUM} ${VALUE};
+ const char *name;
+};
+
+#define DirectFB${NAME}Names(Identifier) struct DFB${NAME}Name Identifier[] = { \\
+EOF
+
+egrep "^ +${PREFIX}_[0-9A-Za-z_]+[ ,]" $HEADER | grep -v ${PREFIX}_${NULL} | perl -p -e "s/^\\s*(${PREFIX}_)([\\w_]+)[ ,].*/ \\{ \\1\\2, \\\"\\2\\\" \\}, \\\\/"
+
+cat << EOF
+ { ${PREFIX}_${NULL}, "${NULL}" } \\
+};
+EOF