stklos.scm 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ;;;; Copyright (C) 1999,2002, 2006, 2010 Free Software Foundation, Inc.
  2. ;;;;
  3. ;;;; This library is free software; you can redistribute it and/or
  4. ;;;; modify it under the terms of the GNU Lesser General Public
  5. ;;;; License as published by the Free Software Foundation; either
  6. ;;;; version 3 of the License, or (at your option) any later version.
  7. ;;;;
  8. ;;;; This library is distributed in the hope that it will be useful,
  9. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. ;;;; Lesser General Public License for more details.
  12. ;;;;
  13. ;;;; You should have received a copy of the GNU Lesser General Public
  14. ;;;; License along with this library; if not, write to the Free Software
  15. ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  16. ;;;;
  17. (define-module (oop goops stklos)
  18. :use-module (oop goops internal)
  19. :no-backtrace
  20. )
  21. ;;;
  22. ;;; This is the stklos compatibility module.
  23. ;;;
  24. ;;; WARNING: This module is under construction. While we expect to be able
  25. ;;; to run most stklos code without problems in the future, this is not the
  26. ;;; case now. The current compatibility is only superficial.
  27. ;;;
  28. ;;; Any comments/complaints/patches are welcome. Tell us about
  29. ;;; your incompatibility problems (bug-guile@gnu.org).
  30. ;;;
  31. ;; Export all bindings that are exported from (oop goops)...
  32. (module-for-each (lambda (sym var)
  33. (module-add! (module-public-interface (current-module))
  34. sym var))
  35. (resolve-interface '(oop goops)))
  36. ;; ...but replace the following bindings:
  37. (export define-class define-method)
  38. ;; Also export the following
  39. (export write-object)
  40. ;;; Enable keyword support (*fixme*---currently this has global effect)
  41. (read-set! keywords 'prefix)
  42. (define-syntax define-class
  43. (syntax-rules ()
  44. ((_ name supers (slot ...) rest ...)
  45. (standard-define-class name supers slot ... rest ...))))
  46. (define (toplevel-define! name val)
  47. (module-define! (current-module) name val))
  48. (define-syntax define-method
  49. (syntax-rules (setter)
  50. ((_ (setter name) rest ...)
  51. (begin
  52. (if (or (not (defined? 'name))
  53. (not (is-a? name <generic-with-setter>)))
  54. (toplevel-define! 'name
  55. (ensure-accessor
  56. (if (defined? 'name) name #f) 'name)))
  57. (add-method! (setter name) (method rest ...))))
  58. ((_ name rest ...)
  59. (begin
  60. (if (or (not (defined? 'name))
  61. (not (or (is-a? name <generic>)
  62. (is-a? name <primitive-generic>))))
  63. (toplevel-define! 'name
  64. (ensure-generic
  65. (if (defined? 'name) name #f) 'name)))
  66. (add-method! name (method rest ...))))))