comp.lang.ada
 help / color / mirror / Atom feed
* Complete Simple Examples of "Pragma Import (CPP,...) With Qualifiers?
@ 2019-09-11 18:16 Ruby_Tuesday@gmail.com
  2019-09-11 22:27 ` Lucretia
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ruby_Tuesday@gmail.com @ 2019-09-11 18:16 UTC (permalink / raw)


The only thing I am seeing in some code are statements such as the one below without any qualifiers:

PRAGMA IMPORT (Convention=> CPP, Entity => "My_Test" ,External_Name => "My_Test");

Are there other versions of this that I could see? What about C++ qualifiers,  members in classes, and namespaces how are they referenced in the pragma?

Thank you,
Ruby

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Complete Simple Examples of "Pragma Import (CPP,...) With Qualifiers?
  2019-09-11 18:16 Complete Simple Examples of "Pragma Import (CPP,...) With Qualifiers? Ruby_Tuesday@gmail.com
@ 2019-09-11 22:27 ` Lucretia
  2019-09-12  5:50 ` godunko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Lucretia @ 2019-09-11 22:27 UTC (permalink / raw)


On Wednesday, 11 September 2019 19:16:04 UTC+1, Ruby_T...@gmail.com  wrote:
> The only thing I am seeing in some code are statements such as the one below without any qualifiers:
> 
> PRAGMA IMPORT (Convention=> CPP, Entity => "My_Test" ,External_Name => "My_Test");
> 
> Are there other versions of this that I could see? What about C++ qualifiers,  members in classes, and namespaces how are they referenced in the pragma?

That is all there is, only bringing in the c++ methods. There used to be a constructor and destructor, but they got rid of those for some unknown reason.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Complete Simple Examples of "Pragma Import (CPP,...) With Qualifiers?
  2019-09-11 18:16 Complete Simple Examples of "Pragma Import (CPP,...) With Qualifiers? Ruby_Tuesday@gmail.com
  2019-09-11 22:27 ` Lucretia
@ 2019-09-12  5:50 ` godunko
  2019-09-12 12:00   ` Ruby_Tuesday@gmail.com
  2019-09-13  0:00 ` Roger
  2019-09-13  0:04 ` Roger
  3 siblings, 1 reply; 6+ messages in thread
From: godunko @ 2019-09-12  5:50 UTC (permalink / raw)


On Wednesday, September 11, 2019 at 9:16:04 PM UTC+3, Ruby_T...@gmail.com wrote:
> 
> Are there other versions of this that I could see? What about C++ qualifiers,  members in classes, and namespaces how are they referenced in the pragma?
> 
You need to use pragma CPP_Constructor to bind constructors. External_Names are always mangled names, used by linker. Class fields may be mapped to record, but you need to control memory layout carefully. So, direct binding to C++ is not so simple and it is very complicated to support it. I personally prefer to create C wrappers around C++ classes when possible, more code need to be produced, but you don't need to take care about low level C++ stuff mapping and update binding each time API/ABI changed or porting to another C++ compiler.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Complete Simple Examples of "Pragma Import (CPP,...) With Qualifiers?
  2019-09-12  5:50 ` godunko
@ 2019-09-12 12:00   ` Ruby_Tuesday@gmail.com
  0 siblings, 0 replies; 6+ messages in thread
From: Ruby_Tuesday@gmail.com @ 2019-09-12 12:00 UTC (permalink / raw)



> > On Wednesday, September 11, 2019 at 9:16:04 PM UTC+3, Ruby_T...@gmail.com 
>> wrote:
> > 
> > Are there other versions of this that I could see? What about C++ qualifiers,  members in classes, and namespaces how are they referenced in the pragma?
> > 

On Thursday, September 12, 2019 at 12:50:44 AM UTC-5, god...@adacore.com wrote:
>   
>                                           Class fields may be mapped to 
> record, but you need to control memory layout carefully. So, direct binding to 
> C++ is not so simple and it is very complicated to support it.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does anyone have an intuitive tutorial on how to accomplish this?

How does the memory layout differ for different things pointed to by the pragma's "External_Name"? Basically, with a simple but complete example how is the Ada code written?

Thank you,
Ruby


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Complete Simple Examples of "Pragma Import (CPP,...) With Qualifiers?
  2019-09-11 18:16 Complete Simple Examples of "Pragma Import (CPP,...) With Qualifiers? Ruby_Tuesday@gmail.com
  2019-09-11 22:27 ` Lucretia
  2019-09-12  5:50 ` godunko
@ 2019-09-13  0:00 ` Roger
  2019-09-13  0:04 ` Roger
  3 siblings, 0 replies; 6+ messages in thread
From: Roger @ 2019-09-13  0:00 UTC (permalink / raw)


On Thursday, September 12, 2019 at 4:16:04 AM UTC+10, Ruby_T...@gmail.com wrote:
> The only thing I am seeing in some code are statements such as the one below without any qualifiers:
> 
> PRAGMA IMPORT (Convention=> CPP, Entity => "My_Test" ,External_Name => "My_Test");
> 
> Are there other versions of this that I could see? What about C++ qualifiers,  members in classes, and namespaces how are they referenced in the pragma?
> 
> Thank you,
> Ruby

I tried doing something similar sometime ago on my Mac but eventually gave up due to continuing difficulties and finally solved my problem by writing some short wrapper programs. 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Complete Simple Examples of "Pragma Import (CPP,...) With Qualifiers?
  2019-09-11 18:16 Complete Simple Examples of "Pragma Import (CPP,...) With Qualifiers? Ruby_Tuesday@gmail.com
                   ` (2 preceding siblings ...)
  2019-09-13  0:00 ` Roger
@ 2019-09-13  0:04 ` Roger
  3 siblings, 0 replies; 6+ messages in thread
From: Roger @ 2019-09-13  0:04 UTC (permalink / raw)


On Thursday, September 12, 2019 at 4:16:04 AM UTC+10, Ruby_T...@gmail.com wrote:
> The only thing I am seeing in some code are statements such as the one below without any qualifiers:
> 
> PRAGMA IMPORT (Convention=> CPP, Entity => "My_Test" ,External_Name => "My_Test");
> 
> Are there other versions of this that I could see? What about C++ qualifiers,  members in classes, and namespaces how are they referenced in the pragma?
> 
> Thank you,
> Ruby

I tried doing something similar sometime ago on my Mac but eventually gave up due to continuing difficulties and finally solved my problem by writing some short  functions in C++ with Ada wrappers.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-13  0:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11 18:16 Complete Simple Examples of "Pragma Import (CPP,...) With Qualifiers? Ruby_Tuesday@gmail.com
2019-09-11 22:27 ` Lucretia
2019-09-12  5:50 ` godunko
2019-09-12 12:00   ` Ruby_Tuesday@gmail.com
2019-09-13  0:00 ` Roger
2019-09-13  0:04 ` Roger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox