Edi,
I tried out the code you gave me but it doesn't do the trick. I've created some test code to illustrate my problem a bit better. It is listed below.
There are two parts to it. You have to build a simple dll which contains a class that simply stores a reference passed to it as an "object". The lisp code simply instantiates a ReferenceComparisonTest object, passes it a reference to itself and then later compares what it passed in with what it got back to see if they are the same thing.
They should be the same but clearly aren't. I think this is the crux of my problem.
Here is the code:
// C#
using System;
namespace ReferenceComparisonTest
{
public class ReferenceComparisonTest
{
private object _reference = null;
public ReferenceComparisonTest()
{
_reference = this;
}
public object reference
{
get { return _reference; }
set { _reference = value; }
}
}
}
;; LISP
(load "../RDNZL/rdnzl-0.12.0/load.lisp")
(rdnzl:enable-rdnzl-syntax)
(rdnzl:import-types "ReferenceComparisonTest" "ReferenceComparisonTest")
(rdnzl:use-namespace "ReferenceComparisonTest")
(defun pointers-equal (a b)
(fli::pointer-eq (rdnzl::pointer a) (rdnzl::pointer b)))
(defun main ()
(let ((x (rdnzl::new "ReferenceComparisonTest")))
;; Make x store a reference to itself.
(setf [%reference x] x)
;; Compare x with what was stored in x. These should be the same.
(if (pointers-equal x [%reference x])
(format t "Excellent! The references are the same as expected.")
(format t "Error! The references were different but should have been the same."))))
(main)
Regards,
Matthew