[fpc-pascal] Re: Automatically exporting C++ API using SWIG??

Michael Van Canneyt michael at freepascal.org
Thu Aug 1 13:36:03 CEST 2013



On Thu, 1 Aug 2013, Sven Barth wrote:

>> Of course I understand it's very attractive to have everything in house
>> and native in FPC, but I suspect the effort needed to develop/maintain
>> it may outweigh that...
> Important point for variant 2: less overhead. Using swig you first flatten 
> the API and then unflatten it again into Object Pascal classes. For callbacks 
> you have also wrappers (which are hidden from you). In case of cppclass you 
> don't have all this, because code will be called directly.

And: it's written in Pascal.

The problem with tools such as swig is, that, unless it works 'out of the box' 
for the particular DLL you're interested in, basically, you are stuck.

Like as in:
Leap.i:259: Error: Syntax error in input(1).

The line in question being:
SWIG_CSBODY_PROXY(public, public, SWIGTYPE)

To make matters worse, the actual error depends on the target output language. Aha....

Hm....

With swig, I must now learn C, C++, the swig .i and .swg file formats. 
And then I must still get started on the swig java/csharp/delphi/whatever backend.

And that is if I am lucky that the providers of the DLL provided me with a input 
file for swig. If not, I still must construct that...

Now if it is written in Pascal, I pull up my sleeves, open whatever it is in 
Lazarus and start debugging/coding. Not so in tools like swig.

Michael.



More information about the fpc-pascal mailing list