home *** CD-ROM | disk | FTP | other *** search
- #!/bin/csh -f
- # produce method lists and class heirarchies for the conversion process
- ##############################################################################
-
- ##############################################################################
- # setup
- ##############################################################################
-
- if ( $#argv == 0 ) then
- set preprocessFiles = `find . \( -name '*.[hmcCM]' -o -name '*.psw*' \) -print`
- else
- set preprocessFiles = ($argv)
- endif
-
- if ( $?conversionDir == 0 ) then
- set conversionDir = "/NextDeveloper/OpenStepConversion/"
- endif
-
- set classHierarchy1 = "CONVERSION/ClassHierarchy1"
-
- set classHierarchy2 = "CONVERSION/ClassHierarchy2"
-
- set allMethodsFile = "CONVERSION/allmethods"
-
- set optionalRect = "CONVERSION/RectMethods"
-
- set optionalString = "CONVERSION/StringMethods"
-
- set optionalStringSym = "CONVERSION/StringDefines"
-
- # set optionalStringFunc = "CONVERSION/optStringFunctions"
-
- set optionalVoid = "CONVERSION/VoidMethods"
-
- set nameConflicts = "CONVERSION/nameConflicts"
-
- set tmp1 = "CONVERSION/tmp1"
-
- set tmp2 = "CONVERSION/tmp2"
-
- set nameChanges = "$conversionDir/ConversionScripts/NSNameConversion.tops"
-
- set allMethodsScript = "$conversionDir/UtilityScripts/topsscripts/findAllMethods.tops"
-
- set cleanMethods = "$conversionDir/UtilityScripts/topsscripts/cleanUpMethods.tops"
-
- set removeCommon = "$conversionDir/UtilityScripts/topsscripts/markOverriden.tops"
-
- set findConflicts = "$conversionDir/UtilityScripts/grepscripts/findOSMethods.fgrep"
-
- set oneline = "$conversionDir/UtilityScripts/lexscripts/oneline"
-
- /bin/rm -rf CONVERSION
-
- /bin/mkdir CONVERSION
-
- ##############################################################################
- # produce first class hierarchy
- ##############################################################################
-
- echo "Generating first class hierarchy"
-
- # find all #import and #include lines
- /usr/bin/egrep '#import|#include' $preprocessFiles > $tmp1
-
- # remove extraneous file and line number info from egrep
- /bin/sed -e 's/^[^#]*\(#.*\)$/\1/' $tmp1 > $tmp2
-
- # remove duplicates
- /usr/bin/sort -u $tmp2 > $tmp1
-
- # cpp tmp2 (contains all #includes and #imports
- /bin/cc -E -I. -I$conversionDir/Headers/3.3Headers $tmp1 >& $tmp2
-
- # find all @interface lines
- /bin/grep '@interface' $preprocessFiles $tmp2 > $tmp1
-
- # delete the category @interfaces
- /bin/sed -e '/(/d' $tmp1 > $tmp2
-
- # convert to Class, Superclass pairings
- /bin/sed -e 's/@interface[ ]*\([a-zA-Z_$0-9%]*\)[ ]*[:]*[ ]*\([a-zA-Z_$0-9%]*\).*$/@\1, \2/' $tmp2 > $tmp1
-
- # add ROOT as the superclass of root classes
- /bin/sed -e 's/^[^@]*@\([a-zA-Z_$0-9%]*\), $/\1, ROOT/' $tmp1 > $tmp2
-
- # again remove extraneous file inf
- /bin/sed -e 's/^[^@]*@\(.*\)$/\1/' $tmp2 > $tmp1
-
- # remove duplicates
- /usr/bin/sort -uo $tmp1 > $tmp2
-
- # save the result
- /bin/mv -f $tmp2 $classHierarchy1
-
- # remove temporary files
- /bin/rm -f $tmp1
-
- ##############################################################################
- # produce second class hierarchy
- # NOTE: this script might be incorrect if the user does not convert all classes
- # to descend from NSObject
- ##############################################################################
-
- echo 'Generating second class hierarchy'
-
- # find all #import and #include lines
- /usr/bin/egrep '#import|#include' $preprocessFiles > $tmp1
-
- # remove extraneous file and line number info from egrep
- /bin/sed -e 's/^[^#]*\(#.*\)$/\1/' $tmp1 > $tmp2
-
- # remove duplicates
- /usr/bin/sort -u $tmp2 > $tmp1
-
- # apply name changes to included files
- tops -scriptfile $nameChanges $tmp1
-
- # cpp tmp1 (contains all #includes and #imports
- /bin/cc -E -I. -I$conversionDir/Headers/3.3Headers $tmp1 >& $tmp2
-
- # find all @interface lines
- /bin/grep '@interface' $preprocessFiles $tmp2 > $tmp1
-
- # delete the category @interfaces
- /bin/sed -e '/(/d' $tmp1 > $tmp2
-
- # apply name changes once again (for client classes)
- tops -scriptfile $nameChanges $tmp2
-
- # find all @interface lines (conversion above may insert warnings)
- /bin/grep '@interface' $tmp2 > $tmp1
- cp $tmp1 $tmp2
-
- # convert to Class, Superclass pairings
- /bin/sed -e 's/@interface[ ]*\([a-zA-Z_$0-9%]*\)[ ]*[:]*[ ]*\([a-zA-Z_$0-9%]*\).*$/@\1, \2/' $tmp2 > $tmp1
-
- # add ROOT as the superclass of root classes
- /bin/sed -e 's/^[^@]*@\([a-zA-Z_$0-9%]*\), $/\1, ROOT/' $tmp1 > $tmp2
-
- # again remove extraneous file inf
- /bin/sed -e 's/^[^@]*@\(.*\)$/\1/' $tmp2 > $tmp1
-
- # fix a few lies
- /bin/sed -e 's/List, NSObject/List, Object/' $tmp1 > $tmp2
- /bin/sed -e 's/Storage, NSObject/Storage, Object/' $tmp2 > $tmp1
- /bin/sed -e 's/NXBundle, NSObject/NXBundle, Object/' $tmp1 > $tmp2
- /bin/sed -e 's/HashTable, NSObject/HashTable, Object/' $tmp2 > $tmp1
-
- # remove duplicates
- /usr/bin/sort -uo $tmp1 > $tmp2
-
- # save the result
- /bin/mv -f $tmp2 $classHierarchy2
-
- # remove temporary files
- /bin/rm -f $tmp1
-
- ##############################################################################
- # get list of all methods
- ##############################################################################
-
- echo "Generating list of all methods"
-
- # generate list of all methods found in implementation files
- tops -scriptfile $allMethodsScript $preprocessFiles > $tmp1
-
- # remove the '{' and extraneous whitespace
- tops -scriptfile $cleanMethods $tmp1
-
- # put all methods on one line
- /bin/cat $tmp1 | $oneline > $tmp2
-
- # remove extraneous lines
- /usr/bin/egrep '^[-a-zA-Z/01-9_:;.+( )*]*$' $tmp2 > $allMethodsFile
-
- # delete overridden kit methods (hopefully there are no name conflicts)
- tops -scriptfile $removeCommon $allMethodsFile
- /bin/sed -e '/OVERRIDDEN/d' $allMethodsFile > $tmp1
- /bin/mv $tmp1 $allMethodsFile
-
- ##############################################################################
- # generate deep conversion string method list
- ##############################################################################
-
- echo 'Generating list of methods for optional string conversion'
-
- # produce candidates for deep string conversion
- /usr/bin/egrep 'char \*|NXAtom' $allMethodsFile > $optionalString
-
-
- ##############################################################################
- # generate deep conversion global symbol list
- ##############################################################################
-
- echo 'Generating list of #defines for optional string conversion'
-
- # produce candidates for deep string conversion
- /usr/bin/egrep '#define *[a-zA-Z_0-9]*[ ]*"|#define[ ]*[a-zA-Z_0-9]*[ ]*NXLocal' $preprocessFiles > $optionalStringSym
- # /usr/bin/egrep 'extern[ ]*const[ ]*char[ ]*\*[^(]*;|extern[ ]*char[ ]*\*[^(]*;' $preprocessFiles >> $optionalStringSym
- # /usr/bin/egrep 'extern[ ]*NXAtom[ ]*[^(]*;|^static[ ]*const[ ]*char[ ]*\*[^(]*;' $preprocessFiles >> $optionalStringSym
- # /usr/bin/egrep '^static[ ]*char[ ]*\*[^(]*;|^static[ ]*NXAtom[ ]*[^(]*;' $preprocessFiles >> $optionalStringSym
-
-
- ##############################################################################
- # generate deep conversion function list
- ##############################################################################
-
- # echo 'Generating list of functions for optional string conversion'
-
- # produce candidates for deep string conversion
- # /usr/bin/egrep 'extern[ ]*const[ ]*char[ ]*\*[^(]*\(|extern[ ]*char[ ]*\*[^(]*\(' $preprocessFiles > $optionalStringFunc
- # /usr/bin/egrep 'extern[ ]*NXAtom[ ]*[^(]*\(|^static[ ]*const[ ]*char[ ]*\*[^(]*\(' $preprocessFiles >> $optionalStringFunc
- # /usr/bin/egrep '^static[ ]*char[ ]*\*[^(]*\(|^static[ ]*NXAtom[ ]*[^(]*\(' $preprocessFiles >> $optionalStringFunc
-
- ##############################################################################
- # generate deep conversion rect/point/size method list
- ##############################################################################
-
- echo 'Generating list of methods for optional rect conversion'
-
- # produce candidates for deep rect conversion
- /usr/bin/egrep 'NXRect[ ]*\*|NXSize[ ]*\*|NXPoint[ ]*\*' $allMethodsFile > $optionalRect
-
-
- #############################################################################
- # generate deep conversion void method list
- ##############################################################################
-
- echo 'Generating list of methods for optional void conversion'
-
- # remove typed methods
- /bin/sed -e '/[+-] *(/d' $allMethodsFile > $tmp1
-
- # remove init, copy and new methods
- /bin/sed -e '/- init.*/d' $tmp1 > $tmp2
- /bin/sed -e '/- copy.*/d' $tmp2 > $tmp1
- /bin/sed -e '/+ new.*/d' $tmp1 > $tmp2
-
- #set the default to SELF-VOID
- /bin/sed -e 's/^\(.*\)$/SELF-VOID \1/' $tmp2 > $tmp1
-
- # save the result
- /bin/mv -f $tmp1 $optionalVoid
-
- ##############################################################################
- # generate list of name conflicts
- ##############################################################################
-
- # echo 'Generating list of potential name conflicts'
-
- # clean up the method list
-
- # mark the beginning the line with %
- # /bin/sed -e 's/^\(.*\)$/%\1/' $allMethodsFile > $tmp2
-
- # replace colons around line numbers with !
- # /bin/sed -e 's/:\([0-9]*\):/&\1&/' $tmp2 > $tmp1
-
- # make every method argument typed
- # /bin/sed -e 's/:/:(id)/g' $tmp1 > $tmp2
- # /bin/sed -e 's/:(id)(/:(/g' $tmp2 > $tmp1
-
- # remove types
- # /bin/sed -e 's/:([^)]*)[ :;]*/:/g' $tmp1 > $tmp2
-
- # find matches
- # /usr/bin/fgrep -f $findConflicts $tmp2 > $tmp1
-
- # remove line number info from the last fgrep
- # /bin/sed -e 's/^[^%]%\(.*\)$/\1/' $tmp1 > $tmp2
-
- # put the line number colons back in
- # /bin/sed -e 's/&/:/' $tmp2 > $tmp1
-
- # store the result
- # /bin/mv -f $tmp1 $nameConflicts
-
- ##############################################################################
- # clean up
- ##############################################################################
-
- /bin/rm -rf $tmp2
-
- /bin/rm -rf $tmp1
-
- /bin/rm -rf $allMethodsFile
-