Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
SWIG Passing Ruby structure arrays into C DLL
John Reynolds
3/20/2008 6:55:00 PM
I have a structure defined in my DLL
[code]
typedef struct _ABC{
int a, b,c;
}ABC;
[/code]
And a function
[code]
void func(int count, ABC * abc)
{
ABC *tempabc = abc;
for (int i=0; i< count; i++)
{
cout << tempabc->a << tempabc->b << tempabc->c << endl;
tempabc++;
}
}
[/code]
The above is compiled into a DLL, say ABC_DLL that can be used in Ruby
using the SWIG interface.
In my ruby script, I create an array of ABC.
[code]
arr=Array.new
temp1 = ABC_DLL::ABC.new
temp1.a=1111
temp1.b=1111
temp1.c=1111
arr = arr << temp1
temp2 = ABC_DLL::ABC.new
temp2.a=2222
temp2.b=2222
temp2.c=2222
arr = arr << temp2
temp3 = ABC_DLL::ABC.new
temp3.a=3333
temp3.b=3333
temp3.c=3333
arr = arr << temp3
[/code]
Question is how do I pass this array (arr) into the DLL function??
I tried
ABC_DLL::func(3,arr[0])
but my func in DLL prints out the following
1111 1111 1111
2434 342332 3423442 (some junk numbers)
2222 2222 2222
I would have expected something like
1111 1111 1111
2222 2222 2222
3333 3333 3333
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
SWIG Passing Ruby structure arrays into C DLL
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password