[mercury-users] Working with exported types

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Jul 27 16:28:56 AEST 2006


On Thu, 27 Jul 2006, Peter Wang wrote:

> On 2006-07-27, Ralph Becket <rafe at csse.unimelb.edu.au> wrote:
>> Julien Fischer, Thursday, 27 July 2006:
>>> Another approach that I have thought about adding (because doing the above
>>> in the OpenGL binding was fairly tedious), is to add a foreign_enum pragma
>>> that would allow you to safely use the values of Mercury enums on the other
>>> side of the foreign language interface, something like:
>>>
>>> 	:- type foo
>>> 		--->	foo
>>> 		;	bar
>>> 		;	baz
>>>
>>> 	:- pragma foreign_enum("C", [
>>> 		foo - "FOO",
>>> 		bar - "BAR",
>>> 		baz - "BAZ"]).
>>>
>>> The compiler would then add the following to the modules .mh file:
>>>
>>> 	#define FOO <representation of foo>
>>> 	#define BAR <representation of bar>
>>> 	#define BAZ (representation of baz>
>>
>> This would be an excellent addition to the FLI.
>
> Can we get something in the opposite direction as well?

What exactly do you mean?  The above also handles the opposite direction.

Julien.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list