;; -*-theme-d-*-

;; Copyright (C) 2008-2013 Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.

;; Expected results: translation and running OK

(define-proper-program (tests test137)

  (import (standard-library core)
	  (standard-library console-io))

  (define-class <window> <object> #t #f #f module ()
    ((name <string> module module)))

  (define-class <dialog> <window> #t #f #f module ()
    ((choices <integer> module module)))

  (define-class <display> <object> #t #f #f module ()
    ((id <string> module module)))

  (define-generic-proc draw)

  (add-method draw
    (lambda (((window <window>) (disp <display>)) <none> nonpure)
      (console-display "window ")
      (console-display (field-ref window 'name))
      (console-newline)))

  (add-method draw
    (lambda (((dialog <dialog>) (disp <display>)) <none> nonpure)
      (console-display "dialog ")
      (console-display (field-ref dialog 'name))
      (console-display " ")
      (console-display (field-ref dialog 'choices))
      (console-newline)))

  (define main
    (lambda (() <integer> nonpure)
      (let ((my-display (make <display> ":0.0"))
	    (my-window (make <window> "Editor"))
	    (my-dialog (make <dialog> "Open" 2)))
	((generic-proc-dispatch-without-result draw (<window> <display>))
	 my-window my-display)
	((generic-proc-dispatch-without-result draw (<dialog> <display>))
	 my-dialog my-display)
      0))))
