October 28, 2019
On Monday, 28 October 2019 at 12:14:50 UTC, Newbie2019 wrote:
> On Monday, 28 October 2019 at 11:14:24 UTC, Cristian Becerescu wrote:
>> Update for week 2 of Milestone 2
>>
>> - PRs from the previous week were successfully merged
>>
>> [...]
>
> Maybe you can try:
>
> u32 i=0;
> typeof(u32.init) f1(); // err
> typeof(int.init) f2(); // err
> typeof(i.init) f2(); // err

Initially I thought about checking if the argument to typeof() is a type or an alias to a type (and just use the argument as is in those scenarios).

But your suggestion is more generic, and it works on all those cases. Thank you! I will try it out.
October 29, 2019
On 2019-10-28 12:14, Cristian Becerescu wrote:

> Another issue is related to translating nested (on multiple levels) anonymous unions and structs (specifically in linux/slab.h, line 596), but I still have to wrap my head around this (because the generated code is a bit complicated).

What exactly is the problem?

-- 
/Jacob Carlborg
November 01, 2019
On Tuesday, 29 October 2019 at 13:34:50 UTC, Jacob Carlborg wrote:
> What exactly is the problem?

Sorry for taking so long to reply.

I've written a simple example where dpp fails to generate valid D code for the problem I mention earlier. The example is in this gist (for syntax highlighting): https://gist.github.com/cbecerescu/9a114bb92b23bd8e275a8eae08c6cc2f

The problem is that getters and setters in A_struct are not generated for the 'c' and 'd' fields from 'union _Anonymous_2'. In fact, not only they are not generated, but, as you can see in the last few lines in the gist, the last 2 generated functions don't make any sense (they don't access any field from _anonymous_5, and so compiling this will fail).


November 02, 2019
On 2019-11-01 21:39, Cristian Becerescu wrote:

> Sorry for taking so long to reply.
> 
> I've written a simple example where dpp fails to generate valid D code for the problem I mention earlier. The example is in this gist (for syntax highlighting): https://gist.github.com/cbecerescu/9a114bb92b23bd8e275a8eae08c6cc2f

Wow, that's complicated. DStep [1] generates this:

extern (C):

struct A_struct
{
    union
    {
        int a;

        struct
        {
            int b;

            union
            {
                int c;
                char d;
            }
        }
    }
}

[1] http://github.com/jacob-carlborg/dstep

-- 
/Jacob Carlborg
November 03, 2019
On Saturday, 2 November 2019 at 17:02:45 UTC, Jacob Carlborg wrote:
> On 2019-11-01 21:39, Cristian Becerescu wrote:
>
>> Sorry for taking so long to reply.
>> 
>> I've written a simple example where dpp fails to generate valid D code for the problem I mention earlier. The example is in this gist (for syntax highlighting): https://gist.github.com/cbecerescu/9a114bb92b23bd8e275a8eae08c6cc2f
>
> Wow, that's complicated.

When encountering anonymous structs or unions, dpp gives them a name. And this forces dpp to declare a member of that 'now-named-anon' record type and also provide accessors for the 'now-named-anon' record (because unnamed records also implicitly declare a member of their type).
November 03, 2019
Update for week 3 of Milestone 2

- I've proposed a solution for the 'typeof with actual types instead of expressions' issue from last week (https://github.com/atilaneves/dpp/pull/201)

- I've identified the problem with the nested C11 structs and unions mentioned last week. An explanation for this was given in response to Jacob's questions above (https://forum.dlang.org/post/ckxmzciqkijaarwgmsdh@forum.dlang.org and https://forum.dlang.org/post/xbbafbbscjlgaoqznxlw@forum.dlang.org). I also proposed a solution for this issue here: https://github.com/atilaneves/dpp/pull/204

- On several occasions (when translating virtio.h), some function parameters' types contain the struct keyowrd which produces compiling errors. I'll try to solve this particular issue and other bugs in the next few days
November 04, 2019
On Sunday, 3 November 2019 at 16:37:36 UTC, Cristian Becerescu wrote:

> When encountering anonymous structs or unions, dpp gives them a name. And this forces dpp to declare a member of that 'now-named-anon' record type and also provide accessors for the 'now-named-anon' record (because unnamed records also implicitly declare a member of their type).

But the question is why is DPP generating named unions/structs when D supports anonymous ones?

--
/Jacob Carlborg
November 04, 2019
On Monday, 4 November 2019 at 09:17:57 UTC, Jacob Carlborg wrote:
> On Sunday, 3 November 2019 at 16:37:36 UTC, Cristian Becerescu wrote:
>
>> When encountering anonymous structs or unions, dpp gives them a name. And this forces dpp to declare a member of that 'now-named-anon' record type and also provide accessors for the 'now-named-anon' record (because unnamed records also implicitly declare a member of their type).
>
> But the question is why is DPP generating named unions/structs when D supports anonymous ones?

Probably because I either didn't know that at the time but knew and forgot. I don't remember what I was trying to do or why just doing the obvious failed.

November 05, 2019
On 05/11/2019 5:48 AM, Atila Neves wrote:
> On Monday, 4 November 2019 at 09:17:57 UTC, Jacob Carlborg wrote:
>> On Sunday, 3 November 2019 at 16:37:36 UTC, Cristian Becerescu wrote:
>>
>>> When encountering anonymous structs or unions, dpp gives them a name. And this forces dpp to declare a member of that 'now-named-anon' record type and also provide accessors for the 'now-named-anon' record (because unnamed records also implicitly declare a member of their type).
>>
>> But the question is why is DPP generating named unions/structs when D supports anonymous ones?
> 
> Probably because I either didn't know that at the time but knew and forgot. I don't remember what I was trying to do or why just doing the obvious failed.

It sounds like you were too liberal in doing this.

There is a variant of struct/union in C which has a named instance but no type name.
November 04, 2019
On 2019-11-04 17:54, rikki cattermole wrote:

> There is a variant of struct/union in C which has a named instance but no type name.

You mean like this?

struct Foo
{
    struct
    {
        int a;
    } b;
}

That still needs to be translated to a named struct in D.

-- 
/Jacob Carlborg