Tools: Improve handling of sequence_protocol in Python bindings generator.
This allows SequenceProtocol being initialized without all members which simplifies Python authoring of binding files.
This commit is contained in:
@@ -537,11 +537,8 @@ def _parse_class(class_node, source_code: str, path: str, imports_mapping: dict)
|
||||
|
||||
# Attach sequence protocol metadata if provided.
|
||||
if sequence_protocol_kwargs is not None:
|
||||
try:
|
||||
seq_protocol = SequenceProtocol(**sequence_protocol_kwargs)
|
||||
py_export.Sequence = seq_protocol
|
||||
except Exception as e:
|
||||
py_export.Sequence = None
|
||||
seq_protocol = SequenceProtocol(**sequence_protocol_kwargs)
|
||||
py_export.Sequence = seq_protocol
|
||||
|
||||
py_export.Attribute.extend(class_attributes)
|
||||
py_export.Methode.extend(class_methods)
|
||||
|
||||
@@ -144,16 +144,16 @@ class SequenceProtocol:
|
||||
All attributes are required booleans.
|
||||
"""
|
||||
|
||||
sq_length: bool
|
||||
sq_concat: bool
|
||||
sq_repeat: bool
|
||||
sq_item: bool
|
||||
mp_subscript: bool
|
||||
sq_ass_item: bool
|
||||
mp_ass_subscript: bool
|
||||
sq_contains: bool
|
||||
sq_inplace_concat: bool
|
||||
sq_inplace_repeat: bool
|
||||
sq_length: bool = False
|
||||
sq_concat: bool = False
|
||||
sq_repeat: bool = False
|
||||
sq_item: bool = False
|
||||
mp_subscript: bool = False
|
||||
sq_ass_item: bool = False
|
||||
mp_ass_subscript: bool = False
|
||||
sq_contains: bool = False
|
||||
sq_inplace_concat: bool = False
|
||||
sq_inplace_repeat: bool = False
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
Reference in New Issue
Block a user