Changeset 3781
- Timestamp:
- 05/17/10 15:08:06 (15 years ago)
- Location:
- issm/trunk/src/c/EnumDefinitions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/EnumDefinitions/SynchronizeMatlabEnum.sh
r3764 r3781 11 11 cat EnumDefinitions.h | grep "[Aa-Zz]Enum" | grep -v StringAsEnum | sed -e "s/,//g" | awk '{ printf "%s %s\n", NR, $0 }' > temp 12 12 13 #Build header of AnalysisTypeFromEnum.m{{{14 cat <<END > AnalysisTypeFromEnum.m15 function string= AnalysisTypeFromEnum(enum)16 % ANALYSISASENUM - get analysis type from Enum13 #Build header of EnumAsString.m {{{1 14 cat <<END > EnumAsString.m 15 function string=EnumAsString(enum) 16 %ENUMASSTRING - output string associated with enum 17 17 % 18 18 % WARNING: DO NOT MODIFY THIS FILE … … 21 21 % 22 22 % Usage: 23 % string= AnalysisTypeFromEnum(enum)23 % string=EnumAsString(enum) 24 24 25 %initialize output 26 string='not found'; 25 switch enum, 26 27 END 28 #}}} 29 #Build header of StringAsEnum.m {{{1 30 cat <<END > StringAsEnum.m 31 function enum=StringAsEnum(name) 32 %STRINGASENUM - output enum associated with string 33 % 34 % WARNING: DO NOT MODIFY THIS FILE 35 % this file has been automatically generated by src/c/SynchronizeMatlabEnum 36 % Please read src/c/README for more information 37 % 38 % Usage: 39 % enum=StringAsEnum(name) 40 27 41 END 28 42 #}}} … … 35 49 36 50 #Get name and enum of the line i 37 NAME=$(cat temp | grep "^[ ]*$i " | awk '{printf("%s",$2);}'); 51 NAMEENUM=$(cat temp | grep "^[ ]*$i " | awk '{printf("%s",$2);}'); 52 NAME=$(echo $NAMEENUM | sed -e "s/Enum//g") 38 53 ENUM=$i; 39 54 #offset Enum by one (Enum begins with 0 and not 1!) … … 57 72 #}}} 58 73 #Add case to matlabenum file{{{ 59 cat <<END > $ (echo $NAME".m")60 function macro=$(echo $NAME )()61 %$(echo `echo $NAME | sed -e "s/[a-z]/\U&/g"`) - Enum of $(echo `echo $NAME | sed -e "s/Enum//"`)74 cat <<END > $ISSM_DIR"/src/m/enum/"$(echo $NAMEENUM".m") 75 function macro=$(echo $NAMEENUM)() 76 %$(echo $NAMEENUM | sed -e "s/[a-z]/\U&/g") - Enum of $(echo $NAME) 62 77 % 63 78 % WARNING: DO NOT MODIFY THIS FILE … … 66 81 % 67 82 % Usage: 68 % macro=$NAME ()83 % macro=$NAMEENUM() 69 84 70 85 macro=$ENUM; 71 86 END 72 87 #}}} 73 #Add case to AnalysisTypeFromEnum file{{{ 74 if [ $(echo $NAME | grep AnalysisEnum) ] 88 #Add case to EnumAsString.m {{{ 89 cat <<END >> EnumAsString.m 90 case $NAMEENUM(), string='$NAME'; return 91 END 92 #}}} 93 #Add case to StringAsEnum.m {{{ 94 if [ $i -eq 1 ] 75 95 then 76 cat <<END >> AnalysisTypeFromEnum.m 77 78 if enum==$NAME(), 79 string='$(echo `echo $NAME | sed -e "s/AnalysisEnum//g" | awk {'print tolower($_)'}`)'; 80 end 96 cat <<END >> StringAsEnum.m 97 if (strcmpi(name,'$NAME')), enum=$NAMEENUM(); return 98 END 99 else 100 cat <<END >> StringAsEnum.m 101 elseif (strcmpi(name,'$NAME')), enum=$NAMEENUM(); return 81 102 END 82 103 fi 83 104 #}}} 84 105 85 #move file to m/enum86 mv $NAME".m" $ISSM_DIR"/src/m/enum/"87 88 106 done 89 107 90 #Footer of AnalysisTypeFromEnum.m{{{ 91 cat <<END >> AnalysisTypeFromEnum.m 108 #Add footer of of EnumAsString.m{{{1 109 cat <<END >> EnumAsString.m 110 otherwise, error(['Enum ' num2str(enum) ' not found']); 92 111 93 %check that an analysis type has been found for enum 94 if strcmp(string,'not found'), 95 error(['AnalysisTypeFromEnum error message: enum ' num2str(enum) ' not supported!']); 112 end 113 END 114 #}}} 115 #Add footer of of StringAsEnum.m{{{1 116 cat <<END >> StringAsEnum.m 117 else error(['Enum ' name ' not found']); 118 96 119 end 97 120 END … … 99 122 100 123 #clean up{{{ 101 mv AnalysisTypeFromEnum.m $ISSM_DIR/src/m/enum/ 124 mv StringAsEnum.m $ISSM_DIR/src/m/enum/ 125 mv EnumAsString.m $ISSM_DIR/src/m/enum/ 102 126 rm temp 103 127 #}}} -
issm/trunk/src/c/EnumDefinitions/SynchronizeStrings.sh
r3764 r3781 21 21 22 22 #include "../shared/shared.h" 23 #include "../include/ macros.h"23 #include "../include/include.h" 24 24 #include "./EnumDefinitions.h" 25 25 … … 42 42 43 43 #include "../shared/shared.h" 44 #include "../include/ macros.h"44 #include "../include/include.h" 45 45 #include "./EnumDefinitions.h" 46 46
Note:
See TracChangeset
for help on using the changeset viewer.