C libraries wrapping

7 messages Options
Embed this post
Permalink
luca.paganotti

C libraries wrapping

Reply Threaded More More options
Print post
Permalink
Hi all,
I'm trying to define eiffel bindings for libproj on a windows box using
EiffelStudio 6.4 GPL version. At the moment i'm able to correctly get values
from macros on the C side to the eiffel one, I'm also able to get and set
values of trivial C structures using only built-in C types like int, long,
double etc... But I'm in troubles with more complex definitions such as
function pointers and so on. Also having troubles to pass simple C struct(s)
to the C side. In the worst case (at least for me ... ) I have to map a C
struct like this:

typedef struct PJconsts {
    XY  (*fwd)(LP, struct PJconsts *);
    LP  (*inv)(XY, struct PJconsts *);
    void (*spc)(LP, struct PJconsts *, struct FACTORS *);
    void (*pfree)(struct PJconsts *);
    const char *descr;
    paralist *params;   /* parameter list */
    int over;   /* over-range flag */
    int geoc;   /* geocentric latitude flag */
        int is_latlong; /* proj=latlong ... not really a projection at all
*/
        int is_geocent; /* proj=geocent ... not really a projection at all
*/
    double
        a,  /* major axis or radius if es==0 */
                a_orig, /* major axis before any +proj related adjustment */
        es, /* e ^ 2 */
                es_orig, /* es before any +proj related adjustment */
        e,  /* eccentricity */
        ra, /* 1/A */
        one_es, /* 1 - e^2 */
        rone_es, /* 1/one_es */
        lam0, phi0, /* central longitude, latitude */
        x0, y0, /* easting and northing */
        k0,    /* general scaling factor */
        to_meter, fr_meter; /* cartesian scaling */

        int     datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
        double  datum_params[7];
        double  from_greenwich; /* prime meridian offset (in radians) */
        double  long_wrap_center; /* 0.0 for -180 to 180, actually in
radians*/

#ifdef PROJ_PARMS__
PROJ_PARMS__
#endif /* end of optional extensions */
} PJ;

and also some functions that receive as formal parameters pointers to this
struct that can be conforming to this type (e.g. of type PJ*) or simply void
pointers. If I can manage such situations I'll probably be able to manage
also simple cases that i want to map from the two languages.

At the moment I really do not know where to begin from.

Probably I'm missing some vital information about the mappings between C and
eiffel ... or what I'm trying to do is not the right way do achieve my goal
...

Has anyone of you done something similar? If so, can you briefly explain me
where to get information to get the job done?

Thanks in advance for any answer.


--------------------------------------------------------------
-- Dott. Ing. Luca Paganotti
-- Via dei Giardini 9
-- 21035 Cunardo (VA)
-- 393 1346898
--------------------------------------------------------------
-- sourceforge email:
-- [hidden email]
--------------------------------------------------------------
--


[Non-text portions of this message have been removed]

Jann Röder

Re: C libraries wrapping

Reply Threaded More More options
Print post
Permalink
Well,
to wrap this struct you need to write setters and getters for each
field. There is special syntax for this available:
http://doc.eiffel.com/book/solutions/c-externals

There is also the Eiffel C wrapper generator, but it always generates C
wrapper libraries which are not necessary with the current Eiffel
compiler. Also hand written wrappers tend to be better than generated ones.

Hope this helps,
Jann

luca paganotti schrieb:

> Hi all,
> I'm trying to define eiffel bindings for libproj on a windows box using
> EiffelStudio 6.4 GPL version. At the moment i'm able to correctly get values
> from macros on the C side to the eiffel one, I'm also able to get and set
> values of trivial C structures using only built-in C types like int, long,
> double etc... But I'm in troubles with more complex definitions such as
> function pointers and so on. Also having troubles to pass simple C struct(s)
> to the C side. In the worst case (at least for me ... ) I have to map a C
> struct like this:
>
> typedef struct PJconsts {
>     XY  (*fwd)(LP, struct PJconsts *);
>     LP  (*inv)(XY, struct PJconsts *);
>     void (*spc)(LP, struct PJconsts *, struct FACTORS *);
>     void (*pfree)(struct PJconsts *);
>     const char *descr;
>     paralist *params;   /* parameter list */
>     int over;   /* over-range flag */
>     int geoc;   /* geocentric latitude flag */
>         int is_latlong; /* proj=latlong ... not really a projection at all
> */
>         int is_geocent; /* proj=geocent ... not really a projection at all
> */
>     double
>         a,  /* major axis or radius if es==0 */
>                 a_orig, /* major axis before any +proj related adjustment */
>         es, /* e ^ 2 */
>                 es_orig, /* es before any +proj related adjustment */
>         e,  /* eccentricity */
>         ra, /* 1/A */
>         one_es, /* 1 - e^2 */
>         rone_es, /* 1/one_es */
>         lam0, phi0, /* central longitude, latitude */
>         x0, y0, /* easting and northing */
>         k0,    /* general scaling factor */
>         to_meter, fr_meter; /* cartesian scaling */
>
>         int     datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
>         double  datum_params[7];
>         double  from_greenwich; /* prime meridian offset (in radians) */
>         double  long_wrap_center; /* 0.0 for -180 to 180, actually in
> radians*/
>
> #ifdef PROJ_PARMS__
> PROJ_PARMS__
> #endif /* end of optional extensions */
> } PJ;
>
> and also some functions that receive as formal parameters pointers to this
> struct that can be conforming to this type (e.g. of type PJ*) or simply void
> pointers. If I can manage such situations I'll probably be able to manage
> also simple cases that i want to map from the two languages.
>
> At the moment I really do not know where to begin from.
>
> Probably I'm missing some vital information about the mappings between C and
> eiffel ... or what I'm trying to do is not the right way do achieve my goal
> ...
>
> Has anyone of you done something similar? If so, can you briefly explain me
> where to get information to get the job done?
>
> Thanks in advance for any answer.
>
>
> --------------------------------------------------------------
> -- Dott. Ing. Luca Paganotti
> -- Via dei Giardini 9
> -- 21035 Cunardo (VA)
> -- 393 1346898
> --------------------------------------------------------------
> -- sourceforge email:
> -- [hidden email]
> --------------------------------------------------------------
> --
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
Colin LeMahieu

