04/24/2004: mkoeppe (Matthias Koeppe)

[Guile] New runtime functions SWIG_PointerAddress,
	    SWIG_PointerType, SWIG_IsPointerOfType, SWIG_IsPointer.

	    [Guile] In -scm mode, wrap several SWIG runtime functions
	    and export them into the module (Swig swigrun).  The
	    runtime module is now built with "module" linkage.

	    [Guile] GOOPS proxy objects now also print the pointer
	    address of the C object.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5912 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Matthias Köppe 2004-05-17 15:47:45 +00:00
commit bfbbb57ae7
5 changed files with 160 additions and 19 deletions

View file

@ -5,13 +5,17 @@
;;;* GOOPS file support
;;;*
;;;* Copyright (C) 2003 John Lenz (jelenz@wisc.edu)
;;;* Copyright (C) 2004 Matthias Koeppe (mkoeppe@mail.math.uni-magdeburg.de)
;;;*
;;;* This file may be freely redistributed without license or fee provided
;;;* this copyright message remains intact.
;;;************************************************************************
(define-module (Swig common))
(use-modules (oop goops))
(define-module (Swig swigrun))
(define-module (Swig common)
#:use-module (oop goops)
#:use-module (Swig swigrun))
(define-class <swig-metaclass> (<class>)
(new-function #:init-value #f))
@ -38,5 +42,28 @@
(if (slot-exists? ret 'swig-smob)
(slot-ref ret 'swig-smob)
ret))))))
(define (display-address o file)
(display (number->string (object-address o) 16) file))
(define (display-pointer-address o file)
(display (number->string (SWIG-PointerAddress o) 16) file))
(define-method (write (o <swig>) file)
;; We display _two_ addresses to show the object's identity:
;; * first the address of the GOOPS proxy object,
;; * second the pointer address.
;; The reason is that proxy objects are created and discarded on the
;; fly, so different proxy objects for the same C object will appear.
(let ((class (class-of o)))
(if (slot-bound? class 'name)
(begin
(display "#<" file)
(display (class-name class) file)
(display #\space file)
(display-address o file)
(display " @ " file)
(display-pointer-address o file)
(display ">" file))
(next-method))))
(export <swig-metaclass> <swig>)