home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_se / external_routine.e < prev    next >
Encoding:
Text File  |  1998-01-16  |  2.2 KB  |  81 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://www.loria.fr/SmallEiffel
  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 {NONE}
  31.    
  32.    make_external_routine(n: like native; desc: STRING) is
  33.       require
  34.      n /= void
  35.       do
  36.      native := n;
  37.      alias_string := desc;
  38.       end;
  39.  
  40. feature    
  41.    
  42.    frozen use_current: BOOLEAN is
  43.       do
  44.      Result := native.use_current(Current);
  45.       end;
  46.  
  47.    external_c_name: STRING is
  48.       do
  49.      if alias_string = Void then
  50.         Result := first_name.to_string;
  51.      else
  52.         Result := alias_string;
  53.      end;
  54.       end;
  55.  
  56. feature {C_PRETTY_PRINTER}
  57.  
  58.    frozen stupid_switch(up_rf: RUN_FEATURE; r: ARRAY[RUN_CLASS]): BOOLEAN is
  59.       do
  60.      Result := native.stupid_switch(first_name.to_string);
  61.       end;
  62.  
  63. feature {NONE}
  64.    
  65.    pretty_print_routine_body is
  66.       do
  67.      fmt.keyword("external");
  68.      native.pretty_print;
  69.      if not external_c_name.is_equal(first_name.to_string) or else
  70.         names.count > 1 then
  71.         fmt.indent;
  72.         fmt.keyword("alias"); 
  73.         fmt.put_character('%"');
  74.         fmt.put_string(external_c_name);
  75.         fmt.put_character('%"');
  76.      end;
  77.       end; 
  78.    
  79. end -- EXTERNAL_ROUTINE
  80.  
  81.