home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / feature_clause.e < prev    next >
Text File  |  1999-06-05  |  5KB  |  179 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr
  4. --                       http://SmallEiffel.loria.fr
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
  11. -- for  more  details.  You  should  have  received a copy of the GNU General
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class FEATURE_CLAUSE
  17. --
  18. -- The contents of a feature clause.
  19. --
  20. -- Note : for a `pretty' pretty_printing, it is necessary to store exactly
  21. --        the original contents (in the source file) of a feature
  22. --        clause.
  23. --
  24.  
  25. inherit GLOBALS;
  26.  
  27. creation make
  28.  
  29. feature
  30.  
  31.    clients: CLIENT_LIST;
  32.          -- The `clients' allowed to use these features.
  33.  
  34.    comment: COMMENT;
  35.          -- The heading comment comming with the clause.
  36.  
  37. feature {NONE}
  38.  
  39.    list: FIXED_ARRAY[E_FEATURE];
  40.          -- Only the features of the current clause.
  41.          -- Note : all features of a class are grouped in a
  42.          -- single DICTIONARY (see BASE_CLASS).
  43.  
  44. feature {ANY}
  45.  
  46.    make(c: like clients; cm: COMMENT; l: like list) is
  47.       require
  48.          c /= Void;
  49.          l /= Void implies not l.empty;
  50.       do
  51.          clients := c;
  52.          comment := cm;
  53.          list := l;
  54.       ensure
  55.          clients = c;
  56.          comment = cm;
  57.          list = l;
  58.       end;
  59.  
  60.    pretty_print is
  61.       local
  62.          i: INTEGER;
  63.       do
  64.          fmt.set_indent_level(0);
  65.          if not fmt.zen_mode then
  66.             fmt.skip(1);
  67.          else
  68.             fmt.indent;
  69.          end;
  70.          fmt.keyword(fz_feature);
  71.          clients.pretty_print;
  72.          fmt.set_indent_level(0);
  73.          if comment /= Void then
  74.             if fmt.zen_mode then
  75.             elseif fmt.column > 15 then
  76.                fmt.set_indent_level(1);
  77.                fmt.indent;
  78.                fmt.set_indent_level(0);
  79.             end;
  80.             comment.pretty_print;
  81.             if not fmt.zen_mode then
  82.                fmt.skip(1);
  83.             end;
  84.          end;
  85.          if list /= Void then
  86.             from
  87.                i := 0;
  88.             until
  89.                i > list.upper
  90.             loop
  91.                fmt.set_indent_level(1);
  92.                fmt.indent;
  93.                if not fmt.zen_mode then
  94.                   fmt.skip(1);
  95.                end;
  96.                list.item(i).pretty_print;
  97.                i := i + 1;
  98.             end;
  99.          end;
  100.          fmt.set_indent_level(0);
  101.          if not fmt.zen_mode then
  102.             fmt.skip(1);
  103.          end;
  104.       end;
  105.  
  106. feature {FEATURE_CLAUSE_LIST}
  107.  
  108.    for_short(bcn: CLASS_NAME; sort: BOOLEAN;
  109.              rf_list: FIXED_ARRAY[RUN_FEATURE]; rc: RUN_CLASS) is
  110.       local
  111.          i: INTEGER;
  112.          f: E_FEATURE;
  113.          heading_done: BOOLEAN;
  114.       do
  115.          if list /= Void then
  116.             if clients.gives_permission_to_any then
  117.                from
  118.                   i := 0;
  119.                until
  120.                   i > list.upper
  121.                loop
  122.                   f := list.item(i);
  123.                   heading_done := f.names.for_short(Current,heading_done,
  124.                                                     bcn,sort,rf_list,rc);
  125.                   i := i + 1;
  126.                end;
  127.             else
  128.                eh.cancel;
  129.             end;
  130.          end;
  131.       end;
  132.  
  133. feature {FEATURE_NAME_LIST}
  134.  
  135.    do_heading_for_short(bcn: CLASS_NAME) is
  136.       do
  137.          if comment = Void then
  138.             short_print.hook_or("hook202","feature(s) from ");
  139.             short_print.a_class_name(bcn);
  140.             short_print.hook_or("hook203","%N");
  141.          else
  142.             short_print.hook_or("hook204","feature(s) from ");
  143.             short_print.a_class_name(bcn);
  144.             short_print.hook_or("hook205","%N");
  145.             comment.short("hook206","   -- ","hook207","%N");
  146.             short_print.hook_or("hook208","");
  147.          end;
  148.       end;
  149.  
  150. feature {FEATURE_CLAUSE_LIST}
  151.  
  152.    add_into(fd: DICTIONARY[E_FEATURE,STRING]) is
  153.       local
  154.          i: INTEGER;
  155.          f: E_FEATURE;
  156.       do
  157.          if list /= Void then
  158.             from
  159.                i := 0;
  160.             until
  161.                i > list.upper
  162.             loop
  163.                f := list.item(i);
  164.                f.set_clients(clients);
  165.                f.add_into(fd);
  166.                i := i + 1;
  167.             end;
  168.          end;
  169.       end;
  170.  
  171. invariant
  172.  
  173.    clients /= Void;
  174.  
  175.    list /= Void implies not list.empty;
  176.  
  177. end -- FEATURE_CLAUSE
  178.  
  179.