[squeak-dev] External language support

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] External language support

Inglada
Hi all,

I am new to Squeak and I would like to know if there is a way to use an external C++ API from it. I find the language and the environment very interesting and I would like to benefit from some legacy code.

I have been searching on the net for an equivalent of SWIG <http://www.swig.org/> for Squeak without success.

Thanks in advance for your help.

Jordi.

--
Jordi Inglada
http://pixel-remote-sensing.blogspot.com/


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] External language support

CdAB63
jordi inglada escreveu:
Hi all,

I am new to Squeak and I would like to know if there is a way to use an external C++ API from it. I find the language and the environment very interesting and I would like to benefit from some legacy code.
Take a look at FFI.
If examples are needed, you can go for the squeak interface for FANN (Fast Artificial Neural Network).
http://leenissen.dk/fann/index.php

I have been searching on the net for an equivalent of SWIG <http://www.swig.org/> for Squeak without success.

Thanks in advance for your help.

Jordi.

--
Jordi Inglada
http://pixel-remote-sensing.blogspot.com/





signature.asc (267 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] External language support

Mariano Martinez Peck
There was an interesting thread about c++.

http://www.nabble.com/-squeak-dev--C%2B%2B-parser-in-Smalltalk--td18191480.html

cheers,

Mariano

On Mon, Dec 1, 2008 at 2:43 PM, Casimiro de Almeida Barreto <[hidden email]> wrote:
jordi inglada escreveu:
Hi all,

I am new to Squeak and I would like to know if there is a way to use an external C++ API from it. I find the language and the environment very interesting and I would like to benefit from some legacy code.
Take a look at FFI.
If examples are needed, you can go for the squeak interface for FANN (Fast Artificial Neural Network).
http://leenissen.dk/fann/index.php

I have been searching on the net for an equivalent of SWIG <http://www.swig.org/> for Squeak without success.

Thanks in advance for your help.

Jordi.

--
Jordi Inglada
http://pixel-remote-sensing.blogspot.com/








Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] External language support

Joshua Gargus-2
In reply to this post by Inglada
Unfortunately, here is currently no direct way to interface directly with C++ code (only C code).  This is due to the lack of standardization of eg: name-mangling between C++ compilers.  However, it is still possible to call C++ code by wrapping the desired functions in C functions (or rather, functions declared as 'extern "C" ').

This should be enough documentation to get you started on the Squeak-to-C part:
http://wiki.squeak.org/squeak/370

Cheers,
Josh



jordi inglada wrote:
Hi all,

I am new to Squeak and I would like to know if there is a way to use an external C++ API from it. I find the language and the environment very interesting and I would like to benefit from some legacy code.

I have been searching on the net for an equivalent of SWIG <http://www.swig.org/> for Squeak without success.

Thanks in advance for your help.

Jordi.

--
Jordi Inglada
http://pixel-remote-sensing.blogspot.com/




Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] External language support

Inglada
Thank you all for the answers. I had a look at FANN and even asked the developer of the Squeak bindings, but, as far as I understand, it is not easy at all to proceed using FFI.

Since I wanted to wrap a library containing several thousands of classes using advanced template features, I guess I will have to find another solution.

Regards,

Jordi

2008/12/1 Joshua Gargus <[hidden email]>
Unfortunately, here is currently no direct way to interface directly with C++ code (only C code).  This is due to the lack of standardization of eg: name-mangling between C++ compilers.  However, it is still possible to call C++ code by wrapping the desired functions in C functions (or rather, functions declared as 'extern "C" ').

This should be enough documentation to get you started on the Squeak-to-C part:
http://wiki.squeak.org/squeak/370

Cheers,
Josh



jordi inglada wrote:
Hi all,

I am new to Squeak and I would like to know if there is a way to use an external C++ API from it. I find the language and the environment very interesting and I would like to benefit from some legacy code.

I have been searching on the net for an equivalent of SWIG <http://www.swig.org/> for Squeak without success.

Thanks in advance for your help.

Jordi.

--
Jordi Inglada
http://pixel-remote-sensing.blogspot.com/








--
Jordi Inglada
http://pixel-remote-sensing.blogspot.com/


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] External language support

