www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - COM/interface question

reply Mike <vertex gmx.at> writes:
I'm getting a strange compilation error with a COM interface I'm trying to
access. Here's the relevant part of the interface:

extern(Windows) interface IASIO : IUnknown
{
    ASIOBool init(void*);
[snip]
    ASIOError getChannels(long*, long*);
[snip]
}

And here's the problem:

test.init(null); // Error: function expected before (), not null of type IASIO*
test.getChannels(&ichans, &ochans); // compiles

test is of type IASIO*. ASIOBool and ASIOError are both aliases for long. The
null in the "init" is not the problem; if I give the function the correct
pointer it doesn't compile as well.

Has anybody any idea why one call compiles and the other doesn't?

-Mike
Dec 02 2007
next sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Mike" <vertex gmx.at> wrote in message 
news:fiuejb$2j6g$1 digitalmars.com...
 I'm getting a strange compilation error with a COM interface I'm trying to 
 access. Here's the relevant part of the interface:

 extern(Windows) interface IASIO : IUnknown
 {
    ASIOBool init(void*);
 [snip]
    ASIOError getChannels(long*, long*);
 [snip]
 }

 And here's the problem:

 test.init(null); // Error: function expected before (), not null of type 
 IASIO*
 test.getChannels(&ichans, &ochans); // compiles

 test is of type IASIO*. ASIOBool and ASIOError are both aliases for long. 
 The null in the "init" is not the problem; if I give the function the 
 correct pointer it doesn't compile as well.

 Has anybody any idea why one call compiles and the other doesn't?
That's certainly odd, but you don't/shouldn't be using an IASIO*. Interfaces are already reference types, so where you'd use an IASIO* in C/C++, use an IASIO in D.
Dec 02 2007
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message 
news:fiuib6$2oiq$1 digitalmars.com...
 "Mike" <vertex gmx.at> wrote in message 
 news:fiuejb$2j6g$1 digitalmars.com...
 I'm getting a strange compilation error with a COM interface I'm trying 
 to access. Here's the relevant part of the interface:

 extern(Windows) interface IASIO : IUnknown
 {
    ASIOBool init(void*);
 [snip]
    ASIOError getChannels(long*, long*);
 [snip]
 }

 And here's the problem:

 test.init(null); // Error: function expected before (), not null of type 
 IASIO*
 test.getChannels(&ichans, &ochans); // compiles

 test is of type IASIO*. ASIOBool and ASIOError are both aliases for long. 
 The null in the "init" is not the problem; if I give the function the 
 correct pointer it doesn't compile as well.

 Has anybody any idea why one call compiles and the other doesn't?
That's certainly odd, but you don't/shouldn't be using an IASIO*. Interfaces are already reference types, so where you'd use an IASIO* in C/C++, use an IASIO in D.
And it just dawned on me why the init isn't working: init is a property of all D types and variables. The second one works because the . there is working like -> in C. init should then work fine if you use an IASIO.
Dec 02 2007
parent Mike <vertex gmx.at> writes:
Ah! Of course! I translated the SDK from C++, where it's all pointers, and
didn't care (excactly because "." does (usually) behaves like "->"). Now it's
all IASIO without pointers.

Thanks!

-Mike

Jarrett Billingsley Wrote:

 "Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message 
 news:fiuib6$2oiq$1 digitalmars.com...
 "Mike" <vertex gmx.at> wrote in message 
 news:fiuejb$2j6g$1 digitalmars.com...
 I'm getting a strange compilation error with a COM interface I'm trying 
 to access. Here's the relevant part of the interface:

 extern(Windows) interface IASIO : IUnknown
 {
    ASIOBool init(void*);
 [snip]
    ASIOError getChannels(long*, long*);
 [snip]
 }

 And here's the problem:

 test.init(null); // Error: function expected before (), not null of type 
 IASIO*
 test.getChannels(&ichans, &ochans); // compiles

 test is of type IASIO*. ASIOBool and ASIOError are both aliases for long. 
 The null in the "init" is not the problem; if I give the function the 
 correct pointer it doesn't compile as well.

 Has anybody any idea why one call compiles and the other doesn't?
That's certainly odd, but you don't/shouldn't be using an IASIO*. Interfaces are already reference types, so where you'd use an IASIO* in C/C++, use an IASIO in D.
And it just dawned on me why the init isn't working: init is a property of all D types and variables. The second one works because the . there is working like -> in C. init should then work fine if you use an IASIO.
Dec 02 2007
prev sibling parent BLS <nanali nospam-wanadoo.fr> writes:
May I suggest to have a look at :
http://www.dsource.org/projects/juno/wiki/TypeLibraryImporter

you'll find worthfull COM information and a nice tool to automate this 
task.
HTH Bjoern

Mike schrieb:
 I'm getting a strange compilation error with a COM interface I'm trying to
access. Here's the relevant part of the interface:
 
 extern(Windows) interface IASIO : IUnknown
 {
     ASIOBool init(void*);
 [snip]
     ASIOError getChannels(long*, long*);
 [snip]
 }
 
 And here's the problem:
 
 test.init(null); // Error: function expected before (), not null of type IASIO*
 test.getChannels(&ichans, &ochans); // compiles
 
 test is of type IASIO*. ASIOBool and ASIOError are both aliases for long. The
null in the "init" is not the problem; if I give the function the correct
pointer it doesn't compile as well.
 
 Has anybody any idea why one call compiles and the other doesn't?
 
 -Mike
Dec 03 2007