X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-pq;a=blobdiff_plain;f=php_pq_type.awk;h=b5d07b4d53c1a6e5707a5265610ef82bbbc4b9ae;hp=c9ed34bbd74f5d0bd74d7231355499389fb941fc;hb=10e7d6adccdd55554f1512de5e829a75aef62461;hpb=fad4fe6a60c56ad5d5752e10abd1085884cc09c2 diff --git a/php_pq_type.awk b/php_pq_type.awk index c9ed34b..b5d07b4 100755 --- a/php_pq_type.awk +++ b/php_pq_type.awk @@ -9,19 +9,36 @@ BEGIN { END { printf "#ifndef PHP_PQ_TYPE_IS_ARRAY\n" printf "# define PHP_PQ_TYPE_IS_ARRAY(oid) (\\\n\t\t0 \\\n" - for (name in arrays) { - printf "\t||\t((oid) == %d) \\\n", arrays[name] + for (oid in arrays) { + printf "\t||\t((oid) == %d) \\\n", oid } printf ")\n#endif\n" + + printf "#ifndef PHP_PQ_TYPE_OF_ARRAY\n" + printf "# define PHP_PQ_TYPE_OF_ARRAY(oid) (" + for (oid in arrays) { + printf "\\\n\t(oid) == %d ? %s : ", oid, arrays[oid] + } + printf "0 \\\n)\n#endif\n" + + printf "#ifndef PHP_PQ_DELIM_OF_ARRAY\n" + printf "# define PHP_PQ_DELIM_OF_ARRAY(oid) (" + for (oid in delims) { + printf "\\\n\t(oid) == %d ? '%s' : ", oid, delims[oid] + } + printf "0 \\\n)\n#endif\n" } /^DATA/ { oid = $4 name = toupper($6) + adelim = $15 + atypoid = $17 if (sub("^_", "", name)) { - arrays[name] = oid + arrays[oid] = atypoid name = name "ARRAY" } + delims[oid] = adelim printf "#ifndef PHP_PQ_OID_%s\n", name printf "# define PHP_PQ_OID_%s %d\n", name, oid printf "#endif\n"