Igor Stasenko
2008/12/4 jordi inglada <[hidden email]>:
> Thank you all for the answers. I had a look at FANN and even asked the
> developer of the Squeak bindings, but, as far as I understand, it is not
> easy at all to proceed using FFI.
>
> Since I wanted to wrap a library containing several thousands of classes
> using advanced template features, I guess I will have to find another
> solution.
>

few years ago i used a modified SWIG to generate an Ogre3d bindings
(which is written in C++) for own smalltalk interpreter.
It would be good to have own parser in smalltalk, because SWIG is a hell.

> Regards,
>
> Jordi
>
> 2008/12/1 Joshua Gargus <[hidden email]>
>>
>> Unfortunately, here is currently no direct way to interface directly with
>> C++ code (only C code).  This is due to the lack of standardization of eg:
>> name-mangling between C++ compilers.  However, it is still possible to call
>> C++ code by wrapping the desired functions in C functions (or rather,
>> functions declared as 'extern "C" ').
>>
>> This should be enough documentation to get you started on the Squeak-to-C
>> part:
>> http://wiki.squeak.org/squeak/370
>>
>> Cheers,
>> Josh
>>
>>
>>
>> jordi inglada wrote:
>>
>> Hi all,
>>
>> I am new to Squeak and I would like to know if there is a way to use an
>> external C++ API from it. I find the language and the environment very
>> interesting and I would like to benefit from some legacy code.
>>
>> I have been searching on the net for an equivalent of SWIG
>> <http://www.swig.org/> for Squeak without success.
>>
>> Thanks in advance for your help.
>>
>> Jordi.
>>
>> --
>> Jordi Inglada
>> http://pixel-remote-sensing.blogspot.com/
>>
>> ________________________________
>>
>>
>>
>>
>>
>
>
>
> --
> Jordi Inglada
> http://pixel-remote-sensing.blogspot.com/
>
>
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] External language support

Inglada


2008/12/4 Igor Stasenko <[hidden email]>


few years ago i used a modified SWIG to generate an Ogre3d bindings
(which is written in C++) for own smalltalk interpreter.
It would be good to have own parser in smalltalk, because SWIG is a hell.

Would you be willing to share the code you produced?



--
Jordi Inglada
http://pixel-remote-sensing.blogspot.com/


Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: External language support

Udo Schneider
jordi inglada schrieb:
> Would you be willing to share the code you produced?
I started something similar on Dolphin. The code parses SWIG XML Output
and generates the Dolphin FFI stuff for it "automagically" including
calls, enums and structures.

However somewhere along the road my experience is that SWIG from it's
nature really expects to produce a combination of C wrapper code and
foreign language code. It's very hard to generate direct FFI code (w/o
using the C wrapper) in some cases as this is simply not SWIGs intention.

I can publish my SWIG stuff if you like.

CU,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: External language support

Igor Stasenko
2008/12/5 Udo Schneider <[hidden email]>:

> jordi inglada schrieb:
>>
>> Would you be willing to share the code you produced?
>
> I started something similar on Dolphin. The code parses SWIG XML Output and
> generates the Dolphin FFI stuff for it "automagically" including calls,
> enums and structures.
>
> However somewhere along the road my experience is that SWIG from it's nature
> really expects to produce a combination of C wrapper code and foreign
> language code. It's very hard to generate direct FFI code (w/o using the C
> wrapper) in some cases as this is simply not SWIGs intention.
>

Right, that's why, my SWIG module generating two files as output:
C wrapper code, and ST glue methods/classes to reflect C++ classes in smalltalk.

As for squeak, the code generation could be changed to generate
squeak-compliant plugin code
or generate wrapper library, which can to be loaded by FFI and play
role as frontend to some foreign library.

> I can publish my SWIG stuff if you like.
>
> CU,
>
> Udo
>

--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] External language support

Antony Blakey-3
In reply to this post by Inglada

On 05/12/2008, at 7:13 AM, jordi inglada wrote:

> Thank you all for the answers. I had a look at FANN and even asked  
> the developer of the Squeak bindings, but, as far as I understand,  
> it is not easy at all to proceed using FFI.
>
> Since I wanted to wrap a library containing several thousands of  
> classes using advanced template features, I guess I will have to  
> find another solution.

