aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-13 01:27:10 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-13 01:27:10 +0000
commitff6d5901efd413e3b2d17f2d1dcd61a5e109f742 (patch)
tree44fb4362e7867285e6a47d1767028662e77c98da
parent438cd3c783936cbb2814637a5c90c6a44f9d4fa9 (diff)
downloadpaludis-ff6d5901efd413e3b2d17f2d1dcd61a5e109f742.tar.gz
paludis-ff6d5901efd413e3b2d17f2d1dcd61a5e109f742.tar.xz
Newer, lighter sr code
-rwxr-xr-xmisc/make_sr.bash345
1 files changed, 154 insertions, 191 deletions
diff --git a/misc/make_sr.bash b/misc/make_sr.bash
index 20c7b75..f2a7a41 100755
--- a/misc/make_sr.bash
+++ b/misc/make_sr.bash
@@ -1,6 +1,9 @@
#!/bin/bash
# vim: set sw=4 sts=4 et tw=0 :
+what_to_make=${1}
+shift
+
echo -n "/* vim"
echo ": set ro : */"
echo
@@ -9,8 +12,13 @@ echo "/* THIS IS A GENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY */"
echo "/* ******************************************************** */"
echo
-what_to_make=${1}
-shift
+if [[ "${what_to_make}" == "--header" ]] ; then
+ echo "#ifdef DOXYGEN"
+ echo "// doxygen needs this to get namespaces right"
+ echo "namespace paludis"
+ echo "{"
+ echo "#endif"
+fi
for src in ${@} ; do
if ! source ${src} ; then
@@ -140,6 +148,8 @@ while read a ; do
}
if [[ "${what_to_make}" == "--header" ]] ; then
+ current_class=${a}
+
if [[ -z ${want_visible} ]] ; then
echo -n "class ${a}"
else
@@ -164,7 +174,7 @@ while read a ; do
echo " public:"
echo
echo " ///\\name Data members"
- echo " ///\{"
+ echo " ///\\{"
echo
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
@@ -172,13 +182,13 @@ while read a ; do
done
echo
- echo " ///\}"
+ echo " ///\\}"
echo
if [[ -n "${want_comparison_operators}" ]] ; then
echo " ///\\name Comparison operators"
- echo " ///\{"
+ echo " ///\\{"
echo
if [[ "${want_comparison_operators}" == "all" ]] ; then
@@ -196,12 +206,12 @@ while read a ; do
done
echo
- echo " ///\}"
+ echo " ///\\}"
echo
fi
echo " ///\\name Basic operations"
- echo " ///\{"
+ echo " ///\\{"
echo
echo " explicit ${a}("
@@ -219,235 +229,177 @@ while read a ; do
make_class_${a}
echo
- echo " ///\}"
+ echo " ///\\}"
echo
if [[ -n "${want_named_args}" ]] ; then
- echo "#ifndef DOXYGEN"
echo " ///\\name Named argument constructor"
- echo " ///\{"
+ echo " ///\\{"
echo
- for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- n=${want_keys[${k}]}
- t=${want_key_types[${k}]}
- echo " /**"
- echo " * Holds the named parameter construction value for ${a}.${n}"
- echo " */"
- echo " class Param_${n}"
- echo " {"
- echo " private:"
- echo " Param_${n}();"
- echo
- echo " public:"
- echo " /// The value"
- echo " $(make_const_ref "${t}" ) ${n};"
- echo
- echo " ///\\name Basic operations"
- echo " ///\{"
- echo
- echo " Param_${n}(const paludis::Empty &, $(make_const_ref "${t}" ) value_for_${n}) :"
- echo " ${n}(value_for_${n})"
- echo " {"
- echo " }"
- echo
- echo " /// Constructor"
- echo " Param_${n}(const paludis::Empty &, const Param_${n} & other) :"
- echo " ${n}(other.${n})"
- echo " {"
- echo " }"
- echo
- echo " ///\}"
- echo " };"
- echo
- echo " /**"
- echo " * Provides the ${n} method for ${a} named parameters."
- echo " */"
- echo " template <typename Before_, typename After_>"
- echo " class ParamNeeded_${n}"
- echo " {"
- echo " private:"
- echo " const Before_ & _before;"
- echo
- echo " public:"
- echo " ///\\name Basic operations"
- echo " ///\{"
- echo
- echo " After_"
- echo " ${n}($(make_const_ref "${t}" ) value_for_${n})"
- echo " {"
- echo " return After_("
- for (( j = 0 ; j < ${#want_keys[@]} ; j++ )) ; do
- if [[ ${j} == ${k} ]] ; then
- echo -n " Param_${n}(_before, value_for_${n})"
- else
- echo -n " _before"
- fi
- if [[ $(( ${j} + 1 )) -lt ${#want_keys[@]} ]] ; then
- echo ","
- else
- echo
- fi
- done
- echo " );"
- echo " }"
- echo
- echo " ParamNeeded_${n}(const Before_ & before, const paludis::Empty &) :"
- echo " _before(before)"
- echo " {"
- echo " }"
- echo
- echo " ///\}"
- echo " };"
- echo
- done
+ echo "/**"
+ echo " * Named arguments for the constructor for ${current_class}."
+ echo " *"
+ echo " * \\see ${current_class}"
+ echo " * \\ingroup grpnamedarguments"
+ echo " * \\nosubgrouping"
+ echo " */"
- echo " /**"
- echo " * Handle named parameters for ${a}."
- echo " */"
- echo " template <"
+ echo "template <"
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- echo -n " bool has_${want_keys[${k}]}_ = true"
+ echo -n " bool has_${k}_ = true"
if [[ $(( ${k} + 1 )) -lt ${#want_keys[@]} ]] ; then
echo ","
else
- echo
+ echo ">"
fi
done
- echo " >"
- echo " class Params :"
+ echo "class NamedArguments"
+ echo "{"
+ echo " friend class ${current_class};"
+ echo " template <"
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- echo " public paludis::Select<has_${want_keys[${k}]}_,"
- echo " Param_${want_keys[${k}]},"
- echo " ParamNeeded_${want_keys[${k}]}<"
- echo -n " Params<"
- for (( j = 0 ; j < ${#want_keys[@]} ; j++ )) ; do
- if [[ ${j} == ${k} ]] ; then
- echo -n "false"
- else
- echo -n "has_${want_keys[${j}]}_"
- fi
- if [[ $(( ${j} + 1 )) -lt ${#want_keys[@]} ]] ; then
- echo -n ", "
- else
- echo ">,"
- fi
- done
- echo -n " Params<"
- for (( j = 0 ; j < ${#want_keys[@]} ; j++ )) ; do
- if [[ ${j} == ${k} ]] ; then
- echo -n "true"
- else
- echo -n "has_${want_keys[${j}]}_"
- fi
- if [[ $(( ${j} + 1 )) -lt ${#want_keys[@]} ]] ; then
- echo -n ", "
- else
- echo "> >"
- fi
- done
- echo " >::Type,"
+ echo -n " bool"
+ if [[ $(( ${k} + 1 )) -lt ${#want_keys[@]} ]] ; then
+ echo ","
+ else
+ echo ">"
+ fi
done
- echo " public paludis::Empty"
- echo " {"
- echo " private:"
- echo " Params();"
+ echo " friend class ${current_class}::NamedArguments;"
echo
- echo " public:"
- echo " ///\\name Basic operations"
- echo " ///\{"
- echo
- echo " Params("
+ echo " private:"
+
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- n=${want_keys[${k}]}
- echo -n " "
- echo -n "const typename paludis::Select<has_${n}_, Param_${n}, paludis::Empty>::Type & value_for_${n}"
+ echo " const typename paludis::Select<has_${k}_, ${want_key_types[${k}]}, paludis::Empty>::Type _v${k};"
+ done
+
+ echo " NamedArguments("
+ for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
+ echo -n " const typename paludis::Select<has_${k}_, ${want_key_types[${k}]}, paludis::Empty>::Type & v${k}"
+ if [[ $(( ${k} + 1 )) -lt ${#want_keys[@]} ]] ; then
+ echo ","
+ else
+ echo ") :"
+ fi
+ done
+ for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
+ echo -n " _v${k}(v${k})"
if [[ $(( ${k} + 1 )) -lt ${#want_keys[@]} ]] ; then
echo ","
else
echo
fi
done
- echo " ) :"
+ echo " {"
+ echo " }"
+
+ echo
+ echo " public:"
+ echo
+
+ echo " ///\\name Value specification functions"
+ echo " ///\\{"
+
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- echo " paludis::Select<has_${want_keys[${k}]}_,"
- echo " Param_${want_keys[${k}]},"
- echo " ParamNeeded_${want_keys[${k}]}<"
- echo -n " Params<"
- for (( j = 0 ; j < ${#want_keys[@]} ; j++ )) ; do
- if [[ ${j} == ${k} ]] ; then
- echo -n "false"
+ echo " /**"
+ echo " * Set the value of the ${current_class}.${want_keys[${k}]} member."
+ echo " */"
+ echo " NamedArguments<"
+ for (( kk = 0 ; kk < ${#want_keys[@]} ; kk++ )) ; do
+ if [[ ${k} == ${kk} ]] ; then
+ echo -n " true"
+ else
+ echo -n " has_${kk}_"
+ fi
+ if [[ $(( ${kk} + 1 )) -lt ${#want_keys[@]} ]] ; then
+ echo ","
else
- echo -n "has_${want_keys[${j}]}_"
+ echo ">"
fi
- if [[ $(( ${j} + 1 )) -lt ${#want_keys[@]} ]] ; then
- echo -n ", "
+ done
+ echo " ${want_keys[${k}]}($(make_const_ref "${want_key_types[${k}]}" ) v)"
+ echo " {"
+ echo " const typename paludis::Select<has_${k}_, void, paludis::Empty>::Type"
+ echo " check_not_already_specified = paludis::Empty::instance;"
+ echo
+ echo " return NamedArguments<"
+ for (( kk = 0 ; kk < ${#want_keys[@]} ; kk++ )) ; do
+ if [[ ${k} == ${kk} ]] ; then
+ echo -n " true"
+ else
+ echo -n " has_${kk}_"
+ fi
+ if [[ $(( ${kk} + 1 )) -lt ${#want_keys[@]} ]] ; then
+ echo ","
else
- echo ">,"
+ echo ">("
fi
done
- echo -n " Params<"
- for (( j = 0 ; j < ${#want_keys[@]} ; j++ )) ; do
- if [[ ${j} == ${k} ]] ; then
- echo -n "true"
+ for (( kk = 0 ; kk < ${#want_keys[@]} ; kk++ )) ; do
+ if [[ ${k} == ${kk} ]] ; then
+ echo -n " v"
else
- echo -n "has_${want_keys[${j}]}_"
+ echo -n " _v${kk}"
fi
- if [[ $(( ${j} + 1 )) -lt ${#want_keys[@]} ]] ; then
- echo -n ", "
+ if [[ $(( ${kk} + 1 )) -lt ${#want_keys[@]} ]] ; then
+ echo ","
else
- echo "> >"
+ echo ");"
fi
done
- echo " >::Type(*this, value_for_${want_keys[${k}]}),"
+
+ echo " }"
+ echo
done
+ echo " ///\\}"
- echo " paludis::Empty()"
- echo " {"
- echo " }"
- echo
- echo " ///\}"
- echo
- echo " };"
echo
+ echo "};"
- echo " /// Create, via named parameters"
- echo -n " static Params<"
+ echo " /**"
+ echo " * Create using named arguments."
+ echo " */"
+ echo " ${current_class}(const NamedArguments<"
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- echo -n "false"
+ echo -n " true"
if [[ $(( ${k} + 1 )) -lt ${#want_keys[@]} ]] ; then
- echo -n ", "
+ echo ","
+ else
+ echo "> & va) :"
fi
done
- echo "> create();"
- echo
- echo "#endif"
- fi
-
- if [[ -n "${want_named_args}" ]] ; then
- echo " ${a}(const Params<"
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- echo -n " true"
+ echo -n " ${want_keys[${k}]}(va._v${k})"
if [[ $(( ${k} + 1 )) -lt ${#want_keys[@]} ]] ; then
echo ","
else
- echo "> & params) :"
+ echo
fi
done
+ echo " {"
+ echo " }"
+
+ echo
+ echo " /**"
+ echo " * Convenience function to create an empty named arguments class."
+ echo " */"
+ echo " static NamedArguments<"
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- echo -n " ${want_keys[${k}]}(params.${want_keys[${k}]})"
+ echo -n " false"
if [[ $(( ${k} + 1 )) -lt ${#want_keys[@]} ]] ; then
echo ","
else
- echo
+ echo ">"
fi
done
- echo " {"
- echo " }"
+ echo " create();"
+
echo
- fi
+ echo " ///\\}"
+ fi
echo "};"
elif [[ "${what_to_make}" == "--source" ]] ; then
@@ -526,33 +478,37 @@ while read a ; do
fi
if [[ -n "${want_named_args}" ]] ; then
-
- echo -n "${a}::Params<"
+ echo
+ echo "${a}::NamedArguments<"
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- echo -n "false"
+ echo -n " false"
if [[ $(( ${k} + 1 )) -lt ${#want_keys[@]} ]] ; then
- echo -n ", "
+ echo ","
+ else
+ echo ">"
fi
done
- echo ">"
echo "${a}::create()"
echo "{"
- echo " return Params<"
+ echo " return ${a}::NamedArguments<"
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- echo -n "false"
+ echo -n " false"
if [[ $(( ${k} + 1 )) -lt ${#want_keys[@]} ]] ; then
- echo -n ", "
+ echo ","
+ else
+ echo ">("
fi
done
- echo -n ">("
for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
- echo -n "Empty()"
+ echo -n " paludis::Empty::instance"
if [[ $(( ${k} + 1 )) -lt ${#want_keys[@]} ]] ; then
- echo -n ", "
+ echo ","
+ else
+ echo ");"
fi
done
- echo ");"
echo "}"
+
fi
else
@@ -561,3 +517,10 @@ while read a ; do
fi
done
+if [[ "${what_to_make}" == "--header" ]] ; then
+ echo "#ifdef DOXYGEN"
+ echo "// end paludis namespace for doxygen"
+ echo "}"
+ echo "#endif"
+fi
+