[5225] | 1 | #!/bin/bash
|
---|
[25836] | 2 | ################################################################################
|
---|
| 3 | # Synchronize EnumToStringx.cpp and StringToEnumx.cpp and MATLAB Enums
|
---|
| 4 | #
|
---|
| 5 | # Get all lines of EnumDefinitions.h which hold Enum | remove all commas > put everything in file temp
|
---|
| 6 | #
|
---|
| 7 | # NOTE: Even when run from this directory, ISSM_DIR must be defined correctly.
|
---|
| 8 | #
|
---|
[16137] | 9 | cat EnumDefinitions.h | grep -e "[0-9]Enum," -e "[a-zA-Z]Enum," -e "MaximumNumberOfDefinitionsEnum" | grep -v include | sed -e "s/,/ /g" | awk '{print $1}' > temp
|
---|
[5227] | 10 |
|
---|
[8224] | 11 | #Removed existing files
|
---|
[14960] | 12 | rm $ISSM_DIR/src/c/shared/Enum/EnumToStringx.cpp
|
---|
| 13 | rm $ISSM_DIR/src/c/shared/Enum/StringToEnumx.cpp
|
---|
[5225] | 14 |
|
---|
[11407] | 15 | #Get number of enums
|
---|
| 16 | NUMENUMS=$(wc -l temp | awk '{printf("%s",$1);}');
|
---|
| 17 |
|
---|
[17806] | 18 | #Deal with Analyses
|
---|
[24313] | 19 | if false ; then
|
---|
[17806] | 20 | #Build EnumToAnalysis.cpp {{{
|
---|
| 21 | #Header
|
---|
| 22 | cat <<END > $ISSM_DIR/src/c/analyses/EnumToAnalysis.cpp
|
---|
| 23 | /*
|
---|
| 24 | * \file EnumToAnalysis.cpp
|
---|
| 25 | * \brief: output class depending on enum
|
---|
| 26 | *
|
---|
| 27 | * WARNING: DO NOT MODIFY THIS FILE
|
---|
| 28 | * this file has been automatically generated by Synchronize.sh
|
---|
| 29 | * Please read README for more information
|
---|
| 30 | */
|
---|
| 31 |
|
---|
| 32 | #include "./analyses.h"
|
---|
| 33 | #include "../shared/shared.h"
|
---|
| 34 |
|
---|
| 35 | Analysis* EnumToAnalysis(int analysis_enum){
|
---|
| 36 |
|
---|
| 37 | switch(analysis_enum){
|
---|
| 38 | END
|
---|
| 39 | #core
|
---|
[17989] | 40 | cat temp | grep [a-zA-Z0-9]Analysis | \
|
---|
[26744] | 41 | grep -v DefaultAnalysis | grep -v RecoveryAnalysis | grep -v FlaimAnalysis | grep -v SurfaceSlopeAnalysis | grep -v BedSlopeAnalysis | \
|
---|
[17806] | 42 | awk '{print "\t\t#ifdef _HAVE_"toupper(substr($1,1,length($1)-12))"_\n\t\t" "case " $1" : return new " substr($1,1,length($1)-4) "();\n\t\t#endif"}' \
|
---|
| 43 | >> $ISSM_DIR/src/c/analyses/EnumToAnalysis.cpp
|
---|
| 44 |
|
---|
| 45 | #Footer
|
---|
| 46 | cat <<END >> $ISSM_DIR/src/c/analyses/EnumToAnalysis.cpp
|
---|
| 47 | default : _error_("enum provided not supported ("<<EnumToStringx(analysis_enum)<<")");
|
---|
| 48 | }
|
---|
| 49 | }
|
---|
| 50 | END
|
---|
| 51 | #}}}
|
---|
| 52 | #Build analyses.m4{{{
|
---|
| 53 | #Header
|
---|
| 54 | cat <<END > $ISSM_DIR/m4/analyses.m4
|
---|
| 55 |
|
---|
| 56 | dnl WARNING: DO NOT MODIFY THIS FILE
|
---|
| 57 | dnl this file has been automatically generated by Synchronize.sh
|
---|
| 58 | dnl Please read README for more information
|
---|
| 59 |
|
---|
| 60 | # AX_ANALYSES_SELECTION
|
---|
| 61 | # -----------------
|
---|
| 62 | # Check for analyses compilation
|
---|
| 63 | AC_DEFUN([AX_ANALYSES_SELECTION],
|
---|
| 64 | [
|
---|
| 65 |
|
---|
| 66 | END
|
---|
| 67 | #core
|
---|
[17989] | 68 | cat temp | grep [a-zA-Z0-9]Analysis | \
|
---|
[17806] | 69 | grep -v DefaultAnalysis | grep -v FlaimAnalysis | grep -v SurfaceSlopeAnalysis | grep -v BedSlopeAnalysis | \
|
---|
| 70 | sed -e "s/AnalysisEnum//g" | \
|
---|
| 71 | awk '{print "dnl with-" $1"{{{\n\
|
---|
| 72 | AC_ARG_WITH([" $1"],\n\
|
---|
| 73 | \tAS_HELP_STRING([--with-" $1" = YES], [compile with " $1" capabilities (default is yes)]),\n\
|
---|
| 74 | \t[" toupper($1)"=$withval],[" toupper($1)"=yes])\n\
|
---|
| 75 | AC_MSG_CHECKING(for " $1" capability compilation)\n\n\
|
---|
| 76 | HAVE_" toupper($1)"=no \n\
|
---|
| 77 | if test \"x$" toupper($1)"\" = \"xyes\"; then\n\
|
---|
| 78 | HAVE_" toupper($1)"=yes\n\
|
---|
[19105] | 79 | AC_DEFINE([_HAVE_" toupper($1)"_],[1],[with " $1" capability])\n\
|
---|
[17806] | 80 | fi\n\
|
---|
| 81 | AM_CONDITIONAL([" toupper($1)"], [test x$HAVE_" toupper($1)" = xyes])\n\
|
---|
| 82 | AC_MSG_RESULT($HAVE_" toupper($1)")\n\
|
---|
| 83 | dnl }}}"}' \
|
---|
| 84 | >> $ISSM_DIR/m4/analyses.m4
|
---|
| 85 |
|
---|
| 86 | #Footer
|
---|
| 87 | cat <<END >> $ISSM_DIR/m4/analyses.m4
|
---|
| 88 |
|
---|
| 89 | ])
|
---|
| 90 | END
|
---|
| 91 | #}}}
|
---|
[22758] | 92 | fi
|
---|
[17806] | 93 |
|
---|
| 94 | #Enum to String conversions
|
---|
[12262] | 95 | #Build EnumToStringx.cpp {{{
|
---|
[8239] | 96 | #Header
|
---|
[14960] | 97 | cat <<END > $ISSM_DIR/src/c/shared/Enum/EnumToStringx.cpp
|
---|
[5225] | 98 | /*
|
---|
[8224] | 99 | * \file EnumToStringx.cpp:
|
---|
[5225] | 100 | * \brief: output string associated with enum
|
---|
| 101 | *
|
---|
| 102 | * WARNING: DO NOT MODIFY THIS FILE
|
---|
[5227] | 103 | * this file has been automatically generated by Synchronize.sh
|
---|
[5225] | 104 | * Please read README for more information
|
---|
| 105 | */
|
---|
| 106 |
|
---|
[12341] | 107 | #include <cstring>
|
---|
[14960] | 108 | #include "./Enum.h"
|
---|
| 109 | #include "../Exceptions/exceptions.h"
|
---|
| 110 | #include "../MemOps/MemOps.h"
|
---|
[5225] | 111 |
|
---|
[11225] | 112 | const char* EnumToStringx(int en){
|
---|
[5225] | 113 |
|
---|
| 114 | switch(en){
|
---|
| 115 |
|
---|
| 116 | END
|
---|
[8239] | 117 | #core
|
---|
[14960] | 118 | cat temp | awk '{print "\t\t" "case " $1" : return \"" substr($1,1,length($1)-4) "\";"}' >> $ISSM_DIR/src/c/shared/Enum/EnumToStringx.cpp
|
---|
[8239] | 119 | #Footer
|
---|
[14960] | 120 | cat <<END >> $ISSM_DIR/src/c/shared/Enum/EnumToStringx.cpp
|
---|
[8239] | 121 | default : return "unknown";
|
---|
| 122 |
|
---|
| 123 | }
|
---|
| 124 | }
|
---|
[11225] | 125 | void EnumToStringx(char** pstring,int enum_in){
|
---|
| 126 | char *string = NULL;
|
---|
| 127 | int len = 0;
|
---|
| 128 |
|
---|
| 129 | len=strlen(EnumToStringx(enum_in));
|
---|
[12450] | 130 | string=xNew<char>(len+1);
|
---|
[11225] | 131 | memcpy(string,EnumToStringx(enum_in),(len+1)*sizeof(char));
|
---|
| 132 |
|
---|
| 133 | /*Assign output pointer*/
|
---|
| 134 | *pstring=string;
|
---|
| 135 | }
|
---|
[23189] | 136 |
|
---|
| 137 | bool IsInputEnum(int enum_in){
|
---|
| 138 | if(enum_in>InputsSTARTEnum && enum_in<InputsENDEnum) return true;
|
---|
| 139 | return false;
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | bool IsParamEnum(int enum_in){
|
---|
| 143 | if(enum_in>ParametersSTARTEnum && enum_in<ParametersENDEnum) return true;
|
---|
| 144 | return false;
|
---|
| 145 | }
|
---|
[8239] | 146 | END
|
---|
[5225] | 147 | #}}}
|
---|
[12365] | 148 | #Build StringToEnumx.cpp {{{
|
---|
[8239] | 149 | #Header
|
---|
[14960] | 150 | cat <<END > $ISSM_DIR/src/c/shared/Enum/StringToEnumx.cpp
|
---|
[5225] | 151 | /*
|
---|
[8224] | 152 | * \file StringToEnumx.cpp:
|
---|
[5225] | 153 | * \brief: output enum associated with string
|
---|
| 154 | *
|
---|
| 155 | * WARNING: DO NOT MODIFY THIS FILE
|
---|
[5227] | 156 | * this file has been automatically generated by Synchronize.sh
|
---|
[5225] | 157 | * Please read README for more information
|
---|
| 158 | */
|
---|
| 159 |
|
---|
[12342] | 160 | #include <cstring>
|
---|
[14960] | 161 | #include "./Enum.h"
|
---|
[14964] | 162 | #include "../Exceptions/exceptions.h"
|
---|
[5225] | 163 |
|
---|
[16560] | 164 | int StringToEnumx(const char* name,bool notfounderror){
|
---|
[5225] | 165 |
|
---|
[11404] | 166 | int stage=1;
|
---|
| 167 |
|
---|
[5225] | 168 | END
|
---|
[11404] | 169 |
|
---|
[8239] | 170 | #core
|
---|
[11404] | 171 | i1=1;
|
---|
| 172 | i2=120;
|
---|
| 173 | for (( i=1 ; i<=100 ; i++ )); do
|
---|
[14960] | 174 | echo " if(stage==$i){" >> $ISSM_DIR//src/c/shared/Enum/StringToEnumx.cpp
|
---|
[11407] | 175 | awk -v i1=$i1 -v i2=$i2 '{if(NR>=i1 && NR<=i2) print $0 }' temp |
|
---|
[14960] | 176 | awk '{print "\t" ((NR==1)?" if":" else if") " (strcmp(name,\"" substr($1,1,length($1)-4) "\")==0) return " $1 ";"}' >> $ISSM_DIR//src/c/shared/Enum/StringToEnumx.cpp
|
---|
| 177 | echo " else stage=$(($i+1));" >> $ISSM_DIR//src/c/shared/Enum/StringToEnumx.cpp
|
---|
| 178 | echo " }" >> $ISSM_DIR//src/c/shared/Enum/StringToEnumx.cpp
|
---|
[24313] | 179 |
|
---|
[11407] | 180 | if [ $i2 -ge $NUMENUMS ]; then break; fi
|
---|
| 181 | let i1=$i1+120
|
---|
| 182 | let i2=$i2+120
|
---|
[11404] | 183 | done
|
---|
| 184 |
|
---|
[11407] | 185 | #footer
|
---|
[14960] | 186 | cat <<END >> $ISSM_DIR/src/c/shared/Enum/StringToEnumx.cpp
|
---|
[11407] | 187 | /*If we reach this point, the string provided has not been found*/
|
---|
[16560] | 188 | if(notfounderror)
|
---|
| 189 | _error_("Enum " << name << " not found");
|
---|
| 190 | else
|
---|
| 191 | return -1;
|
---|
[8239] | 192 | }
|
---|
| 193 | END
|
---|
[5225] | 194 | #}}}
|
---|
[27035] | 195 | #Build issmenum.jl {{{
|
---|
| 196 | #Header
|
---|
| 197 | cat <<END > $ISSM_DIR/src/c/shared/Enum/issmenums.jl
|
---|
| 198 | # WARNING: DO NOT MODIFY THIS FILE
|
---|
| 199 | # this file has been automatically generated by Synchronize.sh
|
---|
| 200 | # Please read README for more information
|
---|
[17806] | 201 |
|
---|
[27035] | 202 | @enum IssmEnum begin
|
---|
| 203 | END
|
---|
| 204 | cat temp | awk '{print "\t" $1}' >> $ISSM_DIR/src/c/shared/Enum/issmenums.jl
|
---|
| 205 | #Move on to EnumToString
|
---|
| 206 | cat <<END >> $ISSM_DIR/src/c/shared/Enum/issmenums.jl
|
---|
| 207 | end
|
---|
| 208 |
|
---|
| 209 | function EnumToString(enum::IssmEnum)
|
---|
| 210 | END
|
---|
| 211 | cat temp | awk '{print "\tif(enum==" $1 ") return \"" substr($1,1,length($1)-4) "\" end"}' >> $ISSM_DIR/src/c/shared/Enum/issmenums.jl
|
---|
| 212 | #Move on to StringToEnumx
|
---|
| 213 | cat <<END >> $ISSM_DIR/src/c/shared/Enum/issmenums.jl
|
---|
| 214 | end
|
---|
| 215 | END
|
---|
| 216 | #}}}
|
---|
| 217 |
|
---|
[24313] | 218 | #vim file
|
---|
| 219 | #Build Enum.vim{{{
|
---|
| 220 | #Header
|
---|
| 221 | cat <<END > $ISSM_DIR/src/c/shared/Enum/Enum.vim
|
---|
| 222 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
---|
| 223 | " ISSM specific c syntax highlighting
|
---|
| 224 | "
|
---|
| 225 | " WARNING: DO NOT MODIFY THIS FILE
|
---|
| 226 | " this file has been automatically generated by Synchronize.sh
|
---|
| 227 | " Please read README for more information
|
---|
| 228 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
---|
| 229 |
|
---|
| 230 | "PETSc
|
---|
| 231 | syn keyword cType Vec Mat SeqVec SeqMat
|
---|
| 232 |
|
---|
| 233 | "ISSM typedefs
|
---|
| 234 | syn keyword cType mxArray ErrorException QuadtreeBox
|
---|
| 235 | syn keyword cType IssmDouble IssmPDouble
|
---|
| 236 |
|
---|
| 237 | "ISSM Enums
|
---|
| 238 | END
|
---|
| 239 | cat temp | awk '{print "syn keyword cConstant " $1}' >> $ISSM_DIR/src/c/shared/Enum/Enum.vim
|
---|
| 240 | cat <<END >> $ISSM_DIR/src/c/shared/Enum/Enum.vim
|
---|
| 241 | "ISSM Enums end
|
---|
| 242 | END
|
---|
| 243 |
|
---|
| 244 | #Synchronize ISSM objects objects
|
---|
| 245 | cat <<END >> $ISSM_DIR/src/c/shared/Enum/Enum.vim
|
---|
| 246 |
|
---|
| 247 | "ISSM objects
|
---|
| 248 | END
|
---|
| 249 | find $ISSM_DIR/src/c/classes -name "*.cpp" -o -name "*.h" | sed -e "s/\// /g" -e "s/\.cpp//" -e "s/\.h//" | awk '{print $(NF)}' | sort | uniq | awk '{ printf "syn keyword cType " $1 "\n"}'>> $ISSM_DIR/src/c/shared/Enum/Enum.vim
|
---|
| 250 | find $ISSM_DIR/src/c/analyses -name "*Analysis.h" | sed -e "s/\// /g" -e "s/\.cpp//" -e "s/\.h//" | awk '{print $(NF)}' | sort | uniq | awk '{ printf "syn keyword cType " $1 "\n"}'>> $ISSM_DIR/src/c/shared/Enum/Enum.vim
|
---|
| 251 | echo "\"ISSM objects end" >> $ISSM_DIR/src/c/shared/Enum/Enum.vim
|
---|
| 252 | #}}}
|
---|
[26744] | 253 | #Build Enumjl.vim{{{
|
---|
| 254 | #Header
|
---|
| 255 | cat <<END > $ISSM_DIR/src/c/shared/Enum/Enumjl.vim
|
---|
| 256 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
---|
| 257 | " ISSM specific julia syntax highlighting
|
---|
| 258 | "
|
---|
| 259 | " WARNING: DO NOT MODIFY THIS FILE
|
---|
| 260 | " this file has been automatically generated by Synchronize.sh
|
---|
| 261 | " Please read README for more information
|
---|
| 262 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
---|
[24313] | 263 |
|
---|
[26744] | 264 | "ISSM Enums
|
---|
| 265 | END
|
---|
| 266 | cat temp | awk '{print "syn keyword juliaConstC " $1}' >> $ISSM_DIR/src/c/shared/Enum/Enumjl.vim
|
---|
| 267 | cat <<END >> $ISSM_DIR/src/c/shared/Enum/Enumjl.vim
|
---|
| 268 | "ISSM Enums end
|
---|
| 269 | END
|
---|
| 270 | #}}}
|
---|
| 271 |
|
---|
[5225] | 272 | #clean up{{{
|
---|
[11407] | 273 | rm temp
|
---|
[5225] | 274 | #}}}
|
---|
| 275 | #print info {{{
|
---|
| 276 | printf "\r "
|
---|
| 277 | printf "\rdone!\n"
|
---|
| 278 | #}}}
|
---|