Re: C libraries wrapping

Reply Threaded More More options
Print post
Permalink
In reply to this post by luca.paganotti
Take a look at inline C functions, it would help a lot with function
pointers.

feature
 fwd_external (function: POINTER lp_parameter: POINTER pjconsts_parameter:
POINTER): POINTER
  external
    "C inline use %"xyz_header.h%""
  alias
    "[
      return ((XY (*)(LP, struct PJconsts *)$function) ($lp_parameter,
$pjconsts_parameter);
    ]"

On Tue, Sep 8, 2009 at 11:48 AM, luca paganotti <[hidden email]>wrote:

>
>
> Hi all,
> I'm trying to define eiffel bindings for libproj on a windows box using
> EiffelStudio 6.4 GPL version. At the moment i'm able to correctly get
> values
> from macros on the C side to the eiffel one, I'm also able to get and set
> values of trivial C structures using only built-in C types like int, long,
> double etc... But I'm in troubles with more complex definitions such as
> function pointers and so on. Also having troubles to pass simple C
> struct(s)
> to the C side. In the worst case (at least for me ... ) I have to map a C
> struct like this:
>
> typedef struct PJconsts {
> XY (*fwd)(LP, struct PJconsts *);
> LP (*inv)(XY, struct PJconsts *);
> void (*spc)(LP, struct PJconsts *, struct FACTORS *);
> void (*pfree)(struct PJconsts *);
> const char *descr;
> paralist *params; /* parameter list */
> int over; /* over-range flag */
> int geoc; /* geocentric latitude flag */
> int is_latlong; /* proj=latlong ... not really a projection at all
> */
> int is_geocent; /* proj=geocent ... not really a projection at all
> */
> double
> a, /* major axis or radius if es==0 */
> a_orig, /* major axis before any +proj related adjustment */
> es, /* e ^ 2 */
> es_orig, /* es before any +proj related adjustment */
> e, /* eccentricity */
> ra, /* 1/A */
> one_es, /* 1 - e^2 */
> rone_es, /* 1/one_es */
> lam0, phi0, /* central longitude, latitude */
> x0, y0, /* easting and northing */
> k0, /* general scaling factor */
> to_meter, fr_meter; /* cartesian scaling */
>
> int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
> double datum_params[7];
> double from_greenwich; /* prime meridian offset (in radians) */
> double long_wrap_center; /* 0.0 for -180 to 180, actually in
> radians*/
>
> #ifdef PROJ_PARMS__
> PROJ_PARMS__
> #endif /* end of optional extensions */
> } PJ;
>
> and also some functions that receive as formal parameters pointers to this
> struct that can be conforming to this type (e.g. of type PJ*) or simply
> void
> pointers. If I can manage such situations I'll probably be able to manage
> also simple cases that i want to map from the two languages.
>
> At the moment I really do not know where to begin from.
>
> Probably I'm missing some vital information about the mappings between C
> and
> eiffel ... or what I'm trying to do is not the right way do achieve my goal
> ...
>
> Has anyone of you done something similar? If so, can you briefly explain me
> where to get information to get the job done?
>
> Thanks in advance for any answer.
>
> ----------------------------------------------------------
> -- Dott. Ing. Luca Paganotti
> -- Via dei Giardini 9
> -- 21035 Cunardo (VA)
> -- 393 1346898
> ----------------------------------------------------------
> -- sourceforge email:
> -- [hidden email]<lucapaganotti%40users.sourceforge.net>
> ----------------------------------------------------------
> --
>
> [Non-text portions of this message have been removed]
>
>  
>


[Non-text portions of this message have been removed]

luca.paganotti

Re: C libraries wrapping

Reply Threaded More More options
Print post
Permalink
In reply to this post by Jann Röder
Hi Jann, thanks for your reply, as I'm learning about eiffel wrappers I
think that may be a good starting point to let ewg create the wrappers for
me and then if it's the case, modify them, so i got and try to use it.
Trying to get ewg installed i get this (attached geant-output.txt) output
with geant final complaint:

...

ewg_parser.ewg_c_macro_parser:

  [gelex] gelex -e -m -o ewg_c_macro_scanner.e ewg_c_macro_scanner.l
  [geyacc] geyacc -v ewg_c_macro_parser.txt --new_typing -t
EWG_C_MACRO_TOKENS -o ewg_c_macro_parser.e ewg_c_macro_parser.y
  [geant] geant -v -b build.eant install
Loading Project's configuration from build.eant
Loading Project's configuration from c:\gobo/misc/ge2e.eant
Building Project

runtime.install:

  [set global] gepp_dir=.
  [set global] spec_dir=spec
  [set global] gepp_file=ewg_external_string_routines

ge2e.ge2e:

  error: number of actual and formal arguments do not match for target
'ge2e' (0 against 3)

BUILD FAILED!

BUILD FAILED!

BUILD FAILED!

i'm guessing that the error is due to the fact that something requiring 3
arguments has received none of them, but i don't know where the arguments
are passed to this target, I see thet gepp_dir, spec_dir and gepp_file
(which I suppose are the target arguments ...) are all set to meaningfull
values, so i do not understand why I get this error.

