Hi,
Is it possible to call a static method of a c class using the FLI? For
ex, if I normally call the sqrt function so...
Class1.Sqrt()
how would I do it using LW's FLI?
(fli:define-foreign-function
(my-sqrt "Sqrt" :source)
((far :int))
:result-type :float
:language :ansi-c
)
(fli:register-module "lisptest")
(my-sqrt 10)
does not seem to do the trick.
thx,
--unm
"Unmesh Kurup" <····@NOSPAM.yahoo.com> wrote in message ·················@news.cis.ohio-state.edu...
> Hi,
> Is it possible to call a static method of a c class using the FLI? For
> ex, if I normally call the sqrt function so...
> Class1.Sqrt()
> how would I do it using LW's FLI?
>
> (fli:define-foreign-function
> (my-sqrt "Sqrt" :source)
> ((far :int))
> :result-type :float
> :language :ansi-c
> )
>
> (fli:register-module "lisptest")
>
> (my-sqrt 10)
>
> does not seem to do the trick.
You have to have an understanding how C++ functions are
named in the object library. The C++ class method has
a name-mangled name in lisptest.so
(or lisptest.dll on Windows). If you can inspect
lisptest.so (probably nm on Unixy systems) and look for
a function starting with something like "Sqrt_XXX", where
XXX is a mangled id for Class1. You can then define a
foreign function with that name.
Another way is to write a extern "C" {} wrapper around
Class1.Sqrt(), something like
extern "C" {
float class1_sqrt (int i) {return Class1.Sqrt(i);}
}
and link it in with lisptest.so.
Then write a fli definition like
(fli:define-foreign-function
(my-sqrt "class1_sqrt" :source)
((far :int))
:result-type :float
:language :ansi-c)
Wade