Re: Interfacing with XPCOM

2008-12-08 Thread John Reimer
Hello Sergey, Sun, 7 Dec 2008 07:04:22 + (UTC), John Reimer wrote: Hello Jason, Sergey Gromov wrote: But what's the typical use case for extern(C++) objects ? I think it's something like this: extern(C++) class CppInterfaceClass { ... } extern(C++) CppInterfaceClass create() { retur

Re: Interfacing with XPCOM

2008-12-08 Thread Sergey Gromov
Sun, 7 Dec 2008 07:04:22 + (UTC), John Reimer wrote: > Hello Jason, > >> Sergey Gromov wrote: >> >>> But what's the typical use case for extern(C++) objects ? I think >>> it's something like this: >>> >>> extern(C++) class CppInterfaceClass { ... } >>> >>> extern(C++) CppInterfaceClass cr

Re: Interfacing with XPCOM

2008-12-06 Thread John Reimer
In the D code, the factory function enforces the stricture that the C++ code is responsible for it's own object creation and destruction. D code should touch this. Last line above meant to say: "D code should NOT touch this" as in, D code should not take any responsibility for creation/destr

Re: Interfacing with XPCOM

2008-12-06 Thread John Reimer
Hello Jason, Sergey Gromov wrote: But what's the typical use case for extern(C++) objects ? I think it's something like this: extern(C++) class CppInterfaceClass { ... } extern(C++) CppInterfaceClass create() { return new CppInterfaceClass(...); } extern(C++) void destroy(CppInterfaceClass

Re: Interfacing with XPCOM

2008-12-06 Thread Jason House
Sergey Gromov wrote: > But what's the typical use case for extern(C++) objects ? I think it's > something like this: > > extern(C++) class CppInterfaceClass { ... } > > extern(C++) CppInterfaceClass create() > { > return new CppInterfaceClass(...); > } > > extern(C++) void destro

Re: Interfacing with XPCOM

2008-12-04 Thread Sergey Gromov
Tue, 02 Dec 2008 22:32:33 -0800, Walter Bright wrote: > John Reimer wrote: >> Is there a ClassInfo flag indicating no-gc-collection for extern(C++) >> interfaces too? > > No. The COM object is special because part of its interface is to do its > own memory management, that isn't true in general

Re: Interfacing with XPCOM

2008-12-02 Thread Walter Bright
John Reimer wrote: Okay, that is an important detail for me to know. But I assumed that a C++ interface must not be allocated in D either. In must acquire a pointer from an external factory that handles the allocation outside of the gc range (C++ code must allocate/delete it's own objects).

Re: Interfacing with XPCOM

2008-12-02 Thread John Reimer
Hello Walter, John Reimer wrote: In D (windows) it would look like so (assuming you have done away with the compilers internal detection of COM interfaces): extern(C++) interface IUnknown: { extern(Windows): int QueryInterface(nsIID* uuid, void **result); int AddRef(); int Release(); } I bet

Re: Interfacing with XPCOM

2008-12-02 Thread Walter Bright
John C wrote: But IUnknown.Release does no such thing. If you're talking about the implementation in std.c.windows.com.ComObject, then all it does is decrement the reference count. It has a comment saying "let the GC reap it" - which is incorrect, since the GC doesn't collect COM objects (as you

Re: Interfacing with XPCOM

2008-12-02 Thread John C
Walter Bright Wrote: > John Reimer wrote: > > In D (windows) it would look like so (assuming you have done away with > > the compilers internal detection of COM interfaces): > > > > extern(C++) interface IUnknown: > > { > > extern(Windows): > > int QueryInterface(nsIID* uuid, void **

Re: Interfacing with XPCOM

2008-12-02 Thread Denis Koroskin
On Tue, 02 Dec 2008 13:23:55 +0300, Walter Bright <[EMAIL PROTECTED]> wrote: John Reimer wrote: In D (windows) it would look like so (assuming you have done away with the compilers internal detection of COM interfaces): extern(C++) interface IUnknown: { extern(Windows): int Que

Re: Interfacing with XPCOM

2008-12-02 Thread Walter Bright
John Reimer wrote: In D (windows) it would look like so (assuming you have done away with the compilers internal detection of COM interfaces): extern(C++) interface IUnknown: { extern(Windows): int QueryInterface(nsIID* uuid, void **result); int AddRef(); int Release

Re: Interfacing with XPCOM

2008-12-01 Thread John Reimer
Hello Walter, John Reimer wrote: It would be nice if extern(C++) were still ported to D 1.0, but the other alternative of enabling extern(System) in COM support (instead of extern(Windows) ) will also work. Unfortunately, extern(C++), even if ported to D1, will not work for COM objects. COM

Re: Interfacing with XPCOM

2008-12-01 Thread Walter Bright
John Reimer wrote: It would be nice if extern(C++) were still ported to D 1.0, but the other alternative of enabling extern(System) in COM support (instead of extern(Windows) ) will also work. Unfortunately, extern(C++), even if ported to D1, will not work for COM objects. COM objects, to be

Re: Interfacing with XPCOM

2008-12-01 Thread John Reimer
Hello Kagamin, G++ uses C++ abstract class for nsISupports, so its methods calling convention is C++ as implemented by g++: http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Compatibility.html Yes, I had a peek at the XULRunner SDK, and it looked something like you say. Thank you for the link.

Re: Interfacing with XPCOM

2008-12-01 Thread John Reimer
Hello Walter, John Reimer wrote: Hello Walter, John Reimer wrote: Hello Walter, So are you saying that XPCOM will work on Linux with D if only the extern(Windows) was actually extern(C++) ? Just to make this clear, I'm banking on that the fact that extern(C++) on an interface should al

Re: Interfacing with XPCOM

2008-12-01 Thread Kagamin
G++ uses C++ abstract class for nsISupports, so its methods calling convention is C++ as implemented by g++: http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Compatibility.html

Re: Interfacing with XPCOM

2008-12-01 Thread Walter Bright
John Reimer wrote: Hello Walter, John Reimer wrote: Hello Walter, So are you saying that XPCOM will work on Linux with D if only the extern(Windows) was actually extern(C++) ? Just to make this clear, I'm banking on that the fact that extern(C++) on an interface should also remove the nec

Re: Interfacing with XPCOM

2008-12-01 Thread Walter Bright
Tomas Lindquist Olsen wrote: Walter Bright wrote: John Reimer wrote: So extern(System) does not translate to extern(C)? Does that mean that all extern(System)'s in my code are defaulting to extern(D)? That'd be a shocker to me. :) If that's true, it would certainly change my understanding

Re: Interfacing with XPCOM

2008-11-30 Thread John Reimer
Hello Tomas, Walter Bright wrote: John Reimer wrote: So extern(System) does not translate to extern(C)? Does that mean that all extern(System)'s in my code are defaulting to extern(D)? That'd be a shocker to me. :) If that's true, it would certainly change my understanding of what I thou

Re: Interfacing with XPCOM

2008-11-30 Thread Tomas Lindquist Olsen
Walter Bright wrote: John Reimer wrote: So extern(System) does not translate to extern(C)? Does that mean that all extern(System)'s in my code are defaulting to extern(D)? That'd be a shocker to me. :) If that's true, it would certainly change my understanding of what I thought was making

Re: Interfacing with XPCOM

2008-11-30 Thread John Reimer
Hello Walter, John Reimer wrote: So extern(System) does not translate to extern(C)? Does that mean that all extern(System)'s in my code are defaulting to extern(D)? That'd be a shocker to me. :) If that's true, it would certainly change my understanding of what I thought was making my code

Re: Interfacing with XPCOM

2008-11-30 Thread Walter Bright
John Reimer wrote: Okay, I'm confused then. While I understand that the compiler uses specifically uses extern(...) to describe the calling convention, I /assumed/ that the compiler was detecting this the extern(C++) like so: I think you're right, I'd forgotten.

Re: Interfacing with XPCOM

2008-11-30 Thread Walter Bright
John Reimer wrote: So extern(System) does not translate to extern(C)? Does that mean that all extern(System)'s in my code are defaulting to extern(D)? That'd be a shocker to me. :) If that's true, it would certainly change my understanding of what I thought was making my code work. :D No,

Re: Interfacing with XPCOM

2008-11-30 Thread John Reimer
Hello Walter, John Reimer wrote: Hello Walter, So are you saying that XPCOM will work on Linux with D if only the extern(Windows) was actually extern(C++) ? Yes, I think so. But I should probably test the theory with dmd 2.0 first just to make sure. This is just about over my head since

Re: Interfacing with XPCOM

2008-11-30 Thread John Reimer
Hello Walter, John Reimer wrote: Hello Walter, So are you saying that XPCOM will work on Linux with D if only the extern(Windows) was actually extern(C++) ? Just to make this clear, I'm banking on that the fact that extern(C++) on an interface should also remove the necessity to alias to a

Re: Interfacing with XPCOM

2008-11-30 Thread Walter Bright
John Reimer wrote: Hello Walter, So are you saying that XPCOM will work on Linux with D if only the extern(Windows) was actually extern(C++) ? Just to make this clear, I'm banking on that the fact that extern(C++) on an interface should also remove the necessity to alias to a COM interfac

Re: Interfacing with XPCOM

2008-11-30 Thread Walter Bright
John Reimer wrote: Hello Walter, So are you saying that XPCOM will work on Linux with D if only the extern(Windows) was actually extern(C++) ? Yes, I think so. But I should probably test the theory with dmd 2.0 first just to make sure. This is just about over my head since I'm not too f

Re: Interfacing with XPCOM

2008-11-30 Thread John Reimer
Hello John, Hello Walter, So are you saying that XPCOM will work on Linux with D if only the extern(Windows) was actually extern(C++) ? Just to make this clear, I'm banking on that the fact that extern(C++) on an interface should also remove the necessity to alias to a COM interface on linux

Re: Interfacing with XPCOM

2008-11-30 Thread John Reimer
Hello Walter, So are you saying that XPCOM will work on Linux with D if only the extern(Windows) was actually extern(C++) ? Just to make this clear, I'm banking on that the fact that extern(C++) on an interface should also remove the necessity to alias to a COM interface on linux. I am gu

Re: Interfacing with XPCOM

2008-11-30 Thread John Reimer
Hello Walter, So are you saying that XPCOM will work on Linux with D if only the extern(Windows) was actually extern(C++) ? Yes, I think so. But I should probably test the theory with dmd 2.0 first just to make sure. This is just about over my head since I'm not too familiar with C++ int

Re: Interfacing with XPCOM

2008-11-30 Thread Walter Bright
So are you saying that XPCOM will work on Linux with D if only the extern(Windows) was actually extern(C++) ?

Interfacing with XPCOM

2008-11-30 Thread John Reimer
As the title suggests, this post is about D interfaces, specifically as supported in D 1.0. Here's some background: I've been working on porting the SWT Browser package to DWT (on Linux) over the last few months. I'm happy to say that I've mostly succeeded despite some rather annoying prob