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

Removed deprecated parameters from inits created by the RPC spec generator #1754

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions generator/transformers/common_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, enum_names=(), struct_names=(), key_words=()):
'origin constructor_argument constructor_prefix deprecated mandatory since '
'method_suffix of_class type_native type_sdl modifier for_name description '
'constructor_argument_override')
self.constructor_named = namedtuple('constructor', 'init self arguments all deprecated')
self.constructor_named = namedtuple('constructor', 'init self arguments all')
self.argument_named = namedtuple('argument', 'origin constructor_argument variable deprecated')
self.names = self.struct_names + tuple(map(lambda e: self._replace_sync(e), enum_names))

Expand Down Expand Up @@ -199,6 +199,10 @@ def extract_constructor(self, data: list, mandatory: bool) -> dict:
arguments = [self.argument_named(origin=first.origin, constructor_argument=self.parentheses(first),
variable=first.constructor_argument, deprecated=first.deprecated)]
for param in data:
if param.deprecated:
joeljfischer marked this conversation as resolved.
Show resolved Hide resolved
# Omit deprecated parameters from the constructors
continue

arguments.append(self.argument_named(origin=param.origin, constructor_argument=self.parentheses(param),
variable=param.constructor_argument, deprecated=param.deprecated))
init.append('{}:({}{}){}'.format(self.minimize_first(param.constructor_prefix),
Expand All @@ -215,7 +219,6 @@ def extract_constructors(self, data: dict) -> tuple:
"""
mandatory = []
not_mandatory = []
deprecated = any([m.deprecated for m in data.values() if getattr(m, 'deprecated', False)])
for param in data.values():
if param.mandatory:
mandatory.append(param)
Expand All @@ -225,13 +228,11 @@ def extract_constructors(self, data: dict) -> tuple:
result = []
if mandatory:
mandatory = self.extract_constructor(mandatory, True)
mandatory['deprecated'] = deprecated
else:
mandatory = OrderedDict()

if not_mandatory:
not_mandatory = self.extract_constructor(not_mandatory, False)
not_mandatory['deprecated'] = deprecated
if mandatory:
not_mandatory['init'] = '{} {}'.format(mandatory['init'], self.minimize_first(not_mandatory['init']))
not_mandatory['all'] = mandatory['arguments'] + not_mandatory['arguments']
Expand Down