diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-04-16 09:57:18 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-04-16 09:57:18 +0200 |
commit | b8fb8382d1d472199970241900a30384a71b8060 (patch) | |
tree | 1cb6b415b98020922bf23f96c1f2967c6cc1eca0 /tools | |
parent | 4b845a0950d2e17fa18c36ca3c399b7ca3a70fac (diff) | |
download | ffi-efl-b8fb8382d1d472199970241900a30384a71b8060.zip ffi-efl-b8fb8382d1d472199970241900a30384a71b8060.tar.gz |
extract-api.sh uses external sed scripts
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/extract-api.sh | 36 | ||||
-rw-r--r-- | tools/sed-enums | 24 | ||||
-rw-r--r-- | tools/sed-functions | 8 |
3 files changed, 52 insertions, 16 deletions
diff --git a/tools/extract-api.sh b/tools/extract-api.sh index 3335fd7..ecf3edd 100755 --- a/tools/extract-api.sh +++ b/tools/extract-api.sh @@ -1,27 +1,31 @@ #! /bin/bash - +# +# TODO : use pkg-config +# +INCLUDE=$(pkg-config --libs ecore |gawk '{ print substr($1,3) }' | sed s/lib/include/) +# +rm *-diff 2>/dev/null +# for header in \ - '/opt/e17/include/eet-1/Eet.h' \ - '/opt/e17/include/edje-1/Edje.h' \ - '/opt/e17/include/evas-1/Evas.h' \ - '/opt/e17/include/evas-1/Evas_GL.h' \ - '/opt/e17/include/ecore-1/Ecore.h' \ - '/opt/e17/include/ecore-1/Ecore_Con.h' \ - '/opt/e17/include/ecore-1/Ecore_Evas.h' \ - '/opt/e17/include/ecore-1/Ecore_Fb.h' \ - '/opt/e17/include/ecore-1/Ecore_File.h' \ - '/opt/e17/include/elementary-0/Elementary.h' \ + "${INCLUDE}/eet-1/Eet.h" \ + "${INCLUDE}/edje-1/Edje.h" \ + "${INCLUDE}/evas-1/Evas.h" \ + "${INCLUDE}/evas-1/Evas_GL.h" \ + "${INCLUDE}/ecore-1/Ecore.h" \ + "${INCLUDE}/ecore-1/Ecore_Con.h" \ + "${INCLUDE}/ecore-1/Ecore_Evas.h" \ + "${INCLUDE}/ecore-1/Ecore_Fb.h" \ + "${INCLUDE}/ecore-1/Ecore_File.h" \ + "${INCLUDE}/elementary-0/Elementary.h" \ ; do # DIR=$(dirname $header) FILE=$(basename $header) # - [ -f $FILE-diff ] && rm $FILE-diff [ -f $FILE ] && mv $FILE $FILE.prev - # loop1 : fix EAPI with return type on separate line - # loop2 : fix EAPI with multilines arguments - cat $header | sed -ne ':loop1;/EAPI.*[^;]$/N;s/\n//;s/ \{2,\}/ /g;t loop1;' -e ':loop2;/,$/N;s/,\n/ /;s/ \{2,\}/ /g;t loop2;' -e 's/^ *EAPI/EAPI/p' > $FILE - # sed -r 's/EAPI ([a-zA-Z][a-zA-Z_ ]*[a-zA-Z]( \*+ ?| ))([a-z[a-z_0-9]*[a-z]) ?\(([a-zA-Z0-9_ \*,\.]+)\) */#\1#\3#\4#/' > $FILE + # + cat $header | sed -n -f sed-functions > $FILE + cat $header | sed -r -n -f sed-enums > $FILE-enum # if [ -f $FILE.prev ]; then diff -u0 $FILE.prev $FILE > $FILE-diff diff --git a/tools/sed-enums b/tools/sed-enums new file mode 100644 index 0000000..13ce112 --- /dev/null +++ b/tools/sed-enums @@ -0,0 +1,24 @@ +s/.*(enum\s+[a-zA-Z0-9_]+).*$/typedef \1 { / +T +h +:attrs +n +s/^\s*([A-Z0-9_]+).*$/\1, / +T next;H;b attrs +:next +/^\s*\}/ ! b attrs +s/^\s*}\s*([a-zA-Z0-9_]+).*$/ } \1;/ +t end +# TODO fix above !! +/^\s*\}\s*;.*$/ { + :loop2 + n + /typedef/ ! b loop2 + s/^\s*typedef\s+enum\s+[a-zA-Z0-9_]+\s+([a-zA-Z0-9_]+)/ } \1/ + t end +} +:end +H;x +s/\n//g +s/ {2,}/ /g +s/, }/ }/p diff --git a/tools/sed-functions b/tools/sed-functions new file mode 100644 index 0000000..bcd57d0 --- /dev/null +++ b/tools/sed-functions @@ -0,0 +1,8 @@ + +# if return type on single line, append next line +/EAPI.*[^;] *$/ { N; s/\n/ / } +# while unfinished argument list, append next line +:loop +/,$/ { N; s/\n/ /; t loop } +s/ \{2,\}/ /g +s/^ *EAPI/EAPI/p |