Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arguments not forwarded to Mixin #31

Open
AnNeub opened this issue Dec 16, 2021 · 2 comments
Open

arguments not forwarded to Mixin #31

AnNeub opened this issue Dec 16, 2021 · 2 comments

Comments

@AnNeub
Copy link

AnNeub commented Dec 16, 2021

If using Mixin the parameters are not forwarded to the MixinClass.

@AnNeub
Copy link
Author

AnNeub commented Dec 16, 2021

See patch, hope it helps. It only forwards parameter if mixin (user_module) is activated.

module_utilities.tpl

<     {{ c.eStructuralFeatures | map(attribute='name') | map('re_sub', '$', '=None') | join(', ') }}
---
>     {{ c.eStructuralFeatures| rejectattr('derived') | map(attribute='name') | map('re_sub', '$', '=None') | join(', ') }}
>     {%- if c.eSuperTypes %}, **kwargs{% endif %}
> {%- endmacro %}
> 
> {%- macro generate_super_init_args(c, user_module=False) -%}
>     {%- if user_module and c.eStructuralFeatures -%}
>     {{ c.eStructuralFeatures| rejectattr('derived') | map(attribute='name') | map('re_sub', '(.+)', '\g<0>= \g<0>') | join(', ') }}
>     {%- endif %}
>     {%- if c.eSuperTypes %}{{', ' if user_module and c.eStructuralFeatures else ''}}**kwargs{% endif %}
91c99
<     def __init__(self{{ generate_class_init_args(c) }}{% if c.eSuperTypes %}, **kwargs{% endif %}):
---
>     def __init__(self{{ generate_class_init_args(c) }}):
97,98c105,107
<         super().__init__({% if c.eSuperTypes %}**kwargs{% endif %})
<     {%- for feature in c.eStructuralFeatures | reject('type', ecore.EReference) %}
---
>         super().__init__({{ generate_super_init_args(c, user_module) }})
> 
>     {%- for feature in c.eStructuralFeatures | reject('type', ecore.EReference) | rejectattr('derived')%}
109,110c118,119
<     def __init__(self{{ generate_class_init_args(c) }}, **kwargs):
<         super().__init__({% if c.eSuperTypes %}**kwargs{% endif %})
---
>     def __init__(self{{ generate_class_init_args(c) }}):
>         super().__init__({{ generate_super_init_args(c, user_module) }})

@AnNeub
Copy link
Author

AnNeub commented Dec 18, 2021

If found some bug in the patch, i have update the pre post. Should work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant