Re: delegate type from function signature

2011-06-26 Thread Robert Clipsham
On 26/06/2011 08:08, Nub Public wrote: Is it possible to get the signature of a function and make a delegate type from it? Something like this: bool fun(int i) {} alias (signature of fun) DelegateType; DelegateType _delegate = delegate(int i) { return i == 0; }; alias typeof(fun)

Re: delegate type from function signature

2011-06-26 Thread Nub Public
On 6/26/2011 5:45 PM, Robert Clipsham wrote: template DelegateType(alias t) { alias ReturnType!t delegate(ParameterTypeTuple!t) DelegateType; } Thanks. This is exactly what I need.

Using immutable values as template parameter hangs dmd

2011-06-26 Thread simendsjo
This is probably not a minimal test case, but it's as far as I got. Don't know what the actual bug is, so I'd be grateful if someone else could help explain it so I can add it to Bugzilla with a better subject. This is using DMD 2.053 on win7. struct S(int N) { immutable SN = N; //

Re: changing in two arrays

2011-06-26 Thread Steven Schveigoffer
simendsjo Wrote: On 26.06.2011 13:59, %u wrote: hi I create two arrays and I want the change in one of them effects the other one. i try int[] array1 = [1, 2, 3, 4, 5]; int[] array2; array2 = array1; // without .dup assert(array1 == array2); assert(array1 is array2); //

Re: Need to do some dirty UTF-8 handling

2011-06-26 Thread Vladimir Panteleev
On Sat, 25 Jun 2011 23:17:37 +0300, Nick Sabalausky a@a.a wrote: Vladimir Panteleev vladi...@thecybershadow.net wrote in message news:op.vxmuvzqbtuz...@cybershadow.mshome.net... string s; foreach (dchar c; r) That doesn't throw on an invalid sequence? You use rawToUTF8 to convert an

Re: Last frame?

2011-06-26 Thread David Nadlinger
Sorry, I don't quite understand the problem – the exception message describes what happened, and the stack trace points to the location. The only thing that strikes me as strange here is that file.foo itself isn't included in the backtrace, but I'd say that's a bug in the exception handling

Re: Using immutable values as template parameter hangs dmd

2011-06-26 Thread Simen Kjaeraas
On Sun, 26 Jun 2011 16:10:04 +0200, simendsjo simen.end...@pandavre.com wrote: This is probably not a minimal test case, but it's as far as I got. Don't know what the actual bug is, so I'd be grateful if someone else could help explain it so I can add it to Bugzilla with a better subject.

Re: Last frame?

2011-06-26 Thread bearophile
David Nadlinger: Sorry, I don't quite understand the problem – the exception message describes what happened, and the stack trace points to the location. The only thing that strikes me as strange here is that file.foo itself isn't included in the backtrace, Right, that's my problem. I'd

Re: Interfacing to C. extern (C) variables

2011-06-26 Thread Robert Clipsham
On 26/06/2011 20:54, Alex_Dovhal wrote: I'd like to call C functions and use C variables in D module. D calls C functions just fine, but how can I use C variables? extern(C) extern int myCVar; -- Robert http://octarineparrot.com/

Re: Interfacing to C. extern (C) variables

2011-06-26 Thread Jimmy Cao
On Sun, Jun 26, 2011 at 5:00 PM, Alex_Dovhal alex_dov...@yahoo.com wrote: Robert Clipsham rob...@octarineparrot.com wrote: On 26/06/2011 20:54, Alex_Dovhal wrote: I'd like to call C functions and use C variables in D module. D calls C functions just fine, but how can I use C variables?

Using COM. Please help.

2011-06-26 Thread Nub Public
Hi. I've been trying to use Direct2D and I ran into some problems. 1. When translating the headers from the Windows SDK, what linkage should I use for the interfaces? Currently I use none and it works, but I want some confirmation in case something comes up later and bites my in the @ss. 2.

Re: Interfacing to C. extern (C) variables

2011-06-26 Thread Alex_Dovhal
Jimmy Cao jcao...@gmail.com wrote: It works for me like this: extern(C){ __gshared int c_var; int func(); } Thanks.

Re: Using COM. Please help.

2011-06-26 Thread Andrej Mitrovic
You mean COM interfaces? I usually do this: interface SomeComInterface : IUnknown { extern(Windows): BOOL PrototypeFoo(); } But maybe this is already implicit when deriving from IUnknown, I wouldn't know. But from what I can tell some of those prototypes seem to have C linkage, maybe