[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Help: SWIG & Ruby

Sebastian Yepes ESN

1/4/2007 1:48:00 PM

Hi All,

I need some help with SWIG and Ruby, I am trying to use some C functions
in ruby.
I have just started with SWIG and have been reading the manual en posts
around the net, but I have not been able to get this to work properly,
here are some if the questions I have:


- When I run opc_connect why isnâ??t â??conn_idâ? assigned any reference?

- Whatâ??s wrong with the â??%apply int *INOUTâ?¦â?, when I run opcif_open,
â??if_idâ? does not get any reference?

- How do I work with the typedefs â??typedef void * XXâ? in ruby?, when I
run opcdata_create, the variable data should get some data or
referenced?

- Is it necessary to create some custom typemaps to make this work?

Any help or example would be appreciated, thanks in advanced for the
help.





ruby Test.rb (OUTPUT)
-----------
TEST: opc_connect
RC: -20 / ID: <<<-- ???
TEST: opcif_open
TYPE: 4 / MODE: 24 / ID: <<<-- ???
RC: -21 / TYPE: 4 / MODE: 24 / ID: <<<-- ???
TEST: opcdata_create
RC: -21 / DATA: <<<-- ???

Test.rb
--------------------------------------
require 'api'
include Api

puts "TEST: opc_connect\n"
conn_id = nil
rc_conn = opc_connect("opc_adm", "OpC_adm", conn_id)
puts "\tRC: #{rc_conn} / ID: #{conn_id}\n"

puts "TEST: opcif_open\n"
if_type = 4
if_name = "SEBASTST"
if_mode = 24
if_id = nil

print "\tTYPE: #{if_type} / MODE: #{if_mode} / ID: #{if_id}\n"
rc_open = opcif_open(if_type, if_name, if_mode, 0, if_id)
print "\tRC: #{rc_open} / TYPE: #{if_type} / MODE: #{if_mode} / ID:
#{if_id}\n"

puts "TEST: opcdata_create\n"
data = nil
rc_data = opcdata_create(0 , data)
puts "\tRC: #{rc_data} / DATA: #{data}\n"
------------------------------



Interface file:
-------------------
%module api

%inline %{
#include "api.h"
%}

%include typemaps.i
%apply int *INOUT { int *interface_id };
--------------------


api.h
--------------------
#define OPCAPI
#define OPCLIBAPI extern

typedef void * opcdata;
typedef void * opcregcond;
typedef void * opc_connection;
typedef void * opc_iterator;
typedef int pipe_handle;
typedef pipe_handle *p_pipe_handle;

OPCLIBAPI int OPCAPI opc_connect (
const char *operator_name,
const char *operator_pwd,
opc_connection *opc_conn );

OPCLIBAPI int OPCAPI opcif_open (
int interface_type,
const char *instance,
int mode,
int max_entries,
int *interface_id );

OPCLIBAPI int OPCAPI opcdata_create (
int data_type,
opcdata *data );
--------------------

--
Posted via http://www.ruby-....

1 Answer

NoSpamAtAll

10/7/2012 8:47:00 PM

0

In article <o9f1781d7ln5r4njb7acrpchcp2r7fftg7@4ax.com>,
The Revd <peeling@degenerate.Grik> wrote:

[...]

limey capital going down the toilet
http://tinyurl.c...

"London falling: youth violence, feuds and fear scar the capital's heart"

What can you expect from these limey bastards!?