Re: [fpc-devel] Linking to C++

2007-01-22 Thread Bogusław Brandys
Jason P Sage wrote: Hello All, This may have been mentioned with different words already - but I'm getting the impression one should write a "C++ handler API" or "thin layer" for the C++ lib one wants to utilize. The idea being FPC would only link on standard calls that more or less ran the unde

[fpc-devel] Some compiler changes...

2007-01-22 Thread Thorsten Engler
While playing around with the compiler source to familiarize myself I've produced the attached patch. While I didn't set out to produce anything for inclusion into the official codebase at least some of the changes might be generally useful. a) now modeswitch: m_ident_escape Allows escaping of id

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Jason P Sage
Hello All, This may have been mentioned with different words already - but I'm getting the impression one should write a "C++ handler API" or "thin layer" for the C++ lib one wants to utilize. The idea being FPC would only link on standard calls that more or less ran the underlying C++ lib like a

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Peter Popov
About the name mangling: this thing is compiler specific. To have really portable code, whoever compiled the DLL should include flattened procedural API model without name mangling. See the Kylix QT libraries: borland have compiled their own version of Qt2.3.0 and have exported things in a

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Daniël Mantione
Op Mon, 22 Jan 2007, schreef Felipe Monteiro de Carvalho: > Maybe the compiler could hide the > procedurization/re-object-orientation, thus making interfacing easier. Already looked at many times, but it is not realistic. Daniël___ fpc-devel maillist

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Felipe Monteiro de Carvalho
On 1/22/07, Jonas Maebe <[EMAIL PROTECTED]> wrote: No, just with "cppdecl" instead of "cdecl". Afaik we even already have that keyword in the compiler. It just doesn't do any C++ name mangling currently. Can´t name mangling be utilized on other calling conventions besides cdecl? -- Felipe Mont

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Felipe Monteiro de Carvalho
On 1/22/07, Felipe Monteiro de Carvalho <[EMAIL PROTECTED]> wrote: And using proceduralization / re-object-orientation manually would result on something even much larger, perhaps 2 times larger or more. Just to avoid mis-interpretation. It´s not only a question of saving lines of code, but als

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Felipe Monteiro de Carvalho
On 1/22/07, Felipe Monteiro de Carvalho <[EMAIL PROTECTED]> wrote: Maybe the compiler could hide the procedurization/re-object-orientation, thus making interfacing easier. Basically this would be nice for me because the Symbian OS headers are incredibly huge. There more then 100.000 lines of .h

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Felipe Monteiro de Carvalho
Maybe the compiler could hide the procedurization/re-object-orientation, thus making interfacing easier. So this: type User = class public function Sum(a, b: cint): cint; cdecl; external 'cpplib.dll'; end; Would be the exact equivalent of: function User_Sum(Self: Pointer; a, b: cint): cint;

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Den Jean
On Monday 22 January 2007 21:14, Peter Popov wrote: > example is the way QT is interfaced with Kylix. It works, only because QT   > is reasonably well written, all the new/deletes of QT objects are   > explicitly wrapped in Kylix, and the published QT member functions don't   > do weird things. All

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Daniël Mantione
Op Mon, 22 Jan 2007, schreef Felipe Monteiro de Carvalho: > On 1/22/07, Daniël Mantione <[EMAIL PROTECTED]> wrote: > > Of course, you can import a class like you did, and even automate it, I > > don't see a problem with adding C++ mangling. But, you cannot use class > > syntax, since classes are

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Den Jean
On Monday 22 January 2007 20:17, Felipe Monteiro de Carvalho wrote: > Hello, > > Now, I utilized dllview software I created and saw that cpplib exports > this function: _ZN4User3SumEii > IIRC C++ compiler/platform dependant. So do not use this to be compiler independant GCC even changed its name ma

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Jonas Maebe
On 22 Jan 2007, at 21:45, Felipe Monteiro de Carvalho wrote: function User.Sum(Self: Pointer; a, b: cint): cint; cdecl; external 'cpplib.dll'; cpp_method_name_mandling; No, just with "cppdecl" instead of "cdecl". Afaik we even already have that keyword in the compiler. It just doesn't do an

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Felipe Monteiro de Carvalho
On 1/22/07, Peter Popov <[EMAIL PROTECTED]> wrote: Take a specific look at the second part, with pure virtual classes. The trouble is it only works for virtual C++ classes (have at least on virtual function - hence a VMT) with single inheritance (single VMT with virtual functions at offset 0). Th

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Felipe Monteiro de Carvalho
I don't know what FPC does with member functions, but Delphi does not export them. You cannot put a member function in the export part of a library. You have to create a wrapper (normal function with Self as the first argument) and then export the wrapper. So, if you happen to have a good class A

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Peter Popov
Further reading on some limited portability of C++ classes into Delphi: http://www.rvelthuis.de/articles/articles-cppobjs.html Take a specific look at the second part, with pure virtual classes. The trouble is it only works for virtual C++ classes (have at least on virtual function - hence a

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Daniël Mantione
Op Mon, 22 Jan 2007, schreef Felipe Monteiro de Carvalho: > So, basically, what I mean with this is: What is needed to add C++ > linking to Free Pascal? It seams to me that it should be easy, we just > need to understand C++ name mangling and choose a sintax to implement > it. Maybe something li

Re: [fpc-devel] Linking to C++

2007-01-22 Thread Peter Popov
The simple answer is that you cannot reliably mix object oriented langugages without severe portability issues and without loosing basic functionality: polymorphism. You simply cannot extend the functionality of a class written in one language from another language. ON THE LINKING PART: all

[fpc-devel] Linking to C++

2007-01-22 Thread Felipe Monteiro de Carvalho
Hello, I was studing how to write the system unit for Symbian OS, and everything on Symbian is C++, so you actually import lot´s of methods from classes, not procedures. So I decided to study the task of linking from Free Pascal to C++ Maybe it´s easy to be implemented, and that would be very ni