www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ide - Mixin analysis support for templated arguments possible?

reply jacobkemple <jacobkemple outlook.com> writes:
So below, if I type  "t." in visual D pops intellisense parses it 
right and it shows example1 as a ubyte, however, if I set it to 
lets say foo!T[] (or anything else templated) intellisense breaks 
support for mixins in this situation despite the code working.

mixin template StructVar(int offset, T, string name)
{
     mixin("struct {"
           ~ "private ubyte[" ~ offset.stringof ~ "] _;"
           ~ T.stringof ~ " " ~ name ~ ";"
           ~ "}");
}

unittest
{
     struct TestStruct
     {
         union
         {
             mixin StructVar!(0x10, ubyte, "example1");
         }
     }

     TestStruct t;
     t.example1 = 0x71;
}



Future support possible or is it a bug by any chance? Looked at 
the code on github but fairly complicated to dive into mixin 
analysis wise.
Mar 01 2019
parent reply Rainer Schuetze <r.sagitario gmx.de> writes:
On 01/03/2019 21:17, jacobkemple wrote:
 So below, if I type  "t." in visual D pops intellisense parses it right
 and it shows example1 as a ubyte, however, if I set it to lets say
 foo!T[] (or anything else templated) intellisense breaks support for
 mixins in this situation despite the code working.
 
 mixin template StructVar(int offset, T, string name)
 {
     mixin("struct {"
           ~ "private ubyte[" ~ offset.stringof ~ "] _;"
           ~ T.stringof ~ " " ~ name ~ ";"
           ~ "}");
 }
 
 unittest
 {
     struct TestStruct
     {
         union
         {
             mixin StructVar!(0x10, ubyte, "example1");
         }
     }
 
     TestStruct t;
     t.example1 = 0x71;
 }
 
 
 
 Future support possible or is it a bug by any chance? Looked at the code
 on github but fairly complicated to dive into mixin analysis wise.
Don't expect wonders, but this problem is "just" that the stringof property of template instances doesn't evaluate to the correct string, i.e. "foo" instead of "foo!int". This should help for the next release: https://github.com/aBothe/D_Parser/pull/218
Mar 02 2019
next sibling parent jacobkemple <jacobkemple outlook.com> writes:
On Saturday, 2 March 2019 at 08:09:00 UTC, Rainer Schuetze wrote:
 On 01/03/2019 21:17, jacobkemple wrote:
 So below, if I type  "t." in visual D pops intellisense parses 
 it right and it shows example1 as a ubyte, however, if I set 
 it to lets say foo!T[] (or anything else templated) 
 intellisense breaks support for mixins in this situation 
 despite the code working.
 
 mixin template StructVar(int offset, T, string name)
 {
     mixin("struct {"
           ~ "private ubyte[" ~ offset.stringof ~ "] _;"
           ~ T.stringof ~ " " ~ name ~ ";"
           ~ "}");
 }
 
 unittest
 {
     struct TestStruct
     {
         union
         {
             mixin StructVar!(0x10, ubyte, "example1");
         }
     }
 
     TestStruct t;
     t.example1 = 0x71;
 }
 
 
 
 Future support possible or is it a bug by any chance? Looked 
 at the code on github but fairly complicated to dive into 
 mixin analysis wise.
Don't expect wonders, but this problem is "just" that the stringof property of template instances doesn't evaluate to the correct string, i.e. "foo" instead of "foo!int". This should help for the next release: https://github.com/aBothe/D_Parser/pull/218
If the issue is as you describe, simply checking if a template type (I assume with checks for the ! token in some fashion?) exist inside the template instance, parse the remainder? I am fairly new to D but that seems reasonable if that is really the issue here.
Mar 02 2019
prev sibling next sibling parent jacobkemple <jacobkemple outlook.com> writes:
On Saturday, 2 March 2019 at 08:09:00 UTC, Rainer Schuetze wrote:
 On 01/03/2019 21:17, jacobkemple wrote:
 [...]
Don't expect wonders, but this problem is "just" that the stringof property of template instances doesn't evaluate to the correct string, i.e. "foo" instead of "foo!int". This should help for the next release: https://github.com/aBothe/D_Parser/pull/218
Sorry for spam, but it appears my above comment is pretty much what the pull request is doing did not review it properly. My bad.
 sb.Append("!(");
 if (t.DeducedTypes.Count() > 0)
 	AcceptType(t.DeducedTypes[0]);
 for (int i = 1; i < t.DeducedTypes.Count(); i++)
 {
 	sb.Append(", ");
 	AcceptType(t.DeducedTypes[i]);
 }
 sb.Append(")");
Mar 02 2019
prev sibling parent reply jacobkemple <jacobkemple outlook.com> writes:
On Saturday, 2 March 2019 at 08:09:00 UTC, Rainer Schuetze wrote:
 On 01/03/2019 21:17, jacobkemple wrote:
 [...]
Don't expect wonders, but this problem is "just" that the stringof property of template instances doesn't evaluate to the correct string, i.e. "foo" instead of "foo!int". This should help for the next release: https://github.com/aBothe/D_Parser/pull/218
Out of curiosity, how does this make its way into the visual d release/beta? Is there some kind of time line for the next release, or can I grab those changes and incorporate it into visual D and build my self?
Mar 14 2019
parent Rainer Schuetze <r.sagitario gmx.de> writes:
On 14/03/2019 23:34, jacobkemple wrote:
 On Saturday, 2 March 2019 at 08:09:00 UTC, Rainer Schuetze wrote:
 On 01/03/2019 21:17, jacobkemple wrote:
 [...]
Don't expect wonders, but this problem is "just" that the stringof property of template instances doesn't evaluate to the correct string, i.e. "foo" instead of "foo!int". This should help for the next release: https://github.com/aBothe/D_Parser/pull/218
Out of curiosity, how does this make its way into the visual d release/beta? Is there some kind of time line for the next release, or can I grab those changes and incorporate it into visual D and build my self?
There is a preliminary build of my development branch (https://github.com/rainers/visuald/tree/master) by AppVeyor: https://ci.appveyor.com/project/rainers/visuald I'll probably create an "official" beta this weekend, too.
Mar 15 2019