Re: opCast, c bindings and normal casts.

2011-07-12 Thread Johannes Pfau
Johannes Pfau wrote: Hi, I have a wrapper for a object aware c library (cairo). Take for example two classes, Surface and a subclass, ImageSurface. Now this code has to be valid: --- auto ptr = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 512, 512); Surface s = new

Declaring a D pointer to a C function

2011-07-12 Thread Johannes Pfau
From a discussion related to derelict: How do you write this: --- alias extern(C) int function(void* test) FTInitFunc; FTInitFunc FT_Init_FreeType --- without the alias?

Re: SDL with D

2011-07-12 Thread Mike Parker
On 7/12/2011 4:21 PM, Dainius (GreatEmerald) wrote: I see. And what about Lua? I see lots and lots of different libraries for that on dsource, and there is even some support in Derelict as well. I assume that LuaD is the one in active development and most fitting for current D2? Derelict has

Re: SDL with D

2011-07-12 Thread Dainius (GreatEmerald)
According to the Derelict page, there already are unofficial bindings. But I guess they wouldn't work with Derelict2 anyway.

Re: Declaring a D pointer to a C function

2011-07-12 Thread Marco Cosentino
On 12/07/2011 11:36, Johannes Pfau wrote: From a discussion related to derelict: How do you write this: --- alias extern(C) int function(void* test) FTInitFunc; FTInitFunc FT_Init_FreeType

Re: Declaring a D pointer to a C function

2011-07-12 Thread Trass3r
You should declare the function pointer without the extern(C). Example: alias int function(void* test) FTInitFunc; extern(C) int foo(void* test){ } FTInitFunc foo_ptr = foo; This worked for me. That's a bug.

Re: A possible feature request: Make writef with %s call to!string for char* parameters

2011-07-12 Thread Steven Schveighoffer
On Mon, 11 Jul 2011 16:37:12 -0400, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: import std.stdio; import std.string; void main() { char* foo = foo\0.dup.ptr; writefln(Foo: %s, foo); } This will write the address of foo. Often when you link with C code you have C structures

Re: Is there any way I can have one handler for multiple exceptions?

2011-07-12 Thread Steven Schveighoffer
On Mon, 11 Jul 2011 18:08:19 -0400, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: I'm trying to do something like the following: import std.exception; class Foo : Exception { this(string msg) { super(msg); } } class Bar : Exception { this(string msg) { super(msg); } } void

Re: Declaring a D pointer to a C function

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 05:36:15 -0400, Johannes Pfau s...@example.com wrote: From a discussion related to derelict: How do you write this: --- alias extern(C) int function(void* test) FTInitFunc; FTInitFunc FT_Init_FreeType

Re: This seems like what could be a common cause of bugs

2011-07-12 Thread Steven Schveighoffer
On Mon, 11 Jul 2011 16:46:07 -0400, Nick Sabalausky a@a.a wrote: Steven Schveighoffer schvei...@yahoo.com wrote in message Hm... I didn't know about that switch, I thought warnings were enabled with -w and that made them errors. I suppose you could stick this in there. -wi: Enable

template instance cannot use local 'f' as parameter to non-global template

2011-07-12 Thread Trass3r
Is this a bug? If not, how do you make it work? void h() {} class Bla { mixin wrap!h; } mixin template wrap(alias f) { void blub(alias g = f)() { } } void main() { Bla b = new Bla(); b.blub(); } test.d(18): Error: template instance cannot use

Re: opCast, c bindings and normal casts.

2011-07-12 Thread Steven Schveighoffer
On Sat, 09 Jul 2011 05:47:51 -0400, Johannes Pfau s...@example.com wrote: Hi, I have a wrapper for a object aware c library (cairo). Take for example two classes, Surface and a subclass, ImageSurface. Now this code has to be valid: --- auto ptr =

Re: opCast, c bindings and normal casts.

2011-07-12 Thread Johannes Pfau
Steven Schveighoffer wrote: On Sat, 09 Jul 2011 05:47:51 -0400, Johannes Pfau s...@example.com wrote: Hi, I have a wrapper for a object aware c library (cairo). Take for example two classes, Surface and a subclass, ImageSurface. Now this code has to be valid: --- auto

Re: Centralizable configured compile-time class instantiation

2011-07-12 Thread shd
Firstly, thanks for response. 2011/7/11 Jesse Phillips jessekphillip...@gmail.com: I'm sorry to say that I don't exactly know what you are trying to achieve or problems you are having. I'm going to trying  and provide details on what I have gotten out of your message. Hopefully i'll clarify

Re: Declaring a D pointer to a C function

2011-07-12 Thread Johannes Pfau
Steven Schveighoffer wrote: On Tue, 12 Jul 2011 05:36:15 -0400, Johannes Pfau s...@example.com wrote: From a discussion related to derelict: How do you write this: --- alias extern(C) int function(void* test) FTInitFunc; FTInitFunc

Re: Declaring a D pointer to a C function

2011-07-12 Thread Johannes Pfau
Trass3r wrote: You should declare the function pointer without the extern(C). Example: alias int function(void* test) FTInitFunc; extern(C) int foo(void* test){ } FTInitFunc foo_ptr = foo; This worked for me. That's a bug. I agree. It looks like the above code assigns a extern(C)

Re: Declaring a D pointer to a C function

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 09:42:22 -0400, Johannes Pfau s...@example.com wrote: Steven Schveighoffer wrote: On Tue, 12 Jul 2011 05:36:15 -0400, Johannes Pfau s...@example.com wrote: From a discussion related to derelict: How do you write this:

Re: Declaring a D pointer to a C function

