add travis-pecl submodule
[m6w6/ext-pq] / php_pq_type.awk
1 #!/usr/bin/awk -f
2
3 BEGIN {
4 printf "#ifndef PHP_PQ_TYPE\n"
5 printf "# define PHP_PQ_TYPE(t,o)\n"
6 printf "#endif\n"
7 }
8
9 END {
10 printf "#ifndef PHP_PQ_TYPE_IS_ARRAY\n"
11 printf "# define PHP_PQ_TYPE_IS_ARRAY(oid) (\\\n\t\t0 \\\n"
12 for (oid in arrays) {
13 printf "\t||\t((oid) == %d) \\\n", oid
14 }
15 printf ")\n#endif\n"
16
17 printf "#ifndef PHP_PQ_TYPE_OF_ARRAY\n"
18 printf "# define PHP_PQ_TYPE_OF_ARRAY(oid) ("
19 for (oid in arrays) {
20 printf "\\\n\t(oid) == %d ? %s : ", oid, arrays[oid]
21 }
22 printf "0 \\\n)\n#endif\n"
23
24 printf "#ifndef PHP_PQ_DELIM_OF_ARRAY\n"
25 printf "# define PHP_PQ_DELIM_OF_ARRAY(oid) ("
26 for (oid in delims) {
27 printf "\\\n\t(oid) == %d ? '%s' : ", oid, delims[oid]
28 }
29 printf "0 \\\n)\n#endif\n"
30 }
31
32 /^DATA/ {
33 oid = $4
34 name = toupper($6)
35 adelim = $15
36 atypoid = $17
37 if (sub("^_", "", name)) {
38 arrays[oid] = atypoid
39 name = name "ARRAY"
40 }
41 delims[oid] = adelim
42 printf "#ifndef PHP_PQ_OID_%s\n", name
43 printf "# define PHP_PQ_OID_%s %d\n", name, oid
44 printf "#endif\n"
45 printf "PHP_PQ_TYPE(\"%s\", %d)\n", name, oid
46 }