Re: Question about call_c

From: masdeval <masdeval_at_yahoo.com.br>
Date: Mon 30 Aug 2004 12:31:40 PM GMT
Message-ID: <001601c48e8d$4f7de480$2806520a@cbraz>
   Hi Tomas,

   to call a C function from Eclipse you could create an external predicate
that receives a pointer to the method. A pointer can be handled by an
EC_word or EC_ref variable just as a double value.
    To pass a pointer to an EC_word do

         EC_word pointer = reinterpret_cast<long>(the C function pointer);

 then, inside the external predicate

        long w;
        pointer.is_long(&w);
        int (*function)() = reinterpret_cast<int*>(w);


    Cheers,

    Christian

----- Original Message -----
From: "Tomas Uribe" <uribe@AI.SRI.COM>
To: <eclipse-users@icparc.ic.ac.uk>
Sent: Saturday, August 28, 2004 3:12 PM
Subject: [eclipse-users] Question about call_c


> Hi. I am trying to use call_c to interface with an external shared library
> that creates its own objects.
>
> If I want to do operations such as
>
>          call_c(string_to_object("asdf"),Object)
>
> and later (within the same goal invocation)
>
>          call_c(object_to_string(Object),string(S)) ,
>
> do I need to wrap O in a handle? (In reality, O is a pointer to the
> object in question, whose memory is managed by the shared library code.)
>
> If so, is there a default handler for pointers?
>
> (Note that I want to call C functions from inside Eclipse; the embedding
> and interfacing manual seems to address mostly the case where Eclipse is
> called by C applications...)
>
> Thanks,
>
> - Tomas
>
>
Received on Mon Aug 30 15:55:00 2004

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:30 PM GMT GMT