2011-07-12 Thread Marco Cosentino
On 12/07/2011 13:15, Trass3r wrote: You should declare the function pointer without the extern(C). Example: alias int function(void* test) FTInitFunc; extern(C) int foo(void* test){ } FTInitFunc foo_ptr = foo; This worked for me. That's a bug. Oh, well, I forgot to mention that the

Re: Declaring a D pointer to a C function

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 09:53:28 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: But wait, don't normal D functions have C calling convention? I thought that was one of the benefits of D's ABI? Tested it out, definitely is different. So this clearly needs to be addressed. -Steve

Re: This seems like what could be a common cause of bugs

2011-07-12 Thread Kagamin
Steven Schveighoffer Wrote: Yes, but this is getting into territory where the false positive rate might get high. I bet it will be difficult to find a real-world example of this false positive.

Re: This seems like what could be a common cause of bugs

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 11:07:57 -0400, Kagamin s...@here.lot wrote: Steven Schveighoffer Wrote: Yes, but this is getting into territory where the false positive rate might get high. I bet it will be difficult to find a real-world example of this false positive. It depends on how the

Re: Centralizable configured compile-time class instantiation

2011-07-12 Thread Kagamin
shd Wrote: Actually, project structure looks like that: * project/ * bin/ * work/ * docs/ * iface/ * ae * ge * pe (...) * impl/ * glfw * ge.window * io.hid.keyboard * io.hid.mouse (you can add other window toolkits, or just

Re: Centralizable configured compile-time class instantiation

2011-07-12 Thread shd
2011/7/12 Kagamin s...@here.lot: You want an IOC container like Unity? exactly And you want the interface-to-class mapping to be configurable externally rather than version out these classes directly in source? like version(UseGL) {  static import wrappers.gl;  alias

Re: Running DMD tests

2011-07-12 Thread Trass3r
Am 13.06.2011, 23:55 Uhr, schrieb Peter Alexander peter.alexander...@gmail.com: I'm trying to run the test suite for DMD, but I'm running into issues. Do I need to set up my environment differently to run dmd in development? How can I get around this? To quote IRC: In theory it's simple:

Re: Is there any way I can have one handler for multiple exceptions?

2011-07-12 Thread Andrej Mitrovic
On 7/12/11, Steven Schveighoffer schvei...@yahoo.com wrote: Call a function? void main() { void handleEx(Exception e) { // exception handling code here } try { } catch(Foo f) { handleEx(f); } catch(Bar b) {

Re: Running DMD tests

2011-07-12 Thread David Nadlinger
The problem you are experiencing comes from no dmd.conf being included with the Git repository. Either you can add one to your Git clone directory, or use your normal system-wide installation which probably has all the paths set up correctly by specifying the DMD variable: »make

Re: translate a macro to D

2011-07-12 Thread teo
I think you may be confusing function templates with plain templates? Yes, I was a bit confused by the syntax, but I found that type of templates on page 281 in TDPL. That is an eponymous template. Thanks.

Re: Running DMD tests

2011-07-12 Thread Trass3r
Am 12.07.2011, 20:57 Uhr, schrieb David Nadlinger s...@klickverbot.at: or use your normal system-wide installation which probably has all the paths set up correctly by specifying the DMD variable: »make DMD=/usr/local/bin/dmd«. Thanks a lot for that hint!

starting independent processes

2011-07-12 Thread captaindet
i am just in the middle of my first little d project. i came to the point where i have to start new processes command line style incl arguments. they need to run independent of the main program, i.e., several such processes need to be started and must run parallel while the main program

Re: Declaring a D pointer to a C function

2011-07-12 Thread Andrej Mitrovic
I just had a bug where a D function is implicitly converted to an extern(C) function pointer. I've had this definition: alias extern (C) void function(void* userData) PaStreamFinishedCallback; And this extern(C) function: PaError Pa_SetStreamFinishedCallback(PaStream* stream,

Re: Declaring a D pointer to a C function

2011-07-12 Thread Trass3r
Is this going to be fixed any time soon? Allowing callbacks with D calling convention where a C callback is expected should be an error, and this is like the 10th time I've ran into this bug. http://d.puremagic.com/issues/show_bug.cgi?id=3797

Re: Declaring a D pointer to a C function

2011-07-12 Thread Andrej Mitrovic
On 7/12/11, Trass3r u...@known.com wrote: Is this going to be fixed any time soon? Allowing callbacks with D calling convention where a C callback is expected should be an error, and this is like the 10th time I've ran into this bug. http://d.puremagic.com/issues/show_bug.cgi?id=3797 Thanks,

Re: Declaring a D pointer to a C function

2011-07-12 Thread Andrej Mitrovic
Oh there's a pull already, this is great. https://github.com/D-Programming-Language/dmd/pull/96

Uninitialized floating-point exceptions - optional compile-time warnings?

2011-07-12 Thread Andrej Mitrovic
I'm wondering about this: void main() { import std.math; FloatingPointControl fpc; fpc.enableExceptions(FloatingPointControl.severeExceptions); float foo; } Declaring uninitialized floating point variables after enabling severe exceptions will throw at runtime: object.Error:

Re: Uninitialized floating-point exceptions - optional compile-time

2011-07-12 Thread bearophile
Andrej Mitrovic: I don't know whether this is intentional or not, I think it was not intentional. Regarding your successive questions, Don is your man and best hope. Bye, bearophile

Re: Uninitialized floating-point exceptions - optional compile-time

2011-07-12 Thread Andrej Mitrovic
I think he's on a vacation though. :p

Re: Centralizable configured compile-time class instantiation

2011-07-12 Thread Jesse Phillips
shd Wrote: Firstly, thanks for response. After reading Kagamin's response, I'm not sure I understand you still. You want to have code reuse, you want to have run-time and compile-time configuration, but you don't want to make use of the technologies/techniques/patterns which facilitate