I'm using gobo 3.9 Ise EiffelStudio GPL 6.4, all my environments variables
seem to be set correctly

Any help will be appreciated.

--------------------------------------------------------------
-- Dott. Ing. Luca Paganotti
-- Via dei Giardini 9
-- 21035 Cunardo (VA)
-- 393 1346898
--------------------------------------------------------------
-- sourceforge email:
-- [hidden email]
--------------------------------------------------------------
--


On Tue, Sep 8, 2009 at 7:33 PM, Jann Röder <[hidden email]> wrote:

>
>
> Well,
> to wrap this struct you need to write setters and getters for each
> field. There is special syntax for this available:
> http://doc.eiffel.com/book/solutions/c-externals
>
> There is also the Eiffel C wrapper generator, but it always generates C
> wrapper libraries which are not necessary with the current Eiffel
> compiler. Also hand written wrappers tend to be better than generated ones.
>
> Hope this helps,
> Jann
>
> luca paganotti schrieb:
>
> > Hi all,
> > I'm trying to define eiffel bindings for libproj on a windows box using
> > EiffelStudio 6.4 GPL version. At the moment i'm able to correctly get
> values
> > from macros on the C side to the eiffel one, I'm also able to get and set
> > values of trivial C structures using only built-in C types like int,
> long,
> > double etc... But I'm in troubles with more complex definitions such as
> > function pointers and so on. Also having troubles to pass simple C
> struct(s)
> > to the C side. In the worst case (at least for me ... ) I have to map a C
> > struct like this:
> >
> > typedef struct PJconsts {
> > XY (*fwd)(LP, struct PJconsts *);
> > LP (*inv)(XY, struct PJconsts *);
> > void (*spc)(LP, struct PJconsts *, struct FACTORS *);
> > void (*pfree)(struct PJconsts *);
> > const char *descr;
> > paralist *params; /* parameter list */
> > int over; /* over-range flag */
> > int geoc; /* geocentric latitude flag */
> > int is_latlong; /* proj=latlong ... not really a projection at all
> > */
> > int is_geocent; /* proj=geocent ... not really a projection at all
> > */
> > double
> > a, /* major axis or radius if es==0 */
> > a_orig, /* major axis before any +proj related adjustment */
> > es, /* e ^ 2 */
> > es_orig, /* es before any +proj related adjustment */
> > e, /* eccentricity */
> > ra, /* 1/A */
> > one_es, /* 1 - e^2 */
> > rone_es, /* 1/one_es */
> > lam0, phi0, /* central longitude, latitude */
> > x0, y0, /* easting and northing */
> > k0, /* general scaling factor */
> > to_meter, fr_meter; /* cartesian scaling */
> >
> > int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
> > double datum_params[7];
> > double from_greenwich; /* prime meridian offset (in radians) */
> > double long_wrap_center; /* 0.0 for -180 to 180, actually in
> > radians*/
> >
> > #ifdef PROJ_PARMS__
> > PROJ_PARMS__
> > #endif /* end of optional extensions */
> > } PJ;
> >
> > and also some functions that receive as formal parameters pointers to
> this
> > struct that can be conforming to this type (e.g. of type PJ*) or simply
> void
> > pointers. If I can manage such situations I'll probably be able to manage
> > also simple cases that i want to map from the two languages.
> >
> > At the moment I really do not know where to begin from.
> >
> > Probably I'm missing some vital information about the mappings between C
> and
> > eiffel ... or what I'm trying to do is not the right way do achieve my
> goal
> > ...
> >
> > Has anyone of you done something similar? If so, can you briefly explain
> me
> > where to get information to get the job done?
> >
> > Thanks in advance for any answer.
> >
> >
> > ----------------------------------------------------------
> > -- Dott. Ing. Luca Paganotti
> > -- Via dei Giardini 9
> > -- 21035 Cunardo (VA)
> > -- 393 1346898
> > ----------------------------------------------------------
> > -- sourceforge email:
> > -- [hidden email]<lucapaganotti%40users.sourceforge.net>
> > ----------------------------------------------------------
> > --
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
>  
>


[Non-text portions of this message have been removed]

luca.paganotti

Re: C libraries wrapping

Reply Threaded More More options
Print post
Permalink
In reply to this post by Jann Röder
... sorry here it is the attachment ...

--------------------------------------------------------------
-- Dott. Ing. Luca Paganotti
-- Via dei Giardini 9
-- 21035 Cunardo (VA)
-- 393 1346898
--------------------------------------------------------------
-- sourceforge email:
-- [hidden email]
--------------------------------------------------------------
--


On Tue, Sep 8, 2009 at 7:33 PM, Jann Röder <[hidden email]> wrote:

