{
  ex2.s

  Contents:

     1. a reflective(extension) class Window
     2. an extension class Border whose allowed set contains Window

  Tests:
    1. the attachment of extension Border to Window;
    2. the access to extension instance variables;
    3. message sends to "object" in extension classes.

  }

reflective(extension) class Window
  private:
    var width, height : integer;
  public:
    proc draw()
      begin
      write(100);
      end
endclass


extension class Border(Window)
  private:
    var size : integer;
  public:
    proc draw()
      begin
      object.draw();
      write(size);
      size = 12;
      end
endclass

class Program
  public:
    proc run()
        var w : Window;
    begin
    w = Window.new();
    w.draw();
    if Reflect.attachExtension(Window, Border) == 0
    then
      w.draw();
      w.draw();
      if Reflect.removeExtension(Window) == 0
      then
        w.draw();
      endif
    endif
    end
endclass

