home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / cool.lha / ice / cpp / scripts / implement < prev    next >
Encoding:
Text File  |  1991-09-04  |  2.8 KB  |  116 lines

  1. #!/bin/sh
  2. # Edit this file ONLY in cpp/scripts/implement
  3. #
  4. # Copyright (C) 1989, Texas Instruments Incorporated. All rights reserved.
  5. #
  6. # This implements a parameterized class by splitting it up into one file per
  7. # template.
  8. #
  9. # Created: LGO 09/18/89 -- Initial design and implementation
  10. # Changed: LGO 10/11/89 -- Added the -F option
  11. #
  12. #Example:
  13. # implement -g -I. -Llibapp.a -c List.h String.h -X"List<String>"
  14. #
  15. # The default file name is the name of the class with an index
  16. # appended to it (e.g. Pair6.o).  The file name must be unique inside
  17. # the library.  Because of this, you can over-ride the default name with
  18. # the -o option (e.g. -oPairSymGen creates a PairSymGen6.o file).
  19. #
  20. # The -Q option puts us in "QUICK" mode, which
  21. # compiles everything in a single file.
  22. #
  23. CC=CC2
  24. CPP=icedir/cpp/cpp
  25. CCArgs=
  26. cppArgs=-D__cplusplus
  27. Implement=
  28. Includes=
  29. arArgs=
  30. noDelete=
  31. name=
  32. isFast=
  33.  
  34. rm -f /tmp/CCC.i /tmp/CCC.C
  35. echo "// CCC implementation input file" > /tmp/CCC.C
  36. for Arg do
  37.     case $Arg in
  38.     -o*)    name=`expr "$Arg" : '-o\(.*\)'`
  39.         ;;
  40.     -X*)    Implement=`expr "$Arg" : '-X\(.*\)'`
  41.         ;;
  42.     *.h)    echo "#include <$Arg>" >> /tmp/CCC.C
  43.         ;;
  44.     -Q)    isFast=1
  45.         ;;
  46.     -L*)    arArgs=`expr "$Arg" : '-L\(.*\)'`
  47.         ;;
  48.     -C)    cppArgs="$cppArgs $Arg"; noDelete=1;
  49.         ;;
  50.     -D*)    cppArgs="$cppArgs $Arg"
  51.         ;;
  52.     -I*)    cppArgs="$cppArgs $Arg"
  53.         ;;
  54.     *)    CCArgs="$CCArgs $Arg"
  55.         ;;
  56.     esac
  57. done
  58. if [ "$arArgs" = "" ]; then
  59.   echo You must specify a library with the -L option
  60.   exit
  61. fi
  62. if [ "$Implement" = "" ]; then
  63.   echo You must specify something to implement with the -X option
  64.   exit
  65. fi
  66. # generate a default name
  67. if [ "$name" = "" ]; then
  68.   name=`expr "$Implement" : '\(.*\)<'`
  69. fi
  70. #
  71. # Check for the fast track - a single compile
  72. #
  73. if [ "$isFast" = "1" ]; then
  74. set ImplementWhat `expr "$Implement" : '\(.*\)<'`
  75. echo "#pragma defmacro IMPLEMENT_1 implement delimiter=> lines $ImplementWhat" >> /tmp/CCC.C
  76. echo "IMPLEMENT_1 $Implement" >> /tmp/CCC.C
  77. (cd /tmp
  78.  mv CCC.C $name.C
  79.  cppC=$CPP
  80.  export cppC
  81.  echo $CC $cppArgs $CCArgs $name.C
  82.  $CC $cppArgs $CCArgs $name.C
  83.  echo ar r $arArgs /tmp/$name.o
  84.  ar r $arArgs /tmp/$name.o
  85. )
  86. if [ "$noDelete" = "" ]; then
  87.   rm -f /tmp/$name.C /tmp/$name.o
  88. fi
  89. exit
  90. fi
  91. #
  92. # Else do it slow and efficient - one file per function
  93. #
  94. echo "#pragma defmacro IMPLEMENT_N implement_n delimiter=> lines" >> /tmp/CCC.C
  95. echo 'MACRO EXPANDING EXPAND_IMPLEMENT(count)' >> /tmp/CCC.C
  96. echo '{IMPLEMENT_N count' "$Implement" '}' >> /tmp/CCC.C
  97. echo "EXPAND_IMPLEMENT(Count)" >> /tmp/CCC.C
  98.  
  99. Count=0
  100. while    file=$name$Count
  101.     cp /tmp/CCC.C /tmp/$file.c
  102.     echo cpp -DCount=$Count $cppArgs /tmp/$file.c
  103.     $CPP -DCount=$Count $cppArgs /tmp/$file.c > /tmp/$file.C
  104. do    
  105.     (cd /tmp; CC2 $CCArgs $file.C)
  106.     echo ar r $arArgs /tmp/$file.o
  107.     ar r $arArgs /tmp/$file.o
  108.     if [ "$noDelete" = "" ]; then
  109.       rm /tmp/$file.c /tmp/$file.C /tmp/$file.o
  110.     fi
  111.     Count=`expr $Count + 1`
  112. done
  113. if [ "$noDelete" = "" ]; then
  114.   rm -f /tmp/CCC.C /tmp/$file.c /tmp/$file.C
  115. fi
  116.