>
>
> Well,
> to wrap this struct you need to write setters and getters for each
> field. There is special syntax for this available:
> http://doc.eiffel.com/book/solutions/c-externals
>
> There is also the Eiffel C wrapper generator, but it always generates C
> wrapper libraries which are not necessary with the current Eiffel
> compiler. Also hand written wrappers tend to be better than generated ones.
>
> Hope this helps,
> Jann
>
> luca paganotti schrieb:
>
> > Hi all,
> > I'm trying to define eiffel bindings for libproj on a windows box using
> > EiffelStudio 6.4 GPL version. At the moment i'm able to correctly get
> values
> > from macros on the C side to the eiffel one, I'm also able to get and set
> > values of trivial C structures using only built-in C types like int,
> long,
> > double etc... But I'm in troubles with more complex definitions such as
> > function pointers and so on. Also having troubles to pass simple C
> struct(s)
> > to the C side. In the worst case (at least for me ... ) I have to map a C
> > struct like this:
> >
> > typedef struct PJconsts {
> > XY (*fwd)(LP, struct PJconsts *);
> > LP (*inv)(XY, struct PJconsts *);
> > void (*spc)(LP, struct PJconsts *, struct FACTORS *);
> > void (*pfree)(struct PJconsts *);
> > const char *descr;
> > paralist *params; /* parameter list */
> > int over; /* over-range flag */
> > int geoc; /* geocentric latitude flag */
> > int is_latlong; /* proj=latlong ... not really a projection at all
> > */
> > int is_geocent; /* proj=geocent ... not really a projection at all
> > */
> > double
> > a, /* major axis or radius if es==0 */
> > a_orig, /* major axis before any +proj related adjustment */
> > es, /* e ^ 2 */
> > es_orig, /* es before any +proj related adjustment */
> > e, /* eccentricity */
> > ra, /* 1/A */
> > one_es, /* 1 - e^2 */
> > rone_es, /* 1/one_es */
> > lam0, phi0, /* central longitude, latitude */
> > x0, y0, /* easting and northing */
> > k0, /* general scaling factor */
> > to_meter, fr_meter; /* cartesian scaling */
> >
> > int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
> > double datum_params[7];
> > double from_greenwich; /* prime meridian offset (in radians) */
> > double long_wrap_center; /* 0.0 for -180 to 180, actually in
> > radians*/
> >
> > #ifdef PROJ_PARMS__
> > PROJ_PARMS__
> > #endif /* end of optional extensions */
> > } PJ;
> >
> > and also some functions that receive as formal parameters pointers to
> this
> > struct that can be conforming to this type (e.g. of type PJ*) or simply
> void
> > pointers. If I can manage such situations I'll probably be able to manage
> > also simple cases that i want to map from the two languages.
> >
> > At the moment I really do not know where to begin from.
> >
> > Probably I'm missing some vital information about the mappings between C
> and
> > eiffel ... or what I'm trying to do is not the right way do achieve my
> goal
> > ...
> >
> > Has anyone of you done something similar? If so, can you briefly explain
> me
> > where to get information to get the job done?
> >
> > Thanks in advance for any answer.
> >
> >
> > ----------------------------------------------------------
> > -- Dott. Ing. Luca Paganotti
> > -- Via dei Giardini 9
> > -- 21035 Cunardo (VA)
> > -- 393 1346898
> > ----------------------------------------------------------
> > -- sourceforge email:
> > -- [hidden email]<lucapaganotti%40users.sourceforge.net>
> > ----------------------------------------------------------
> > --
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
>  
>

  ----------

Loading Project's configuration from build.eant
Building Project

ewg_root.init:


ewg_root.init_os:


ewg_root.init_windows:

  [set] warning: you are using the name of the builtin variable 'exe' in a <set> task
  [set global] exe=.exe

ewg_root.install:

  [geant] geant -v -b build.eant install
Loading Project's configuration from build.eant
Building Project

src.init:


src.install:

  [set global] target=install

src.do_all:

  [geant] geant -v -b c:\ewg\src\ewg\build.eant install
Loading Project's configuration from c:\ewg\src\ewg\build.eant
Loading Project's configuration from c:\gobo/misc/eiffel.eant
Loading Project's configuration from c:\gobo/misc/ge2e.eant
Building Project

eiffel.init:

  [set global] eiffel=ge

eiffel.init_eiffel:

  [set global] eiffel=ge

eiffel.init_os:


eiffel.init_windows:


ewg.init_system:

  [set global] system=ewg
  [set global] system_dir=c:\ewg\src\ewg

eiffel.install:


eiffel.xace:

  [set global] a_format=
  [gexace] gexace --define="GOBO_EIFFEL=ge GOBO_OS=windows GOBO_CC=msc" --system="ge" c:\ewg\src\ewg\system.xace

eiffel.xace:

  [set global] a_format=
  [gexace] gexace --define="GOBO_EIFFEL=ge GOBO_OS=windows GOBO_CC=msc" --system="ise" c:\ewg\src\ewg\system.xace

eiffel.other_install:

  [geant] geant -v -b c:\ewg\src\drc\build.eant install
Loading Project's configuration from c:\ewg\src\drc\build.eant
Loading Project's configuration from c:\gobo/misc/eiffel.eant
Loading Project's configuration from c:\gobo/misc/ge2e.eant
Building Project

eiffel.init:

  [set global] eiffel=ge

eiffel.init_eiffel:

  [set global] eiffel=ge

eiffel.init_os:


eiffel.init_windows:


drc.init_system:

  [set global] system=drc
  [set global] system_dir=c:\ewg/src/drc/

eiffel.install:


eiffel.xace:

  [set global] a_format=
  [gexace] gexace --define="GOBO_EIFFEL=ge GOBO_OS=windows GOBO_CC=msc" --system="ge" c:\ewg\src\drc\system.xace

eiffel.xace:

  [set global] a_format=
  [gexace] gexace --define="GOBO_EIFFEL=ge GOBO_OS=windows GOBO_CC=msc" --system="ise" c:\ewg\src\drc\system.xace

eiffel.other_install:

  [geant] geant -v -b build.eant install
Loading Project's configuration from build.eant
Building Project

ewg_parser.install:


ewg_parser.ewg_c_parser:

  [gelex] gelex -e -m -o ewg_c_scanner.e ewg_c_scanner.l
  [geyacc] geyacc -v ewg_c_parser.txt --new_typing -t EWG_C_TOKENS -o ewg_c_parser.e ewg_c_parser.y

ewg_parser.ewg_c_macro_parser:

  [gelex] gelex -e -m -o ewg_c_macro_scanner.e ewg_c_macro_scanner.l
  [geyacc] geyacc -v ewg_c_macro_parser.txt --new_typing -t EWG_C_MACRO_TOKENS -o ewg_c_macro_parser.e ewg_c_macro_parser.y
  [geant] geant -v -b build.eant install
