home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rox.zip / roxinfo.cmd < prev    next >
OS/2 REXX Batch file  |  1993-08-22  |  8KB  |  274 lines

  1. /*------------------------------------------------------------------
  2.  * roxload.cmd :
  3.  *------------------------------------------------------------------
  4.  * 08-19-93 originally by Patrick J. Mueller
  5.  *------------------------------------------------------------------*/
  6.  
  7. parse arg fileSpecs
  8.  
  9. if (fileSpecs = "") then
  10.    Usage()
  11.  
  12. if RxFuncQuery("SysLoadFuncs") then
  13.    do
  14.    rc = RxFuncAdd("SysLoadFuncs","RexxUtil","SysLoadFuncs")
  15.    rc = SysLoadFuncs()
  16.    end
  17.  
  18. /*------------------------------------------------------------------
  19.  * process each file spec
  20.  *------------------------------------------------------------------*/
  21. class.  = ""
  22. class.0 = 0
  23.  
  24. do i = 1 to words(fileSpecs)
  25.    rc = processFileSpec(word(fileSpecs,i))
  26. end
  27.  
  28. do i = 1 to class.0
  29.    class = class.i
  30.  
  31.    say copies("-",70)
  32.    say "class:" class
  33.  
  34.    /*---------------------------------------------------------------
  35.     * inherited classes
  36.     *---------------------------------------------------------------*/
  37.    say "   inherits"
  38.    rc = printInherits(class,0)
  39.  
  40.    /*---------------------------------------------------------------
  41.     * vars
  42.     *---------------------------------------------------------------*/
  43.    say "   vars"
  44.    vars = class.class.!vars
  45.    do j = 1 to words(vars)
  46.       say "        " word(vars,j)
  47.    end
  48.  
  49.    ivars = inheritedVars(class,vars)
  50.    do j = 1 to words(ivars)
  51.       say "       *" word(ivars,j)
  52.    end
  53.  
  54.    /*---------------------------------------------------------------
  55.     * methods
  56.     *---------------------------------------------------------------*/
  57.    say "   methods"
  58.    methods = class.class.!methods
  59.    do j = 1 to words(methods)
  60.       say "        " word(methods,j)
  61.    end
  62.  
  63.    imethods = inheritedMethods(class,methods)
  64.    do j = 1 to words(imethods)
  65.       say "       *" word(imethods,j)
  66.    end
  67.  
  68.    say
  69. end
  70.  
  71. exit
  72.  
  73. /*------------------------------------------------------------------
  74.  * process a file specification
  75.  *------------------------------------------------------------------*/
  76. processFileSpec: procedure expose class.
  77.  
  78.    rc = SysFileTree(arg(1),"file.","FO")
  79.  
  80.    if (rc <> 0) then
  81.       file.0 = 0
  82.  
  83.    do i = 1 to file.0
  84.       rc = processFile(file.i)
  85.    end
  86.  
  87.    return ""
  88.  
  89. /*------------------------------------------------------------------
  90.  * process a file
  91.  *------------------------------------------------------------------*/
  92. processFile: procedure expose class.
  93.    fileName = arg(1)
  94.  
  95.    if ("" = stream(fileName,"C","QUERY EXISTS")) then
  96.       do
  97.       say "File '"fileName"' does not exist."
  98.       return 1
  99.       end
  100.  
  101.    /*------------------------------------------------------------------
  102.     * read the file
  103.     *------------------------------------------------------------------*/
  104.    line.0 = 0
  105.  
  106.    do i = 1 by 1 while (lines(fileName) > 0)
  107.       line = linein(fileName)
  108.  
  109.       line.0 = i
  110.       line.i = line
  111.    end
  112.  
  113.    rc = stream(fileName,"C","CLOSE")
  114.  
  115.    /*------------------------------------------------------------------
  116.     * start processing
  117.     *------------------------------------------------------------------*/
  118.    class      = ""
  119.  
  120.    do lineNo = 1 to line.0
  121.       line = line.lineNo
  122.  
  123.       if (substr(line,1,2) = ":*") then
  124.          iterate
  125.  
  126.       /*---------------------------------------------------------------
  127.        * keyword found?
  128.        *---------------------------------------------------------------*/
  129.       if (substr(line,1,1) <> ":") then
  130.          iterate
  131.  
  132.       /*------------------------------------------------------------
  133.        * handle keyword line
  134.        *------------------------------------------------------------*/
  135.       parse var line ":" key rest
  136.       parse var rest rest1 .
  137.  
  138.       key = translate(key)
  139.       select
  140.          when (key = "CLASS") then
  141.             do
  142.             class = rest1
  143.  
  144.             if (class.class = "") then
  145.                do
  146.                o           = class.0 + 1
  147.                class.0     = o
  148.                class.o     = class
  149.                class.class = o
  150.                end
  151.             end
  152.  
  153.          when (key = "INCLUDE") then
  154.             rc = processFile(rest1)
  155.  
  156.          when (key = "INHERITS") then
  157.             do i = 1 to words(rest)
  158.                var = word(rest,i)
  159.                class.class.!inherits = class.class.!inherits var
  160.             end
  161.  
  162.          when (key = "VARS") then
  163.             do i = 1 to words(rest)
  164.                var = word(rest,i)
  165.                class.class.!vars = class.class.!vars var
  166.             end
  167.  
  168.          when (key = "METHOD") then
  169.             class.class.!methods = class.class.!methods rest1
  170.  
  171.          otherwise
  172.             nop
  173.       end
  174.  
  175.    end
  176.  
  177.    return 0
  178.  
  179. /*------------------------------------------------------------------
  180.  * printed inherited class 'tree'
  181.  *------------------------------------------------------------------*/
  182. printInherits: procedure expose class.
  183.    class  = arg(1)
  184.    indent = arg(2)
  185.  
  186.    inherits = class.class.!inherits
  187.    do i = 1 to words(inherits)
  188.       inherit = word(inherits,i)
  189.  
  190.       say "        " copies(" ",indent) || inherit
  191.  
  192.       rc = printInherits(inherit,indent+1)
  193.    end
  194.  
  195.    return ""
  196.  
  197. /*------------------------------------------------------------------
  198.  * return inherited variables for a class
  199.  *------------------------------------------------------------------*/
  200. inheritedVars: procedure expose class.
  201.    class = arg(1)
  202.    vars  = arg(2)
  203.  
  204.    inherits = class.class.!inherits
  205.  
  206.    ivars = ""
  207.    do i = 1 to words(inherits)
  208.       iclass = word(inherits,i)
  209.       newvars = class.iclass.!vars inheritedVars(iclass)
  210.  
  211.       do j = 1 to words(newvars)
  212.          newvar = word(newvars,j)
  213.          if (0 = wordpos(newvar,vars)) &,
  214.             (0 = wordpos(newvar,ivars)) &,
  215.             ("INIT" <> translate(newvar)) &,
  216.             ("DEINIT" <> translate(newvar)) then
  217.             ivars = ivars newvar
  218.       end
  219.  
  220.    end
  221.  
  222.    return space(ivars)
  223.  
  224. /*------------------------------------------------------------------
  225.  * return inherited methods for a class
  226.  *------------------------------------------------------------------*/
  227. inheritedMethods: procedure expose class.
  228.    class   = arg(1)
  229.    methods = arg(2)
  230.  
  231.    inherits = class.class.!inherits
  232.  
  233.    imethods = ""
  234.    do i = 1 to words(inherits)
  235.       iclass = word(inherits,i)
  236.       newmethods  = class.iclass.!methods inheritedMethods(iclass)
  237.  
  238.       do j = 1 to words(newmethods)
  239.          newmethod = word(newmethods,j)
  240.          if (0 = wordpos(newmethod,methods)) &,
  241.             (0 = wordpos(newmethod,imethods)) &,
  242.             ("INIT" <> translate(newmethod)) &,
  243.             ("DEINIT" <> translate(newmethod)) then
  244.             imethods = imethods newmethod
  245.       end
  246.    end
  247.  
  248.    return space(imethods)
  249.  
  250.  
  251. /*------------------------------------------------------------------
  252.  * some simple help
  253.  *------------------------------------------------------------------*/
  254. Usage: procedure
  255.    parse source . . me .
  256.    if (os = "OS/2") then
  257.       parse value filespec("name",me) with me "." .
  258.  
  259.    say "usage:"
  260.    say "   " me "<fileSpec> <fileSpec> ..."
  261.    say "is used to display Rox class info from the specified files"
  262.    say
  263.    say "where:"
  264.    say "   <fileSpec> - is a file specification"
  265.    say
  266.    say "For each class defined in the .rox files specified, the following"
  267.    say "information is provided:"
  268.    say "   - class name"
  269.    say "   - 'tree' of inherited classes"
  270.    say "   - list of variables (variables with * beside them are inherited)"
  271.    say "   - list of methods (methods with * beside them are inherited)"
  272.  
  273.    exit
  274.