Best Python code snippet using autotest_python
schema.py
Source:schema.py
1# THIS FILE HAS BEEN GENERATED AUTOMATICALLY BY capnpy2# do not edit by hand3# generated on 2019-10-21 11:284# cython: language_level=25from capnpy import ptr as _ptr6from capnpy.struct_ import Struct as _Struct7from capnpy.struct_ import check_tag as _check_tag8from capnpy.struct_ import undefined as _undefined9from capnpy.enum import enum as _enum, fill_enum as _fill_enum10from capnpy.enum import BaseEnum as _BaseEnum11from capnpy.type import Types as _Types12from capnpy.segment.builder import SegmentBuilder as _SegmentBuilder13from capnpy.list import List as _List14from capnpy.list import PrimitiveItemType as _PrimitiveItemType15from capnpy.list import BoolItemType as _BoolItemType16from capnpy.list import TextItemType as _TextItemType17from capnpy.list import TextUnicodeItemType as _TextUnicodeItemType18from capnpy.list import StructItemType as _StructItemType19from capnpy.list import EnumItemType as _EnumItemType20from capnpy.list import VoidItemType as _VoidItemType21from capnpy.list import ListItemType as _ListItemType22from capnpy.anypointer import AnyPointer as _AnyPointer23from capnpy.util import text_bytes_repr as _text_bytes_repr24from capnpy.util import text_unicode_repr as _text_unicode_repr25from capnpy.util import float32_repr as _float32_repr26from capnpy.util import float64_repr as _float64_repr27from capnpy.util import extend_module_maybe as _extend_module_maybe28from capnpy.util import check_version as _check_version29from capnpy.util import encode_maybe as _encode_maybe30__capnpy_id__ = 0xa93fc509624c72d931__capnpy_version__ = '0.7.1.dev8+g4a9c343'32__capnproto_version__ = '0.7.0'33# schema compiled with --no-version-check, skipping the call to _check_version34# not including reflection data35#### FORWARD DECLARATIONS ####36class ElementSize(_BaseEnum):37 __capnpy_id__ = 1510213469561645290238 __members__ = ('empty', 'bit', 'byte', 'twoBytes', 'fourBytes', 'eightBytes', 'pointer', 'inlineComposite',)39 @staticmethod40 def _new(x):41 return ElementSize(x)42_fill_enum(ElementSize)43_ElementSize_list_item_type = _EnumItemType(ElementSize)44class Field_slot(_Struct): pass45Field_slot.__name__ = 'Field.slot'46class Field_group(_Struct): pass47Field_group.__name__ = 'Field.group'48class Field_ordinal(_Struct): pass49Field_ordinal.__name__ = 'Field.ordinal'50class Field_ordinal__tag__(_BaseEnum):51 __capnpy_id__ = None52 __members__ = ('implicit', 'explicit',)53 @staticmethod54 def _new(x):55 return Field_ordinal__tag__(x)56_fill_enum(Field_ordinal__tag__)57class Field(_Struct): pass58Field.__name__ = 'Field'59class Field__tag__(_BaseEnum):60 __capnpy_id__ = None61 __members__ = ('slot', 'group',)62 @staticmethod63 def _new(x):64 return Field__tag__(x)65_fill_enum(Field__tag__)66class Node_struct(_Struct): pass67Node_struct.__name__ = 'Node.struct'68class Node_enum(_Struct): pass69Node_enum.__name__ = 'Node.enum'70class Node_interface(_Struct): pass71Node_interface.__name__ = 'Node.interface'72class Node_const(_Struct): pass73Node_const.__name__ = 'Node.const'74class Node_annotation(_Struct): pass75Node_annotation.__name__ = 'Node.annotation'76class Node_NestedNode(_Struct): pass77Node_NestedNode.__name__ = 'Node.NestedNode'78class Node_Parameter(_Struct): pass79Node_Parameter.__name__ = 'Node.Parameter'80class Node_SourceInfo_Member(_Struct): pass81Node_SourceInfo_Member.__name__ = 'Node.SourceInfo.Member'82class Node_SourceInfo(_Struct): pass83Node_SourceInfo.__name__ = 'Node.SourceInfo'84class Node(_Struct): pass85Node.__name__ = 'Node'86class Node__tag__(_BaseEnum):87 __capnpy_id__ = None88 __members__ = ('file', 'struct', 'enum', 'interface', 'const', 'annotation',)89 @staticmethod90 def _new(x):91 return Node__tag__(x)92_fill_enum(Node__tag__)93class Enumerant(_Struct): pass94Enumerant.__name__ = 'Enumerant'95class Method(_Struct): pass96Method.__name__ = 'Method'97class Superclass(_Struct): pass98Superclass.__name__ = 'Superclass'99class Type_list(_Struct): pass100Type_list.__name__ = 'Type.list'101class Type_enum(_Struct): pass102Type_enum.__name__ = 'Type.enum'103class Type_struct(_Struct): pass104Type_struct.__name__ = 'Type.struct'105class Type_interface(_Struct): pass106Type_interface.__name__ = 'Type.interface'107class Type_anyPointer_unconstrained(_Struct): pass108Type_anyPointer_unconstrained.__name__ = 'Type.anyPointer.unconstrained'109class Type_anyPointer_unconstrained__tag__(_BaseEnum):110 __capnpy_id__ = None111 __members__ = ('anyKind', 'struct', 'list', 'capability',)112 @staticmethod113 def _new(x):114 return Type_anyPointer_unconstrained__tag__(x)115_fill_enum(Type_anyPointer_unconstrained__tag__)116class Type_anyPointer_parameter(_Struct): pass117Type_anyPointer_parameter.__name__ = 'Type.anyPointer.parameter'118class Type_anyPointer_implicitMethodParameter(_Struct): pass119Type_anyPointer_implicitMethodParameter.__name__ = 'Type.anyPointer.implicitMethodParameter'120class Type_anyPointer(_Struct): pass121Type_anyPointer.__name__ = 'Type.anyPointer'122class Type_anyPointer__tag__(_BaseEnum):123 __capnpy_id__ = None124 __members__ = ('unconstrained', 'parameter', 'implicitMethodParameter',)125 @staticmethod126 def _new(x):127 return Type_anyPointer__tag__(x)128_fill_enum(Type_anyPointer__tag__)129class Type(_Struct): pass130Type.__name__ = 'Type'131class Type__tag__(_BaseEnum):132 __capnpy_id__ = None133 __members__ = ('void', 'bool', 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64', 'float32', 'float64', 'text', 'data', 'list', 'enum', 'struct', 'interface', 'anyPointer',)134 @staticmethod135 def _new(x):136 return Type__tag__(x)137_fill_enum(Type__tag__)138class Value(_Struct): pass139Value.__name__ = 'Value'140class Value__tag__(_BaseEnum):141 __capnpy_id__ = None142 __members__ = ('void', 'bool', 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64', 'float32', 'float64', 'text', 'data', 'list', 'enum', 'struct', 'interface', 'anyPointer',)143 @staticmethod144 def _new(x):145 return Value__tag__(x)146_fill_enum(Value__tag__)147class Annotation(_Struct): pass148Annotation.__name__ = 'Annotation'149class Brand_Scope(_Struct): pass150Brand_Scope.__name__ = 'Brand.Scope'151class Brand_Scope__tag__(_BaseEnum):152 __capnpy_id__ = None153 __members__ = ('bind', 'inherit',)154 @staticmethod155 def _new(x):156 return Brand_Scope__tag__(x)157_fill_enum(Brand_Scope__tag__)158class Brand_Binding(_Struct): pass159Brand_Binding.__name__ = 'Brand.Binding'160class Brand_Binding__tag__(_BaseEnum):161 __capnpy_id__ = None162 __members__ = ('unbound', 'type',)163 @staticmethod164 def _new(x):165 return Brand_Binding__tag__(x)166_fill_enum(Brand_Binding__tag__)167class Brand(_Struct): pass168Brand.__name__ = 'Brand'169class CapnpVersion(_Struct): pass170CapnpVersion.__name__ = 'CapnpVersion'171class CodeGeneratorRequest_RequestedFile_Import(_Struct): pass172CodeGeneratorRequest_RequestedFile_Import.__name__ = 'CodeGeneratorRequest.RequestedFile.Import'173class CodeGeneratorRequest_RequestedFile(_Struct): pass174CodeGeneratorRequest_RequestedFile.__name__ = 'CodeGeneratorRequest.RequestedFile'175class CodeGeneratorRequest(_Struct): pass176CodeGeneratorRequest.__name__ = 'CodeGeneratorRequest'177#### DEFINITIONS ####178@Field_slot.__extend__179class Field_slot(_Struct):180 __capnpy_id__ = 0xc42305476bb4746f181 __static_data_size__ = 3182 __static_ptrs_size__ = 4183 184 185 @property186 def offset(self):187 # no union check188 value = self._read_primitive(4, ord(b'I'))189 if 0 != 0:190 value = value ^ 0191 return value192 193 @property194 def type(self):195 # no union check196 offset = 16197 p = self._read_fast_ptr(offset)198 if _ptr.kind(p) == _ptr.FAR:199 offset, p = self._read_far_ptr(offset)200 else:201 offset += self._ptrs_offset202 if p == 0:203 return None204 obj = Type.__new__(Type)205 obj._init_from_pointer(self._seg, offset, p)206 return obj207 208 def get_type(self):209 res = self.type210 if res is None:211 return Type.from_buffer(b'', 0, data_size=0, ptrs_size=0)212 return res213 214 def has_type(self):215 ptr = self._read_fast_ptr(16)216 return ptr != 0217 218 @property219 def defaultValue(self):220 # no union check221 offset = 24222 p = self._read_fast_ptr(offset)223 if _ptr.kind(p) == _ptr.FAR:224 offset, p = self._read_far_ptr(offset)225 else:226 offset += self._ptrs_offset227 if p == 0:228 return None229 obj = Value.__new__(Value)230 obj._init_from_pointer(self._seg, offset, p)231 return obj232 233 def get_defaultValue(self):234 res = self.defaultValue235 if res is None:236 return Value.from_buffer(b'', 0, data_size=0, ptrs_size=0)237 return res238 239 def has_defaultValue(self):240 ptr = self._read_fast_ptr(24)241 return ptr != 0242 243 @property244 def hadExplicitDefault(self):245 # no union check246 value = self._read_bit(16, 1)247 if False != 0:248 value = value ^ False249 return value250 251 def shortrepr(self):252 parts = []253 parts.append("offset = %s" % self.offset)254 if self.has_type(): parts.append("type = %s" % self.get_type().shortrepr())255 if self.has_defaultValue(): parts.append("defaultValue = %s" % self.get_defaultValue().shortrepr())256 parts.append("hadExplicitDefault = %s" % str(self.hadExplicitDefault).lower())257 return "(%s)" % ", ".join(parts)258_Field_slot_list_item_type = _StructItemType(Field_slot)259@Field_group.__extend__260class Field_group(_Struct):261 __capnpy_id__ = 0xcafccddb68db1d11262 __static_data_size__ = 3263 __static_ptrs_size__ = 4264 265 266 @property267 def typeId(self):268 # no union check269 value = self._read_primitive(16, ord(b'Q'))270 if 0 != 0:271 value = value ^ 0272 return value273 274 def shortrepr(self):275 parts = []276 parts.append("typeId = %s" % self.typeId)277 return "(%s)" % ", ".join(parts)278_Field_group_list_item_type = _StructItemType(Field_group)279@Field_ordinal.__extend__280class Field_ordinal(_Struct):281 __capnpy_id__ = 0xbb90d5c287870be6282 __static_data_size__ = 3283 __static_ptrs_size__ = 4284 285 286 __tag__ = Field_ordinal__tag__287 __tag_offset__ = 10288 289 def is_implicit(self):290 return self._read_int16(10) == 0291 def is_explicit(self):292 return self._read_int16(10) == 1293 294 @property295 def implicit(self):296 self._ensure_union(0)297 return None298 299 @property300 def explicit(self):301 self._ensure_union(1)302 value = self._read_primitive(12, ord(b'H'))303 if 0 != 0:304 value = value ^ 0305 return value306 307 def shortrepr(self):308 parts = []309 if self.is_implicit(): parts.append("implicit = %s" % "void")310 if self.is_explicit(): parts.append("explicit = %s" % self.explicit)311 return "(%s)" % ", ".join(parts)312_Field_ordinal_list_item_type = _StructItemType(Field_ordinal)313@Field.__extend__314class Field(_Struct):315 __capnpy_id__ = 0x9aad50a41f4af45f316 __static_data_size__ = 3317 __static_ptrs_size__ = 4318 319 noDiscriminant = 65535320 321 __tag__ = Field__tag__322 __tag_offset__ = 8323 324 def is_slot(self):325 return self._read_int16(8) == 0326 def is_group(self):327 return self._read_int16(8) == 1328 329 @property330 def name(self):331 # no union check332 return self._read_text_bytes(0)333 334 def get_name(self):335 return self._read_text_bytes(0, default_=b"")336 337 def has_name(self):338 ptr = self._read_fast_ptr(0)339 return ptr != 0340 341 @property342 def codeOrder(self):343 # no union check344 value = self._read_primitive(0, ord(b'H'))345 if 0 != 0:346 value = value ^ 0347 return value348 349 @property350 def annotations(self):351 # no union check352 return self._read_list(8, _Annotation_list_item_type)353 354 def get_annotations(self):355 res = self.annotations356 if res is None:357 return _List.from_buffer(b'', 0, 0, 0, _Annotation_list_item_type)358 return res359 360 def has_annotations(self):361 ptr = self._read_fast_ptr(8)362 return ptr != 0363 364 @property365 def discriminantValue(self):366 # no union check367 value = self._read_primitive(2, ord(b'H'))368 if 65535 != 0:369 value = value ^ 65535370 return value371 372 @property373 def slot(self):374 self._ensure_union(0)375 obj = Field_slot.__new__(Field_slot)376 _Struct._init_from_buffer(obj, self._seg, self._data_offset,377 self._data_size, self._ptrs_size)378 return obj379 380 @staticmethod381 def Slot(offset=0, type=None, defaultValue=None, hadExplicitDefault=False):382 return offset, type, defaultValue, hadExplicitDefault,383 384 @property385 def group(self):386 self._ensure_union(1)387 obj = Field_group.__new__(Field_group)388 _Struct._init_from_buffer(obj, self._seg, self._data_offset,389 self._data_size, self._ptrs_size)390 return obj391 392 @staticmethod393 def Group(typeId=0):394 return typeId,395 396 @property397 def ordinal(self):398 # no union check399 obj = Field_ordinal.__new__(Field_ordinal)400 _Struct._init_from_buffer(obj, self._seg, self._data_offset,401 self._data_size, self._ptrs_size)402 return obj403 404 @staticmethod405 def Ordinal(implicit=_undefined, explicit=_undefined):406 return implicit, explicit,407 408 @staticmethod409 def __new(name=None, codeOrder=0, annotations=None, discriminantValue=65535, slot=_undefined, group=_undefined, ordinal=(_undefined, _undefined,)):410 builder = _SegmentBuilder()411 pos = builder.allocate(56)412 anonymous__curtag = None413 ordinal__curtag = None414 builder.alloc_text(pos + 24, name)415 builder.write_uint16(pos + 0, codeOrder)416 builder.copy_from_list(pos + 32, _Annotation_list_item_type, annotations)417 discriminantValue ^= 65535418 builder.write_uint16(pos + 2, discriminantValue)419 if slot is not _undefined:420 anonymous__curtag = _check_tag(anonymous__curtag, 'slot')421 builder.write_int16(8, 0)422 slot_offset, slot_type, slot_defaultValue, slot_hadExplicitDefault, = slot423 builder.write_uint32(pos + 4, slot_offset)424 builder.copy_from_struct(pos + 40, Type, slot_type)425 builder.copy_from_struct(pos + 48, Value, slot_defaultValue)426 builder.write_bool(16, 0, slot_hadExplicitDefault)427 if group is not _undefined:428 anonymous__curtag = _check_tag(anonymous__curtag, 'group')429 builder.write_int16(8, 1)430 group_typeId, = group431 builder.write_uint64(pos + 16, group_typeId)432 ordinal_implicit, ordinal_explicit, = ordinal433 if ordinal_implicit is not _undefined:434 ordinal__curtag = _check_tag(ordinal__curtag, 'implicit')435 builder.write_int16(10, 0)436 if ordinal_explicit is not _undefined:437 ordinal__curtag = _check_tag(ordinal__curtag, 'explicit')438 builder.write_int16(10, 1)439 builder.write_uint16(pos + 12, ordinal_explicit)440 return builder.as_string()441 442 def __init__(self, name=None, codeOrder=0, annotations=None, discriminantValue=65535, slot=_undefined, group=_undefined, ordinal=(_undefined, _undefined,)):443 _buf = Field.__new(name, codeOrder, annotations, discriminantValue, slot, group, ordinal)444 self._init_from_buffer(_buf, 0, 3, 4)445 446 @classmethod447 def new_slot(cls, name=None, codeOrder=0, annotations=None, discriminantValue=65535, slot=(0, None, None, False,), ordinal=(_undefined, _undefined,)):448 buf = Field.__new(name=name, codeOrder=codeOrder, annotations=annotations, discriminantValue=discriminantValue, slot=slot, ordinal=ordinal, group=_undefined)449 return cls.from_buffer(buf, 0, 3, 4)450 451 @classmethod452 def new_group(cls, name=None, codeOrder=0, annotations=None, discriminantValue=65535, group=(0,), ordinal=(_undefined, _undefined,)):453 buf = Field.__new(name=name, codeOrder=codeOrder, annotations=annotations, discriminantValue=discriminantValue, group=group, ordinal=ordinal, slot=_undefined)454 return cls.from_buffer(buf, 0, 3, 4)455 456 def shortrepr(self):457 parts = []458 if self.has_name(): parts.append("name = %s" % _text_bytes_repr(self.get_name()))459 parts.append("codeOrder = %s" % self.codeOrder)460 if self.has_annotations(): parts.append("annotations = %s" % self.get_annotations().shortrepr())461 parts.append("discriminantValue = %s" % self.discriminantValue)462 if self.is_slot(): parts.append("slot = %s" % self.slot.shortrepr())463 if self.is_group(): parts.append("group = %s" % self.group.shortrepr())464 parts.append("ordinal = %s" % self.ordinal.shortrepr())465 return "(%s)" % ", ".join(parts)466_Field_list_item_type = _StructItemType(Field)467@Node_struct.__extend__468class Node_struct(_Struct):469 __capnpy_id__ = 0x9ea0b19b37fb4435470 __static_data_size__ = 5471 __static_ptrs_size__ = 6472 473 474 @property475 def dataWordCount(self):476 # no union check477 value = self._read_primitive(14, ord(b'H'))478 if 0 != 0:479 value = value ^ 0480 return value481 482 @property483 def pointerCount(self):484 # no union check485 value = self._read_primitive(24, ord(b'H'))486 if 0 != 0:487 value = value ^ 0488 return value489 490 @property491 def preferredListEncoding(self):492 # no union check493 value = self._read_int16(26)494 if 0 != 0:495 value = (value ^ 0)496 return ElementSize._new(value)497 498 @property499 def isGroup(self):500 # no union check501 value = self._read_bit(28, 1)502 if False != 0:503 value = value ^ False504 return value505 506 @property507 def discriminantCount(self):508 # no union check509 value = self._read_primitive(30, ord(b'H'))510 if 0 != 0:511 value = value ^ 0512 return value513 514 @property515 def discriminantOffset(self):516 # no union check517 value = self._read_primitive(32, ord(b'I'))518 if 0 != 0:519 value = value ^ 0520 return value521 522 @property523 def fields(self):524 # no union check525 return self._read_list(24, _Field_list_item_type)526 527 def get_fields(self):528 res = self.fields529 if res is None:530 return _List.from_buffer(b'', 0, 0, 0, _Field_list_item_type)531 return res532 533 def has_fields(self):534 ptr = self._read_fast_ptr(24)535 return ptr != 0536 537 def shortrepr(self):538 parts = []539 parts.append("dataWordCount = %s" % self.dataWordCount)540 parts.append("pointerCount = %s" % self.pointerCount)541 parts.append("preferredListEncoding = %s" % self.preferredListEncoding)542 parts.append("isGroup = %s" % str(self.isGroup).lower())543 parts.append("discriminantCount = %s" % self.discriminantCount)544 parts.append("discriminantOffset = %s" % self.discriminantOffset)545 if self.has_fields(): parts.append("fields = %s" % self.get_fields().shortrepr())546 return "(%s)" % ", ".join(parts)547_Node_struct_list_item_type = _StructItemType(Node_struct)548@Node_enum.__extend__549class Node_enum(_Struct):550 __capnpy_id__ = 0xb54ab3364333f598551 __static_data_size__ = 5552 __static_ptrs_size__ = 6553 554 555 @property556 def enumerants(self):557 # no union check558 return self._read_list(24, _Enumerant_list_item_type)559 560 def get_enumerants(self):561 res = self.enumerants562 if res is None:563 return _List.from_buffer(b'', 0, 0, 0, _Enumerant_list_item_type)564 return res565 566 def has_enumerants(self):567 ptr = self._read_fast_ptr(24)568 return ptr != 0569 570 def shortrepr(self):571 parts = []572 if self.has_enumerants(): parts.append("enumerants = %s" % self.get_enumerants().shortrepr())573 return "(%s)" % ", ".join(parts)574_Node_enum_list_item_type = _StructItemType(Node_enum)575@Node_interface.__extend__576class Node_interface(_Struct):577 __capnpy_id__ = 0xe82753cff0c2218f578 __static_data_size__ = 5579 __static_ptrs_size__ = 6580 581 582 @property583 def methods(self):584 # no union check585 return self._read_list(24, _Method_list_item_type)586 587 def get_methods(self):588 res = self.methods589 if res is None:590 return _List.from_buffer(b'', 0, 0, 0, _Method_list_item_type)591 return res592 593 def has_methods(self):594 ptr = self._read_fast_ptr(24)595 return ptr != 0596 597 @property598 def superclasses(self):599 # no union check600 return self._read_list(32, _Superclass_list_item_type)601 602 def get_superclasses(self):603 res = self.superclasses604 if res is None:605 return _List.from_buffer(b'', 0, 0, 0, _Superclass_list_item_type)606 return res607 608 def has_superclasses(self):609 ptr = self._read_fast_ptr(32)610 return ptr != 0611 612 def shortrepr(self):613 parts = []614 if self.has_methods(): parts.append("methods = %s" % self.get_methods().shortrepr())615 if self.has_superclasses(): parts.append("superclasses = %s" % self.get_superclasses().shortrepr())616 return "(%s)" % ", ".join(parts)617_Node_interface_list_item_type = _StructItemType(Node_interface)618@Node_const.__extend__619class Node_const(_Struct):620 __capnpy_id__ = 0xb18aa5ac7a0d9420621 __static_data_size__ = 5622 __static_ptrs_size__ = 6623 624 625 @property626 def type(self):627 # no union check628 offset = 24629 p = self._read_fast_ptr(offset)630 if _ptr.kind(p) == _ptr.FAR:631 offset, p = self._read_far_ptr(offset)632 else:633 offset += self._ptrs_offset634 if p == 0:635 return None636 obj = Type.__new__(Type)637 obj._init_from_pointer(self._seg, offset, p)638 return obj639 640 def get_type(self):641 res = self.type642 if res is None:643 return Type.from_buffer(b'', 0, data_size=0, ptrs_size=0)644 return res645 646 def has_type(self):647 ptr = self._read_fast_ptr(24)648 return ptr != 0649 650 @property651 def value(self):652 # no union check653 offset = 32654 p = self._read_fast_ptr(offset)655 if _ptr.kind(p) == _ptr.FAR:656 offset, p = self._read_far_ptr(offset)657 else:658 offset += self._ptrs_offset659 if p == 0:660 return None661 obj = Value.__new__(Value)662 obj._init_from_pointer(self._seg, offset, p)663 return obj664 665 def get_value(self):666 res = self.value667 if res is None:668 return Value.from_buffer(b'', 0, data_size=0, ptrs_size=0)669 return res670 671 def has_value(self):672 ptr = self._read_fast_ptr(32)673 return ptr != 0674 675 def shortrepr(self):676 parts = []677 if self.has_type(): parts.append("type = %s" % self.get_type().shortrepr())678 if self.has_value(): parts.append("value = %s" % self.get_value().shortrepr())679 return "(%s)" % ", ".join(parts)680_Node_const_list_item_type = _StructItemType(Node_const)681@Node_annotation.__extend__682class Node_annotation(_Struct):683 __capnpy_id__ = 0xec1619d4400a0290684 __static_data_size__ = 5685 __static_ptrs_size__ = 6686 687 688 @property689 def type(self):690 # no union check691 offset = 24692 p = self._read_fast_ptr(offset)693 if _ptr.kind(p) == _ptr.FAR:694 offset, p = self._read_far_ptr(offset)695 else:696 offset += self._ptrs_offset697 if p == 0:698 return None699 obj = Type.__new__(Type)700 obj._init_from_pointer(self._seg, offset, p)701 return obj702 703 def get_type(self):704 res = self.type705 if res is None:706 return Type.from_buffer(b'', 0, data_size=0, ptrs_size=0)707 return res708 709 def has_type(self):710 ptr = self._read_fast_ptr(24)711 return ptr != 0712 713 @property714 def targetsFile(self):715 # no union check716 value = self._read_bit(14, 1)717 if False != 0:718 value = value ^ False719 return value720 721 @property722 def targetsConst(self):723 # no union check724 value = self._read_bit(14, 2)725 if False != 0:726 value = value ^ False727 return value728 729 @property730 def targetsEnum(self):731 # no union check732 value = self._read_bit(14, 4)733 if False != 0:734 value = value ^ False735 return value736 737 @property738 def targetsEnumerant(self):739 # no union check740 value = self._read_bit(14, 8)741 if False != 0:742 value = value ^ False743 return value744 745 @property746 def targetsStruct(self):747 # no union check748 value = self._read_bit(14, 16)749 if False != 0:750 value = value ^ False751 return value752 753 @property754 def targetsField(self):755 # no union check756 value = self._read_bit(14, 32)757 if False != 0:758 value = value ^ False759 return value760 761 @property762 def targetsUnion(self):763 # no union check764 value = self._read_bit(14, 64)765 if False != 0:766 value = value ^ False767 return value768 769 @property770 def targetsGroup(self):771 # no union check772 value = self._read_bit(14, 128)773 if False != 0:774 value = value ^ False775 return value776 777 @property778 def targetsInterface(self):779 # no union check780 value = self._read_bit(15, 1)781 if False != 0:782 value = value ^ False783 return value784 785 @property786 def targetsMethod(self):787 # no union check788 value = self._read_bit(15, 2)789 if False != 0:790 value = value ^ False791 return value792 793 @property794 def targetsParam(self):795 # no union check796 value = self._read_bit(15, 4)797 if False != 0:798 value = value ^ False799 return value800 801 @property802 def targetsAnnotation(self):803 # no union check804 value = self._read_bit(15, 8)805 if False != 0:806 value = value ^ False807 return value808 809 def shortrepr(self):810 parts = []811 if self.has_type(): parts.append("type = %s" % self.get_type().shortrepr())812 parts.append("targetsFile = %s" % str(self.targetsFile).lower())813 parts.append("targetsConst = %s" % str(self.targetsConst).lower())814 parts.append("targetsEnum = %s" % str(self.targetsEnum).lower())815 parts.append("targetsEnumerant = %s" % str(self.targetsEnumerant).lower())816 parts.append("targetsStruct = %s" % str(self.targetsStruct).lower())817 parts.append("targetsField = %s" % str(self.targetsField).lower())818 parts.append("targetsUnion = %s" % str(self.targetsUnion).lower())819 parts.append("targetsGroup = %s" % str(self.targetsGroup).lower())820 parts.append("targetsInterface = %s" % str(self.targetsInterface).lower())821 parts.append("targetsMethod = %s" % str(self.targetsMethod).lower())822 parts.append("targetsParam = %s" % str(self.targetsParam).lower())823 parts.append("targetsAnnotation = %s" % str(self.targetsAnnotation).lower())824 return "(%s)" % ", ".join(parts)825_Node_annotation_list_item_type = _StructItemType(Node_annotation)826@Node_NestedNode.__extend__827class Node_NestedNode(_Struct):828 __capnpy_id__ = 0xdebf55bbfa0fc242829 __static_data_size__ = 1830 __static_ptrs_size__ = 1831 832 833 @property834 def name(self):835 # no union check836 return self._read_text_bytes(0)837 838 def get_name(self):839 return self._read_text_bytes(0, default_=b"")840 841 def has_name(self):842 ptr = self._read_fast_ptr(0)843 return ptr != 0844 845 @property846 def id(self):847 # no union check848 value = self._read_primitive(0, ord(b'Q'))849 if 0 != 0:850 value = value ^ 0851 return value852 853 @staticmethod854 def __new(name=None, id=0):855 builder = _SegmentBuilder()856 pos = builder.allocate(16)857 builder.alloc_text(pos + 8, name)858 builder.write_uint64(pos + 0, id)859 return builder.as_string()860 861 def __init__(self, name=None, id=0):862 _buf = Node_NestedNode.__new(name, id)863 self._init_from_buffer(_buf, 0, 1, 1)864 865 def shortrepr(self):866 parts = []867 if self.has_name(): parts.append("name = %s" % _text_bytes_repr(self.get_name()))868 parts.append("id = %s" % self.id)869 return "(%s)" % ", ".join(parts)870_Node_NestedNode_list_item_type = _StructItemType(Node_NestedNode)871@Node_Parameter.__extend__872class Node_Parameter(_Struct):873 __capnpy_id__ = 0xb9521bccf10fa3b1874 __static_data_size__ = 0875 __static_ptrs_size__ = 1876 877 878 @property879 def name(self):880 # no union check881 return self._read_text_bytes(0)882 883 def get_name(self):884 return self._read_text_bytes(0, default_=b"")885 886 def has_name(self):887 ptr = self._read_fast_ptr(0)888 return ptr != 0889 890 @staticmethod891 def __new(name=None):892 builder = _SegmentBuilder()893 pos = builder.allocate(8)894 builder.alloc_text(pos + 0, name)895 return builder.as_string()896 897 def __init__(self, name=None):898 _buf = Node_Parameter.__new(name)899 self._init_from_buffer(_buf, 0, 0, 1)900 901 def shortrepr(self):902 parts = []903 if self.has_name(): parts.append("name = %s" % _text_bytes_repr(self.get_name()))904 return "(%s)" % ", ".join(parts)905_Node_Parameter_list_item_type = _StructItemType(Node_Parameter)906@Node_SourceInfo_Member.__extend__907class Node_SourceInfo_Member(_Struct):908 __capnpy_id__ = 0xc2ba9038898e1fa2909 __static_data_size__ = 0910 __static_ptrs_size__ = 1911 912 913 @property914 def docComment(self):915 # no union check916 return self._read_text_bytes(0)917 918 def get_docComment(self):919 return self._read_text_bytes(0, default_=b"")920 921 def has_docComment(self):922 ptr = self._read_fast_ptr(0)923 return ptr != 0924 925 @staticmethod926 def __new(docComment=None):927 builder = _SegmentBuilder()928 pos = builder.allocate(8)929 builder.alloc_text(pos + 0, docComment)930 return builder.as_string()931 932 def __init__(self, docComment=None):933 _buf = Node_SourceInfo_Member.__new(docComment)934 self._init_from_buffer(_buf, 0, 0, 1)935 936 def shortrepr(self):937 parts = []938 if self.has_docComment(): parts.append("docComment = %s" % _text_bytes_repr(self.get_docComment()))939 return "(%s)" % ", ".join(parts)940_Node_SourceInfo_Member_list_item_type = _StructItemType(Node_SourceInfo_Member)941@Node_SourceInfo.__extend__942class Node_SourceInfo(_Struct):943 __capnpy_id__ = 0xf38e1de3041357ae944 __static_data_size__ = 1945 __static_ptrs_size__ = 2946 947 Member = Node_SourceInfo_Member948 949 @property950 def id(self):951 # no union check952 value = self._read_primitive(0, ord(b'Q'))953 if 0 != 0:954 value = value ^ 0955 return value956 957 @property958 def docComment(self):959 # no union check960 return self._read_text_bytes(0)961 962 def get_docComment(self):963 return self._read_text_bytes(0, default_=b"")964 965 def has_docComment(self):966 ptr = self._read_fast_ptr(0)967 return ptr != 0968 969 @property970 def members(self):971 # no union check972 return self._read_list(8, _Node_SourceInfo_Member_list_item_type)973 974 def get_members(self):975 res = self.members976 if res is None:977 return _List.from_buffer(b'', 0, 0, 0, _Node_SourceInfo_Member_list_item_type)978 return res979 980 def has_members(self):981 ptr = self._read_fast_ptr(8)982 return ptr != 0983 984 @staticmethod985 def __new(id=0, docComment=None, members=None):986 builder = _SegmentBuilder()987 pos = builder.allocate(24)988 builder.write_uint64(pos + 0, id)989 builder.alloc_text(pos + 8, docComment)990 builder.copy_from_list(pos + 16, _Node_SourceInfo_Member_list_item_type, members)991 return builder.as_string()992 993 def __init__(self, id=0, docComment=None, members=None):994 _buf = Node_SourceInfo.__new(id, docComment, members)995 self._init_from_buffer(_buf, 0, 1, 2)996 997 def shortrepr(self):998 parts = []999 parts.append("id = %s" % self.id)1000 if self.has_docComment(): parts.append("docComment = %s" % _text_bytes_repr(self.get_docComment()))1001 if self.has_members(): parts.append("members = %s" % self.get_members().shortrepr())1002 return "(%s)" % ", ".join(parts)1003_Node_SourceInfo_list_item_type = _StructItemType(Node_SourceInfo)1004@Node.__extend__1005class Node(_Struct):1006 __capnpy_id__ = 0xe682ab4cf923a4171007 __static_data_size__ = 51008 __static_ptrs_size__ = 61009 1010 NestedNode = Node_NestedNode1011 Parameter = Node_Parameter1012 SourceInfo = Node_SourceInfo1013 1014 __tag__ = Node__tag__1015 __tag_offset__ = 121016 1017 def is_file(self):1018 return self._read_int16(12) == 01019 def is_struct(self):1020 return self._read_int16(12) == 11021 def is_enum(self):1022 return self._read_int16(12) == 21023 def is_interface(self):1024 return self._read_int16(12) == 31025 def is_const(self):1026 return self._read_int16(12) == 41027 def is_annotation(self):1028 return self._read_int16(12) == 51029 1030 @property1031 def id(self):1032 # no union check1033 value = self._read_primitive(0, ord(b'Q'))1034 if 0 != 0:1035 value = value ^ 01036 return value1037 1038 @property1039 def displayName(self):1040 # no union check1041 return self._read_text_bytes(0)1042 1043 def get_displayName(self):1044 return self._read_text_bytes(0, default_=b"")1045 1046 def has_displayName(self):1047 ptr = self._read_fast_ptr(0)1048 return ptr != 01049 1050 @property1051 def displayNamePrefixLength(self):1052 # no union check1053 value = self._read_primitive(8, ord(b'I'))1054 if 0 != 0:1055 value = value ^ 01056 return value1057 1058 @property1059 def scopeId(self):1060 # no union check1061 value = self._read_primitive(16, ord(b'Q'))1062 if 0 != 0:1063 value = value ^ 01064 return value1065 1066 @property1067 def nestedNodes(self):1068 # no union check1069 return self._read_list(8, _Node_NestedNode_list_item_type)1070 1071 def get_nestedNodes(self):1072 res = self.nestedNodes1073 if res is None:1074 return _List.from_buffer(b'', 0, 0, 0, _Node_NestedNode_list_item_type)1075 return res1076 1077 def has_nestedNodes(self):1078 ptr = self._read_fast_ptr(8)1079 return ptr != 01080 1081 @property1082 def annotations(self):1083 # no union check1084 return self._read_list(16, _Annotation_list_item_type)1085 1086 def get_annotations(self):1087 res = self.annotations1088 if res is None:1089 return _List.from_buffer(b'', 0, 0, 0, _Annotation_list_item_type)1090 return res1091 1092 def has_annotations(self):1093 ptr = self._read_fast_ptr(16)1094 return ptr != 01095 1096 @property1097 def file(self):1098 self._ensure_union(0)1099 return None1100 1101 @property1102 def struct(self):1103 self._ensure_union(1)1104 obj = Node_struct.__new__(Node_struct)1105 _Struct._init_from_buffer(obj, self._seg, self._data_offset,1106 self._data_size, self._ptrs_size)1107 return obj1108 1109 @staticmethod1110 def Struct(dataWordCount=0, pointerCount=0, preferredListEncoding=0, isGroup=False, discriminantCount=0, discriminantOffset=0, fields=None):1111 return dataWordCount, pointerCount, preferredListEncoding, isGroup, discriminantCount, discriminantOffset, fields,1112 1113 @property1114 def enum(self):1115 self._ensure_union(2)1116 obj = Node_enum.__new__(Node_enum)1117 _Struct._init_from_buffer(obj, self._seg, self._data_offset,1118 self._data_size, self._ptrs_size)1119 return obj1120 1121 @staticmethod1122 def Enum(enumerants=None):1123 return enumerants,1124 1125 @property1126 def interface(self):1127 self._ensure_union(3)1128 obj = Node_interface.__new__(Node_interface)1129 _Struct._init_from_buffer(obj, self._seg, self._data_offset,1130 self._data_size, self._ptrs_size)1131 return obj1132 1133 @staticmethod1134 def Interface(methods=None, superclasses=None):1135 return methods, superclasses,1136 1137 @property1138 def const(self):1139 self._ensure_union(4)1140 obj = Node_const.__new__(Node_const)1141 _Struct._init_from_buffer(obj, self._seg, self._data_offset,1142 self._data_size, self._ptrs_size)1143 return obj1144 1145 @staticmethod1146 def Const(type=None, value=None):1147 return type, value,1148 1149 @property1150 def annotation(self):1151 self._ensure_union(5)1152 obj = Node_annotation.__new__(Node_annotation)1153 _Struct._init_from_buffer(obj, self._seg, self._data_offset,1154 self._data_size, self._ptrs_size)1155 return obj1156 1157 @staticmethod1158 def Annotation(type=None, targetsFile=False, targetsConst=False, targetsEnum=False, targetsEnumerant=False, targetsStruct=False, targetsField=False, targetsUnion=False, targetsGroup=False, targetsInterface=False, targetsMethod=False, targetsParam=False, targetsAnnotation=False):1159 return type, targetsFile, targetsConst, targetsEnum, targetsEnumerant, targetsStruct, targetsField, targetsUnion, targetsGroup, targetsInterface, targetsMethod, targetsParam, targetsAnnotation,1160 1161 @property1162 def parameters(self):1163 # no union check1164 return self._read_list(40, _Node_Parameter_list_item_type)1165 1166 def get_parameters(self):1167 res = self.parameters1168 if res is None:1169 return _List.from_buffer(b'', 0, 0, 0, _Node_Parameter_list_item_type)1170 return res1171 1172 def has_parameters(self):1173 ptr = self._read_fast_ptr(40)1174 return ptr != 01175 1176 @property1177 def isGeneric(self):1178 # no union check1179 value = self._read_bit(36, 1)1180 if False != 0:1181 value = value ^ False1182 return value1183 1184 @staticmethod1185 def __new(id=0, displayName=None, displayNamePrefixLength=0, scopeId=0, nestedNodes=None, annotations=None, file=_undefined, struct=_undefined, enum=_undefined, interface=_undefined, const=_undefined, annotation=_undefined, parameters=None, isGeneric=False):1186 builder = _SegmentBuilder()1187 pos = builder.allocate(88)1188 anonymous__curtag = None1189 builder.write_uint64(pos + 0, id)1190 builder.alloc_text(pos + 40, displayName)1191 builder.write_uint32(pos + 8, displayNamePrefixLength)1192 builder.write_uint64(pos + 16, scopeId)1193 builder.copy_from_list(pos + 48, _Node_NestedNode_list_item_type, nestedNodes)1194 builder.copy_from_list(pos + 56, _Annotation_list_item_type, annotations)1195 if file is not _undefined:1196 anonymous__curtag = _check_tag(anonymous__curtag, 'file')1197 builder.write_int16(12, 0)1198 if struct is not _undefined:1199 anonymous__curtag = _check_tag(anonymous__curtag, 'struct')1200 builder.write_int16(12, 1)1201 struct_dataWordCount, struct_pointerCount, struct_preferredListEncoding, struct_isGroup, struct_discriminantCount, struct_discriminantOffset, struct_fields, = struct1202 builder.write_uint16(pos + 14, struct_dataWordCount)1203 builder.write_uint16(pos + 24, struct_pointerCount)1204 builder.write_int16(pos + 26, struct_preferredListEncoding)1205 builder.write_bool(28, 0, struct_isGroup)1206 builder.write_uint16(pos + 30, struct_discriminantCount)1207 builder.write_uint32(pos + 32, struct_discriminantOffset)1208 builder.copy_from_list(pos + 64, _Field_list_item_type, struct_fields)1209 if enum is not _undefined:1210 anonymous__curtag = _check_tag(anonymous__curtag, 'enum')1211 builder.write_int16(12, 2)1212 enum_enumerants, = enum1213 builder.copy_from_list(pos + 64, _Enumerant_list_item_type, enum_enumerants)1214 if interface is not _undefined:1215 anonymous__curtag = _check_tag(anonymous__curtag, 'interface')1216 builder.write_int16(12, 3)1217 interface_methods, interface_superclasses, = interface1218 builder.copy_from_list(pos + 64, _Method_list_item_type, interface_methods)1219 builder.copy_from_list(pos + 72, _Superclass_list_item_type, interface_superclasses)1220 if const is not _undefined:1221 anonymous__curtag = _check_tag(anonymous__curtag, 'const')1222 builder.write_int16(12, 4)1223 const_type, const_value, = const1224 builder.copy_from_struct(pos + 64, Type, const_type)1225 builder.copy_from_struct(pos + 72, Value, const_value)1226 if annotation is not _undefined:1227 anonymous__curtag = _check_tag(anonymous__curtag, 'annotation')1228 builder.write_int16(12, 5)1229 annotation_type, annotation_targetsFile, annotation_targetsConst, annotation_targetsEnum, annotation_targetsEnumerant, annotation_targetsStruct, annotation_targetsField, annotation_targetsUnion, annotation_targetsGroup, annotation_targetsInterface, annotation_targetsMethod, annotation_targetsParam, annotation_targetsAnnotation, = annotation1230 builder.copy_from_struct(pos + 64, Type, annotation_type)1231 builder.write_bool(14, 0, annotation_targetsFile)1232 builder.write_bool(14, 1, annotation_targetsConst)1233 builder.write_bool(14, 2, annotation_targetsEnum)1234 builder.write_bool(14, 3, annotation_targetsEnumerant)1235 builder.write_bool(14, 4, annotation_targetsStruct)1236 builder.write_bool(14, 5, annotation_targetsField)1237 builder.write_bool(14, 6, annotation_targetsUnion)1238 builder.write_bool(14, 7, annotation_targetsGroup)1239 builder.write_bool(15, 0, annotation_targetsInterface)1240 builder.write_bool(15, 1, annotation_targetsMethod)1241 builder.write_bool(15, 2, annotation_targetsParam)1242 builder.write_bool(15, 3, annotation_targetsAnnotation)1243 builder.copy_from_list(pos + 80, _Node_Parameter_list_item_type, parameters)1244 builder.write_bool(36, 0, isGeneric)1245 return builder.as_string()1246 1247 def __init__(self, id=0, displayName=None, displayNamePrefixLength=0, scopeId=0, nestedNodes=None, annotations=None, file=_undefined, struct=_undefined, enum=_undefined, interface=_undefined, const=_undefined, annotation=_undefined, parameters=None, isGeneric=False):1248 _buf = Node.__new(id, displayName, displayNamePrefixLength, scopeId, nestedNodes, annotations, file, struct, enum, interface, const, annotation, parameters, isGeneric)1249 self._init_from_buffer(_buf, 0, 5, 6)1250 1251 @classmethod1252 def new_file(cls, id=0, displayName=None, displayNamePrefixLength=0, scopeId=0, nestedNodes=None, annotations=None, file=None, parameters=None, isGeneric=False):1253 buf = Node.__new(id=id, displayName=displayName, displayNamePrefixLength=displayNamePrefixLength, scopeId=scopeId, nestedNodes=nestedNodes, annotations=annotations, file=file, parameters=parameters, isGeneric=isGeneric, struct=_undefined, enum=_undefined, interface=_undefined, const=_undefined, annotation=_undefined)1254 return cls.from_buffer(buf, 0, 5, 6)1255 1256 @classmethod1257 def new_struct(cls, id=0, displayName=None, displayNamePrefixLength=0, scopeId=0, nestedNodes=None, annotations=None, struct=(0, 0, 0, False, 0, 0, None,), parameters=None, isGeneric=False):1258 buf = Node.__new(id=id, displayName=displayName, displayNamePrefixLength=displayNamePrefixLength, scopeId=scopeId, nestedNodes=nestedNodes, annotations=annotations, struct=struct, parameters=parameters, isGeneric=isGeneric, file=_undefined, enum=_undefined, interface=_undefined, const=_undefined, annotation=_undefined)1259 return cls.from_buffer(buf, 0, 5, 6)1260 1261 @classmethod1262 def new_enum(cls, id=0, displayName=None, displayNamePrefixLength=0, scopeId=0, nestedNodes=None, annotations=None, enum=(None,), parameters=None, isGeneric=False):1263 buf = Node.__new(id=id, displayName=displayName, displayNamePrefixLength=displayNamePrefixLength, scopeId=scopeId, nestedNodes=nestedNodes, annotations=annotations, enum=enum, parameters=parameters, isGeneric=isGeneric, file=_undefined, struct=_undefined, interface=_undefined, const=_undefined, annotation=_undefined)1264 return cls.from_buffer(buf, 0, 5, 6)1265 1266 @classmethod1267 def new_interface(cls, id=0, displayName=None, displayNamePrefixLength=0, scopeId=0, nestedNodes=None, annotations=None, interface=(None, None,), parameters=None, isGeneric=False):1268 buf = Node.__new(id=id, displayName=displayName, displayNamePrefixLength=displayNamePrefixLength, scopeId=scopeId, nestedNodes=nestedNodes, annotations=annotations, interface=interface, parameters=parameters, isGeneric=isGeneric, file=_undefined, struct=_undefined, enum=_undefined, const=_undefined, annotation=_undefined)1269 return cls.from_buffer(buf, 0, 5, 6)1270 1271 @classmethod1272 def new_const(cls, id=0, displayName=None, displayNamePrefixLength=0, scopeId=0, nestedNodes=None, annotations=None, const=(None, None,), parameters=None, isGeneric=False):1273 buf = Node.__new(id=id, displayName=displayName, displayNamePrefixLength=displayNamePrefixLength, scopeId=scopeId, nestedNodes=nestedNodes, annotations=annotations, const=const, parameters=parameters, isGeneric=isGeneric, file=_undefined, struct=_undefined, enum=_undefined, interface=_undefined, annotation=_undefined)1274 return cls.from_buffer(buf, 0, 5, 6)1275 1276 @classmethod1277 def new_annotation(cls, id=0, displayName=None, displayNamePrefixLength=0, scopeId=0, nestedNodes=None, annotations=None, annotation=(None, False, False, False, False, False, False, False, False, False, False, False, False,), parameters=None, isGeneric=False):1278 buf = Node.__new(id=id, displayName=displayName, displayNamePrefixLength=displayNamePrefixLength, scopeId=scopeId, nestedNodes=nestedNodes, annotations=annotations, annotation=annotation, parameters=parameters, isGeneric=isGeneric, file=_undefined, struct=_undefined, enum=_undefined, interface=_undefined, const=_undefined)1279 return cls.from_buffer(buf, 0, 5, 6)1280 1281 def shortrepr(self):1282 parts = []1283 parts.append("id = %s" % self.id)1284 if self.has_displayName(): parts.append("displayName = %s" % _text_bytes_repr(self.get_displayName()))1285 parts.append("displayNamePrefixLength = %s" % self.displayNamePrefixLength)1286 parts.append("scopeId = %s" % self.scopeId)1287 if self.has_nestedNodes(): parts.append("nestedNodes = %s" % self.get_nestedNodes().shortrepr())1288 if self.has_annotations(): parts.append("annotations = %s" % self.get_annotations().shortrepr())1289 if self.is_file(): parts.append("file = %s" % "void")1290 if self.is_struct(): parts.append("struct = %s" % self.struct.shortrepr())1291 if self.is_enum(): parts.append("enum = %s" % self.enum.shortrepr())1292 if self.is_interface(): parts.append("interface = %s" % self.interface.shortrepr())1293 if self.is_const(): parts.append("const = %s" % self.const.shortrepr())1294 if self.is_annotation(): parts.append("annotation = %s" % self.annotation.shortrepr())1295 if self.has_parameters(): parts.append("parameters = %s" % self.get_parameters().shortrepr())1296 parts.append("isGeneric = %s" % str(self.isGeneric).lower())1297 return "(%s)" % ", ".join(parts)1298_Node_list_item_type = _StructItemType(Node)1299@Enumerant.__extend__1300class Enumerant(_Struct):1301 __capnpy_id__ = 0x978a7cebdc549a4d1302 __static_data_size__ = 11303 __static_ptrs_size__ = 21304 1305 1306 @property1307 def name(self):1308 # no union check1309 return self._read_text_bytes(0)1310 1311 def get_name(self):1312 return self._read_text_bytes(0, default_=b"")1313 1314 def has_name(self):1315 ptr = self._read_fast_ptr(0)1316 return ptr != 01317 1318 @property1319 def codeOrder(self):1320 # no union check1321 value = self._read_primitive(0, ord(b'H'))1322 if 0 != 0:1323 value = value ^ 01324 return value1325 1326 @property1327 def annotations(self):1328 # no union check1329 return self._read_list(8, _Annotation_list_item_type)1330 1331 def get_annotations(self):1332 res = self.annotations1333 if res is None:1334 return _List.from_buffer(b'', 0, 0, 0, _Annotation_list_item_type)1335 return res1336 1337 def has_annotations(self):1338 ptr = self._read_fast_ptr(8)1339 return ptr != 01340 1341 @staticmethod1342 def __new(name=None, codeOrder=0, annotations=None):1343 builder = _SegmentBuilder()1344 pos = builder.allocate(24)1345 builder.alloc_text(pos + 8, name)1346 builder.write_uint16(pos + 0, codeOrder)1347 builder.copy_from_list(pos + 16, _Annotation_list_item_type, annotations)1348 return builder.as_string()1349 1350 def __init__(self, name=None, codeOrder=0, annotations=None):1351 _buf = Enumerant.__new(name, codeOrder, annotations)1352 self._init_from_buffer(_buf, 0, 1, 2)1353 1354 def shortrepr(self):1355 parts = []1356 if self.has_name(): parts.append("name = %s" % _text_bytes_repr(self.get_name()))1357 parts.append("codeOrder = %s" % self.codeOrder)1358 if self.has_annotations(): parts.append("annotations = %s" % self.get_annotations().shortrepr())1359 return "(%s)" % ", ".join(parts)1360_Enumerant_list_item_type = _StructItemType(Enumerant)1361@Method.__extend__1362class Method(_Struct):1363 __capnpy_id__ = 0x9500cce23b334d801364 __static_data_size__ = 31365 __static_ptrs_size__ = 51366 1367 1368 @property1369 def name(self):1370 # no union check1371 return self._read_text_bytes(0)1372 1373 def get_name(self):1374 return self._read_text_bytes(0, default_=b"")1375 1376 def has_name(self):1377 ptr = self._read_fast_ptr(0)1378 return ptr != 01379 1380 @property1381 def codeOrder(self):1382 # no union check1383 value = self._read_primitive(0, ord(b'H'))1384 if 0 != 0:1385 value = value ^ 01386 return value1387 1388 @property1389 def paramStructType(self):1390 # no union check1391 value = self._read_primitive(8, ord(b'Q'))1392 if 0 != 0:1393 value = value ^ 01394 return value1395 1396 @property1397 def resultStructType(self):1398 # no union check1399 value = self._read_primitive(16, ord(b'Q'))1400 if 0 != 0:1401 value = value ^ 01402 return value1403 1404 @property1405 def annotations(self):1406 # no union check1407 return self._read_list(8, _Annotation_list_item_type)1408 1409 def get_annotations(self):1410 res = self.annotations1411 if res is None:1412 return _List.from_buffer(b'', 0, 0, 0, _Annotation_list_item_type)1413 return res1414 1415 def has_annotations(self):1416 ptr = self._read_fast_ptr(8)1417 return ptr != 01418 1419 @property1420 def paramBrand(self):1421 # no union check1422 offset = 161423 p = self._read_fast_ptr(offset)1424 if _ptr.kind(p) == _ptr.FAR:1425 offset, p = self._read_far_ptr(offset)1426 else:1427 offset += self._ptrs_offset1428 if p == 0:1429 return None1430 obj = Brand.__new__(Brand)1431 obj._init_from_pointer(self._seg, offset, p)1432 return obj1433 1434 def get_paramBrand(self):1435 res = self.paramBrand1436 if res is None:1437 return Brand.from_buffer(b'', 0, data_size=0, ptrs_size=0)1438 return res1439 1440 def has_paramBrand(self):1441 ptr = self._read_fast_ptr(16)1442 return ptr != 01443 1444 @property1445 def resultBrand(self):1446 # no union check1447 offset = 241448 p = self._read_fast_ptr(offset)1449 if _ptr.kind(p) == _ptr.FAR:1450 offset, p = self._read_far_ptr(offset)1451 else:1452 offset += self._ptrs_offset1453 if p == 0:1454 return None1455 obj = Brand.__new__(Brand)1456 obj._init_from_pointer(self._seg, offset, p)1457 return obj1458 1459 def get_resultBrand(self):1460 res = self.resultBrand1461 if res is None:1462 return Brand.from_buffer(b'', 0, data_size=0, ptrs_size=0)1463 return res1464 1465 def has_resultBrand(self):1466 ptr = self._read_fast_ptr(24)1467 return ptr != 01468 1469 @property1470 def implicitParameters(self):1471 # no union check1472 return self._read_list(32, _Node_Parameter_list_item_type)1473 1474 def get_implicitParameters(self):1475 res = self.implicitParameters1476 if res is None:1477 return _List.from_buffer(b'', 0, 0, 0, _Node_Parameter_list_item_type)1478 return res1479 1480 def has_implicitParameters(self):1481 ptr = self._read_fast_ptr(32)1482 return ptr != 01483 1484 @staticmethod1485 def __new(name=None, codeOrder=0, paramStructType=0, resultStructType=0, annotations=None, paramBrand=None, resultBrand=None, implicitParameters=None):1486 builder = _SegmentBuilder()1487 pos = builder.allocate(64)1488 builder.alloc_text(pos + 24, name)1489 builder.write_uint16(pos + 0, codeOrder)1490 builder.write_uint64(pos + 8, paramStructType)1491 builder.write_uint64(pos + 16, resultStructType)1492 builder.copy_from_list(pos + 32, _Annotation_list_item_type, annotations)1493 builder.copy_from_struct(pos + 40, Brand, paramBrand)1494 builder.copy_from_struct(pos + 48, Brand, resultBrand)1495 builder.copy_from_list(pos + 56, _Node_Parameter_list_item_type, implicitParameters)1496 return builder.as_string()1497 1498 def __init__(self, name=None, codeOrder=0, paramStructType=0, resultStructType=0, annotations=None, paramBrand=None, resultBrand=None, implicitParameters=None):1499 _buf = Method.__new(name, codeOrder, paramStructType, resultStructType, annotations, paramBrand, resultBrand, implicitParameters)1500 self._init_from_buffer(_buf, 0, 3, 5)1501 1502 def shortrepr(self):1503 parts = []1504 if self.has_name(): parts.append("name = %s" % _text_bytes_repr(self.get_name()))1505 parts.append("codeOrder = %s" % self.codeOrder)1506 parts.append("paramStructType = %s" % self.paramStructType)1507 parts.append("resultStructType = %s" % self.resultStructType)1508 if self.has_annotations(): parts.append("annotations = %s" % self.get_annotations().shortrepr())1509 if self.has_paramBrand(): parts.append("paramBrand = %s" % self.get_paramBrand().shortrepr())1510 if self.has_resultBrand(): parts.append("resultBrand = %s" % self.get_resultBrand().shortrepr())1511 if self.has_implicitParameters(): parts.append("implicitParameters = %s" % self.get_implicitParameters().shortrepr())1512 return "(%s)" % ", ".join(parts)1513_Method_list_item_type = _StructItemType(Method)1514@Superclass.__extend__1515class Superclass(_Struct):1516 __capnpy_id__ = 0xa9962a9ed0a4d7f81517 __static_data_size__ = 11518 __static_ptrs_size__ = 11519 1520 1521 @property1522 def id(self):1523 # no union check1524 value = self._read_primitive(0, ord(b'Q'))1525 if 0 != 0:1526 value = value ^ 01527 return value1528 1529 @property1530 def brand(self):1531 # no union check1532 offset = 01533 p = self._read_fast_ptr(offset)1534 if _ptr.kind(p) == _ptr.FAR:1535 offset, p = self._read_far_ptr(offset)1536 else:1537 offset += self._ptrs_offset1538 if p == 0:1539 return None1540 obj = Brand.__new__(Brand)1541 obj._init_from_pointer(self._seg, offset, p)1542 return obj1543 1544 def get_brand(self):1545 res = self.brand1546 if res is None:1547 return Brand.from_buffer(b'', 0, data_size=0, ptrs_size=0)1548 return res1549 1550 def has_brand(self):1551 ptr = self._read_fast_ptr(0)1552 return ptr != 01553 1554 @staticmethod1555 def __new(id=0, brand=None):1556 builder = _SegmentBuilder()1557 pos = builder.allocate(16)1558 builder.write_uint64(pos + 0, id)1559 builder.copy_from_struct(pos + 8, Brand, brand)1560 return builder.as_string()1561 1562 def __init__(self, id=0, brand=None):1563 _buf = Superclass.__new(id, brand)1564 self._init_from_buffer(_buf, 0, 1, 1)1565 1566 def shortrepr(self):1567 parts = []1568 parts.append("id = %s" % self.id)1569 if self.has_brand(): parts.append("brand = %s" % self.get_brand().shortrepr())1570 return "(%s)" % ", ".join(parts)1571_Superclass_list_item_type = _StructItemType(Superclass)1572@Type_list.__extend__1573class Type_list(_Struct):1574 __capnpy_id__ = 0x87e739250a60ea971575 __static_data_size__ = 31576 __static_ptrs_size__ = 11577 1578 1579 @property1580 def elementType(self):1581 # no union check1582 offset = 01583 p = self._read_fast_ptr(offset)1584 if _ptr.kind(p) == _ptr.FAR:1585 offset, p = self._read_far_ptr(offset)1586 else:1587 offset += self._ptrs_offset1588 if p == 0:1589 return None1590 obj = Type.__new__(Type)1591 obj._init_from_pointer(self._seg, offset, p)1592 return obj1593 1594 def get_elementType(self):1595 res = self.elementType1596 if res is None:1597 return Type.from_buffer(b'', 0, data_size=0, ptrs_size=0)1598 return res1599 1600 def has_elementType(self):1601 ptr = self._read_fast_ptr(0)1602 return ptr != 01603 1604 def shortrepr(self):1605 parts = []1606 if self.has_elementType(): parts.append("elementType = %s" % self.get_elementType().shortrepr())1607 return "(%s)" % ", ".join(parts)1608_Type_list_list_item_type = _StructItemType(Type_list)1609@Type_enum.__extend__1610class Type_enum(_Struct):1611 __capnpy_id__ = 0x9e0e78711a7f87a91612 __static_data_size__ = 31613 __static_ptrs_size__ = 11614 1615 1616 @property1617 def typeId(self):1618 # no union check1619 value = self._read_primitive(8, ord(b'Q'))1620 if 0 != 0:1621 value = value ^ 01622 return value1623 1624 @property1625 def brand(self):1626 # no union check1627 offset = 01628 p = self._read_fast_ptr(offset)1629 if _ptr.kind(p) == _ptr.FAR:1630 offset, p = self._read_far_ptr(offset)1631 else:1632 offset += self._ptrs_offset1633 if p == 0:1634 return None1635 obj = Brand.__new__(Brand)1636 obj._init_from_pointer(self._seg, offset, p)1637 return obj1638 1639 def get_brand(self):1640 res = self.brand1641 if res is None:1642 return Brand.from_buffer(b'', 0, data_size=0, ptrs_size=0)1643 return res1644 1645 def has_brand(self):1646 ptr = self._read_fast_ptr(0)1647 return ptr != 01648 1649 def shortrepr(self):1650 parts = []1651 parts.append("typeId = %s" % self.typeId)1652 if self.has_brand(): parts.append("brand = %s" % self.get_brand().shortrepr())1653 return "(%s)" % ", ".join(parts)1654_Type_enum_list_item_type = _StructItemType(Type_enum)1655@Type_struct.__extend__1656class Type_struct(_Struct):1657 __capnpy_id__ = 0xac3a6f60ef4cc6d31658 __static_data_size__ = 31659 __static_ptrs_size__ = 11660 1661 1662 @property1663 def typeId(self):1664 # no union check1665 value = self._read_primitive(8, ord(b'Q'))1666 if 0 != 0:1667 value = value ^ 01668 return value1669 1670 @property1671 def brand(self):1672 # no union check1673 offset = 01674 p = self._read_fast_ptr(offset)1675 if _ptr.kind(p) == _ptr.FAR:1676 offset, p = self._read_far_ptr(offset)1677 else:1678 offset += self._ptrs_offset1679 if p == 0:1680 return None1681 obj = Brand.__new__(Brand)1682 obj._init_from_pointer(self._seg, offset, p)1683 return obj1684 1685 def get_brand(self):1686 res = self.brand1687 if res is None:1688 return Brand.from_buffer(b'', 0, data_size=0, ptrs_size=0)1689 return res1690 1691 def has_brand(self):1692 ptr = self._read_fast_ptr(0)1693 return ptr != 01694 1695 def shortrepr(self):1696 parts = []1697 parts.append("typeId = %s" % self.typeId)1698 if self.has_brand(): parts.append("brand = %s" % self.get_brand().shortrepr())1699 return "(%s)" % ", ".join(parts)1700_Type_struct_list_item_type = _StructItemType(Type_struct)1701@Type_interface.__extend__1702class Type_interface(_Struct):1703 __capnpy_id__ = 0xed8bca69f7fb0cbf1704 __static_data_size__ = 31705 __static_ptrs_size__ = 11706 1707 1708 @property1709 def typeId(self):1710 # no union check1711 value = self._read_primitive(8, ord(b'Q'))1712 if 0 != 0:1713 value = value ^ 01714 return value1715 1716 @property1717 def brand(self):1718 # no union check1719 offset = 01720 p = self._read_fast_ptr(offset)1721 if _ptr.kind(p) == _ptr.FAR:1722 offset, p = self._read_far_ptr(offset)1723 else:1724 offset += self._ptrs_offset1725 if p == 0:1726 return None1727 obj = Brand.__new__(Brand)1728 obj._init_from_pointer(self._seg, offset, p)1729 return obj1730 1731 def get_brand(self):1732 res = self.brand1733 if res is None:1734 return Brand.from_buffer(b'', 0, data_size=0, ptrs_size=0)1735 return res1736 1737 def has_brand(self):1738 ptr = self._read_fast_ptr(0)1739 return ptr != 01740 1741 def shortrepr(self):1742 parts = []1743 parts.append("typeId = %s" % self.typeId)1744 if self.has_brand(): parts.append("brand = %s" % self.get_brand().shortrepr())1745 return "(%s)" % ", ".join(parts)1746_Type_interface_list_item_type = _StructItemType(Type_interface)1747@Type_anyPointer_unconstrained.__extend__1748class Type_anyPointer_unconstrained(_Struct):1749 __capnpy_id__ = 0x8e3b5f79fe5936561750 __static_data_size__ = 31751 __static_ptrs_size__ = 11752 1753 1754 __tag__ = Type_anyPointer_unconstrained__tag__1755 __tag_offset__ = 101756 1757 def is_anyKind(self):1758 return self._read_int16(10) == 01759 def is_struct(self):1760 return self._read_int16(10) == 11761 def is_list(self):1762 return self._read_int16(10) == 21763 def is_capability(self):1764 return self._read_int16(10) == 31765 1766 @property1767 def anyKind(self):1768 self._ensure_union(0)1769 return None1770 1771 @property1772 def struct(self):1773 self._ensure_union(1)1774 return None1775 1776 @property1777 def list(self):1778 self._ensure_union(2)1779 return None1780 1781 @property1782 def capability(self):1783 self._ensure_union(3)1784 return None1785 1786 def shortrepr(self):1787 parts = []1788 if self.is_anyKind(): parts.append("anyKind = %s" % "void")1789 if self.is_struct(): parts.append("struct = %s" % "void")1790 if self.is_list(): parts.append("list = %s" % "void")1791 if self.is_capability(): parts.append("capability = %s" % "void")1792 return "(%s)" % ", ".join(parts)1793_Type_anyPointer_unconstrained_list_item_type = _StructItemType(Type_anyPointer_unconstrained)1794@Type_anyPointer_parameter.__extend__1795class Type_anyPointer_parameter(_Struct):1796 __capnpy_id__ = 0x9dd1f724f4614a851797 __static_data_size__ = 31798 __static_ptrs_size__ = 11799 1800 1801 @property1802 def scopeId(self):1803 # no union check1804 value = self._read_primitive(16, ord(b'Q'))1805 if 0 != 0:1806 value = value ^ 01807 return value1808 1809 @property1810 def parameterIndex(self):1811 # no union check1812 value = self._read_primitive(10, ord(b'H'))1813 if 0 != 0:1814 value = value ^ 01815 return value1816 1817 def shortrepr(self):1818 parts = []1819 parts.append("scopeId = %s" % self.scopeId)1820 parts.append("parameterIndex = %s" % self.parameterIndex)1821 return "(%s)" % ", ".join(parts)1822_Type_anyPointer_parameter_list_item_type = _StructItemType(Type_anyPointer_parameter)1823@Type_anyPointer_implicitMethodParameter.__extend__1824class Type_anyPointer_implicitMethodParameter(_Struct):1825 __capnpy_id__ = 0xbaefc9120c56e2741826 __static_data_size__ = 31827 __static_ptrs_size__ = 11828 1829 1830 @property1831 def parameterIndex(self):1832 # no union check1833 value = self._read_primitive(10, ord(b'H'))1834 if 0 != 0:1835 value = value ^ 01836 return value1837 1838 def shortrepr(self):1839 parts = []1840 parts.append("parameterIndex = %s" % self.parameterIndex)1841 return "(%s)" % ", ".join(parts)1842_Type_anyPointer_implicitMethodParameter_list_item_type = _StructItemType(Type_anyPointer_implicitMethodParameter)1843@Type_anyPointer.__extend__1844class Type_anyPointer(_Struct):1845 __capnpy_id__ = 0xc2573fe8a23e49f11846 __static_data_size__ = 31847 __static_ptrs_size__ = 11848 1849 1850 __tag__ = Type_anyPointer__tag__1851 __tag_offset__ = 81852 1853 def is_unconstrained(self):1854 return self._read_int16(8) == 01855 def is_parameter(self):1856 return self._read_int16(8) == 11857 def is_implicitMethodParameter(self):1858 return self._read_int16(8) == 21859 1860 @property1861 def unconstrained(self):1862 self._ensure_union(0)1863 obj = Type_anyPointer_unconstrained.__new__(Type_anyPointer_unconstrained)1864 _Struct._init_from_buffer(obj, self._seg, self._data_offset,1865 self._data_size, self._ptrs_size)1866 return obj1867 1868 @staticmethod1869 def Unconstrained(anyKind=_undefined, struct=_undefined, list=_undefined, capability=_undefined):1870 return anyKind, struct, list, capability,1871 1872 @property1873 def parameter(self):1874 self._ensure_union(1)1875 obj = Type_anyPointer_parameter.__new__(Type_anyPointer_parameter)1876 _Struct._init_from_buffer(obj, self._seg, self._data_offset,1877 self._data_size, self._ptrs_size)1878 return obj1879 1880 @staticmethod1881 def Parameter(scopeId=0, parameterIndex=0):1882 return scopeId, parameterIndex,1883 1884 @property1885 def implicitMethodParameter(self):1886 self._ensure_union(2)1887 obj = Type_anyPointer_implicitMethodParameter.__new__(Type_anyPointer_implicitMethodParameter)1888 _Struct._init_from_buffer(obj, self._seg, self._data_offset,1889 self._data_size, self._ptrs_size)1890 return obj1891 1892 @staticmethod1893 def Implicitmethodparameter(parameterIndex=0):1894 return parameterIndex,1895 1896 def shortrepr(self):1897 parts = []1898 if self.is_unconstrained(): parts.append("unconstrained = %s" % self.unconstrained.shortrepr())1899 if self.is_parameter(): parts.append("parameter = %s" % self.parameter.shortrepr())1900 if self.is_implicitMethodParameter(): parts.append("implicitMethodParameter = %s" % self.implicitMethodParameter.shortrepr())1901 return "(%s)" % ", ".join(parts)1902_Type_anyPointer_list_item_type = _StructItemType(Type_anyPointer)1903@Type.__extend__1904class Type(_Struct):1905 __capnpy_id__ = 0xd07378ede1f9cc601906 __static_data_size__ = 31907 __static_ptrs_size__ = 11908 1909 1910 __tag__ = Type__tag__1911 __tag_offset__ = 01912 1913 def is_void(self):1914 return self._read_int16(0) == 01915 def is_bool(self):1916 return self._read_int16(0) == 11917 def is_int8(self):1918 return self._read_int16(0) == 21919 def is_int16(self):1920 return self._read_int16(0) == 31921 def is_int32(self):1922 return self._read_int16(0) == 41923 def is_int64(self):1924 return self._read_int16(0) == 51925 def is_uint8(self):1926 return self._read_int16(0) == 61927 def is_uint16(self):1928 return self._read_int16(0) == 71929 def is_uint32(self):1930 return self._read_int16(0) == 81931 def is_uint64(self):1932 return self._read_int16(0) == 91933 def is_float32(self):1934 return self._read_int16(0) == 101935 def is_float64(self):1936 return self._read_int16(0) == 111937 def is_text(self):1938 return self._read_int16(0) == 121939 def is_data(self):1940 return self._read_int16(0) == 131941 def is_list(self):1942 return self._read_int16(0) == 141943 def is_enum(self):1944 return self._read_int16(0) == 151945 def is_struct(self):1946 return self._read_int16(0) == 161947 def is_interface(self):1948 return self._read_int16(0) == 171949 def is_anyPointer(self):1950 return self._read_int16(0) == 181951 1952 @property1953 def void(self):1954 self._ensure_union(0)1955 return None1956 1957 @property1958 def bool(self):1959 self._ensure_union(1)1960 return None1961 1962 @property1963 def int8(self):1964 self._ensure_union(2)1965 return None1966 1967 @property1968 def int16(self):1969 self._ensure_union(3)1970 return None1971 1972 @property1973 def int32(self):1974 self._ensure_union(4)1975 return None1976 1977 @property1978 def int64(self):1979 self._ensure_union(5)1980 return None1981 1982 @property1983 def uint8(self):1984 self._ensure_union(6)1985 return None1986 1987 @property1988 def uint16(self):1989 self._ensure_union(7)1990 return None1991 1992 @property1993 def uint32(self):1994 self._ensure_union(8)1995 return None1996 1997 @property1998 def uint64(self):1999 self._ensure_union(9)2000 return None2001 2002 @property2003 def float32(self):2004 self._ensure_union(10)2005 return None2006 2007 @property2008 def float64(self):2009 self._ensure_union(11)2010 return None2011 2012 @property2013 def text(self):2014 self._ensure_union(12)2015 return None2016 2017 @property2018 def data(self):2019 self._ensure_union(13)2020 return None2021 2022 @property2023 def list(self):2024 self._ensure_union(14)2025 obj = Type_list.__new__(Type_list)2026 _Struct._init_from_buffer(obj, self._seg, self._data_offset,2027 self._data_size, self._ptrs_size)2028 return obj2029 2030 @staticmethod2031 def List(elementType=None):2032 return elementType,2033 2034 @property2035 def enum(self):2036 self._ensure_union(15)2037 obj = Type_enum.__new__(Type_enum)2038 _Struct._init_from_buffer(obj, self._seg, self._data_offset,2039 self._data_size, self._ptrs_size)2040 return obj2041 2042 @staticmethod2043 def Enum(typeId=0, brand=None):2044 return typeId, brand,2045 2046 @property2047 def struct(self):2048 self._ensure_union(16)2049 obj = Type_struct.__new__(Type_struct)2050 _Struct._init_from_buffer(obj, self._seg, self._data_offset,2051 self._data_size, self._ptrs_size)2052 return obj2053 2054 @staticmethod2055 def Struct(typeId=0, brand=None):2056 return typeId, brand,2057 2058 @property2059 def interface(self):2060 self._ensure_union(17)2061 obj = Type_interface.__new__(Type_interface)2062 _Struct._init_from_buffer(obj, self._seg, self._data_offset,2063 self._data_size, self._ptrs_size)2064 return obj2065 2066 @staticmethod2067 def Interface(typeId=0, brand=None):2068 return typeId, brand,2069 2070 @property2071 def anyPointer(self):2072 self._ensure_union(18)2073 obj = Type_anyPointer.__new__(Type_anyPointer)2074 _Struct._init_from_buffer(obj, self._seg, self._data_offset,2075 self._data_size, self._ptrs_size)2076 return obj2077 2078 @staticmethod2079 def Anypointer(unconstrained=_undefined, parameter=_undefined, implicitMethodParameter=_undefined):2080 return unconstrained, parameter, implicitMethodParameter,2081 2082 @staticmethod2083 def __new(void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined):2084 builder = _SegmentBuilder()2085 pos = builder.allocate(32)2086 anonymous__curtag = None2087 anyPointer__curtag = None2088 anyPointer_unconstrained__curtag = None2089 if void is not _undefined:2090 anonymous__curtag = _check_tag(anonymous__curtag, 'void')2091 builder.write_int16(0, 0)2092 if bool is not _undefined:2093 anonymous__curtag = _check_tag(anonymous__curtag, 'bool')2094 builder.write_int16(0, 1)2095 if int8 is not _undefined:2096 anonymous__curtag = _check_tag(anonymous__curtag, 'int8')2097 builder.write_int16(0, 2)2098 if int16 is not _undefined:2099 anonymous__curtag = _check_tag(anonymous__curtag, 'int16')2100 builder.write_int16(0, 3)2101 if int32 is not _undefined:2102 anonymous__curtag = _check_tag(anonymous__curtag, 'int32')2103 builder.write_int16(0, 4)2104 if int64 is not _undefined:2105 anonymous__curtag = _check_tag(anonymous__curtag, 'int64')2106 builder.write_int16(0, 5)2107 if uint8 is not _undefined:2108 anonymous__curtag = _check_tag(anonymous__curtag, 'uint8')2109 builder.write_int16(0, 6)2110 if uint16 is not _undefined:2111 anonymous__curtag = _check_tag(anonymous__curtag, 'uint16')2112 builder.write_int16(0, 7)2113 if uint32 is not _undefined:2114 anonymous__curtag = _check_tag(anonymous__curtag, 'uint32')2115 builder.write_int16(0, 8)2116 if uint64 is not _undefined:2117 anonymous__curtag = _check_tag(anonymous__curtag, 'uint64')2118 builder.write_int16(0, 9)2119 if float32 is not _undefined:2120 anonymous__curtag = _check_tag(anonymous__curtag, 'float32')2121 builder.write_int16(0, 10)2122 if float64 is not _undefined:2123 anonymous__curtag = _check_tag(anonymous__curtag, 'float64')2124 builder.write_int16(0, 11)2125 if text is not _undefined:2126 anonymous__curtag = _check_tag(anonymous__curtag, 'text')2127 builder.write_int16(0, 12)2128 if data is not _undefined:2129 anonymous__curtag = _check_tag(anonymous__curtag, 'data')2130 builder.write_int16(0, 13)2131 if list is not _undefined:2132 anonymous__curtag = _check_tag(anonymous__curtag, 'list')2133 builder.write_int16(0, 14)2134 list_elementType, = list2135 builder.copy_from_struct(pos + 24, Type, list_elementType)2136 if enum is not _undefined:2137 anonymous__curtag = _check_tag(anonymous__curtag, 'enum')2138 builder.write_int16(0, 15)2139 enum_typeId, enum_brand, = enum2140 builder.write_uint64(pos + 8, enum_typeId)2141 builder.copy_from_struct(pos + 24, Brand, enum_brand)2142 if struct is not _undefined:2143 anonymous__curtag = _check_tag(anonymous__curtag, 'struct')2144 builder.write_int16(0, 16)2145 struct_typeId, struct_brand, = struct2146 builder.write_uint64(pos + 8, struct_typeId)2147 builder.copy_from_struct(pos + 24, Brand, struct_brand)2148 if interface is not _undefined:2149 anonymous__curtag = _check_tag(anonymous__curtag, 'interface')2150 builder.write_int16(0, 17)2151 interface_typeId, interface_brand, = interface2152 builder.write_uint64(pos + 8, interface_typeId)2153 builder.copy_from_struct(pos + 24, Brand, interface_brand)2154 if anyPointer is not _undefined:2155 anonymous__curtag = _check_tag(anonymous__curtag, 'anyPointer')2156 builder.write_int16(0, 18)2157 anyPointer_unconstrained, anyPointer_parameter, anyPointer_implicitMethodParameter, = anyPointer2158 if anyPointer_unconstrained is not _undefined:2159 anyPointer__curtag = _check_tag(anyPointer__curtag, 'unconstrained')2160 builder.write_int16(8, 0)2161 anyPointer_unconstrained_anyKind, anyPointer_unconstrained_struct, anyPointer_unconstrained_list, anyPointer_unconstrained_capability, = anyPointer_unconstrained2162 if anyPointer_unconstrained_anyKind is not _undefined:2163 anyPointer_unconstrained__curtag = _check_tag(anyPointer_unconstrained__curtag, 'anyKind')2164 builder.write_int16(10, 0)2165 if anyPointer_unconstrained_struct is not _undefined:2166 anyPointer_unconstrained__curtag = _check_tag(anyPointer_unconstrained__curtag, 'struct')2167 builder.write_int16(10, 1)2168 if anyPointer_unconstrained_list is not _undefined:2169 anyPointer_unconstrained__curtag = _check_tag(anyPointer_unconstrained__curtag, 'list')2170 builder.write_int16(10, 2)2171 if anyPointer_unconstrained_capability is not _undefined:2172 anyPointer_unconstrained__curtag = _check_tag(anyPointer_unconstrained__curtag, 'capability')2173 builder.write_int16(10, 3)2174 if anyPointer_parameter is not _undefined:2175 anyPointer__curtag = _check_tag(anyPointer__curtag, 'parameter')2176 builder.write_int16(8, 1)2177 anyPointer_parameter_scopeId, anyPointer_parameter_parameterIndex, = anyPointer_parameter2178 builder.write_uint64(pos + 16, anyPointer_parameter_scopeId)2179 builder.write_uint16(pos + 10, anyPointer_parameter_parameterIndex)2180 if anyPointer_implicitMethodParameter is not _undefined:2181 anyPointer__curtag = _check_tag(anyPointer__curtag, 'implicitMethodParameter')2182 builder.write_int16(8, 2)2183 anyPointer_implicitMethodParameter_parameterIndex, = anyPointer_implicitMethodParameter2184 builder.write_uint16(pos + 10, anyPointer_implicitMethodParameter_parameterIndex)2185 return builder.as_string()2186 2187 def __init__(self, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined):2188 _buf = Type.__new(void, bool, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float32, float64, text, data, list, enum, struct, interface, anyPointer)2189 self._init_from_buffer(_buf, 0, 3, 1)2190 2191 @classmethod2192 def new_void(cls, void=None):2193 buf = Type.__new(void=void, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2194 return cls.from_buffer(buf, 0, 3, 1)2195 2196 @classmethod2197 def new_bool(cls, bool=None):2198 buf = Type.__new(bool=bool, void=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2199 return cls.from_buffer(buf, 0, 3, 1)2200 2201 @classmethod2202 def new_int8(cls, int8=None):2203 buf = Type.__new(int8=int8, void=_undefined, bool=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2204 return cls.from_buffer(buf, 0, 3, 1)2205 2206 @classmethod2207 def new_int16(cls, int16=None):2208 buf = Type.__new(int16=int16, void=_undefined, bool=_undefined, int8=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2209 return cls.from_buffer(buf, 0, 3, 1)2210 2211 @classmethod2212 def new_int32(cls, int32=None):2213 buf = Type.__new(int32=int32, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2214 return cls.from_buffer(buf, 0, 3, 1)2215 2216 @classmethod2217 def new_int64(cls, int64=None):2218 buf = Type.__new(int64=int64, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2219 return cls.from_buffer(buf, 0, 3, 1)2220 2221 @classmethod2222 def new_uint8(cls, uint8=None):2223 buf = Type.__new(uint8=uint8, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2224 return cls.from_buffer(buf, 0, 3, 1)2225 2226 @classmethod2227 def new_uint16(cls, uint16=None):2228 buf = Type.__new(uint16=uint16, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2229 return cls.from_buffer(buf, 0, 3, 1)2230 2231 @classmethod2232 def new_uint32(cls, uint32=None):2233 buf = Type.__new(uint32=uint32, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2234 return cls.from_buffer(buf, 0, 3, 1)2235 2236 @classmethod2237 def new_uint64(cls, uint64=None):2238 buf = Type.__new(uint64=uint64, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2239 return cls.from_buffer(buf, 0, 3, 1)2240 2241 @classmethod2242 def new_float32(cls, float32=None):2243 buf = Type.__new(float32=float32, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2244 return cls.from_buffer(buf, 0, 3, 1)2245 2246 @classmethod2247 def new_float64(cls, float64=None):2248 buf = Type.__new(float64=float64, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2249 return cls.from_buffer(buf, 0, 3, 1)2250 2251 @classmethod2252 def new_text(cls, text=None):2253 buf = Type.__new(text=text, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2254 return cls.from_buffer(buf, 0, 3, 1)2255 2256 @classmethod2257 def new_data(cls, data=None):2258 buf = Type.__new(data=data, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2259 return cls.from_buffer(buf, 0, 3, 1)2260 2261 @classmethod2262 def new_list(cls, list=(None,)):2263 buf = Type.__new(list=list, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2264 return cls.from_buffer(buf, 0, 3, 1)2265 2266 @classmethod2267 def new_enum(cls, enum=(0, None,)):2268 buf = Type.__new(enum=enum, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2269 return cls.from_buffer(buf, 0, 3, 1)2270 2271 @classmethod2272 def new_struct(cls, struct=(0, None,)):2273 buf = Type.__new(struct=struct, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, interface=_undefined, anyPointer=_undefined)2274 return cls.from_buffer(buf, 0, 3, 1)2275 2276 @classmethod2277 def new_interface(cls, interface=(0, None,)):2278 buf = Type.__new(interface=interface, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, anyPointer=_undefined)2279 return cls.from_buffer(buf, 0, 3, 1)2280 2281 @classmethod2282 def new_anyPointer(cls, anyPointer=(_undefined, _undefined, _undefined,)):2283 buf = Type.__new(anyPointer=anyPointer, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined)2284 return cls.from_buffer(buf, 0, 3, 1)2285 2286 def shortrepr(self):2287 parts = []2288 if self.is_void(): parts.append("void = %s" % "void")2289 if self.is_bool(): parts.append("bool = %s" % "void")2290 if self.is_int8(): parts.append("int8 = %s" % "void")2291 if self.is_int16(): parts.append("int16 = %s" % "void")2292 if self.is_int32(): parts.append("int32 = %s" % "void")2293 if self.is_int64(): parts.append("int64 = %s" % "void")2294 if self.is_uint8(): parts.append("uint8 = %s" % "void")2295 if self.is_uint16(): parts.append("uint16 = %s" % "void")2296 if self.is_uint32(): parts.append("uint32 = %s" % "void")2297 if self.is_uint64(): parts.append("uint64 = %s" % "void")2298 if self.is_float32(): parts.append("float32 = %s" % "void")2299 if self.is_float64(): parts.append("float64 = %s" % "void")2300 if self.is_text(): parts.append("text = %s" % "void")2301 if self.is_data(): parts.append("data = %s" % "void")2302 if self.is_list(): parts.append("list = %s" % self.list.shortrepr())2303 if self.is_enum(): parts.append("enum = %s" % self.enum.shortrepr())2304 if self.is_struct(): parts.append("struct = %s" % self.struct.shortrepr())2305 if self.is_interface(): parts.append("interface = %s" % self.interface.shortrepr())2306 if self.is_anyPointer(): parts.append("anyPointer = %s" % self.anyPointer.shortrepr())2307 return "(%s)" % ", ".join(parts)2308_Type_list_item_type = _StructItemType(Type)2309@Value.__extend__2310class Value(_Struct):2311 __capnpy_id__ = 0xce23dcd2d7b00c9b2312 __static_data_size__ = 22313 __static_ptrs_size__ = 12314 2315 2316 __tag__ = Value__tag__2317 __tag_offset__ = 02318 2319 def is_void(self):2320 return self._read_int16(0) == 02321 def is_bool(self):2322 return self._read_int16(0) == 12323 def is_int8(self):2324 return self._read_int16(0) == 22325 def is_int16(self):2326 return self._read_int16(0) == 32327 def is_int32(self):2328 return self._read_int16(0) == 42329 def is_int64(self):2330 return self._read_int16(0) == 52331 def is_uint8(self):2332 return self._read_int16(0) == 62333 def is_uint16(self):2334 return self._read_int16(0) == 72335 def is_uint32(self):2336 return self._read_int16(0) == 82337 def is_uint64(self):2338 return self._read_int16(0) == 92339 def is_float32(self):2340 return self._read_int16(0) == 102341 def is_float64(self):2342 return self._read_int16(0) == 112343 def is_text(self):2344 return self._read_int16(0) == 122345 def is_data(self):2346 return self._read_int16(0) == 132347 def is_list(self):2348 return self._read_int16(0) == 142349 def is_enum(self):2350 return self._read_int16(0) == 152351 def is_struct(self):2352 return self._read_int16(0) == 162353 def is_interface(self):2354 return self._read_int16(0) == 172355 def is_anyPointer(self):2356 return self._read_int16(0) == 182357 2358 @property2359 def void(self):2360 self._ensure_union(0)2361 return None2362 2363 @property2364 def bool(self):2365 self._ensure_union(1)2366 value = self._read_bit(2, 1)2367 if False != 0:2368 value = value ^ False2369 return value2370 2371 @property2372 def int8(self):2373 self._ensure_union(2)2374 value = self._read_primitive(2, ord(b'b'))2375 if 0 != 0:2376 value = value ^ 02377 return value2378 2379 @property2380 def int16(self):2381 self._ensure_union(3)2382 value = self._read_primitive(2, ord(b'h'))2383 if 0 != 0:2384 value = value ^ 02385 return value2386 2387 @property2388 def int32(self):2389 self._ensure_union(4)2390 value = self._read_primitive(4, ord(b'i'))2391 if 0 != 0:2392 value = value ^ 02393 return value2394 2395 @property2396 def int64(self):2397 self._ensure_union(5)2398 value = self._read_primitive(8, ord(b'q'))2399 if 0 != 0:2400 value = value ^ 02401 return value2402 2403 @property2404 def uint8(self):2405 self._ensure_union(6)2406 value = self._read_primitive(2, ord(b'B'))2407 if 0 != 0:2408 value = value ^ 02409 return value2410 2411 @property2412 def uint16(self):2413 self._ensure_union(7)2414 value = self._read_primitive(2, ord(b'H'))2415 if 0 != 0:2416 value = value ^ 02417 return value2418 2419 @property2420 def uint32(self):2421 self._ensure_union(8)2422 value = self._read_primitive(4, ord(b'I'))2423 if 0 != 0:2424 value = value ^ 02425 return value2426 2427 @property2428 def uint64(self):2429 self._ensure_union(9)2430 value = self._read_primitive(8, ord(b'Q'))2431 if 0 != 0:2432 value = value ^ 02433 return value2434 2435 @property2436 def float32(self):2437 self._ensure_union(10)2438 value = self._read_primitive(4, ord(b'f'))2439 if 0.0 != 0:2440 value = value ^ 0.02441 return value2442 2443 @property2444 def float64(self):2445 self._ensure_union(11)2446 value = self._read_primitive(8, ord(b'd'))2447 if 0.0 != 0:2448 value = value ^ 0.02449 return value2450 2451 @property2452 def text(self):2453 self._ensure_union(12)2454 return self._read_text_bytes(0)2455 2456 def get_text(self):2457 return self._read_text_bytes(0, default_=b"")2458 2459 def has_text(self):2460 ptr = self._read_fast_ptr(0)2461 return ptr != 02462 2463 @property2464 def data(self):2465 self._ensure_union(13)2466 return self._read_data(0)2467 2468 def get_data(self):2469 return self._read_data(0, default_=b"")2470 2471 def has_data(self):2472 ptr = self._read_fast_ptr(0)2473 return ptr != 02474 2475 @property2476 def list(self):2477 self._ensure_union(14)2478 if not self.has_list():2479 return None2480 return _AnyPointer(self, 0)2481 2482 def has_list(self):2483 ptr = self._read_fast_ptr(0)2484 return ptr != 02485 2486 @property2487 def enum(self):2488 self._ensure_union(15)2489 value = self._read_primitive(2, ord(b'H'))2490 if 0 != 0:2491 value = value ^ 02492 return value2493 2494 @property2495 def struct(self):2496 self._ensure_union(16)2497 if not self.has_struct():2498 return None2499 return _AnyPointer(self, 0)2500 2501 def has_struct(self):2502 ptr = self._read_fast_ptr(0)2503 return ptr != 02504 2505 @property2506 def interface(self):2507 self._ensure_union(17)2508 return None2509 2510 @property2511 def anyPointer(self):2512 self._ensure_union(18)2513 if not self.has_anyPointer():2514 return None2515 return _AnyPointer(self, 0)2516 2517 def has_anyPointer(self):2518 ptr = self._read_fast_ptr(0)2519 return ptr != 02520 2521 @staticmethod2522 def __new(void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined):2523 builder = _SegmentBuilder()2524 pos = builder.allocate(24)2525 anonymous__curtag = None2526 if void is not _undefined:2527 anonymous__curtag = _check_tag(anonymous__curtag, 'void')2528 builder.write_int16(0, 0)2529 if bool is not _undefined:2530 anonymous__curtag = _check_tag(anonymous__curtag, 'bool')2531 builder.write_int16(0, 1)2532 builder.write_bool(2, 0, bool)2533 if int8 is not _undefined:2534 anonymous__curtag = _check_tag(anonymous__curtag, 'int8')2535 builder.write_int16(0, 2)2536 builder.write_int8(pos + 2, int8)2537 if int16 is not _undefined:2538 anonymous__curtag = _check_tag(anonymous__curtag, 'int16')2539 builder.write_int16(0, 3)2540 builder.write_int16(pos + 2, int16)2541 if int32 is not _undefined:2542 anonymous__curtag = _check_tag(anonymous__curtag, 'int32')2543 builder.write_int16(0, 4)2544 builder.write_int32(pos + 4, int32)2545 if int64 is not _undefined:2546 anonymous__curtag = _check_tag(anonymous__curtag, 'int64')2547 builder.write_int16(0, 5)2548 builder.write_int64(pos + 8, int64)2549 if uint8 is not _undefined:2550 anonymous__curtag = _check_tag(anonymous__curtag, 'uint8')2551 builder.write_int16(0, 6)2552 builder.write_uint8(pos + 2, uint8)2553 if uint16 is not _undefined:2554 anonymous__curtag = _check_tag(anonymous__curtag, 'uint16')2555 builder.write_int16(0, 7)2556 builder.write_uint16(pos + 2, uint16)2557 if uint32 is not _undefined:2558 anonymous__curtag = _check_tag(anonymous__curtag, 'uint32')2559 builder.write_int16(0, 8)2560 builder.write_uint32(pos + 4, uint32)2561 if uint64 is not _undefined:2562 anonymous__curtag = _check_tag(anonymous__curtag, 'uint64')2563 builder.write_int16(0, 9)2564 builder.write_uint64(pos + 8, uint64)2565 if float32 is not _undefined:2566 anonymous__curtag = _check_tag(anonymous__curtag, 'float32')2567 builder.write_int16(0, 10)2568 builder.write_float32(pos + 4, float32)2569 if float64 is not _undefined:2570 anonymous__curtag = _check_tag(anonymous__curtag, 'float64')2571 builder.write_int16(0, 11)2572 builder.write_float64(pos + 8, float64)2573 if text is not _undefined:2574 anonymous__curtag = _check_tag(anonymous__curtag, 'text')2575 builder.write_int16(0, 12)2576 builder.alloc_text(pos + 16, text)2577 if data is not _undefined:2578 anonymous__curtag = _check_tag(anonymous__curtag, 'data')2579 builder.write_int16(0, 13)2580 builder.alloc_data(pos + 16, data)2581 if list is not _undefined:2582 anonymous__curtag = _check_tag(anonymous__curtag, 'list')2583 builder.write_int16(0, 14)2584 raise NotImplementedError('Unsupported field type: (name = "list", codeOrder = 14, discriminantValue = 14, slot = (offset = 0, type = (anyPointer = (unconstrained = (anyKind = void))), defaultValue = (anyPointer = ???), hadExplicitDefault = false), ordinal = (explicit = 14))')2585 if enum is not _undefined:2586 anonymous__curtag = _check_tag(anonymous__curtag, 'enum')2587 builder.write_int16(0, 15)2588 builder.write_uint16(pos + 2, enum)2589 if struct is not _undefined:2590 anonymous__curtag = _check_tag(anonymous__curtag, 'struct')2591 builder.write_int16(0, 16)2592 raise NotImplementedError('Unsupported field type: (name = "struct", codeOrder = 16, discriminantValue = 16, slot = (offset = 0, type = (anyPointer = (unconstrained = (anyKind = void))), defaultValue = (anyPointer = ???), hadExplicitDefault = false), ordinal = (explicit = 16))')2593 if interface is not _undefined:2594 anonymous__curtag = _check_tag(anonymous__curtag, 'interface')2595 builder.write_int16(0, 17)2596 if anyPointer is not _undefined:2597 anonymous__curtag = _check_tag(anonymous__curtag, 'anyPointer')2598 builder.write_int16(0, 18)2599 raise NotImplementedError('Unsupported field type: (name = "anyPointer", codeOrder = 18, discriminantValue = 18, slot = (offset = 0, type = (anyPointer = (unconstrained = (anyKind = void))), defaultValue = (anyPointer = ???), hadExplicitDefault = false), ordinal = (explicit = 18))')2600 return builder.as_string()2601 2602 def __init__(self, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined):2603 _buf = Value.__new(void, bool, int8, int16, int32, int64, uint8, uint16, uint32, uint64, float32, float64, text, data, list, enum, struct, interface, anyPointer)2604 self._init_from_buffer(_buf, 0, 2, 1)2605 2606 @classmethod2607 def new_void(cls, void=None):2608 buf = Value.__new(void=void, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2609 return cls.from_buffer(buf, 0, 2, 1)2610 2611 @classmethod2612 def new_bool(cls, bool=False):2613 buf = Value.__new(bool=bool, void=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2614 return cls.from_buffer(buf, 0, 2, 1)2615 2616 @classmethod2617 def new_int8(cls, int8=0):2618 buf = Value.__new(int8=int8, void=_undefined, bool=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2619 return cls.from_buffer(buf, 0, 2, 1)2620 2621 @classmethod2622 def new_int16(cls, int16=0):2623 buf = Value.__new(int16=int16, void=_undefined, bool=_undefined, int8=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2624 return cls.from_buffer(buf, 0, 2, 1)2625 2626 @classmethod2627 def new_int32(cls, int32=0):2628 buf = Value.__new(int32=int32, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2629 return cls.from_buffer(buf, 0, 2, 1)2630 2631 @classmethod2632 def new_int64(cls, int64=0):2633 buf = Value.__new(int64=int64, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2634 return cls.from_buffer(buf, 0, 2, 1)2635 2636 @classmethod2637 def new_uint8(cls, uint8=0):2638 buf = Value.__new(uint8=uint8, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2639 return cls.from_buffer(buf, 0, 2, 1)2640 2641 @classmethod2642 def new_uint16(cls, uint16=0):2643 buf = Value.__new(uint16=uint16, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2644 return cls.from_buffer(buf, 0, 2, 1)2645 2646 @classmethod2647 def new_uint32(cls, uint32=0):2648 buf = Value.__new(uint32=uint32, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2649 return cls.from_buffer(buf, 0, 2, 1)2650 2651 @classmethod2652 def new_uint64(cls, uint64=0):2653 buf = Value.__new(uint64=uint64, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2654 return cls.from_buffer(buf, 0, 2, 1)2655 2656 @classmethod2657 def new_float32(cls, float32=0.0):2658 buf = Value.__new(float32=float32, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2659 return cls.from_buffer(buf, 0, 2, 1)2660 2661 @classmethod2662 def new_float64(cls, float64=0.0):2663 buf = Value.__new(float64=float64, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2664 return cls.from_buffer(buf, 0, 2, 1)2665 2666 @classmethod2667 def new_text(cls, text=None):2668 buf = Value.__new(text=text, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2669 return cls.from_buffer(buf, 0, 2, 1)2670 2671 @classmethod2672 def new_data(cls, data=None):2673 buf = Value.__new(data=data, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2674 return cls.from_buffer(buf, 0, 2, 1)2675 2676 @classmethod2677 def new_list(cls, list=None):2678 buf = Value.__new(list=list, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, enum=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2679 return cls.from_buffer(buf, 0, 2, 1)2680 2681 @classmethod2682 def new_enum(cls, enum=0):2683 buf = Value.__new(enum=enum, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, struct=_undefined, interface=_undefined, anyPointer=_undefined)2684 return cls.from_buffer(buf, 0, 2, 1)2685 2686 @classmethod2687 def new_struct(cls, struct=None):2688 buf = Value.__new(struct=struct, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, interface=_undefined, anyPointer=_undefined)2689 return cls.from_buffer(buf, 0, 2, 1)2690 2691 @classmethod2692 def new_interface(cls, interface=None):2693 buf = Value.__new(interface=interface, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, anyPointer=_undefined)2694 return cls.from_buffer(buf, 0, 2, 1)2695 2696 @classmethod2697 def new_anyPointer(cls, anyPointer=None):2698 buf = Value.__new(anyPointer=anyPointer, void=_undefined, bool=_undefined, int8=_undefined, int16=_undefined, int32=_undefined, int64=_undefined, uint8=_undefined, uint16=_undefined, uint32=_undefined, uint64=_undefined, float32=_undefined, float64=_undefined, text=_undefined, data=_undefined, list=_undefined, enum=_undefined, struct=_undefined, interface=_undefined)2699 return cls.from_buffer(buf, 0, 2, 1)2700 2701 def shortrepr(self):2702 parts = []2703 if self.is_void(): parts.append("void = %s" % "void")2704 if self.is_bool(): parts.append("bool = %s" % str(self.bool).lower())2705 if self.is_int8(): parts.append("int8 = %s" % self.int8)2706 if self.is_int16(): parts.append("int16 = %s" % self.int16)2707 if self.is_int32(): parts.append("int32 = %s" % self.int32)2708 if self.is_int64(): parts.append("int64 = %s" % self.int64)2709 if self.is_uint8(): parts.append("uint8 = %s" % self.uint8)2710 if self.is_uint16(): parts.append("uint16 = %s" % self.uint16)2711 if self.is_uint32(): parts.append("uint32 = %s" % self.uint32)2712 if self.is_uint64(): parts.append("uint64 = %s" % self.uint64)2713 if self.is_float32(): parts.append("float32 = %s" % _float32_repr(self.float32))2714 if self.is_float64(): parts.append("float64 = %s" % _float64_repr(self.float64))2715 if self.is_text() and (self.has_text() or2716 not False):2717 parts.append("text = %s" % _text_bytes_repr(self.get_text()))2718 if self.is_data() and (self.has_data() or2719 not False):2720 parts.append("data = %s" % _text_bytes_repr(self.get_data()))2721 if self.is_list() and (self.has_list() or2722 not False):2723 parts.append("list = %s" % "???")2724 if self.is_enum(): parts.append("enum = %s" % self.enum)2725 if self.is_struct() and (self.has_struct() or2726 not False):2727 parts.append("struct = %s" % "???")2728 if self.is_interface(): parts.append("interface = %s" % "void")2729 if self.is_anyPointer() and (self.has_anyPointer() or2730 not False):2731 parts.append("anyPointer = %s" % "???")2732 return "(%s)" % ", ".join(parts)2733_Value_list_item_type = _StructItemType(Value)2734@Annotation.__extend__2735class Annotation(_Struct):2736 __capnpy_id__ = 0xf1c8950dab2575422737 __static_data_size__ = 12738 __static_ptrs_size__ = 22739 2740 2741 @property2742 def id(self):2743 # no union check2744 value = self._read_primitive(0, ord(b'Q'))2745 if 0 != 0:2746 value = value ^ 02747 return value2748 2749 @property2750 def value(self):2751 # no union check2752 offset = 02753 p = self._read_fast_ptr(offset)2754 if _ptr.kind(p) == _ptr.FAR:2755 offset, p = self._read_far_ptr(offset)2756 else:2757 offset += self._ptrs_offset2758 if p == 0:2759 return None2760 obj = Value.__new__(Value)2761 obj._init_from_pointer(self._seg, offset, p)2762 return obj2763 2764 def get_value(self):2765 res = self.value2766 if res is None:2767 return Value.from_buffer(b'', 0, data_size=0, ptrs_size=0)2768 return res2769 2770 def has_value(self):2771 ptr = self._read_fast_ptr(0)2772 return ptr != 02773 2774 @property2775 def brand(self):2776 # no union check2777 offset = 82778 p = self._read_fast_ptr(offset)2779 if _ptr.kind(p) == _ptr.FAR:2780 offset, p = self._read_far_ptr(offset)2781 else:2782 offset += self._ptrs_offset2783 if p == 0:2784 return None2785 obj = Brand.__new__(Brand)2786 obj._init_from_pointer(self._seg, offset, p)2787 return obj2788 2789 def get_brand(self):2790 res = self.brand2791 if res is None:2792 return Brand.from_buffer(b'', 0, data_size=0, ptrs_size=0)2793 return res2794 2795 def has_brand(self):2796 ptr = self._read_fast_ptr(8)2797 return ptr != 02798 2799 @staticmethod2800 def __new(id=0, value=None, brand=None):2801 builder = _SegmentBuilder()2802 pos = builder.allocate(24)2803 builder.write_uint64(pos + 0, id)2804 builder.copy_from_struct(pos + 8, Value, value)2805 builder.copy_from_struct(pos + 16, Brand, brand)2806 return builder.as_string()2807 2808 def __init__(self, id=0, value=None, brand=None):2809 _buf = Annotation.__new(id, value, brand)2810 self._init_from_buffer(_buf, 0, 1, 2)2811 2812 def shortrepr(self):2813 parts = []2814 parts.append("id = %s" % self.id)2815 if self.has_value(): parts.append("value = %s" % self.get_value().shortrepr())2816 if self.has_brand(): parts.append("brand = %s" % self.get_brand().shortrepr())2817 return "(%s)" % ", ".join(parts)2818_Annotation_list_item_type = _StructItemType(Annotation)2819@Brand_Scope.__extend__2820class Brand_Scope(_Struct):2821 __capnpy_id__ = 0xabd73485a9636bc92822 __static_data_size__ = 22823 __static_ptrs_size__ = 12824 2825 2826 __tag__ = Brand_Scope__tag__2827 __tag_offset__ = 82828 2829 def is_bind(self):2830 return self._read_int16(8) == 02831 def is_inherit(self):2832 return self._read_int16(8) == 12833 2834 @property2835 def scopeId(self):2836 # no union check2837 value = self._read_primitive(0, ord(b'Q'))2838 if 0 != 0:2839 value = value ^ 02840 return value2841 2842 @property2843 def bind(self):2844 self._ensure_union(0)2845 return self._read_list(0, _Brand_Binding_list_item_type)2846 2847 def get_bind(self):2848 res = self.bind2849 if res is None:2850 return _List.from_buffer(b'', 0, 0, 0, _Brand_Binding_list_item_type)2851 return res2852 2853 def has_bind(self):2854 ptr = self._read_fast_ptr(0)2855 return ptr != 02856 2857 @property2858 def inherit(self):2859 self._ensure_union(1)2860 return None2861 2862 @staticmethod2863 def __new(scopeId=0, bind=_undefined, inherit=_undefined):2864 builder = _SegmentBuilder()2865 pos = builder.allocate(24)2866 anonymous__curtag = None2867 builder.write_uint64(pos + 0, scopeId)2868 if bind is not _undefined:2869 anonymous__curtag = _check_tag(anonymous__curtag, 'bind')2870 builder.write_int16(8, 0)2871 builder.copy_from_list(pos + 16, _Brand_Binding_list_item_type, bind)2872 if inherit is not _undefined:2873 anonymous__curtag = _check_tag(anonymous__curtag, 'inherit')2874 builder.write_int16(8, 1)2875 return builder.as_string()2876 2877 def __init__(self, scopeId=0, bind=_undefined, inherit=_undefined):2878 _buf = Brand_Scope.__new(scopeId, bind, inherit)2879 self._init_from_buffer(_buf, 0, 2, 1)2880 2881 @classmethod2882 def new_bind(cls, scopeId=0, bind=None):2883 buf = Brand_Scope.__new(scopeId=scopeId, bind=bind, inherit=_undefined)2884 return cls.from_buffer(buf, 0, 2, 1)2885 2886 @classmethod2887 def new_inherit(cls, scopeId=0, inherit=None):2888 buf = Brand_Scope.__new(scopeId=scopeId, inherit=inherit, bind=_undefined)2889 return cls.from_buffer(buf, 0, 2, 1)2890 2891 def shortrepr(self):2892 parts = []2893 parts.append("scopeId = %s" % self.scopeId)2894 if self.is_bind() and (self.has_bind() or2895 not True):2896 parts.append("bind = %s" % self.get_bind().shortrepr())2897 if self.is_inherit(): parts.append("inherit = %s" % "void")2898 return "(%s)" % ", ".join(parts)2899_Brand_Scope_list_item_type = _StructItemType(Brand_Scope)2900@Brand_Binding.__extend__2901class Brand_Binding(_Struct):2902 __capnpy_id__ = 0xc863cd16969ee7fc2903 __static_data_size__ = 12904 __static_ptrs_size__ = 12905 2906 2907 __tag__ = Brand_Binding__tag__2908 __tag_offset__ = 02909 2910 def is_unbound(self):2911 return self._read_int16(0) == 02912 def is_type(self):2913 return self._read_int16(0) == 12914 2915 @property2916 def unbound(self):2917 self._ensure_union(0)2918 return None2919 2920 @property2921 def type(self):2922 self._ensure_union(1)2923 offset = 02924 p = self._read_fast_ptr(offset)2925 if _ptr.kind(p) == _ptr.FAR:2926 offset, p = self._read_far_ptr(offset)2927 else:2928 offset += self._ptrs_offset2929 if p == 0:2930 return None2931 obj = Type.__new__(Type)2932 obj._init_from_pointer(self._seg, offset, p)2933 return obj2934 2935 def get_type(self):2936 res = self.type2937 if res is None:2938 return Type.from_buffer(b'', 0, data_size=0, ptrs_size=0)2939 return res2940 2941 def has_type(self):2942 ptr = self._read_fast_ptr(0)2943 return ptr != 02944 2945 @staticmethod2946 def __new(unbound=_undefined, type=_undefined):2947 builder = _SegmentBuilder()2948 pos = builder.allocate(16)2949 anonymous__curtag = None2950 if unbound is not _undefined:2951 anonymous__curtag = _check_tag(anonymous__curtag, 'unbound')2952 builder.write_int16(0, 0)2953 if type is not _undefined:2954 anonymous__curtag = _check_tag(anonymous__curtag, 'type')2955 builder.write_int16(0, 1)2956 builder.copy_from_struct(pos + 8, Type, type)2957 return builder.as_string()2958 2959 def __init__(self, unbound=_undefined, type=_undefined):2960 _buf = Brand_Binding.__new(unbound, type)2961 self._init_from_buffer(_buf, 0, 1, 1)2962 2963 @classmethod2964 def new_unbound(cls, unbound=None):2965 buf = Brand_Binding.__new(unbound=unbound, type=_undefined)2966 return cls.from_buffer(buf, 0, 1, 1)2967 2968 @classmethod2969 def new_type(cls, type=None):2970 buf = Brand_Binding.__new(type=type, unbound=_undefined)2971 return cls.from_buffer(buf, 0, 1, 1)2972 2973 def shortrepr(self):2974 parts = []2975 if self.is_unbound(): parts.append("unbound = %s" % "void")2976 if self.is_type() and (self.has_type() or2977 not False):2978 parts.append("type = %s" % self.get_type().shortrepr())2979 return "(%s)" % ", ".join(parts)2980_Brand_Binding_list_item_type = _StructItemType(Brand_Binding)2981@Brand.__extend__2982class Brand(_Struct):2983 __capnpy_id__ = 0x903455f06065422b2984 __static_data_size__ = 02985 __static_ptrs_size__ = 12986 2987 Scope = Brand_Scope2988 Binding = Brand_Binding2989 2990 @property2991 def scopes(self):2992 # no union check2993 return self._read_list(0, _Brand_Scope_list_item_type)2994 2995 def get_scopes(self):2996 res = self.scopes2997 if res is None:2998 return _List.from_buffer(b'', 0, 0, 0, _Brand_Scope_list_item_type)2999 return res3000 3001 def has_scopes(self):3002 ptr = self._read_fast_ptr(0)3003 return ptr != 03004 3005 @staticmethod3006 def __new(scopes=None):3007 builder = _SegmentBuilder()3008 pos = builder.allocate(8)3009 builder.copy_from_list(pos + 0, _Brand_Scope_list_item_type, scopes)3010 return builder.as_string()3011 3012 def __init__(self, scopes=None):3013 _buf = Brand.__new(scopes)3014 self._init_from_buffer(_buf, 0, 0, 1)3015 3016 def shortrepr(self):3017 parts = []3018 if self.has_scopes(): parts.append("scopes = %s" % self.get_scopes().shortrepr())3019 return "(%s)" % ", ".join(parts)3020_Brand_list_item_type = _StructItemType(Brand)3021@CapnpVersion.__extend__3022class CapnpVersion(_Struct):3023 __capnpy_id__ = 0xd85d305b7d8399633024 __static_data_size__ = 13025 __static_ptrs_size__ = 03026 3027 3028 @property3029 def major(self):3030 # no union check3031 value = self._read_primitive(0, ord(b'H'))3032 if 0 != 0:3033 value = value ^ 03034 return value3035 3036 @property3037 def minor(self):3038 # no union check3039 value = self._read_primitive(2, ord(b'B'))3040 if 0 != 0:3041 value = value ^ 03042 return value3043 3044 @property3045 def micro(self):3046 # no union check3047 value = self._read_primitive(3, ord(b'B'))3048 if 0 != 0:3049 value = value ^ 03050 return value3051 3052 @staticmethod3053 def __new(major=0, minor=0, micro=0):3054 builder = _SegmentBuilder()3055 pos = builder.allocate(8)3056 builder.write_uint16(pos + 0, major)3057 builder.write_uint8(pos + 2, minor)3058 builder.write_uint8(pos + 3, micro)3059 return builder.as_string()3060 3061 def __init__(self, major=0, minor=0, micro=0):3062 _buf = CapnpVersion.__new(major, minor, micro)3063 self._init_from_buffer(_buf, 0, 1, 0)3064 3065 def shortrepr(self):3066 parts = []3067 parts.append("major = %s" % self.major)3068 parts.append("minor = %s" % self.minor)3069 parts.append("micro = %s" % self.micro)3070 return "(%s)" % ", ".join(parts)3071_CapnpVersion_list_item_type = _StructItemType(CapnpVersion)3072@CodeGeneratorRequest_RequestedFile_Import.__extend__3073class CodeGeneratorRequest_RequestedFile_Import(_Struct):3074 __capnpy_id__ = 0xae504193122357e53075 __static_data_size__ = 13076 __static_ptrs_size__ = 13077 3078 3079 @property3080 def id(self):3081 # no union check3082 value = self._read_primitive(0, ord(b'Q'))3083 if 0 != 0:3084 value = value ^ 03085 return value3086 3087 @property3088 def name(self):3089 # no union check3090 return self._read_text_bytes(0)3091 3092 def get_name(self):3093 return self._read_text_bytes(0, default_=b"")3094 3095 def has_name(self):3096 ptr = self._read_fast_ptr(0)3097 return ptr != 03098 3099 @staticmethod3100 def __new(id=0, name=None):3101 builder = _SegmentBuilder()3102 pos = builder.allocate(16)3103 builder.write_uint64(pos + 0, id)3104 builder.alloc_text(pos + 8, name)3105 return builder.as_string()3106 3107 def __init__(self, id=0, name=None):3108 _buf = CodeGeneratorRequest_RequestedFile_Import.__new(id, name)3109 self._init_from_buffer(_buf, 0, 1, 1)3110 3111 def shortrepr(self):3112 parts = []3113 parts.append("id = %s" % self.id)3114 if self.has_name(): parts.append("name = %s" % _text_bytes_repr(self.get_name()))3115 return "(%s)" % ", ".join(parts)3116_CodeGeneratorRequest_RequestedFile_Import_list_item_type = _StructItemType(CodeGeneratorRequest_RequestedFile_Import)3117@CodeGeneratorRequest_RequestedFile.__extend__3118class CodeGeneratorRequest_RequestedFile(_Struct):3119 __capnpy_id__ = 0xcfea0eb02e8100623120 __static_data_size__ = 13121 __static_ptrs_size__ = 23122 3123 Import = CodeGeneratorRequest_RequestedFile_Import3124 3125 @property3126 def id(self):3127 # no union check3128 value = self._read_primitive(0, ord(b'Q'))3129 if 0 != 0:3130 value = value ^ 03131 return value3132 3133 @property3134 def filename(self):3135 # no union check3136 return self._read_text_bytes(0)3137 3138 def get_filename(self):3139 return self._read_text_bytes(0, default_=b"")3140 3141 def has_filename(self):3142 ptr = self._read_fast_ptr(0)3143 return ptr != 03144 3145 @property3146 def imports(self):3147 # no union check3148 return self._read_list(8, _CodeGeneratorRequest_RequestedFile_Import_list_item_type)3149 3150 def get_imports(self):3151 res = self.imports3152 if res is None:3153 return _List.from_buffer(b'', 0, 0, 0, _CodeGeneratorRequest_RequestedFile_Import_list_item_type)3154 return res3155 3156 def has_imports(self):3157 ptr = self._read_fast_ptr(8)3158 return ptr != 03159 3160 @staticmethod3161 def __new(id=0, filename=None, imports=None):3162 builder = _SegmentBuilder()3163 pos = builder.allocate(24)3164 builder.write_uint64(pos + 0, id)3165 builder.alloc_text(pos + 8, filename)3166 builder.copy_from_list(pos + 16, _CodeGeneratorRequest_RequestedFile_Import_list_item_type, imports)3167 return builder.as_string()3168 3169 def __init__(self, id=0, filename=None, imports=None):3170 _buf = CodeGeneratorRequest_RequestedFile.__new(id, filename, imports)3171 self._init_from_buffer(_buf, 0, 1, 2)3172 3173 def shortrepr(self):3174 parts = []3175 parts.append("id = %s" % self.id)3176 if self.has_filename(): parts.append("filename = %s" % _text_bytes_repr(self.get_filename()))3177 if self.has_imports(): parts.append("imports = %s" % self.get_imports().shortrepr())3178 return "(%s)" % ", ".join(parts)3179_CodeGeneratorRequest_RequestedFile_list_item_type = _StructItemType(CodeGeneratorRequest_RequestedFile)3180@CodeGeneratorRequest.__extend__3181class CodeGeneratorRequest(_Struct):3182 __capnpy_id__ = 0xbfc546f6210ad7ce3183 __static_data_size__ = 03184 __static_ptrs_size__ = 43185 3186 RequestedFile = CodeGeneratorRequest_RequestedFile3187 3188 @property3189 def nodes(self):3190 # no union check3191 return self._read_list(0, _Node_list_item_type)3192 3193 def get_nodes(self):3194 res = self.nodes3195 if res is None:3196 return _List.from_buffer(b'', 0, 0, 0, _Node_list_item_type)3197 return res3198 3199 def has_nodes(self):3200 ptr = self._read_fast_ptr(0)3201 return ptr != 03202 3203 @property3204 def requestedFiles(self):3205 # no union check3206 return self._read_list(8, _CodeGeneratorRequest_RequestedFile_list_item_type)3207 3208 def get_requestedFiles(self):3209 res = self.requestedFiles3210 if res is None:3211 return _List.from_buffer(b'', 0, 0, 0, _CodeGeneratorRequest_RequestedFile_list_item_type)3212 return res3213 3214 def has_requestedFiles(self):3215 ptr = self._read_fast_ptr(8)3216 return ptr != 03217 3218 @property3219 def capnpVersion(self):3220 # no union check3221 offset = 163222 p = self._read_fast_ptr(offset)3223 if _ptr.kind(p) == _ptr.FAR:3224 offset, p = self._read_far_ptr(offset)3225 else:3226 offset += self._ptrs_offset3227 if p == 0:3228 return None3229 obj = CapnpVersion.__new__(CapnpVersion)3230 obj._init_from_pointer(self._seg, offset, p)3231 return obj3232 3233 def get_capnpVersion(self):3234 res = self.capnpVersion3235 if res is None:3236 return CapnpVersion.from_buffer(b'', 0, data_size=0, ptrs_size=0)3237 return res3238 3239 def has_capnpVersion(self):3240 ptr = self._read_fast_ptr(16)3241 return ptr != 03242 3243 @property3244 def sourceInfo(self):3245 # no union check3246 return self._read_list(24, _Node_SourceInfo_list_item_type)3247 3248 def get_sourceInfo(self):3249 res = self.sourceInfo3250 if res is None:3251 return _List.from_buffer(b'', 0, 0, 0, _Node_SourceInfo_list_item_type)3252 return res3253 3254 def has_sourceInfo(self):3255 ptr = self._read_fast_ptr(24)3256 return ptr != 03257 3258 @staticmethod3259 def __new(nodes=None, requestedFiles=None, capnpVersion=None, sourceInfo=None):3260 builder = _SegmentBuilder()3261 pos = builder.allocate(32)3262 builder.copy_from_list(pos + 0, _Node_list_item_type, nodes)3263 builder.copy_from_list(pos + 8, _CodeGeneratorRequest_RequestedFile_list_item_type, requestedFiles)3264 builder.copy_from_struct(pos + 16, CapnpVersion, capnpVersion)3265 builder.copy_from_list(pos + 24, _Node_SourceInfo_list_item_type, sourceInfo)3266 return builder.as_string()3267 3268 def __init__(self, nodes=None, requestedFiles=None, capnpVersion=None, sourceInfo=None):3269 _buf = CodeGeneratorRequest.__new(nodes, requestedFiles, capnpVersion, sourceInfo)3270 self._init_from_buffer(_buf, 0, 0, 4)3271 3272 def shortrepr(self):3273 parts = []3274 if self.has_nodes(): parts.append("nodes = %s" % self.get_nodes().shortrepr())3275 if self.has_requestedFiles(): parts.append("requestedFiles = %s" % self.get_requestedFiles().shortrepr())3276 if self.has_capnpVersion(): parts.append("capnpVersion = %s" % self.get_capnpVersion().shortrepr())3277 if self.has_sourceInfo(): parts.append("sourceInfo = %s" % self.get_sourceInfo().shortrepr())3278 return "(%s)" % ", ".join(parts)3279_CodeGeneratorRequest_list_item_type = _StructItemType(CodeGeneratorRequest)...
typingplus.py
Source:typingplus.py
...25import pkg_resources26import six27if 0: # pylint: disable=using-constant-test28 # Assure names exist so typingplus connsumers don't get linting errors.29 class _Undefined(object):30 """A class with the methods expected of objects in this library."""31 def __call__(self, *args, **kwargs):32 """Do nothing."""33 pass34 __getitem__ = __call__35 _UNDEFINED = _Undefined()36 AbstractSet = _UNDEFINED37 Any = _UNDEFINED38 AnyStr = _UNDEFINED39 AsyncContextManager = _UNDEFINED40 AsyncGenerator = _UNDEFINED41 AsyncIterable = _UNDEFINED42 AsyncIterator = _UNDEFINED43 Awaitable = _UNDEFINED44 ByteString = _UNDEFINED45 Callable = _UNDEFINED46 ChainMap = _UNDEFINED47 ClassVar = _UNDEFINED48 Collection = _UNDEFINED49 Container = _UNDEFINED...
itd.py
Source:itd.py
1# Python MPD/iTunes library2# Copyright (C) 2010 Nathan Charles3#4# This program is free software: you can redistribute it and/or modify5# it under the terms of the GNU General Public License as published by6# the Free Software Foundation, either version 3 of the License, or7# (at your option) any later version.8#9# This program is distributed in the hope that it will be useful,10# but WITHOUT ANY WARRANTY; without even the implied warranty of11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12# GNU General Public License for more details.13#14# You should have received a copy of the GNU General Public License15# along with this program. If not, see <http://www.gnu.org/licenses/>.16HELLO_PREFIX = "OK MPD "17ERROR_PREFIX = "ACK "18SUCCESS = "OK"19NEXT = "list_OK"20import appscript21import math22import SocketServer23class iTunesModel(object):24 """This class maps mpd keywords to iTunes applescript calls25 """26 def __init__(self):27 try:28 self.iTunes = appscript.app('iTunes')29 except:30 return -131 def _getstate(self):32 """This is a setup function in case iTunes views have changed and33 current state is undefined34 returns tuple of playlist and track"""35 playlist = ""36 track = ""37 try:38 playlist = self.iTunes.current_playlist()39 track = self.iTunes.current_track()40 except:41 try:42 self.iTunes.play()43 self.iTunes.pause()44 except:45 return -1,-146 return playlist, track47 def undefined():48 """49 playid [SONGID]50 Begins playing the playlist at song SONGID.51 seek {SONGPOS} {TIME}52 Seeks to position TIME (in seconds) of entry SONGPOS in the playlist.53 seekid {SONGID} {TIME}54 Seeks to the position TIME (in seconds) of song SONGID.55 """56 pass57 def play(self, song = -1):58 """59 play [SONGPOS]60 Begins playing the playlist at song number SONGPOS.61 """62 self.iTunes.play()63 #return True64 def pause(self, bool = 1):65 """66 pause {PAUSE}67 Toggles pause/resumes playing, PAUSE is 0 or 1.68 Note69 The use of pause command w/o the PAUSE argument is deprecated.70 """71 self.iTunes.pause()72 #return True73 def next(self):74 """75 Plays next song in the playlist.76 """77 self.iTunes.next_track()78 #return True79 def previous(self):80 """81 Plays previous song in the playlist.82 """83 self.iTunes.previous_track()84 #return True85 86 def stop(self):87 """88 Stops playing.89 """90 self.iTunes.stop()91 #return True92 #STATUS93 def status(self):94 """95 volume: 0-10096 repeat: 0 or 197 single: 0 or 198 consume: 0 or 199 playlist: 31-bit unsigned integer, the playlist version number100 playlistlength: integer, the length of the playlist101 state: play, stop, or pause102 song: playlist song number of the current song stopped on or playing103 songid: playlist songid of the current song stopped on or playing104 nextsong: playlist song number of the next song to be played105 nextsongid: playlist songid of the next song to be played106 time: total time elapsed (of current playing/paused song)107 elapsed: 108 Total time elapsed within the current song, with higher resolution.109 bitrate: instantaneous bitrate in kbps110 xfade: crossfade in seconds111 audio: sampleRate:bits:channels112 updatings_db: job id113 error: if there is an error, returns message here114 volume: -1\nrepeat: 0\nrandom: 0\nsingle: 0\nconsume: 0\nplaylist: 2\nplaylistlength: 0\nxfade: 0\nstate: stop\nlist_OK\nOK\n115 0.15.0116 volume: 100117 repeat: 0118 random: 0119 single: 0120 consume: 0121 playlist: 5122 playlistlength: 3123 xfade: 0124 state: play125 song: 0126 songid: 0127 time: 284:390128 bitrate: 256129 audio: 44100:24:2130 nextsong: 1131 nextsongid: 1132 list_OK133 file: Us vs Us/01 Banner.mp3134 Time: 390135 Artist: Psalters136 Title: Banner137 Album: Us vs Us138 Track: 1/14139 Date: 2004140 Genre: World141 Disc: 1/1142 Pos: 0143 Id: 0144 list_OK145 OK146 """147 cplaylist, ctrack = self._getstate()148 repeat = {appscript.k.off: [0,0],149 appscript.k.one:[1,1],150 appscript.k.all:[1,0]}151 #stopped/playing/paused/fast forwarding/rewinding'152 state = { appscript.k.stopped: "stop",153 appscript.k.playing: "play",154 appscript.k.paused: "pause",155 appscript.k.fast_forwarding: "play",156 appscript.k.rewinding: "play"}157 random = { True : 1,158 False : 0}159 ret = "volume: %s\n" % self.iTunes.sound_volume.get()160 ret += "repeat: %s\n" % repeat[cplaylist.song_repeat.get()][0]161 ret += "random: %s\n" % random[cplaylist.shuffle.get()] 162 ret += "single: %s\n" % repeat[cplaylist.song_repeat.get()][1]163 ret += "consume: %s\n" % "0"164 ret += "playlist: %s\n" % "2" 165 ret += "playlistlength: %s\n" % cplaylist.duration.get() 166 ret += "xfade: %s\n" % "0"167 ret += "state: %s\n" % state[self.iTunes.player_state.get()]168 ret += "song: %s\n" % "1"169 ret += "songid: %s\n" % "1"170 ret += "time: %s:%s\n" % ( self.iTunes.player_position.get(), 171 math.trunc(ctrack.duration.get()))172 ret += "bitrate: %s\n" % "256"173 ret += "audio: %s\n" % "44100:24:2"174 ret += "nextsong: %s\n" % "2"175 ret += "nextsongid: %s\n" % "2"176 return ret177 def stats(self):178 """179 Displays statistics.180 artists: number of artists181 songs: number of albums182 uptime: daemon uptime in seconds183 db_playtime: sum of all song times in the db184 db_update: last db update in UNIX time185 playtime: time length of music played186 """187 pass188 def currentsong(self):189 cplaylist, ctrack = self._getstate()190 ret = "Time: %s\n" % math.trunc(ctrack.duration.get())191 ret += "Album: %s\n" % ctrack.album.get() 192 ret += "Artist: %s\n" % ctrack.artist.get() 193 ret += "Title: %s\n" % self.iTunes.current_track.name.get()194 ret += "Track: %s\n" % self.iTunes.current_track.track_number.get()195 ret += "Pos: %s\n" % self.iTunes.player_position.get()196 return ret197 def plchanges(self, args):198 pass199 def lsinfo(self, args):200 """201 Usage 202 lsinfo [<string directory>]203 Purpose 204 List contents of <string directory>, from the database.205 Arguments206 <string directory>207 """208 pass209 def search(self, args):210 """211 search <string type> <string what>212 search filename bastards_pick_wrong_man213 file: vocal/onion_radio_news/the_onion_radio_news_-_bastards_pick_wrong_man.mp3214 Time: 36215 Artist: Onion Radio News 216 Title: Bastards Pick Wrong Man to Mess With217 Genre: Comedy218 OK219 """220 print args221 cplaylist, ctrack = self._getstate()222 type,what = args.split('" "')223 ret = ""224 query = what.strip().strip('\"')225 #print cplaylist.file_tracks()226 print "query '%s'" % query227 for i in cplaylist.search(for_=query):228 ret += "file: %s/%s.mp3\n" % (i.artist(), i.name())229 #print i.file_track.location()230 ret += "Time: %s\n" % math.trunc(i.duration())231 ret += "Title: %s\n" % i.name()232 ret += "Artist: %s\n" % i.artist()233 ret += "Album: %s\n" % i.album()234 ret += "Track: %s\n" % i.track_number()235 ret += "Date: %s\n" % i.year()236 ret += "Genre: %s\n" % i.genre()237 return ret238 239 #PLAYBACK OPTIONS240 def consume(self, args):241 """242 consume {STATE}243 Sets consume state to STATE, STATE should be 0 or 1. When consume is activated, each song played is removed from playlist.244 """245 pass246 def crossfade(self, args):247 """248 crossfade {SECONDS}249 Sets crossfading between songs.250 """251 pass252 def random(self, args):253 """254 random {STATE}255 Sets random state to STATE, STATE should be 0 or 1.256 song repeat (off/one/all) : playback repeat mode257 """258 pass259 def repeat(self, args):260 """261 repeat {STATE}262 Sets repeat state to STATE, STATE should be 0 or 1.263 song repeat (off/one/all) : playback repeat mode264 """265 cplaylist, ctrack = self._getstate()266 state = { "off":0, "all":1}267 cplaylist.song_repeat.set(state[args])268 def single(self, args):269 """270 single {STATE}271 Sets single state to STATE, STATE should be 0 or 1. When single is 272 activated, playback is stopped after current song, or song is repeated 273 if the 'repeat' mode is enabled.274 """275 cplaylist, ctrack = self._getstate()276 state = { "off":0, "one":1}277 cplaylist.song_repeat.set(state[args])278 def setvol(self, args):279 """280 setvol {VOL}281 Sets volume to VOL, the range of volume is 0-100.282 """283 self.iTunes.sound_volume.set(args)284 def to_code():285 """286 Playback options287 replay_gain_mode {MODE}288 Sets the replay gain mode. One of off, track, album.289 Changing the mode during playback may take several seconds, because 290 the new settings does not affect the buffered data.291 This command triggers the options idle event.292 replay_gain_status293 Prints replay gain options. Currently, only the variable 294 replay_gain_mode is returned.295 """296 pass297class controller(object):298 """This class impliments a controller that parses data into commands and 299 handles executes those commands300 The default backend is iTunes via applescript but something else could be301 implimented.302 """303 def __init__(self, backend = iTunesModel()):304 self.iterate = False305 self.model = backend306 self._commands = {307 # Status Commands308 "clearerror": self._undefined,309 "currentsong": self.model.currentsong,310 "idle": self._undefined,311 "noidle": None,312 "status": self.model.status,313 "stats": self._undefined,314 # Playback Option Commands315 "consume": self._undefined,316 "crossfade": self._undefined,317 "random": self.model.random,318 "repeat": self.model.repeat,319 "setvol": self.model.setvol,320 "single": self.model.single,321 "volume": self._undefined,322 # Playback Control Commands323 "next": self.model.next,324 "pause": self.model.pause,325 "play": self.model.play,326 "playid": self._undefined,327 "previous": self.model.previous,328 "seek": self._undefined,329 "seekid": self._undefined,330 "stop": self._undefined,331 # Playlist Commands332 "add": self._undefined,333 "addid": self._undefined,334 "clear": self._undefined,335 "delete": self._undefined,336 "deleteid": self._undefined,337 "move": self._undefined,338 "moveid": self._undefined,339 "playlist": self._undefined,340 "playlistfind": self._undefined,341 "playlistid": self._undefined,342 "playlistinfo": self._undefined,343 "playlistsearch": self._undefined,344 "plchanges": self.model.plchanges,345 "plchangesposid": self._undefined,346 "shuffle": self._undefined,347 "swap": self._undefined,348 "swapid": self._undefined,349 # Stored Playlist Commands350 "listplaylist": self._undefined,351 "listplaylistinfo": self._undefined,352 "listplaylists": self._undefined,353 "load": self._undefined,354 "playlistadd": self._undefined,355 "playlistclear": self._undefined,356 "playlistdelete": self._undefined,357 "playlistmove": self._undefined,358 "rename": self._undefined,359 "rm": self._undefined,360 "save": self._undefined,361 # Database Commands362 "count": self._undefined,363 "find": self._undefined,364 "list": self._undefined,365 "listall": self._undefined,366 "listallinfo": self._undefined,367 "lsinfo": self._undefined,368 "search": self.model.search,369 "update": self._undefined,370 # Connection Commands371 "close": None,372 "kill": None,373 "password": self._undefined,374 "ping": self._undefined,375 # Audio Output Commands376 "disableoutput": self._undefined,377 "enableoutput": self._undefined,378 "outputs": self._undefined,379 # Reflection Commands380 "commands": self._undefined,381 "notcommands": self._undefined,382 "tagtypes": self._undefined,383 "urlhandlers": self._undefined,384 # stuff385 "command_list_ok_begin": self._undefined,386 "command_list_end": self._undefined,387 }388 def _undefined(self, attr=None):389 print "undefined"390 def _execute(self, command):391 cmd, sep, args = command.partition(' ')392 print "running command: %s" % cmd393 if cmd:394 try:395 if args:396 return self._commands[cmd.strip()](args)397 #return getattr(self.model, cmd.strip())(args)398 else:399 return self._commands[cmd.strip()]()400 #return getattr(self.model, cmd.strip())(args)401 except:402 return self._undefined()403 print "undefined"404 def handle(self, command):405 retval = ''406 if command.find('list_ok') is not -1:407 ListOK = True408 else:409 ListOK = False410 if command.find('command_list') is not -1:411 command_list = command.strip().split('\n')412 print command_list413 for c in command_list:414 if c:415 rc = self._execute(c)416 if rc:417 retval += rc418 if ListOK:419 retval += NEXT + "\n"420 else:421 retval = self._execute(command) 422 if retval:423 return "%sOK\n" % retval424 else:425 return "OK\n"426def escape(text):427 return text.replace("\\", "\\\\").replace('"', '\\"').replace(' ',"_")428class iTDRequestHandler(SocketServer.BaseRequestHandler ):429 """This class provides an interface which impliments the mpd spec430 """431 def setup(self):432 print self.client_address, 'connected!'433 self.request.send('OK MPD ' + version + '\n')434 def handle(self):435 data = 'dummy'436 while data:437 data = self.request.recv(1024)438 print data439 #self.request.send(mpd.command(data))440 ret = mpd.handle(data)441 print ret442 self.request.send(ret)443 def finish(self):444 print self.client_address, 'disconnected!'445def usage():446 pass447if __name__ == "__main__":448 import getopt449 import sys450 opts, args = getopt.getopt(sys.argv[1:], 'dfh')451 if opts:452 for o,a in opts:453 if o == '-h':454 usage()455 sys.exit(1)456 if o == '-d':457 #run in background458 import daemon459 daemon.daemonize()460 if o == '-f':461 #run in forground462 print "Running in Foreground"463 else:464 usage()465 sys.exit(1)466 try:467 version ='0.16.0'468 mpdport = 6600469 mpd = controller()470 server = SocketServer.ThreadingTCPServer(('', mpdport), 471 iTDRequestHandler)472 server.serve_forever()473 except (KeyboardInterrupt, SystemExit):474 sys.exit(1)475 except:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!