summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-10-21 11:18:11 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-10-21 11:18:11 +0200
commit961dd6b19e860f3a47c4435f359f7c372cb03084 (patch)
treeeb744dedc67c8acf6d5e135c115b7428e8b49da6
parent3a9ae6b9d5f30898ec06819897145efc475a5625 (diff)
downloadffi-efl-961dd6b19e860f3a47c4435f359f7c372cb03084.zip
ffi-efl-961dd6b19e860f3a47c4435f359f7c372cb03084.tar.gz
add comment to sed scripts, fix sed-enum
-rw-r--r--tools/sed-callbacks11
-rw-r--r--tools/sed-enums17
-rw-r--r--tools/sed-functions8
-rw-r--r--tools/sed-types18
-rw-r--r--tools/sed-variables3
5 files changed, 47 insertions, 10 deletions
diff --git a/tools/sed-callbacks b/tools/sed-callbacks
index 4a2e27f..42051ba 100644
--- a/tools/sed-callbacks
+++ b/tools/sed-callbacks
@@ -1,11 +1,20 @@
+# drop if don't start with typedef
+/^\s*typedef/ ! b
+# one line typedef xxx (...); we are done
s/^\s*typedef\s+(.*)(\(\*?\w+\))?\s*(\(.*\));.*$/typedef \1 \2 \3;/
t finish
+# if ends with ,
s/^\s*typedef\s+(.*)(\(\*?\w+\))?\s*(\(.*,)/typedef \1 \2 \3/
+# drop if substitution fail, copy pattern to hold space
T;h
:loop;n
+# append each parameters
/,$/ { H; b loop }
-/;$/ { H;x}
+# when ; reached, append a swap hold space to pattern space
+/;.*$/ { H;x}
:finish
+# drop \n
s/\n//g
+# replace multi spaces with one
s/ {2,}/ /g
p
diff --git a/tools/sed-enums b/tools/sed-enums
index ffc193b..14738ac 100644
--- a/tools/sed-enums
+++ b/tools/sed-enums
@@ -1,17 +1,32 @@
-s/^\s*(typedef)?\s+(enum(\s+\w+)?).*$/typedef \2 { /
+# drop if don't start with (typedef)? enum
+/^\s*(typedef\s)?\s*enum/ ! b
+#
+s/^\s*(typedef\s)?\s*(enum(\s+\w+)?).*$/typedef \2 { /
+# drop if substitution fail, copy pattern to hold space
T;h
:attrs;n
+# read again if {
+/^\s*\{/ b attrs
+# append each item
s/^\s*([A-Z0-9_]+)(\s*=\s*-?[0-9]+)?.*$/\1\2, /
+# goto next if subsitution fails, append pattern, loop
T next;H;b attrs
:next
+# try again if } not found
/^\s*\}/ ! b attrs
+# read enumeration name
s/^\s*}\s*(\w+).*$/ } \1;/
t finish
:close
+# read the enum typedef
s/^\s*typedef\s+enum\s+\w+\s+(\w+)\s*;/ } \1/
+# leave if substitution works, or read next line and retry
t finish;n;b close
:finish
+# append pattern, exchange hold space and pattern space
H;x
+# remove \n
s/\n//g
+# replace multi spaces with one
s/ {2,}/ /g
s/, }/ }/p
diff --git a/tools/sed-functions b/tools/sed-functions
index 296cab1..ac784a5 100644
--- a/tools/sed-functions
+++ b/tools/sed-functions
@@ -1,9 +1,13 @@
-/EAPI extern/ b
-# if return type on single line, append next line
+# drop if don't start with EAPI
+/^\s*EAPI/ ! b
+# drop extern definitions
+/EAPI\s+extern/ b
+# if does not end with ;, append next line
/EAPI.*[^;]\s*$/ { N; s/\n/ / }
# while unfinished argument list, append next line
:loop
/,$/ { N; s/\n/ /; t loop }
+# replace multi spaces with one ...
s/ {2,}/ /g
s/\s+EINA_.*/;/
s/^\s*EAPI/EAPI/p
diff --git a/tools/sed-types b/tools/sed-types
index 7ac79a2..52a7252 100644
--- a/tools/sed-types
+++ b/tools/sed-types
@@ -1,14 +1,22 @@
+# drop if don't start with typedef
+/^\s*typedef/ ! b
+# read one line typedef (struct)? (word*)? (*)? word;
s/^\s*typedef\s+(struct\s+)?((\w+\**\s+)*)(\w+)\s*;.*$/typedef \1 \2 \4;/
t finish
+# read multi line
s/^\s*typedef\s+(struct.*[^;].*)/typedef \1/
-T
-h
-:loop
-n
+# leave if substitution fails, or copy pattern to hold space
+T; h
+:loop; n
+# read till } is reached
/^\s*\}/ ! b loop
+# take care of the last } word;
s/^\s*\}\s*(\w+)\s*;.*$/\1;/
+# append pattern to hold space, then swap
H;x
-s/\n/ /g
:finish
+# remove \n
+s/\n/ /g
+# replace multi spaces with one ...
s/ {2,}/ /g
p
diff --git a/tools/sed-variables b/tools/sed-variables
index 3f11c67..36c612f 100644
--- a/tools/sed-variables
+++ b/tools/sed-variables
@@ -1 +1,2 @@
-s/(EAPI\s+extern\s+\w+\s+\*?\w+\s*;).*$/\1/p
+# variable should be EAPI extern word word;;
+s/^\s*(EAPI\s+extern\s+\w+\s+\*?\w+\s*;).*$/\1/p