January 09, 2012
On Monday, 9 January 2012 at 18:04:58 UTC, Michel Fortin wrote:
>> Hmm another difficulty is how to switch between mangling schemes.
>
> One thing that could be done is instead of the namespace argument, have a mangled name argument. Then use CTFE to build the mangled name (if you want to).
>
> This would also solve the problem we have on OS X where some C functions use a mangled name with a '$' in them thanks to the use of some GCC attribute in the system headers.
>
> Or maybe it should be a pragma instead.

Interesting idea. But how to do it properly?
A namespace or a class may have lots of functions and I really wouldn't want to be forced to write pragma(mangledName, gccmangle("Bla", ...)) before every declaration.
January 10, 2012
Le 09/01/2012 19:19, Trass3r a écrit :
> On Monday, 9 January 2012 at 18:04:58 UTC, Michel Fortin wrote:
>>> Hmm another difficulty is how to switch between mangling schemes.
>>
>> One thing that could be done is instead of the namespace argument,
>> have a mangled name argument. Then use CTFE to build the mangled name
>> (if you want to).
>>
>> This would also solve the problem we have on OS X where some C
>> functions use a mangled name with a '$' in them thanks to the use of
>> some GCC attribute in the system headers.
>>
>> Or maybe it should be a pragma instead.
>
> Interesting idea. But how to do it properly?
> A namespace or a class may have lots of functions and I really wouldn't
> want to be forced to write pragma(mangledName, gccmangle("Bla", ...))
> before every declaration.

@mangled("encrypted klingon here") void foo();

Where encrypted klingon can be generated using CTFE.
January 10, 2012
On 01/10/2012 10:28 AM, deadalnix wrote:
> Le 09/01/2012 19:19, Trass3r a écrit :
>> On Monday, 9 January 2012 at 18:04:58 UTC, Michel Fortin wrote:
>>>> Hmm another difficulty is how to switch between mangling schemes.
>>>
>>> One thing that could be done is instead of the namespace argument,
>>> have a mangled name argument. Then use CTFE to build the mangled name
>>> (if you want to).
>>>
>>> This would also solve the problem we have on OS X where some C
>>> functions use a mangled name with a '$' in them thanks to the use of
>>> some GCC attribute in the system headers.
>>>
>>> Or maybe it should be a pragma instead.
>>
>> Interesting idea. But how to do it properly?
>> A namespace or a class may have lots of functions and I really wouldn't
>> want to be forced to write pragma(mangledName, gccmangle("Bla", ...))
>> before every declaration.
>
> @mangled("encrypted klingon here") void foo();
>
> Where encrypted klingon can be generated using CTFE.

It's like the vapi files. (Vala)

//encrypted klingon here.
[CCode (cname = "gtk_cell_area_class_find_cell_property")]		
public class unowned GLib.ParamSpec find_cell_property (string property_name);
//alias here		

With the alias in D you can use the original.
January 10, 2012
On Tue, 10 Jan 2012 10:28:54 +0100, deadalnix <deadalnix@gmail.com> wrote:

> Le 09/01/2012 19:19, Trass3r a écrit :
>> On Monday, 9 January 2012 at 18:04:58 UTC, Michel Fortin wrote:
>>>> Hmm another difficulty is how to switch between mangling schemes.
>>>
>>> One thing that could be done is instead of the namespace argument,
>>> have a mangled name argument. Then use CTFE to build the mangled name
>>> (if you want to).
>>>
>>> This would also solve the problem we have on OS X where some C
>>> functions use a mangled name with a '$' in them thanks to the use of
>>> some GCC attribute in the system headers.
>>>
>>> Or maybe it should be a pragma instead.
>>
>> Interesting idea. But how to do it properly?
>> A namespace or a class may have lots of functions and I really wouldn't
>> want to be forced to write pragma(mangledName, gccmangle("Bla", ...))
>> before every declaration.
>
> @mangled("encrypted klingon here") void foo();
>
> Where encrypted klingon can be generated using CTFE.

Quite nice.
It also makes pretty clear that one is responsible to
avoid symbol collisions.
January 10, 2012
On 2012-01-10 09:28:54 +0000, deadalnix <deadalnix@gmail.com> said:

> Le 09/01/2012 19:19, Trass3r a écrit :
>> On Monday, 9 January 2012 at 18:04:58 UTC, Michel Fortin wrote:
>>>> Hmm another difficulty is how to switch between mangling schemes.
>>> 
>>> One thing that could be done is instead of the namespace argument,
>>> have a mangled name argument. Then use CTFE to build the mangled name
>>> (if you want to).
>>> 
>>> This would also solve the problem we have on OS X where some C
>>> functions use a mangled name with a '$' in them thanks to the use of
>>> some GCC attribute in the system headers.
>>> 
>>> Or maybe it should be a pragma instead.
>> 
>> Interesting idea. But how to do it properly?
>> A namespace or a class may have lots of functions and I really wouldn't
>> want to be forced to write pragma(mangledName, gccmangle("Bla", ...))
>> before every declaration.
> 
> @mangled("encrypted klingon here") void foo();
> 
> Where encrypted klingon can be generated using CTFE.

Another idea which would be much less verbose:

	extern(C++, gccmangle)
	void foo();

Here, gccmangle is a CTFE-capable function that'd be called like this:

	gccmangle("foo");

So if you need a namespace argument, just add one:

	extern(C++, gccmangle, "bar::baz")
	void foo();

which would call the function like this to get the mangled name:

	gccmangle("foo","bar::baz");

The syntax doesn't sound quite right to me, hopefully someone can make it better.

-- 
Michel Fortin
michel.fortin@michelf.com
http://michelf.com/

January 10, 2012
On Tuesday, 10 January 2012 at 12:09:14 UTC, Michel Fortin wrote:
> Another idea which would be much less verbose:
>
> 	extern(C++, gccmangle)
> 	void foo();
>
> Here, gccmangle is a CTFE-capable function that'd be called like this:
>
> 	gccmangle("foo");
>
> So if you need a namespace argument, just add one:
>
> 	extern(C++, gccmangle, "bar::baz")
> 	void foo();
>
> which would call the function like this to get the mangled name:
>
> 	gccmangle("foo","bar::baz");
>
> The syntax doesn't sound quite right to me, hopefully someone can make it better.

At least you could use extern(...) : and extern(...) {} this way.
January 10, 2012
On Tuesday, 10 January 2012 at 09:27:03 UTC, deadalnix wrote:
> Le 09/01/2012 19:19, Trass3r a écrit :
>> On Monday, 9 January 2012 at 18:04:58 UTC, Michel Fortin wrote:
>>> Or maybe it should be a pragma instead.
>>
>> Interesting idea. But how to do it properly?
>> A namespace or a class may have lots of functions and I really wouldn't
>> want to be forced to write pragma(mangledName, gccmangle("Bla", ...))
>> before every declaration.
>
> @mangled("encrypted klingon here") void foo();
>
> Where encrypted klingon can be generated using CTFE.

And how is this any better than pragma??
1 2
Next ›   Last »