home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / shareware / dev / ppcsmalleiffel / lib_show / external / c / external_demo.e next >
Encoding:
Text File  |  1998-01-16  |  1.8 KB  |  88 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class EXTERNAL_DEMO
  5.    --   
  6.    -- How to use external (calling C from Eiffel);
  7.    --
  8.    -- You can compile this file doing :
  9.    --       compile external_demo make src.c
  10.    -- or doing :
  11.    --       compile external_demo make src.o
  12.    -- 
  13.    -- Execution should gives output like `external_demo.good_output'.
  14.    --
  15. creation {ANY}
  16.    make
  17.    
  18. feature {ANY}
  19.    
  20.    make is
  21.       do
  22.      integer2c(6);
  23.      character2c('a');
  24.      boolean2c(true);
  25.      real2c(3.5);
  26.      double2c((3.5).to_double);
  27.      double2c(3.5);
  28.      string2c(("Hi C World %N").to_external);
  29.      any2c(Current);
  30.      any2c("Hi");
  31.      current2c;
  32.      std_output.put_integer(integer2eiffel);
  33.      std_output.put_character(character2eiffel);
  34.       end;
  35.    
  36.    integer2c(i: INTEGER) is
  37.      -- Send an INTEGER to C
  38.       external "C_WithoutCurrent"
  39.       end;
  40.    
  41.    character2c(c: CHARACTER) is
  42.      -- Send a CHARACTER to C
  43.       external "C_WithoutCurrent"
  44.       end;
  45.    
  46.    boolean2c(b: BOOLEAN) is
  47.      -- Send a BOOLEAN to C
  48.       external "C_WithoutCurrent"
  49.       end;
  50.    
  51.    real2c(r: REAL) is
  52.      -- Send a REAL to C
  53.       external "C_WithoutCurrent"
  54.       end;
  55.    
  56.    double2c(d: DOUBLE) is
  57.      -- Send a DOUBLE to C
  58.       external "C_WithoutCurrent"
  59.       end;
  60.  
  61.    string2c(s: POINTER) is
  62.      -- Send a STRING to C
  63.       external "C_WithoutCurrent"
  64.       end;
  65.  
  66.    any2c(a: ANY) is
  67.      -- Send a reference to C
  68.       external "C_WithoutCurrent"
  69.       end;
  70.  
  71.    current2c is
  72.      -- Also send Current to C.
  73.       external "C_WithCurrent"
  74.       end;
  75.  
  76.    integer2eiffel: INTEGER is
  77.      -- Receive an INTEGER from C
  78.       external "C_WithoutCurrent"
  79.       end;
  80.  
  81.    character2eiffel: CHARACTER is
  82.      -- Receive a CHARACTER from C
  83.       external "C_WithoutCurrent"
  84.       end;
  85.  
  86. end -- EXTERNAL_DEMO
  87.  
  88.