I've uses gccxml for this purpose in VisualWorks. I reified the gccxml  
output as ST objects, and then used them to generate the DLLCC  
methods. I subsequently abandoned that and switched to clang, because  
I was already using llvm and was interested in using llvm to jit FFI  
stubs that did the mediation. Described on my blog starting here:

   http://www.cincomsmalltalk.com/userblogs/antony/blogView?showComments=true&printTitle=Generating_cross-platform_high_performance_native_code_in_VisualWorks.&entry=3372121629

and a comment about gccxml here:

   http://www.cincomsmalltalk.com/userblogs/antony/blogView?showComments=true&printTitle=Seaweed:_whats_wrong_with_GCCXML&entry=3372431209

Anyway, if you have a generic and ongoing requirement, I would  
recommend clang, with the caveat that I'm not sure of the current  
state of it's advanced C++ template handling. Failing that, you may  
have success with gccxml.

Antony Blakey
-------------
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787

Nothing is really work unless you would rather be doing something else.
   -- J. M. Barre



Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] External language support

Igor Stasenko
2008/12/6 Antony Blakey <[hidden email]>:

>
> On 05/12/2008, at 7:13 AM, jordi inglada wrote:
>
>> Thank you all for the answers. I had a look at FANN and even asked the
>> developer of the Squeak bindings, but, as far as I understand, it is not
>> easy at all to proceed using FFI.
>>
>> Since I wanted to wrap a library containing several thousands of classes
>> using advanced template features, I guess I will have to find another
>> solution.
>
> I've uses gccxml for this purpose in VisualWorks. I reified the gccxml
> output as ST objects, and then used them to generate the DLLCC methods. I
> subsequently abandoned that and switched to clang, because I was already
> using llvm and was interested in using llvm to jit FFI stubs that did the
> mediation. Described on my blog starting here:
>
>  http://www.cincomsmalltalk.com/userblogs/antony/blogView?showComments=true&printTitle=Generating_cross-platform_high_performance_native_code_in_VisualWorks.&entry=3372121629
>
> and a comment about gccxml here:
>
>  http://www.cincomsmalltalk.com/userblogs/antony/blogView?showComments=true&printTitle=Seaweed:_whats_wrong_with_GCCXML&entry=3372431209
>
> Anyway, if you have a generic and ongoing requirement, I would recommend
> clang, with the caveat that I'm not sure of the current state of it's
> advanced C++ template handling. Failing that, you may have success with
> gccxml.
>

Yeah, LLVM/Clang could be cool alternative.
Btw,  reading your blog, you seem expressing same ideas as me - use
JIT to produce native code for primitives directly from language. Then
thinking a little farther - once you can implement all primitives in
new style, you then don't need a conventional VM anymore. Wellcome to
Moebius project :) http://code.google.com/p/moebius-st/


> Antony Blakey
> -------------
> CTO, Linkuistics Pty Ltd
> Ph: 0438 840 787
>
> Nothing is really work unless you would rather be doing something else.
>  -- J. M. Barre
>


--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] External language support

Stephan Eggermont-3
In reply to this post by Inglada
What about the work done with Panda3D at Disney?

Cary Sandvig and Jesse Schell wrote a paper on what they did in 2000:
http://www.cs.princeton.edu/courses/archive/fall02/cs526/papers/panda.pdf
Current versions no longer support Smalltalk.

Did they just use a c++ subset?


Stephan


Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: External language support

Andreas.Raab
Stephan Eggermont wrote:
> What about the work done with Panda3D at Disney?

Panda3D had a highly reflective layer on top of the C++ stuff which
allowed them to inspect and construct the proper interfaces at runtime.
John Sarkela  did this based on top of the FFI (this project was the
driving force for the FFI).

I don't recall the specifics but I think Panda exported all its stuff
using C bindings and hooked this together via the FFI. You should ask
John for the details.

Cheers,
    - Andreas

> Cary Sandvig and Jesse Schell wrote a paper on what they did in 2000:
> http://www.cs.princeton.edu/courses/archive/fall02/cs526/papers/panda.pdf
> Current versions no longer support Smalltalk.
>
> Did they just use a c++ subset?
>
>
> Stephan
>
>
>