www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Structs and Interfaces in COM Bindings

reply "Adam Wilson" <flyboynw gmail.com> writes:
Hi guys,

I have been beating my head against this wall for a few days and I am  
having difficult understanding what's going on here. I am building the  
DirectX COM bindings for Aurora and DMD is popping out an "Undefined  
Identifier" error when I use an interface as a member of a struct.  
Consider the following:

public struct DWRITE_GLYPH_RUN {
	IDWriteFontFace fontFace; //Error: Undefined Identifier
	//...
}

// ... More Structs. Followed by some Interfaces.

mixin(uuid!(IDWriteFontFace, "5f49804d-7024-4d43-bfa9-d25984f53849"));
public interface IDWriteFontFace : IUnknown
{
extern(Windows):
	HRESULT GetDesignGlyphMetrics(const(uint*) Indices, uint Count,  
DWRITE_GLYPH_METRICS*
	//...
	void ReleaseFontTable(void* TableContext);
}

//... More Interfaces

mixin(uuid!(IDWriteGdiInterop, "1edd9491-9853-4299-898f-6432983b6f3a"));
public interface IDWriteGdiInterop : IUnknown
{
extern(Windows):
	//...
	HRESULT CreateFontFaceFromHdc(HDC HDC, IDWriteFontFace * FontFace); //  
NOT an error here
	//...
}

I am fighting a bug in 2.065.0 or am I doing something wrong?

Full source: https://github.com/auroragraphics/directx

Any help would be greatly appreciated!

-- 
Adam Wilson
GitHub/IRC: LightBender
Aurora Project Coordinator
May 18 2014
next sibling parent "Adam Wilson" <flyboynw gmail.com> writes:
Addendum:

In the module Structs and Interfaces are wrapped with static if blocks in  
the following manner:

static if(DX110)
{
	//Enumerations
}
static if(DX111) { //...}
static if(DX112) { //...}

static if(DX110)
{
	//Structs
}
static if(DX111) { //...}
static if(DX112) { //...}

static if(DX110)
{
	//Interfaces
}
static if(DX111) { //...}
static if(DX112) { //...}

Could this be causing the problem, even if the struct and interface have  
matching static if qualifiers (in this case: DX110)?

-- 
Adam Wilson
GitHub/IRC: LightBender
Aurora Project Coordinator
May 18 2014
prev sibling next sibling parent "Adam Wilson" <flyboynw gmail.com> writes:
On Sun, 18 May 2014 17:48:45 -0700, Adam Wilson <flyboynw gmail.com> wrote:

 Addendum:

 In the module Structs and Interfaces are wrapped with static if blocks  
 in the following manner:

 static if(DX110)
 {
 	//Enumerations
 }
 static if(DX111) { //...}
 static if(DX112) { //...}

 static if(DX110)
 {
 	//Structs
 }
 static if(DX111) { //...}
 static if(DX112) { //...}

 static if(DX110)
 {
 	//Interfaces
 }
 static if(DX111) { //...}
 static if(DX112) { //...}

 Could this be causing the problem, even if the struct and interface have  
 matching static if qualifiers (in this case: DX110)?

I just tried moving the struct to the interfaces static if block and surprisingly enough, it compiled. IIRC static if isn't supposed to introduce a new scope. So I am definitely leaning towards bug. If so, there goes my DConf demo... -- Adam Wilson GitHub/IRC: LightBender Aurora Project Coordinator
May 18 2014
prev sibling next sibling parent "Adam Wilson" <flyboynw gmail.com> writes:
On Sun, 18 May 2014 17:48:45 -0700, Adam Wilson <flyboynw gmail.com> wrote:

 Addendum:

 In the module Structs and Interfaces are wrapped with static if blocks  
 in the following manner:

 static if(DX110)
 {
 	//Enumerations
 }
 static if(DX111) { //...}
 static if(DX112) { //...}

 static if(DX110)
 {
 	//Structs
 }
 static if(DX111) { //...}
 static if(DX112) { //...}

 static if(DX110)
 {
 	//Interfaces
 }
 static if(DX111) { //...}
 static if(DX112) { //...}

 Could this be causing the problem, even if the struct and interface have  
 matching static if qualifiers (in this case: DX110)?

An interesting note: If I use a struct or enum from further up the file in an interface it compiles fine, but if I use an interface further down the file in a struct, it throws an error. -- Adam Wilson GitHub/IRC: LightBender Aurora Project Coordinator
May 18 2014
prev sibling parent "Dicebot" <public dicebot.lv> writes:
On Monday, 19 May 2014 at 01:27:00 UTC, Adam Wilson wrote:
 An interesting note: If I use a struct or enum from further up 
 the file in an interface it compiles fine, but if I use an 
 interface further down the file in a struct, it throws an error.

It sounds like of on those bugs related to order of semantic analysis. Just a random guess though.
May 19 2014