stklos.scm 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ;;;; Copyright (C) 1999,2002, 2006, 2010, 2011 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-rule (define-class name supers (slot ...) rest ...)
  43. (standard-define-class name supers slot ... rest ...))
  44. (define (toplevel-define! name val)
  45. (module-define! (current-module) name val))
  46. (define-syntax define-method
  47. (syntax-rules (setter)
  48. ((_ (setter name) rest ...)
  49. (begin
  50. (if (or (not (defined? 'name))
  51. (not (is-a? name <generic-with-setter>)))
  52. (toplevel-define! 'name
  53. (ensure-accessor
  54. (if (defined? 'name) name #f) 'name)))
  55. (add-method! (setter name) (method rest ...))))
  56. ((_ name rest ...)
  57. (begin
  58. (if (or (not (defined? 'name))
  59. (not (or (is-a? name <generic>)
  60. (is-a? name <primitive-generic>))))
  61. (toplevel-define! 'name
  62. (ensure-generic
  63. (if (defined? 'name) name #f) 'name)))
  64. (add-method! name (method rest ...))))))