chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] FFI: wrapping method that returns object


From: Felix Winkelmann
Subject: Re: [Chicken-users] FFI: wrapping method that returns object
Date: Thu, 23 Sep 2004 12:37:37 +0200
User-agent: Mozilla Thunderbird 0.5 (X11/20040208)

Sergey Khorev wrote:

(define n (make <N>))
(define a (make <A>))
(define t (makeT a 100))
(getX n t) ; got access violation when trying to get pointer to T


This is a bug: there is no default initialize method
for <c++-object>, so the implicit invocation of (make <T> 'this PTR)
in the result of makeT doesn't set the pointer properly.

Please find attached a patch, which should work (needs a recompile
of chicken).

Note that I haven't tested this very heavily, but it works with
your example.


cheers,
felix

--- tinyclos.scm        2004-09-23 12:30:39.237748872 +0200
+++ tinyclos.scm.~1.14.~        2004-05-15 02:19:17.000000000 +0200
@@ -1320,13 +1320,6 @@
 (define (subclass? x y)
   (if (memq y (compute-cpl x)) #t #f) )
 
-
-;;; C++ support:
-
-(define-method (initialize (this <c++-object>) initargs) 
-  (when (and (pair? initargs) (eq? 'this (##sys#slot initargs 0)))
-    (##tinyclos#slot-set! this 'this (cadr initargs)) ) )
-
 (define (make-instance-from-pointer ptr cls)
   (and ptr 
        (not (##sys#null-pointer? ptr))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]