Thread overview
How to see result of a mixin? (equivalent of running C preprocessor)
Jul 24, 2009
asd
Jul 24, 2009
Ary Borenszweig
Jul 24, 2009
Ary Borenszweig
Jul 24, 2009
Lutger
D-ObjC error in D2 (was: Re: How to see result of a mixin?)
Jul 24, 2009
asd
Jul 25, 2009
asd
Re: D-ObjC error in D2
Jul 25, 2009
Ary Borenszweig
Jul 25, 2009
Ary Borenszweig
Jul 26, 2009
Trass3r
July 24, 2009
I'm trying to get D-ObjC bridge working and I'm getting weird errors triggered somewhere deeply in a mix of templates and mixins that's too hard for me to understand.

How can I analyze such problem in D? Is it possible to tell dmd to run only compile-time functions/templates and output that as a D source?
July 24, 2009
asd wrote:
> I'm trying to get D-ObjC bridge working and I'm getting weird errors triggered somewhere deeply in a mix of templates and mixins that's too hard for me to understand.
> 
> How can I analyze such problem in D? Is it possible to tell dmd to run only compile-time functions/templates and output that as a D source?

You can debug templates and mixins using Descent:

http://dsource.org/project/descent
July 24, 2009
Ary Borenszweig wrote:
> asd wrote:
>> I'm trying to get D-ObjC bridge working and I'm getting weird errors triggered somewhere deeply in a mix of templates and mixins that's too hard for me to understand.
>>
>> How can I analyze such problem in D? Is it possible to tell dmd to run only compile-time functions/templates and output that as a D source?
> 
> You can debug templates and mixins using Descent:
> 
> http://dsource.org/project/descent

I mean... http://dsource.org/projects/descent
July 24, 2009
asd wrote:

> I'm trying to get D-ObjC bridge working and I'm getting weird errors triggered somewhere deeply in a mix of templates and mixins that's too hard for me to understand.
> 
> How can I analyze such problem in D? Is it possible to tell dmd to run only compile-time functions/templates and output that as a D source?

Not directly except with descent. It's worth it to try descent compile time debugger (and compile time view!), really awesome stuff.

Other than that, you can use pragma(msg, ...) where you have several options for ... depending on what you want to debug and whether it's D1 or D2. .stringof property and typeof() are useful for this. Take a look at std.traits and for D2 at __traits. Generally the error messages with such code is not so friendly.

String mixins can also just be printed with writeln / Stdout.





July 24, 2009
thanks for quick response!

Lutger Wrote:

> Not directly except with descent. It's worth it to try descent compile time debugger (and compile time view!), really awesome stuff.

It's indeed pretty nice, but unfortunately it doesn't seem to show mixins:

>	public void STARTS_HERE() {}
>
>	mixin ObjcMethodInfo!(objcForward_isEqual_, BOOL, "isEqual:", id);
>
>	public void  ENDS_HERE(int h) {}

is displayed in Descent's Compile-Time view as:

>	void STARTS_HERE() {
>	}
>
>	void ENDS_HERE(int h) {
>	}

Error I'm trying to fix is:
cocoa/foundation/object.d(74): Error: function cocoa.foundation.object.NSObject.ObjcMethodInfo!(objcForward_isEqual_,byte,"isEqual:",objc_ob
ject*).ObjcSubclassIfNeeded!().ObjcSubclass!().ObjcSubclass!("NSObject"c).objcHardWired multiple overrides of same function

My guess is that I need to make this mixin to insert override keyword when neccessary, but haven't figured out yet how.
July 25, 2009
> Error I'm trying to fix is:
> cocoa/foundation/object.d(74): Error: function cocoa.foundation.object.NSObject.ObjcMethodInfo!(objcForward_isEqual_,byte,"isEqual:",objc_ob
> ject*).ObjcSubclassIfNeeded!().ObjcSubclass!().ObjcSubclass!("NSObject"c).objcHardWired multiple overrides of same function

Solved! I've sprinkled the code with pragma(msg,"I'm not dead yet") and it led me to the actual source of problem.

Thanks for the tip!
July 25, 2009
asd escribió:
> thanks for quick response!
> 
> Lutger Wrote:
> 
>> Not directly except with descent. It's worth it to try descent compile time debugger (and compile time view!), really awesome stuff. 
> 
> It's indeed pretty nice, but unfortunately it doesn't seem to show mixins:
> 
>> 	public void STARTS_HERE() {}
>> 	
>> 	mixin ObjcMethodInfo!(objcForward_isEqual_, BOOL, "isEqual:", id);
>> 	
>> 	public void  ENDS_HERE(int h) {}
> 
> is displayed in Descent's Compile-Time view as:
> 
>> 	void STARTS_HERE() {
>> 	}
>>
>> 	void ENDS_HERE(int h) {
>> 	}

Maybe because it can't instantiante the template. :-)

The idea in these cases is to debug the instantiation. Right click on it -> Source -> Debug at Compile Time. The debug view opens, you can step into, and when an error happens it'll be printed in the console at the line where it happens.
July 25, 2009
Ary Borenszweig escribió:
> asd escribió:
>> thanks for quick response!
>>
>> Lutger Wrote:
>>
>>> Not directly except with descent. It's worth it to try descent compile time debugger (and compile time view!), really awesome stuff. 
>>
>> It's indeed pretty nice, but unfortunately it doesn't seem to show mixins:
>>
>>>     public void STARTS_HERE() {}
>>>         mixin ObjcMethodInfo!(objcForward_isEqual_, BOOL, "isEqual:", id);
>>>         public void  ENDS_HERE(int h) {}
>>
>> is displayed in Descent's Compile-Time view as:
>>
>>>     void STARTS_HERE() {
>>>     }
>>>
>>>     void ENDS_HERE(int h) {
>>>     }
> 
> Maybe because it can't instantiante the template. :-)
> 
> The idea in these cases is to debug the instantiation. Right click on it -> Source -> Debug at Compile Time. The debug view opens, you can step into, and when an error happens it'll be printed in the console at the line where it happens.

But now I see "D2". Still not supported by Descent, awww...
July 26, 2009
Ary Borenszweig schrieb:
> But now I see "D2". Still not supported by Descent, awww...

Unfortunately, yes :(