home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / bin / wpidl2xh.cmd < prev    next >
OS/2 REXX Batch file  |  1998-04-02  |  8KB  |  255 lines

  1. /*
  2.  * Copyright (c) International Business Machines Corporation 1994
  3.  * WPIDL2XH.CMD
  4.  *
  5.  * Command file to emit XH header file from Workplace Shell IDL.
  6.  * This command assumes the toolkit include paths are set accordingly.
  7.  *
  8.  * Invoke this command file on each Workplace Shell class's .idl file
  9.  * from the OS/2 toolkit to re-generate headers for C++.  This is
  10.  * only necessary when you upgrade to a new level of the SOMobject's
  11.  * Toolkit.  Invoking the SOM compiler's xh emitter will not do this
  12.  * for you, as the Workplace Shell classes currently only maintain
  13.  * passthrus for .h files for C.
  14.  *
  15.  * Usage:
  16.  *   wpidl2xh <inputfile>
  17.  *
  18.  * History:
  19.  *   09/11/94 - Eric E. Osmann * Created
  20.  */
  21.  
  22. parse upper arg inputfile
  23. say 'WPIDL2XH - IBM Corporation (c) 1994, Version 1.0'
  24. say ''
  25.  
  26. /*
  27.  * Check for an input file.
  28.  */
  29. if( inputfile = '' ) then do
  30.   say "no input file specified"
  31.   exit 99
  32. end
  33.  
  34. /*
  35.  * Make sure the file exists
  36.  */
  37. if stream( inputfile, 'c', 'query exists' ) == '' then do
  38.   say inputfile "file doesn't exist"
  39.   exit 98
  40. end
  41.  
  42. /*
  43.  * Initialization of the temporary output files
  44.  */
  45. '@echo off'
  46. outputfile1 = "$wptmp1.idl"
  47. "erase" outputfile1 "2>nul >nul"
  48. outputfile2 = "$wptmp2.idl"
  49. "erase" outputfile2 "2>nul >nul"
  50. say 'Processing 'inputfile
  51.  
  52. /*
  53.  * Read every line from the file and parse it.
  54.  * Change c_h to c_xh and SOMAny to SOMObject.
  55.  * Pass one
  56.  */
  57. do while lines( inputfile )
  58.   line = linein( inputfile )
  59.  
  60.   /*
  61.    * Look for 'passthru C_h' combination
  62.    */
  63.   if pos( 'passthru C_h', line ) \= 0 then
  64.   do
  65.      cpos = pos( 'C_h', line )
  66.      hpos = pos( 'h', line, cpos )
  67.      line = insert( 'x', line, hpos - 1 )
  68.      rc = lineout( outputfile1, line )
  69.   end
  70.   else if pos( 'SOMAny', line ) \= 0 then
  71.   do
  72.      spos = pos( 'SOMAny', line )        /* look for 'SOMAny'  */
  73.      line = delstr( line, spos, 6 )
  74.      line = insert( 'SOMObject', line, spos - 1 )
  75.      rc = lineout( outputfile1, line )
  76.   end
  77.   else
  78.      rc = lineout( outputfile1, line )
  79. end  /* of do while */
  80. rc = stream( outputfile1, c, "close" )
  81.  
  82. /*
  83.  * Special case IDL files.
  84.  * Pass two
  85.  */
  86. if( inputfile = 'WPOBJECT.IDL' ) then
  87. do
  88.    Say 'Special case processing for 'inputfile
  89.    do while lines( outputfile1 )
  90.       line = linein( outputfile1 )
  91.       if pos('#ifndef M_WPObject',line ) \= 0 then
  92.       do
  93.          line = linein( outputfile1 )
  94.          line = linein( outputfile1 )
  95.          rc = lineout( outputfile2, '"      class M_WPObject;"' )
  96.       end
  97.       else if pos( '#ifndef WPObject', line ) \= 0 then
  98.       do
  99.          line = linein( outputfile1 )
  100.          line = linein( outputfile1 )
  101.          rc = lineout( outputfile2, '"      class WPObject;"' )
  102.       end
  103.       else if pos( '#define WPFolder SOMObject', line ) \= 0 then
  104.       do
  105.          /* -- Note ------------------------------------------- */
  106.          /* SOM_WPFolder_xh if defined by wpfolder.xh and is    */
  107.          /* subject to change with future major releases of     */
  108.          /* SOM, so therefore the following statement may need  */
  109.          /* to change accordingly.                              */
  110.          /* --------------------------------------------------- */
  111.          rc = lineout( outputfile2, '"      #ifndef SOM_WPFolder_xh"' )
  112.          rc = lineout( outputfile2, '"        #define WPFolder WPObject"' )
  113.          rc = lineout( outputfile2, '"      #endif"' )
  114.       end
  115.       else if pos( '#define OBJECT_FROM_PREC', line ) \= 0 then
  116.       do
  117.          pvoidpos = pos( 'PVOID', line )
  118.          line = delstr( line, pvoidpos, 5 )
  119.          line = insert( 'WPObject *', line, pvoidpos - 1 )
  120.          rc = lineout( outputfile2, line )
  121.       end
  122.       else
  123.       do
  124.          rc = lineout( outputfile2, line )
  125.       end
  126.    end /* do while lines( outputfile1 ) */
  127. end   /* if infile = WPOBJECT.IDL */
  128.  
  129. /*
  130.  * WPFOLDER case
  131.  */
  132. else if( inputfile = 'WPFOLDER.IDL' ) then
  133. do
  134.    Say 'Special case processing for 'inputfile
  135.    linein( outputfile1, 1, 0 )
  136.    do while lines( outputfile1 )
  137.       line = linein( outputfile1 )
  138.       if pos( 'passthru C_xh', line ) \= 0 then
  139.       do
  140.          rc = lineout( outputfile2, 'passthru C_xh = ""' )
  141.          rc = lineout( outputfile2, '"     #ifdef WPFolder"' )
  142.          rc = lineout( outputfile2, '"         #undef WPFolder"' )
  143.          rc = lineout( outputfile2, '"         class  WPFolder;"' )
  144.          rc = lineout( outputfile2, '"     #endif"' )
  145.          rc = lineout( outputfile2, '"";' )
  146.          rc = lineout( outputfile2, '' )
  147.          rc = lineout( outputfile2, 'passthru C_xh_after = ""' )
  148.       end
  149.       else
  150.       do
  151.          rc = lineout( outputfile2, line )
  152.       end
  153.    end  /* do while lines */
  154. end     /* if inputfile = wpfolder.idl */
  155.  
  156. /*
  157.  * WPCLSMGR.IDL case
  158.  */
  159. else if( inputfile = 'WPCLSMGR.IDL' ) then
  160. do
  161.    Say 'Special case processing for 'inputfile
  162.    do while lines( outputfile1 )
  163.       line = linein( outputfile1 )
  164.       if pos( 'dllname = "pmwp.dll"', line ) \= 0 then
  165.       do
  166.          rc = lineout( outputfile2, '    dllname = "pmwp.dll";' )
  167.          rc = lineout( outputfile2, '' )
  168.          rc = lineout( outputfile2, 'passthru C_xh_after = ""' )
  169.          rc = lineout( outputfile2, '"     #ifndef wpobject_xh"' )
  170.          rc = lineout( outputfile2, '"         #include \"wpobject.xh\""' )
  171.          rc = lineout( outputfile2, '"     #endif"' )
  172.          rc = lineout( outputfile2, '"";' )
  173.       end
  174.       else
  175.       do
  176.          rc = lineout( outputfile2, line )
  177.       end
  178.    end  /* do while lines */
  179. end
  180.  
  181. /*
  182.  * WPMWV.IDL case
  183.  */
  184. else if( inputfile = 'WPMWV.IDL' ) then
  185. do
  186.    Say 'Special case processing for 'inputfile
  187.    do while lines( outputfile1 )
  188.       line = linein( outputfile1 )
  189.       if pos( 'passthru C_xh', line ) \= 0 then
  190.       do
  191.          rc = lineout( outputfile2, 'passthru C_xh_after = ""' )
  192.       end
  193.       else if pos( '#ifndef WPObject', line ) \= 0 then
  194.       do
  195.          line = linein( outputfile1 )
  196.          line = linein( outputfile1 )
  197.       end
  198.       else
  199.       do
  200.          rc = lineout( outputfile2, line )
  201.       end
  202.    end  /* do while lines */
  203. end
  204.  
  205. /*
  206.  * WPDISK.IDL case
  207.  */
  208. else if( inputfile = 'WPDISK.IDL' ) then
  209. do
  210.    Say 'Special case processing for 'inputfile
  211.    do while lines( outputfile1 )
  212.       line = linein( outputfile1 )
  213.       if pos( 'passthru C_xh', line ) \= 0 then
  214.       do
  215.          rc = lineout( outputfile2, 'passthru C_xh_after = ""' )
  216.          rc = lineout( outputfile2, '"     #ifndef wprootf_xh"' )
  217.          rc = lineout( outputfile2, '"         #include \"wprootf.xh\""' )
  218.          rc = lineout( outputfile2, '"     #endif"' )
  219.       end
  220.       else if pos( '#ifndef WPRootFolder', line ) \= 0 then
  221.       do
  222.          line = linein( outputfile1 )
  223.          line = linein( outputfile1 )
  224.       end
  225.       else
  226.       do
  227.          rc = lineout( outputfile2, line )
  228.       end
  229.    end  /* do while lines */
  230. end
  231.  
  232. /*
  233.  * For all other cases, set the first pass output file to
  234.  * second pass output file so that the SC compiler is happy.
  235.  */
  236. else
  237.    do
  238.       outputfile2 = outputfile1
  239.    end
  240.  
  241. /*
  242.  * Close streams before calling emitter.
  243.  */
  244. rc = stream( outputfile1, c, "close" )
  245. rc = stream( outputfile2, c, "close" )
  246.  
  247. /*
  248.  * Finally, emit the xh header file.
  249.  */
  250. say 'Emitting xh file for 'inputfile
  251. sc '-C 128000 -S 128000 -mnoint -mnotc -s"xh" 'outputfile2
  252. 'erase' outputfile1 outputfile2 '>nul 2>nul'
  253.  
  254. /* End of command file */
  255.