Loading Project's configuration from build.eant
Loading Project's configuration from c:\gobo/misc/ge2e.eant
Building Project

runtime.install:

  [set global] gepp_dir=.
  [set global] spec_dir=spec
  [set global] gepp_file=ewg_external_string_routines

ge2e.ge2e:

  error: number of actual and formal arguments do not match for target 'ge2e' (0 against 3)

BUILD FAILED!

BUILD FAILED!

BUILD FAILED!



[Non-text portions of this message have been removed]

Jocelyn.Fiat

Re: C libraries wrapping

Reply Threaded More More options
Print post
Permalink
This mailing list does not accept attachment file.
So you need to share it using another solution.

    http://pastebin.com/ is nice to share piece of code
    If you want to share more complex data  (for instance zip), you
might use any web upload/download solution (there are many)
        For instance, http://imageshack.us/ is commonly used to share
image (screenshot...)
    For file sharing, I don't know the most popular one, so feel free to
use the most adapted for you usage (box.net, yousendit.com, ...and so on ...

-- Jocelyn


luca paganotti wrote:

> ... sorry here it is the attachment ...
>
> --------------------------------------------------------------
> -- Dott. Ing. Luca Paganotti
> -- Via dei Giardini 9
> -- 21035 Cunardo (VA)
> -- 393 1346898
> --------------------------------------------------------------
> -- sourceforge email:
> -- [hidden email]
> --------------------------------------------------------------
> --
>
>
> On Tue, Sep 8, 2009 at 7:33 PM, Jann Röder <[hidden email]> wrote:
>
>  
>> Well,
>> to wrap this struct you need to write setters and getters for each
>> field. There is special syntax for this available:
>> http://doc.eiffel.com/book/solutions/c-externals
>>
>> There is also the Eiffel C wrapper generator, but it always generates C
>> wrapper libraries which are not necessary with the current Eiffel
>> compiler. Also hand written wrappers tend to be better than generated ones.
>>
>> Hope this helps,
>> Jann
>>
>> luca paganotti schrieb:
>>
>>    
>>> Hi all,
>>> I'm trying to define eiffel bindings for libproj on a windows box using
>>> EiffelStudio 6.4 GPL version. At the moment i'm able to correctly get
>>>      
>> values
>>    
>>> from macros on the C side to the eiffel one, I'm also able to get and set
>>> values of trivial C structures using only built-in C types like int,
>>>      
>> long,
>>    
>>> double etc... But I'm in troubles with more complex definitions such as
>>> function pointers and so on. Also having troubles to pass simple C
>>>      
>> struct(s)
>>    
>>> to the C side. In the worst case (at least for me ... ) I have to map a C
>>> struct like this:
>>>
>>> typedef struct PJconsts {
>>> XY (*fwd)(LP, struct PJconsts *);
>>> LP (*inv)(XY, struct PJconsts *);
>>> void (*spc)(LP, struct PJconsts *, struct FACTORS *);
>>> void (*pfree)(struct PJconsts *);
>>> const char *descr;
>>> paralist *params; /* parameter list */
>>> int over; /* over-range flag */
>>> int geoc; /* geocentric latitude flag */
>>> int is_latlong; /* proj=latlong ... not really a projection at all
>>> */
>>> int is_geocent; /* proj=geocent ... not really a projection at all
>>> */
>>> double
>>> a, /* major axis or radius if es==0 */
>>> a_orig, /* major axis before any +proj related adjustment */
>>> es, /* e ^ 2 */
>>> es_orig, /* es before any +proj related adjustment */
>>> e, /* eccentricity */
>>> ra, /* 1/A */
>>> one_es, /* 1 - e^2 */
>>> rone_es, /* 1/one_es */
>>> lam0, phi0, /* central longitude, latitude */
>>> x0, y0, /* easting and northing */
>>> k0, /* general scaling factor */
>>> to_meter, fr_meter; /* cartesian scaling */
>>>
>>> int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
>>> double datum_params[7];
>>> double from_greenwich; /* prime meridian offset (in radians) */
>>> double long_wrap_center; /* 0.0 for -180 to 180, actually in
>>> radians*/
>>>
>>> #ifdef PROJ_PARMS__
>>> PROJ_PARMS__
>>> #endif /* end of optional extensions */
>>> } PJ;
>>>
>>> and also some functions that receive as formal parameters pointers to
>>>      
>> this
>>    
>>> struct that can be conforming to this type (e.g. of type PJ*) or simply
>>>      
>> void
>>    
>>> pointers. If I can manage such situations I'll probably be able to manage
>>> also simple cases that i want to map from the two languages.
>>>
>>> At the moment I really do not know where to begin from.
>>>
>>> Probably I'm missing some vital information about the mappings between C
>>>      
>> and
>>    
>>> eiffel ... or what I'm trying to do is not the right way do achieve my
>>>      
>> goal
>>    
>>> ...
>>>
>>> Has anyone of you done something similar? If so, can you briefly explain
>>>      
>> me
>>    
>>> where to get information to get the job done?
>>>
>>> Thanks in advance for any answer.
>>>
>>>
>>> ----------------------------------------------------------
>>> -- Dott. Ing. Luca Paganotti
>>> -- Via dei Giardini 9
>>> -- 21035 Cunardo (VA)
>>> -- 393 1346898
>>> ----------------------------------------------------------
>>> -- sourceforge email:
>>> -- [hidden email]<lucapaganotti%40users.sourceforge.net>
>>> ----------------------------------------------------------
>>> --
>>>
>>>
>>> [Non-text portions of this message have been removed]
>>>
>>>
>>>
>>> ------------------------------------
>>>
>>> Yahoo! Groups Links
>>>
>>>
>>>
>>>      
>>  
>>
>>    
>
>   ----------
>
> Loading Project's configuration from build.eant
>
> Building Project
>
>
>
> ewg_root.init:
>
>
>
>
>
> ewg_root.init_os:
>
>
>
>
>
> ewg_root.init_windows:
>
>
>
>   [set] warning: you are using the name of the builtin variable 'exe' in a <set> task
>
>   [set global] exe=.exe
>
>
>
> ewg_root.install:
>
>
>
>   [geant] geant -v -b build.eant install
>
> Loading Project's configuration from build.eant
>
> Building Project
>
>
>
> src.init:
>
>
>
>
>
> src.install:
>
>
>
>   [set global] target=install
>
>
>
> src.do_all:
>
>
>
>   [geant] geant -v -b c:\ewg\src\ewg\build.eant install
>
> Loading Project's configuration from c:\ewg\src\ewg\build.eant
>
> Loading Project's configuration from c:\gobo/misc/eiffel.eant
>
> Loading Project's configuration from c:\gobo/misc/ge2e.eant
>
> Building Project
>
>
>
> eiffel.init:
>
>
>
>   [set global] eiffel=ge
>
>
>
> eiffel.init_eiffel:
>
>
>
>   [set global] eiffel=ge
>
>
>
> eiffel.init_os:
>
>
>
>
>
> eiffel.init_windows:
>
>
>
>
>
> ewg.init_system:
>
>
>
>   [set global] system=ewg
>
>   [set global] system_dir=c:\ewg\src\ewg
>
>
>
> eiffel.install:
>
>
>
>
>
> eiffel.xace:
>
>
>
>   [set global] a_format=
>
>   [gexace] gexace --define="GOBO_EIFFEL=ge GOBO_OS=windows GOBO_CC=msc" --system="ge" c:\ewg\src\ewg\system.xace
>
>
>
> eiffel.xace:
>
>
>
>   [set global] a_format=
>
>   [gexace] gexace --define="GOBO_EIFFEL=ge GOBO_OS=windows GOBO_CC=msc" --system="ise" c:\ewg\src\ewg\system.xace
>
>
>
> eiffel.other_install:
>
>
>
>   [geant] geant -v -b c:\ewg\src\drc\build.eant install
>
> Loading Project's configuration from c:\ewg\src\drc\build.eant
>
> Loading Project's configuration from c:\gobo/misc/eiffel.eant
>
> Loading Project's configuration from c:\gobo/misc/ge2e.eant
>
> Building Project
>
>
>
> eiffel.init:
>
>
>
>   [set global] eiffel=ge
>
>
>
> eiffel.init_eiffel:
>
>
>
>   [set global] eiffel=ge
>
>
>
> eiffel.init_os:
>
>
>
>
>
> eiffel.init_windows:
>
>
>
>
>
> drc.init_system:
>
>
>
>   [set global] system=drc
>
>   [set global] system_dir=c:\ewg/src/drc/
>
>
>
> eiffel.install:
>
>
>
>
>
> eiffel.xace:
>
>
>
>   [set global] a_format=
>
>   [gexace] gexace --define="GOBO_EIFFEL=ge GOBO_OS=windows GOBO_CC=msc" --system="ge" c:\ewg\src\drc\system.xace
>
>
>
> eiffel.xace:
>
>
>
>   [set global] a_format=
>
>   [gexace] gexace --define="GOBO_EIFFEL=ge GOBO_OS=windows GOBO_CC=msc" --system="ise" c:\ewg\src\drc\system.xace
>
>
>
> eiffel.other_install:
>
>
>
>   [geant] geant -v -b build.eant install
>
> Loading Project's configuration from build.eant
>
> Building Project
>
>
>
> ewg_parser.install:
>
>
>
>
>
> ewg_parser.ewg_c_parser:
>
>
>
>   [gelex] gelex -e -m -o ewg_c_scanner.e ewg_c_scanner.l
>
>   [geyacc] geyacc -v ewg_c_parser.txt --new_typing -t EWG_C_TOKENS -o ewg_c_parser.e ewg_c_parser.y
>
>
>
> ewg_parser.ewg_c_macro_parser:
>
>
>
>   [gelex] gelex -e -m -o ewg_c_macro_scanner.e ewg_c_macro_scanner.l
>
>   [geyacc] geyacc -v ewg_c_macro_parser.txt --new_typing -t EWG_C_MACRO_TOKENS -o ewg_c_macro_parser.e ewg_c_macro_parser.y
>
>   [geant] geant -v -b build.eant install
>
> Loading Project's configuration from build.eant
>
> Loading Project's configuration from c:\gobo/misc/ge2e.eant
>
> Building Project
>
>
>
> runtime.install:
>
>
>
>   [set global] gepp_dir=.
>
>   [set global] spec_dir=spec
>
>   [set global] gepp_file=ewg_external_string_routines
>
>
>
> ge2e.ge2e:
>
>
>
>   error: number of actual and formal arguments do not match for target 'ge2e' (0 against 3)
>
>
>
> BUILD FAILED!
>
>
>
> BUILD FAILED!
>
>
>
> BUILD FAILED!
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
>
>  

luca.paganotti

Re: C libraries wrapping

Reply Threaded More More options
Print post
Permalink
Ok, thanks.

I've posted on pastebin.com the full log i get from geant. If anyone wants
to see it the url is http://pastebin.com/m59a9b026

--------------------------------------------------------------
-- Dott. Ing. Luca Paganotti
-- Via dei Giardini 9
-- 21035 Cunardo (VA)
-- 393 1346898
--------------------------------------------------------------
-- sourceforge email:
-- [hidden email]
--------------------------------------------------------------
--


On Mon, Sep 14, 2009 at 12:17 PM, Jocelyn <[hidden email]> wrote:

>
>
> This mailing list does not accept attachment file.
> So you need to share it using another solution.
>
> http://pastebin.com/ is nice to share piece of code
> If you want to share more complex data (for instance zip), you
> might use any web upload/download solution (there are many)
> For instance, http://imageshack.us/ is commonly used to share
> image (screenshot...)
> For file sharing, I don't know the most popular one, so feel free to
> use the most adapted for you usage (box.net, yousendit.com, ...and so on
> ...
>
> -- Jocelyn
>
>
> luca paganotti wrote:
> > ... sorry here it is the attachment ...
> >
> > ----------------------------------------------------------
> > -- Dott. Ing. Luca Paganotti
> > -- Via dei Giardini 9
> > -- 21035 Cunardo (VA)
> > -- 393 1346898
> > ----------------------------------------------------------
> > -- sourceforge email:
> > -- [hidden email]<lucapaganotti%40users.sourceforge.net>
> > ----------------------------------------------------------
> > --
> >
> >
> > On Tue, Sep 8, 2009 at 7:33 PM, Jann Röder <[hidden email]<roederja%40student.ethz.ch>>
> wrote:
> >
> >
> >> Well,
> >> to wrap this struct you need to write setters and getters for each
> >> field. There is special syntax for this available:
> >> http://doc.eiffel.com/book/solutions/c-externals
> >>
> >> There is also the Eiffel C wrapper generator, but it always generates C
> >> wrapper libraries which are not necessary with the current Eiffel
> >> compiler. Also hand written wrappers tend to be better than generated
> ones.
> >>
> >> Hope this helps,
> >> Jann
> >>
> >> luca paganotti schrieb:
> >>
> >>
> >>> Hi all,
> >>> I'm trying to define eiffel bindings for libproj on a windows box using
> >>> EiffelStudio 6.4 GPL version. At the moment i'm able to correctly get
> >>>
> >> values
> >>
> >>> from macros on the C side to the eiffel one, I'm also able to get and
> set
> >>> values of trivial C structures using only built-in C types like int,
> >>>
> >> long,
> >>
> >>> double etc... But I'm in troubles with more complex definitions such as
> >>> function pointers and so on. Also having troubles to pass simple C
> >>>
> >> struct(s)
> >>
> >>> to the C side. In the worst case (at least for me ... ) I have to map a
> C
> >>> struct like this:
> >>>
> >>> typedef struct PJconsts {
> >>> XY (*fwd)(LP, struct PJconsts *);
> >>> LP (*inv)(XY, struct PJconsts *);
> >>> void (*spc)(LP, struct PJconsts *, struct FACTORS *);
> >>> void (*pfree)(struct PJconsts *);
> >>> const char *descr;
> >>> paralist *params; /* parameter list */
> >>> int over; /* over-range flag */
> >>> int geoc; /* geocentric latitude flag */
> >>> int is_latlong; /* proj=latlong ... not really a projection at all
> >>> */
> >>> int is_geocent; /* proj=geocent ... not really a projection at all
> >>> */
> >>> double
> >>> a, /* major axis or radius if es==0 */
> >>> a_orig, /* major axis before any +proj related adjustment */
> >>> es, /* e ^ 2 */
> >>> es_orig, /* es before any +proj related adjustment */
> >>> e, /* eccentricity */
> >>> ra, /* 1/A */
> >>> one_es, /* 1 - e^2 */
> >>> rone_es, /* 1/one_es */
> >>> lam0, phi0, /* central longitude, latitude */
> >>> x0, y0, /* easting and northing */
> >>> k0, /* general scaling factor */
> >>> to_meter, fr_meter; /* cartesian scaling */
> >>>
> >>> int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
> >>> double datum_params[7];
> >>> double from_greenwich; /* prime meridian offset (in radians) */
> >>> double long_wrap_center; /* 0.0 for -180 to 180, actually in
> >>> radians*/
> >>>
> >>> #ifdef PROJ_PARMS__
> >>> PROJ_PARMS__
> >>> #endif /* end of optional extensions */
> >>> } PJ;
> >>>
> >>> and also some functions that receive as formal parameters pointers to
> >>>
> >> this
> >>
> >>> struct that can be conforming to this type (e.g. of type PJ*) or simply
> >>>
> >> void
> >>
> >>> pointers. If I can manage such situations I'll probably be able to
> manage
> >>> also simple cases that i want to map from the two languages.
> >>>
> >>> At the moment I really do not know where to begin from.
> >>>
> >>> Probably I'm missing some vital information about the mappings between
> C
> >>>
> >> and
> >>
> >>> eiffel ... or what I'm trying to do is not the right way do achieve my
> >>>
> >> goal
> >>
> >>> ...
> >>>
> >>> Has anyone of you done something similar? If so, can you briefly
> explain
> >>>
> >> me
> >>
> >>> where to get information to get the job done?
> >>>
> >>> Thanks in advance for any answer.
> >>>
> >>>
> >>> ----------------------------------------------------------
> >>> -- Dott. Ing. Luca Paganotti
> >>> -- Via dei Giardini 9
> >>> -- 21035 Cunardo (VA)
> >>> -- 393 1346898
> >>> ----------------------------------------------------------
> >>> -- sourceforge email:
> >>> -- [hidden email]<lucapaganotti%40users.sourceforge.net>
> <lucapaganotti%40users.sourceforge.net>
> >>> ----------------------------------------------------------
> >>> --
> >>>
> >>>
> >>> [Non-text portions of this message have been removed]
> >>>
> >>>
> >>>
> >>> ------------------------------------
> >>>
> >>> Yahoo! Groups Links
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >
> > ----------
> >
> > Loading Project's configuration from build.eant
> >
> > Building Project
> >
> >
> >
> > ewg_root.init:
> >
> >
> >
> >
> >
> > ewg_root.init_os:
> >
> >
> >
> >
> >
> > ewg_root.init_windows:
> >
> >
> >
> > [set] warning: you are using the name of the builtin variable 'exe' in a
> <set> task
> >
> > [set global] exe=.exe
> >
> >
> >
> > ewg_root.install:
> >
> >
> >
> > [geant] geant -v -b build.eant install
> >
> > Loading Project's configuration from build.eant
> >
> > Building Project
> >
> >
> >
> > src.init:
> >
> >
> >
> >
> >
> > src.install:
> >
> >
> >
> > [set global] target=install
> >
> >
> >
> > src.do_all:
> >
> >
> >
> > [geant] geant -v -b c:\ewg\src\ewg\build.eant install
> >
> > Loading Project's configuration from c:\ewg\src\ewg\build.eant
> >
> > Loading Project's configuration from c:\gobo/misc/eiffel.eant
> >
> > Loading Project's configuration from c:\gobo/misc/ge2e.eant
> >
> > Building Project
> >
> >
> >
> > eiffel.init:
> >
> >
> >
> > [set global] eiffel=ge
> >
> >
> >
> > eiffel.init_eiffel:
> >
> >
> >
> > [set global] eiffel=ge
> >
> >
> >
> > eiffel.init_os:
> >
> >
> >
> >
> >
> > eiffel.init_windows:
> >
> >
> >
> >
> >
> > ewg.init_system:
> >
> >
> >
> > [set global] system=ewg
> >
> > [set global] system_dir=c:\ewg\src\ewg
> >
> >
> >
> > eiffel.install:
> >
> >
> >
> >
> >
> > eiffel.xace:
> >
> >
> >
> > [set global] a_format=
> >
> > [gexace] gexace --define="GOBO_EIFFEL=ge GOBO_OS=windows GOBO_CC=msc"
> --system="ge" c:\ewg\src\ewg\system.xace
> >
> >
> >
> > eiffel.xace:
> >
> >
> >
> > [set global] a_format=
> >
> > [gexace] gexace --define="GOBO_EIFFEL=ge GOBO_OS=windows GOBO_CC=msc"
> --system="ise" c:\ewg\src\ewg\system.xace
> >
> >
> >
> > eiffel.other_install:
> >
> >
> >
> > [geant] geant -v -b c:\ewg\src\drc\build.eant install
> >
> > Loading Project's configuration from c:\ewg\src\drc\build.eant
> >
> > Loading Project's configuration from c:\gobo/misc/eiffel.eant
> >
> > Loading Project's configuration from c:\gobo/misc/ge2e.eant
> >
> > Building Project
> >
> >
> >
> > eiffel.init:
> >
> >
> >
> > [set global] eiffel=ge
> >
> >
> >
> > eiffel.init_eiffel:
> >
> >
> >
> > [set global] eiffel=ge
> >
> >
> >
> > eiffel.init_os:
> >
> >
> >
> >
> >
> > eiffel.init_windows:
> >
> >
> >
> >
> >
> > drc.init_system:
> >
> >
> >
> > [set global] system=drc
> >
> > [set global] system_dir=c:\ewg/src/drc/
> >
> >
> >
> > eiffel.install:
> >
> >
> >
> >
> >
> > eiffel.xace:
> >
> >
> >
> > [set global] a_format=
> >
> > [gexace] gexace --define="GOBO_EIFFEL=ge GOBO_OS=windows GOBO_CC=msc"
> --system="ge" c:\ewg\src\drc\system.xace
> >
> >
> >
> > eiffel.xace:
> >
> >
> >
> > [set global] a_format=
> >
> > [gexace] gexace --define="GOBO_EIFFEL=ge GOBO_OS=windows GOBO_CC=msc"
> --system="ise" c:\ewg\src\drc\system.xace
> >
> >
> >
> > eiffel.other_install:
> >
> >
> >
> > [geant] geant -v -b build.eant install
> >
> > Loading Project's configuration from build.eant
> >
> > Building Project
> >
> >
> >
> > ewg_parser.install:
> >
> >
> >
> >
> >
> > ewg_parser.ewg_c_parser:
> >
> >
> >
> > [gelex] gelex -e -m -o ewg_c_scanner.e ewg_c_scanner.l
> >
> > [geyacc] geyacc -v ewg_c_parser.txt --new_typing -t EWG_C_TOKENS -o
> ewg_c_parser.e ewg_c_parser.y
> >
> >
> >
> > ewg_parser.ewg_c_macro_parser:
> >
> >
> >
> > [gelex] gelex -e -m -o ewg_c_macro_scanner.e ewg_c_macro_scanner.l
> >
> > [geyacc] geyacc -v ewg_c_macro_parser.txt --new_typing -t
> EWG_C_MACRO_TOKENS -o ewg_c_macro_parser.e ewg_c_macro_parser.y
> >
> > [geant] geant -v -b build.eant install
> >
> > Loading Project's configuration from build.eant
> >
> > Loading Project's configuration from c:\gobo/misc/ge2e.eant
> >
> > Building Project
> >
> >
> >
> > runtime.install:
> >
> >
> >
> > [set global] gepp_dir=.
> >
> > [set global] spec_dir=spec
> >
> > [set global] gepp_file=ewg_external_string_routines
> >
> >
> >
> > ge2e.ge2e:
> >
> >
> >
> > error: number of actual and formal arguments do not match for target
> 'ge2e' (0 against 3)
> >
> >
> >
> > BUILD FAILED!
> >
> >
> >
> > BUILD FAILED!
> >
> >
> >
> > BUILD FAILED!
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
>
>  
>


[Non-text portions of this message have been removed]