home *** CD-ROM | disk | FTP | other *** search
- #! /bin/csh -f
-
- if ( $?conversionDir == 0 ) then
- set conversionDir = "/NextDeveloper/OpenStepConversion/"
- endif
-
- set tmp1 = "CONVERSION/tmp1"
- set tmp2 = "CONVERSION/tmp2"
- set tmp3 = "CONVERSION/tmp3"
- set tmp4 = "CONVERSION/tmp4"
- set tmp5 = "CONVERSION/tmp5"
- set tmp6 = "CONVERSION/tmp6"
- set tmp7 = "CONVERSION/tmp7"
- set tmp8 = "CONVERSION/tmp8"
- set tmp9 = "CONVERSION/tmp9"
-
- ##############################################################################
- # produce optional conversion script
- ##############################################################################
-
- # prep
- if ($1 == rect) then
- echo 'Generating optional rect conversion script'
- set optConvert = "CONVERSION/RectMethods"
- set optConvertTops = "CONVERSION/RectMethods.tops"
- else if ($1 == point) then
- set optConvert = "CONVERSION/RectMethods"
- set optConvertTops = "CONVERSION/RectMethods.tops"
- else if ($1 == size) then
- set optConvert = "CONVERSION/RectMethods"
- set optConvertTops = "CONVERSION/RectMethods.tops"
- else if ($1 == string) then
- echo 'Generating optional string conversion script'
- set optConvert = "CONVERSION/StringMethods"
- set optConvertTops = "CONVERSION/StringMethods.tops"
- set optStringSym = "CONVERSION/StringDefines"
- else if ($1 == void) then
- echo 'Generating optional void conversion script'
- set optConvert = "CONVERSION/VoidMethods"
- set optConvertTops = "CONVERSION/VoidMethods.tops"
- endif
-
- # remove file info, we need to retain the SELF, ID, SELFNIL for void
- if ($1 == void) then
- /bin/sed -e 's/^\([-A-Z]*\)[^-+]*[-+] *\(.*\)$/\1 \2/' $optConvert > $tmp1
- else
- /bin/sed -e 's/^[^-+]*[-+] *\(.*\)$/\1/' $optConvert > $tmp1
- endif
-
- # make every parameter typed
- /bin/sed -e 's/:/:(id)/g' $tmp1 > $tmp2
- /bin/sed -e 's/:(id)(/:(/g' $tmp2 > $tmp1
-
- # remove parameter names
- /bin/sed -e 's/\(:([^)]*)\)[^ :;]*/\1/g' $tmp1 > $tmp2
-
- # remove the semicolon
- /bin/sed -e 's/;//' $tmp2 > $tmp1
-
- # mark the parameters to be converted
- switch ($1)
- case rect:
- /bin/sed -e 's/( *const *NXRect *\* *)/@convert@/g' $tmp1 > $tmp2
- /bin/sed -e 's/( *NXRect *\* *)/@convert@/g' $tmp2 > $tmp1
- breaksw
- case point:
- /bin/sed -e 's/( *const *NXPoint *\* *)/@convert@/g' $tmp1 > $tmp2
- /bin/sed -e 's/( *NXPoint *\* *)/@convert@/g' $tmp2 > $tmp1
- breaksw
- case size:
- /bin/sed -e 's/( *const *NXSize *\* *)/@convert@/g' $tmp1 > $tmp2
- /bin/sed -e 's/( *NXSize *\* *)/@convert@/g' $tmp2 > $tmp1
- breaksw
- case string:
- /bin/sed -e 's/( *const *char *\* *)/@convert@/g' $tmp1 > $tmp2
- /bin/sed -e 's/( *char *\* *)/@convert@/g' $tmp2 > $tmp1
- breaksw
- case atom:
- /bin/sed -e 's/( *NXAtom *)/@convert@/g' $tmp1 > $tmp2
- /bin/cp $tmp2 $tmp1
- breaksw
- case stringarray:
- /bin/sed -e 's/( *NXAtom *\* *)/@convert@/g' $tmp1 > $tmp2
- /bin/sed -e 's/( *const *\* *char *\* *)/@convert@/g' $tmp2 > $tmp2
- breaksw
- case void:
- breaksw
- endsw
-
- # remove all other types
- /bin/sed -e 's/([^)]*)/ /g' $tmp1 > $tmp2
-
- # thats where the void similarity ends
- if ($1 == void) goto doVoid
-
- # number the converted params by the order they appear
- /bin/sed -e 's/\([^@]*\)@convert@ */\1<convert1> /' $tmp2 > $tmp1
- /bin/sed -e 's/\([^@]*\)@convert@ */\1<convert2> /' $tmp1 > $tmp2
- /bin/sed -e 's/\([^@]*\)@convert@ */\1<convert3> /' $tmp2 > $tmp1
- /bin/sed -e 's/\([^@]*\)@convert@ */\1<convert4> /' $tmp1 > $tmp2
- /bin/sed -e 's/\([^@]*\)@convert@ */\1<convert5> /' $tmp2 > $tmp1
- /bin/sed -e 's/\([^@]*\)@convert@ */\1<convert6> /' $tmp1 > $tmp2
-
- # store those with return types converted in tmp3
- /usr/bin/egrep '^ *<' $tmp2 > $tmp3
-
- # strip off any <convert> in the return type position
- /bin/sed -e 's/^ *<convert1>\(.*\)$/\1/' $tmp2 > $tmp1
-
- # delete all <convert>s but <convert1> and save
- /bin/sed -e 's/<convert[^1]>//g' $tmp1 > $tmp4
-
- # delete all <convert>s but <convert2> and save
- /bin/sed -e 's/<convert[^2]>//g' $tmp1 > $tmp5
-
- # delete all <convert>s but <convert3> and save
- /bin/sed -e 's/<convert[^3]>//g' $tmp1 > $tmp6
-
- # delete all <convert>s but <convert4> and save
- /bin/sed -e 's/<convert[^4]>//g' $tmp1 > $tmp7
-
- # delete all <convert>s but <convert5> and save
- /bin/sed -e 's/<convert[^5]>//g' $tmp1 > $tmp8
-
- # delete all <convert>s but <convert6> and save
- /bin/sed -e 's/<convert[^6]>//g' $tmp1 > $tmp9
-
- # convert all convert[1-6] into just convert
- /bin/sed -e 's/<convert[0-9]>/<convert>/g' $tmp4 > $tmp1
- /bin/cat $tmp1 > $tmp4
-
- # convert all convert[1-6] into just convert
- /bin/sed -e 's/<convert[0-9]>/<convert>/g' $tmp5 > $tmp1
- /bin/cat $tmp1 > $tmp5
-
- # convert all convert[1-6] into just convert
- /bin/sed -e 's/<convert[0-9]>/<convert>/g' $tmp6 > $tmp1
- /bin/cat $tmp1 > $tmp6
-
- # convert all convert[1-6] into just convert
- /bin/sed -e 's/<convert[0-9]>/<convert>/g' $tmp7 > $tmp1
- /bin/cat $tmp1 > $tmp7
-
- # convert all convert[1-6] into just convert
- /bin/sed -e 's/<convert[0-9]>/<convert>/g' $tmp8 > $tmp1
- /bin/cat $tmp1 > $tmp8
-
- # convert all convert[1-6] into just convert
- /bin/sed -e 's/<convert[0-9]>/<convert>/g' $tmp9 > $tmp1
- /bin/cat $tmp1 > $tmp9
-
- # make a unique list of those that require replacement
- /bin/cat $tmp4 | /usr/bin/sort -ou > $tmp1
- /bin/grep '<' $tmp1 > $tmp4
-
- # make a unique list of those that require replacement
- /bin/cat $tmp5 | /usr/bin/sort -ou > $tmp1
- /bin/grep '<' $tmp1 > $tmp5
-
- # make a unique list of those that require replacement
- /bin/cat $tmp6 | /usr/bin/sort -ou > $tmp1
- /bin/grep '<' $tmp1 > $tmp6
-
- # make a unique list of those that require replacement
- /bin/cat $tmp7 | /usr/bin/sort -ou > $tmp1
- /bin/grep '<' $tmp1 > $tmp7
-
- # make a unique list of those that require replacement
- /bin/cat $tmp8 | /usr/bin/sort -ou > $tmp1
- /bin/grep '<' $tmp1 > $tmp8
-
- # make a unique list of those that require replacement
- /bin/cat $tmp9 | /usr/bin/sort -ou > $tmp1
- /bin/grep '<' $tmp1 > $tmp9
-
- # put these in good form for the script
- /bin/sed -e 's/^\(.*\)$/"\1"/' $tmp4 > $tmp1
- /bin/sed -e 's/^" *\(.*\)$/ "\1/' $tmp1 > $tmp2
- /bin/sed -e 's/:[ ]*\(.*\)/:\1/g' $tmp2 > $tmp1
- /bin/sed -e 's/ *"$/"/g' $tmp1 > $tmp4
-
- # put these in good form for the script
- /bin/sed -e 's/^\(.*\)$/"\1"/' $tmp5 > $tmp1
- /bin/sed -e 's/^" *\(.*\)$/ "\1/' $tmp1 > $tmp2
- /bin/sed -e 's/:[ ]*\(.*\)/:\1/g' $tmp2 > $tmp1
- /bin/sed -e 's/ *"$/"/g' $tmp1 > $tmp5
-
- # put these in good form for the script
- /bin/sed -e 's/^\(.*\)$/"\1"/' $tmp6 > $tmp1
- /bin/sed -e 's/^" *\(.*\)$/ "\1/' $tmp1 > $tmp2
- /bin/sed -e 's/:[ ]*\(.*\)/:\1/g' $tmp2 > $tmp1
- /bin/sed -e 's/ *"$/"/g' $tmp1 > $tmp6
-
- # put these in good form for the script
- /bin/sed -e 's/^\(.*\)$/"\1"/' $tmp7 > $tmp1
- /bin/sed -e 's/^" *\(.*\)$/ "\1/' $tmp1 > $tmp2
- /bin/sed -e 's/:[ ]*\(.*\)/:\1/g' $tmp2 > $tmp1
- /bin/sed -e 's/ *"$/"/g' $tmp1 > $tmp7
-
- # put these in good form for the script
- /bin/sed -e 's/^\(.*\)$/"\1"/' $tmp8 > $tmp1
- /bin/sed -e 's/^" *\(.*\)$/ "\1/' $tmp1 > $tmp2
- /bin/sed -e 's/:[ ]*\(.*\)/:\1/g' $tmp2 > $tmp1
- /bin/sed -e 's/ *"$/"/g' $tmp1 > $tmp8
-
- # put these in good form for the script
- /bin/sed -e 's/^\(.*\)$/"\1"/' $tmp9 > $tmp1
- /bin/sed -e 's/^" *\(.*\)$/ "\1/' $tmp1 > $tmp2
- /bin/sed -e 's/:[ ]*\(.*\)/:\1/g' $tmp2 > $tmp1
- /bin/sed -e 's/ *"$/"/g' $tmp1 > $tmp9
-
- # put them into the script
-
- # *** tmp4 ***
-
- switch ($1)
- case rect:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSRect)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' > $optConvertTops
- breaksw
- case point:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSPoint)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case size:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSSize)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case string:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_arg>" with "[NSString stringWithCString:<convert_arg>]"\
- replace "<convert_type>" with "(NSString *)"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>" with "[<convert_param> cString]"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' > $optConvertTops
- breaksw
- endsw
-
- # insert the methods
- /bin/cat $tmp4 >> $optConvertTops
-
- echo ' }' >> $optConvertTops
- echo >> $optConvertTops
-
- # put them into the script
-
- # *** tmp5 ***
-
- switch ($1)
- case rect:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSRect)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case point:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSPoint)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case size:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSSize)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case string:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_arg>" with "[NSString stringWithCString:<convert_arg>]"\
- replace "<convert_type>" with "(NSString *)"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>" with "[<convert_param> cString]"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- endsw
-
- # insert the methods
- /bin/cat $tmp5 >> $optConvertTops
-
- echo ' }' >> $optConvertTops
- echo >> $optConvertTops
-
- # put them into the script
-
- # *** tmp6 ***
-
- switch ($1)
- case rect:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSRect)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case point:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSPoint)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case size:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSSize)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case string:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_arg>" with "[NSString stringWithCString:<convert_arg>]"\
- replace "<convert_type>" with "(NSString *)"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>" with "[<convert_param> cString]"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- endsw
-
- # insert the methods
- /bin/cat $tmp6 >> $optConvertTops
-
- echo ' }' >> $optConvertTops
- echo >> $optConvertTops
-
- # put them into the script
-
- # *** tmp7 ***
-
- switch ($1)
- case rect:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSRect)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case point:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSPoint)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case size:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSSize)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case string:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_arg>" with "[NSString stringWithCString:<convert_arg>]"\
- replace "<convert_type>" with "(NSString *)"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>" with "[<convert_param> cString]"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- endsw
-
- # insert the methods
- /bin/cat $tmp7 >> $optConvertTops
-
- echo ' }' >> $optConvertTops
- echo >> $optConvertTops
-
- # put them into the script
-
- # *** tmp8 ***
-
- switch ($1)
- case rect:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSRect)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case point:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSPoint)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case size:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSSize)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case string:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_arg>" with "[NSString stringWithCString:<convert_arg>]"\
- replace "<convert_type>" with "(NSString *)"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>" with "[<convert_param> cString]"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- endsw
-
- # insert the methods
- /bin/cat $tmp8 >> $optConvertTops
-
- echo ' }' >> $optConvertTops
- echo >> $optConvertTops
-
- # put them into the script
-
- # *** tmp9 ***
-
- switch ($1)
- case rect:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSRect)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case point:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSPoint)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case size:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_type>" with "(NSSize)"\
- replace "<convert_arg>" with "*<convert_arg>"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>->" with "*<convert_param>."\
- replace "<convert_param>" with "&<convert_param>"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case string:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<convert_arg>" with "[NSString stringWithCString:<convert_arg>]"\
- replace "<convert_type>" with "(NSString *)"\
- }\
- within ("<implementation>") {\
- replace "<convert_param>" with "[<convert_param> cString]"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- endsw
-
- # insert the methods
- /bin/cat $tmp9 >> $optConvertTops
-
- echo ' }' >> $optConvertTops
- echo >> $optConvertTops
-
- # now do the return type conversions
-
- # delete all <convert>s but <convert1> and save
- /bin/sed -e 's/<convert[^1]>/ /g' $tmp3 | sed -e 's/<convert1> */<convert>/' > $tmp2
-
- # put these in good form for the script
- /bin/sed -e 's/^\(.*\)$/"\1"/' $tmp2 > $tmp1
- /bin/sed -e 's/^" *\(.*\)$/ "\1/' $tmp1 > $tmp2
- /bin/sed -e 's/: *\(.*\)$/:\1/g' $tmp2 > $tmp1
- /bin/sed -e 's/ *"$/"/g' $tmp1 > $tmp2
-
- # remove duplicates
- /bin/cat $tmp2 | /usr/bin/sort -u > $tmp1
-
- # put them into the script
-
- switch ($1)
- case rect:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<rettype>" with "(NSRect)"\
- }\
- within ("<implementation>") {\
- replace "return <exp>;" with "return *<exp>;"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case point:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<rettype>" with "(NSPoint)"\
- }\
- within ("<implementation>") {\
- replace "return <exp>;" with "return *<exp>;"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case size:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<rettype>" with "(NSPoint)"\
- }\
- within ("<implementation>") {\
- replace "return <exp>;" with "return *<exp>;"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case string:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<rettype>" with "(NSString *)"\
- replace "<call>" with "[<call> cString]"\
- }\
- within ("<implementation>") {\
- replace "return <exp>;" with "return [NSString stringWithCString:<exp>];"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- case void:
- echo '\
- \
- replacemethod "<sel>" with same {\
- replace "<rettype>" with "(void)"\
- }\
- within ("<implementation>") {\
- replace "return <exp>;" with "return [NSString stringWithCString:<exp>];"\
- }\
- where "<sel>" isOneOf { \
- "PLACEHOLDERMETHOD" ' >> $optConvertTops
- breaksw
- endsw
-
- # insert the methods
- /bin/cat $tmp1 >> $optConvertTops
-
- # finish up the rule
- echo ' }' >> $optConvertTops
- echo >> $optConvertTops
-
- # do the string defines
- if ($1 == string) then
-
- /usr/bin/egrep '#define' $optStringSym > $tmp2
- /bin/sed -e 's/^[^#]*#define[ ]*\([^ ]*\)[ ]*\(.*\)$/ "\1",/' $tmp2 > $tmp1
- echo '\
- \
- replace "<symbol>" with "[<symbol> cString]"\
- where "<symbol>" isOneOf { \
- "PLACEHOLDERSYMBOL" ' >> $optConvertTops
-
- cat $tmp1 >> $optConvertTops
-
- echo ' } \
- \
- replace "#define [<symbol> cString] <t function>(<b args>)" with "#define <symbol> [NSString stringWithCString:<t function>(<b args>)]" \
- \
- replace "#define [<symbol> cString] <t aString>" with "#define <symbol> [NSString stringWithCString:<t aString>]" \
- ' >> $optConvertTops
-
- endif
-
- exit
-
- doVoid:
- # here is the void stuff, so far we have removed parameter types and names
-
- # make a unique list of those that require replacement
- /bin/cat $tmp2 | /usr/bin/sort -ou > $tmp1
-
- # put these in good form for the script
- /bin/sed -e 's/^\([-A-Z]*\) *\(.*\)$/\1 "\2"/' $tmp1 > $tmp2
- /bin/sed -e 's/: *\(.*\)$/:\1/g' $tmp2 > $tmp1
- /bin/sed -e 's/ *"$/"/g' $tmp1 > $tmp2
-
- echo ' \
- SELFNIL-BOOL "PLACEHOLDER" \
- SELF-VOID "PLACEHOLDER" \
- OBJ-VOID "PLACEHOLDER"' >> $tmp2
-
- # store the id to void methods in $tmp3
- /usr/bin/egrep '^ *OBJ-VOID' $tmp2 > $tmp1
- /bin/sed -e 's/^ *OBJ-VOID\(.*\)$/\1/' $tmp1 > $tmp3
-
- # put them in the script
- echo '\
- replacemethod "<sel>" with same {\
- replace "<rettype>" with "(void)"\
- }\
- where "<sel>" isOneOf {' > $optConvertTops
-
- #insert the methods
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' }' >> $optConvertTops
- echo >> $optConvertTops
-
- # store the id to void methods in $tmp3
- /usr/bin/egrep '^ *SELFNIL-BOOL' $tmp2 > $tmp1
- /bin/sed -e 's/^ *SELFNIL-BOOL\(.*\)$/\1/' $tmp1 > $tmp3
-
- # put them in the script
- echo '\
- replacemethod "<sel>" with same { \
- replace "<rettype>" with "(BOOL)" \
- } \
- within ("<implementation>") { \
- replace "return self;" with "return YES;" \
- replace "return (self);" with "return YES;" \
- replace "return nil;" with "return NO;" \
- replace "return (nil);" with "return NO;" \
- replace "return NULL;" with "return NO;" \
- replace "return (NULL);" with "return NO;" \
- } \
- where "<sel>" isOneOf {' >> $optConvertTops
-
- #insert the methods
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' }' >> $optConvertTops
- echo >> $optConvertTops
-
- # store the self to void methods in $tmp3
- /usr/bin/egrep '^ *SELF-VOID' $tmp2 > $tmp1
- /bin/sed -e 's/^ *SELF-VOID\(.*\)$/\1/' $tmp1 > $tmp3
-
- # put them in the script
- echo '\
- replacemethod "<sel>" with same {\
- replace "<rettype>" with "(void)"\
- }\
- within ("<implementation>") { \
- replace "return self;" with "return;"\
- replace "return (self)" with "return;"\
- }\
- where "<sel>" isOneOf {' >> $optConvertTops
-
- #insert the methods
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' }' >> $optConvertTops
- echo >> $optConvertTops
-
- # now we do some extra work for the SELF-VOID calls
-
- # number the params by the order they appear
- /bin/sed -e 's/\([^:]*\):/\1@<convert1>/' $tmp3 > $tmp1
- /bin/sed -e 's/\([^:]*\):/\1@<convert2>/' $tmp1 > $tmp2
- /bin/sed -e 's/\([^:]*\):/\1@<convert3>/' $tmp2 > $tmp1
- /bin/sed -e 's/\([^:]*\):/\1@<convert4>/' $tmp1 > $tmp2
- /bin/sed -e 's/\([^:]*\):/\1@<convert5>/' $tmp2 > $tmp1
- /bin/sed -e 's/\([^:]*\):/\1@<convert6>/' $tmp1 > $tmp2
- /bin/sed -e 's/\([^:]*\):/\1@<convert7>/' $tmp2 > $tmp1
-
- # write out the rules
- echo '\
- \
- replace "if (<b cond>) return [<obj> <b method>];" with "if (<b cond>) {[<obj> <b method>]; return;}" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "if (<b cond>) return ([<obj> <b method>]);" with "if (<b cond>) {[<obj> <b method>]; return;}" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "return [<obj> <b method>];" with "[<obj> <b method>]; return;" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "return ([<obj> <b method>]);" with "[<obj> <b method>]; return;" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "if (<b cond>) <token var> = [<token obj> <b method>];" \
- with "if (<b cond>) {[<token obj> <b method>]; <token var> = <token obj>;}" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "if (<b cond>) <token var> = [<obj> <b method>];" with "if (<b cond>) {<token var> = <obj>; [<token var> <b method>];}" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "<w w><token var> = [<token obj> <b method>];" with "[<token obj> <b method>];<w w><token var> = <token obj>;" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "<w w><token var> = [<obj> <b method>];" with "<token var> = <obj>;<w w>[<token var> <b method>];" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "if (<b cond>) [[<token obj> <b method>] <b dosomething>];" with "if (<b cond>) {[<token obj> <b method>]; [<token obj> <b dosomething>];}" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "if (<b cond>) <token var> = [[<token obj> <b method>] <b dosomething>];" \
- with "if (<b cond>) {[<token obj> <b method>]; <token var> = [<token obj> <b dosomething>];}" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "<w w><token var> = [[<token obj> <b method>] <b dosomething>];" \
- with "[<token obj> <b method>];<w w><token var> = [<token obj> <b dosomething>];" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "<w w>[[<token obj> <b method>] <b dosomething>];" \
- with "[<token obj> <b method>];<w w>[<token obj> <b dosomething>];" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "if (<b cond>) [<b objAndMethod1>:[<token obj> <b method>]<w w><b rest>];" \
- with "if (<b cond>) {[<token obj> <b method>]; [<b objAndMethod1>:<token obj><w w><b rest>];}" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "<w w1>[<b objAndMethod1>:[<token obj> <b method>]<w w2><b rest>];" \
- with "[<token obj> <b method>];<w w1>[<b objAndMethod1>:<token obj><w w2><b rest>];" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "[[[<token obj> <b dosomething>] <b method>] <b dosomething Else>];" \
- with "{ \
- id newVar = [<token obj> <b dosomething>]; \
- [newVar <b method>]; \
- [newVar <b dosomething>Else]; \
- }" \
- warning "VoidConversion: creating new variable to deal with methods returning void (previously self)" \
- where "<b method>" isOneOf {' >> $optConvertTops
-
- /bin/cat $tmp3 >> $optConvertTops
-
- echo ' } \
- \
- replace "- (void)<b method><w w1>{<w w2><b implementation>return;}" \
- with "- (void)<b method><w w1>{<w w2><b implementation> \
- }" \
- ' >> $optConvertTops
-
- /bin/rm -rf $tmp1
- /bin/rm -rf $tmp2
- /bin/rm -rf $tmp3
- /bin/rm -rf $tmp4
- /bin/rm -rf $tmp5
- /bin/rm -rf $tmp6
- /bin/rm -rf $tmp7
- /bin/rm -rf $tmp8
- /bin/rm -rf $tmp9
-
-