Calypso: Direct and full interfacing to C++
Kelly via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Tue May 19 17:01:59 PDT 2015
On Tuesday, 19 May 2015 at 19:57:45 UTC, Suliman wrote:
>
>>import (C++) GDALWarpOperation;
>>import (C++) GDALAccess;
>>import (C++) GDALWarpOptions;
>
> How do you understand which files should be imported?
>
These aren't files being imported, they are
classes/structs/templates being imported for use. Files are
'modmap'ed not imported in Calypso.
It can be tricky to know which classes/structs/templates need to
be imported if you aren't writing a program from scratch AND know
the library fairly well. What you can do is run Calypso and if it
complains that there is an 'undefined identifier', then check to
see if that identifier is a class/struct/template and try to
import it to see if the problem is fixed. Not an ideal
programming philosophy, of course, but it can help at the
beginning to let Calypso do some work for you.
There are also clues in the source code...if you have to 'new'
anything then it will need probably to be imported.
>> GDALWarpOptions* psWarpOptions = GDALCreateWarpOptions();
> GDALWarpOptions* is type?
> would:
> auto psWarpOptions = GDALCreateWarpOptions();
> work?
>
This actually ties in with the question above...and yes, 'auto'
will work. 'Auto' is definitely your friend with Calypso, as
sometimes it isn't clear what the C++ type would translate into.
Now the big thing with 'auto', in this case, is that if you use
'auto' then you don't even need the 'import (C++)
GDALWarpOptions'!!!! Calypso will figure it out and do it for you.
This is a bit of a double edge sword though, because sometimes
you will really want/need to know the type you are dealing with
and what it translates into. Hopefully this doesn't happen too
often.
>>Windows
> I hope to be able to test it in nearest time. As I wrote before
> I have not enough knowlages to build it's by myself, so I will
> wait bin builds.
>
>> If gdalwarper.h includes gdal.h and GDALDatasetH is declared
>> in gdal.h, then gdal.h gets imported too?
>
> +1 for question!
Since everything in the headers on the C++ side is sort of mashed
together into the PCH (pre-compiled header) file, and you import
every global variable/typedef/function/namespace using the
special "_", then you can get access to all of these globals via
the one modmap of gdalwarper.h.
Some more well-behaved libraries that have multiple namespaces
can be easier to deal with because you can be quite specific with
what you want to import, instead of just importing 'EVERYTHING'
and then only using a small portion of it.
This is an "As far as I understand it!!!" type of answer designed
to be a little less technical. Please see Elie's answers to these
questions for a more technical and in depth explanation (and the
CORRECT explanation, as I may be somewhat off in my
interpretation here :) !! )
Thanks,
Kelly
More information about the Digitalmars-d-announce
mailing list