[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] FFI: wrapping method that returns object
From: |
Sergey Khorev |
Subject: |
Re: [Chicken-users] FFI: wrapping method that returns object |
Date: |
Thu, 23 Sep 2004 12:48:35 +0400 |
> Your wrapper is the correct way of doing this.
Then I have a question ;)) I have created such wrapper, but got
strange access violation in chicken.dll during C_c_pointer_or_null.
My knowledge of Chicken internals are (temporarily) insufficient to
understand what is wrong. It seems that ___abstract is such a reason.
Windows, MSVC6 SP5 and SP6.
#>
class T;
class N
{
char dummy[128];
public:
N() {}
int getX(T&);
};
class T
{
char dummy[128];
int x;
public:
T(int x_) : x(x_) {}
friend class N;
};
class A
{
char dummy[128];
public:
A() {}
T makeT(int x) { T t(x); return t; }
};
int N::getX(T &t)
{
return t.x;
}
<#
#>?
class T;
class N
{
public:
N() {}
int getX(T &);
};
___abstract class T
{
};
class A
{
public:
A() {}
};
<#
#>!
T *makeT(A &a, int x)
{
return new T(a.makeT(x));
}
<#
(require-extension tinyclos)
(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
> If you want to avoid coding, you might write your own little
> preprocessor using `foreign-parse/spec' (see the manual):
> this macro could (for example) parse the specification, remodel
> the interface and generate foreign declarations again.
> (This is kind of weird, but actually pretty cool).
Definitely, I should try this ;))