[fpc-devel] First cppclass test
Sven Barth
svenmauren at vr-web.de
Thu Nov 12 22:12:55 CET 2009
Hi again!
Florian Klaempfl schrieb:
> Sven Barth schrieb:
>> Florian Klaempfl schrieb:
>>> Sven Barth schrieb:
>>>> All in all I have the following goals for (my) future work on this:
>>>> * make a cppclass an implicit pointer
>>> I don't like this idea because C++-classes aren't an implicit pointer
>>> either.
>>>
>> At first I wanted to disagree with you... philosophing about the Pascal
>> way of doing things, bla, bla...
>
> Pascal has also objects which are no pointers ;)
>
I know... I know... that might have contributed a bit to my decision to
give up implicit pointers ^^
>
>> If so, how do you
>> suggest to write those tests, especially as they (currently) rely on a
>> external library...
>
> Libraries or object files? FPC does similiar testing for C linking: the
> C sources are checked in into
> http://svn.freepascal.org/svn/fpc/trunk/tests/test/cg/obj/
> Compiled object files lay in the appropriate sub dir of this dir.
>
> Testing C++ class linking should be done similiar imo.
>
In theory that is possible, but I found a practical problem: C++ code
requires libstdc++ or at least libsupc++ which implements the "new" and
"delete" operators. And to make things worse: this library isn't
available in the Windows release of the compiler... (not a real problem
for me as I'm working on Linux...)
While I could be able to simulate the needed functionality of the
library through Pascal units with correct named procedures/functions, I
don't think that this is the way to go. A better solution (at least for
compiler tests) would be to just compile but not link those test units.
Does the test framework support such an option?
The following is the syntax I'm currently trying to implement:
TMyTestClass = cppclass
procedure MyTestMethod1;
procedure MyTestMethod2; name 'SecondMethod';
end; external 'foolib.so' name 'MyTestClass' namespace 'Foo::Bar';
This corresponds to this C++ class interface:
namespace Foo::Bar {
class MyTestClass {
public:
void MyTestMethod1();
void SecondMethod();
};
}
The "external foo name bar"-part should be pretty easy (thanks to Jonas'
objc branch which enabled me to find the right spots to include my code
^^ ). The 'name' for methods shouldn't be that complicated, too. But for
namespace support I'll need to introduce a new keyword "namespace".
Any comments on this proposal?
Because of the LLVM thread, I think I'll also check the LLVM API to
order the priority of needed features (e. g. virtual methods).
Greetings,
Sven
More information about the fpc-devel
mailing list