home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / archive / SmallEiffel.lha / SmallEiffel / lib_se / external_routine.e < prev    next >
Text File  |  1999-06-05  |  3KB  |  103 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. deferred class EXTERNAL_ROUTINE
  17.    --
  18.    -- For routines implemented with a call to a foreign language.
  19.    -- Root of EXTERNAL_PROCEDURE and EXTERNAL_FUNCTION.
  20.    --
  21.  
  22. inherit ROUTINE;
  23.  
  24. feature
  25.  
  26.    native: NATIVE;
  27.  
  28.    alias_string: STRING;
  29.  
  30. feature
  31.  
  32.    is_deferred: BOOLEAN is false;
  33.  
  34. feature {NONE}
  35.  
  36.    make_external_routine(n: like native; desc: STRING) is
  37.       require
  38.          n /= void
  39.       do
  40.          native := n;
  41.          alias_string := desc;
  42.       end;
  43.  
  44. feature
  45.  
  46.    frozen set_rescue_compound(c: COMPOUND) is
  47.       do
  48.          if c /= Void then
  49.             eh.add_position(c.start_position);
  50.          else
  51.             eh.add_position(start_position);
  52.          end;
  53.          eh.append("External feature must not have rescue compound.");
  54.          eh.print_as_fatal_error;
  55.       end;
  56.  
  57.    frozen use_current: BOOLEAN is
  58.       do
  59.          Result := native.use_current(Current);
  60.       end;
  61.  
  62.    external_c_name: STRING is
  63.       do
  64.          if alias_string = Void then
  65.             Result := first_name.to_string;
  66.          else
  67.             Result := alias_string;
  68.          end;
  69.       end;
  70.  
  71. feature {C_PRETTY_PRINTER}
  72.  
  73.    frozen stupid_switch(up_rf: RUN_FEATURE; r: ARRAY[RUN_CLASS]): BOOLEAN is
  74.       do
  75.          Result := native.stupid_switch(first_name.to_string);
  76.          if Result then
  77.             cpp.put_comment("SSER");
  78.          end;
  79.       end;
  80.  
  81. feature {NONE}
  82.  
  83.    pretty_print_routine_body is
  84.       do
  85.          fmt.keyword("external");
  86.          native.pretty_print;
  87.          if not external_c_name.is_equal(first_name.to_string) or else
  88.             names.count > 1 then
  89.             fmt.indent;
  90.             fmt.keyword("alias");
  91.             fmt.put_character('%"');
  92.             fmt.put_string(external_c_name);
  93.             fmt.put_character('%"');
  94.          end;
  95.       end;
  96.  
  97.    pretty_print_rescue is
  98.       do
  99.       end;
  100.  
  101. end -- EXTERNAL_ROUTINE
  102.  
  103.