How to use load_attributes method in autotest

Best Python code snippet using autotest_python

Parser.py

Source:Parser.py Github

copy

Full Screen

...86 new_element.load(element)87 self.namespaces.append(new_element)88 return True89 return False90 def load_attributes(self, dom_node):91 if dom_node.hasAttribute("project_name"):92 cur_attr = dom_node.getAttribute("project_name")93 self.project_name = cur_attr94 self.project_name_filled = True95 if dom_node.hasAttribute("major_version"):96 cur_attr = dom_node.getAttribute("major_version")97 self.major_version = string_to_int(cur_attr)98 self.major_version_filled = True99 if dom_node.hasAttribute("minor_version"):100 cur_attr = dom_node.getAttribute("minor_version")101 self.minor_version = string_to_int(cur_attr)102 self.minor_version_filled = True103 if dom_node.hasAttribute("patch_version"):104 cur_attr = dom_node.getAttribute("patch_version")105 self.patch_version = string_to_int(cur_attr)106 self.patch_version_filled = True107 if dom_node.hasAttribute("include_once"):108 cur_attr = dom_node.getAttribute("include_once")109 self.include_once = string_to_bool(cur_attr)110 self.include_once_filled = True111 def load(self, dom_node):112 for element in dom_node.childNodes:113 self.load_element(element)114 self.load_attributes(dom_node)115class TNamespace(object):116 def __init__(self):117 self.all_items = []118 self.name = ""119 self.name_filled = False120 self.implementation_header = ""121 self.implementation_header_filled = False122 self.overload_suffix_mode = TOverloadSuffixMode.Notify123 self.overload_suffix_mode_filled = False124 self.generate_tests = True125 self.generate_tests_filled = False126 self.documentations = []127 self.external_namespaces = []128 self.external_libraries = []129 self.includes = []130 self.functions_prologs = []131 self.methods_prologs = []132 self.namespaces = []133 self.include_headers = []134 self.enumerations = []135 self.classes = []136 self.functions = []137 self.templates = []138 self.property_set_prefixes = []139 self.property_get_prefixes = []140 self.property_get_consts = []141 self.mapped_types = []142 def load_element(self, element):143 if element.nodeName == "documentation":144 new_element = TDocumentation()145 new_element.load(element)146 self.documentations.append(new_element)147 return True148 if element.nodeName == "external_namespace":149 new_element = TExternalNamespace()150 new_element.load(element)151 self.external_namespaces.append(new_element)152 return True153 if element.nodeName == "external_library":154 new_element = TExternalLibrary()155 new_element.load(element)156 self.external_libraries.append(new_element)157 return True158 if element.nodeName == "include":159 new_element = TApiInclude()160 new_element.load(element)161 self.includes.append(new_element)162 return True163 if element.nodeName == "functions_prolog":164 new_element = TProlog()165 new_element.load(element)166 self.functions_prologs.append(new_element)167 return True168 if element.nodeName == "methods_prolog":169 new_element = TProlog()170 new_element.load(element)171 self.methods_prologs.append(new_element)172 return True173 if element.nodeName == "namespace":174 new_element = TNamespace()175 new_element.load(element)176 self.namespaces.append(new_element)177 return True178 if element.nodeName == "include_header":179 new_element = THeaderInclude()180 new_element.load(element)181 self.include_headers.append(new_element)182 return True183 if element.nodeName == "enumeration":184 new_element = TEnumeration()185 new_element.load(element)186 self.enumerations.append(new_element)187 return True188 if element.nodeName == "class":189 new_element = TClass()190 new_element.load(element)191 self.classes.append(new_element)192 return True193 if element.nodeName == "function":194 new_element = TFunction()195 new_element.load(element)196 self.functions.append(new_element)197 return True198 if element.nodeName == "template":199 new_element = TTemplate()200 new_element.load(element)201 self.templates.append(new_element)202 return True203 if element.nodeName == "property_set_prefix":204 new_element = TPropertySetPrefix()205 new_element.load(element)206 self.property_set_prefixes.append(new_element)207 return True208 if element.nodeName == "property_get_prefix":209 new_element = TPropertyGetPrefix()210 new_element.load(element)211 self.property_get_prefixes.append(new_element)212 return True213 if element.nodeName == "property_get_const":214 new_element = TPropertyGetConst()215 new_element.load(element)216 self.property_get_consts.append(new_element)217 return True218 if element.nodeName == "mapped_type":219 new_element = TMappedType()220 new_element.load(element)221 self.mapped_types.append(new_element)222 return True223 return False224 def load_attributes(self, dom_node):225 if dom_node.hasAttribute("name"):226 cur_attr = dom_node.getAttribute("name")227 self.name = cur_attr228 self.name_filled = True229 if dom_node.hasAttribute("implementation_header"):230 cur_attr = dom_node.getAttribute("implementation_header")231 self.implementation_header = cur_attr232 self.implementation_header_filled = True233 if dom_node.hasAttribute("overload_suffix_mode"):234 cur_attr = dom_node.getAttribute("overload_suffix_mode")235 self.overload_suffix_mode = TOverloadSuffixMode.load(cur_attr)236 self.overload_suffix_mode_filled = True237 if dom_node.hasAttribute("generate_tests"):238 cur_attr = dom_node.getAttribute("generate_tests")239 self.generate_tests = string_to_bool(cur_attr)240 self.generate_tests_filled = True241 def load(self, dom_node):242 for element in dom_node.childNodes:243 self.load_element(element)244 self.load_attributes(dom_node)245class TGenericDocumentation(object):246 def __init__(self):247 self.all_items = []248 self.references = []249 self.formulas = []250 self.see_alsos = []251 def load_element(self, element):252 if element.nodeName == "reference":253 new_element = TReference()254 new_element.load(element)255 self.references.append(new_element)256 self.all_items.append(new_element)257 return True258 if element.nodeName == "formula":259 new_element = TFormula()260 new_element.load(element)261 self.formulas.append(new_element)262 self.all_items.append(new_element)263 return True264 if element.nodeName == "see_also":265 new_element = TGenericDocumentation()266 new_element.load(element)267 self.see_alsos.append(new_element)268 self.all_items.append(new_element)269 return True270 if element.nodeType == element.TEXT_NODE:271 cur_texts = [text.strip() for text in element.data.split('\n')]272 first = True273 for text in cur_texts:274 if first and self.all_items and type(self.all_items[-1]) is str:275 self.all_items[-1] += text276 else:277 self.all_items.append(text)278 first = False279 return True280 return False281 def load_attributes(self, dom_node):282 pass283 def load(self, dom_node):284 for element in dom_node.childNodes:285 self.load_element(element)286 self.load_attributes(dom_node)287class TDocumentation(TGenericDocumentation):288 def __init__(self):289 super().__init__()290 self.briefs = []291 self.returns = []292 def load_element(self, element):293 if super().load_element(element):294 return True295 if element.nodeName == "brief":296 new_element = TGenericDocumentation()297 new_element.load(element)298 self.briefs.append(new_element)299 self.all_items.append(new_element)300 return True301 if element.nodeName == "returns":302 new_element = TGenericDocumentation()303 new_element.load(element)304 self.returns.append(new_element)305 self.all_items.append(new_element)306 return True307 if element.nodeType == element.TEXT_NODE:308 cur_texts = [text.strip() for text in element.data.split('\n')]309 first = True310 for text in cur_texts:311 if first and self.all_items and type(self.all_items[-1]) is str:312 self.all_items[-1] += text313 else:314 self.all_items.append(text)315 first = False316 return True317 return False318 def load_attributes(self, dom_node):319 super().load_attributes(dom_node)320 def load(self, dom_node):321 for element in dom_node.childNodes:322 self.load_element(element)323 self.load_attributes(dom_node)324class TReference(object):325 def __init__(self):326 self.all_items = []327 def load_element(self, element):328 if element.nodeType == element.TEXT_NODE:329 cur_texts = [text.strip() for text in element.data.split('\n')]330 first = True331 for text in cur_texts:332 if first and self.all_items and type(self.all_items[-1]) is str:333 self.all_items[-1] += text334 else:335 self.all_items.append(text)336 first = False337 return True338 return False339 def load_attributes(self, dom_node):340 pass341 def load(self, dom_node):342 for element in dom_node.childNodes:343 self.load_element(element)344 self.load_attributes(dom_node)345class TFormula(object):346 def __init__(self):347 self.all_items = []348 self.inline = True349 self.inline_filled = False350 def load_element(self, element):351 if element.nodeType == element.TEXT_NODE:352 cur_texts = [text.strip() for text in element.data.split('\n')]353 first = True354 for text in cur_texts:355 if first and self.all_items and type(self.all_items[-1]) is str:356 self.all_items[-1] += text357 else:358 self.all_items.append(text)359 first = False360 return True361 return False362 def load_attributes(self, dom_node):363 if dom_node.hasAttribute("inline"):364 cur_attr = dom_node.getAttribute("inline")365 self.inline = string_to_bool(cur_attr)366 self.inline_filled = True367 def load(self, dom_node):368 for element in dom_node.childNodes:369 self.load_element(element)370 self.load_attributes(dom_node)371class TExternalNamespace(object):372 def __init__(self):373 self.all_items = []374 self.include = ""375 self.include_filled = False376 self.name = ""377 self.name_filled = False378 self.detach_method_name = "Detach"379 self.detach_method_name_filled = False380 self.get_raw_pointer_method_name = "GetRawPointer"381 self.get_raw_pointer_method_name_filled = False382 self.project_name = ""383 self.project_name_filled = False384 self.classes = []385 self.namespaces = []386 self.enumerations = []387 def load_element(self, element):388 if element.nodeName == "class":389 new_element = TExternalClass()390 new_element.load(element)391 self.classes.append(new_element)392 return True393 if element.nodeName == "namespace":394 new_element = TExternalNamespace()395 new_element.load(element)396 self.namespaces.append(new_element)397 return True398 if element.nodeName == "enumeration":399 new_element = TExternalEnumeration()400 new_element.load(element)401 self.enumerations.append(new_element)402 return True403 return False404 def load_attributes(self, dom_node):405 if dom_node.hasAttribute("include"):406 cur_attr = dom_node.getAttribute("include")407 self.include = cur_attr408 self.include_filled = True409 if dom_node.hasAttribute("name"):410 cur_attr = dom_node.getAttribute("name")411 self.name = cur_attr412 self.name_filled = True413 if dom_node.hasAttribute("detach_method_name"):414 cur_attr = dom_node.getAttribute("detach_method_name")415 self.detach_method_name = cur_attr416 self.detach_method_name_filled = True417 if dom_node.hasAttribute("get_raw_pointer_method_name"):418 cur_attr = dom_node.getAttribute("get_raw_pointer_method_name")419 self.get_raw_pointer_method_name = cur_attr420 self.get_raw_pointer_method_name_filled = True421 if dom_node.hasAttribute("project_name"):422 cur_attr = dom_node.getAttribute("project_name")423 self.project_name = cur_attr424 self.project_name_filled = True425 def load(self, dom_node):426 for element in dom_node.childNodes:427 self.load_element(element)428 self.load_attributes(dom_node)429class TExternalClass(object):430 def __init__(self):431 self.all_items = []432 self.name = ""433 self.name_filled = False434 self.wrap_name = ""435 self.wrap_name_filled = False436 self.include_declaration = ""437 self.include_declaration_filled = False438 self.include_definition = ""439 self.include_definition_filled = False440 self.enumerations = []441 def load_element(self, element):442 if element.nodeName == "enumeration":443 new_element = TExternalEnumeration()444 new_element.load(element)445 self.enumerations.append(new_element)446 return True447 return False448 def load_attributes(self, dom_node):449 if dom_node.hasAttribute("name"):450 cur_attr = dom_node.getAttribute("name")451 self.name = cur_attr452 self.name_filled = True453 if dom_node.hasAttribute("wrap_name"):454 cur_attr = dom_node.getAttribute("wrap_name")455 self.wrap_name = cur_attr456 self.wrap_name_filled = True457 if dom_node.hasAttribute("include_declaration"):458 cur_attr = dom_node.getAttribute("include_declaration")459 self.include_declaration = cur_attr460 self.include_declaration_filled = True461 if dom_node.hasAttribute("include_definition"):462 cur_attr = dom_node.getAttribute("include_definition")463 self.include_definition = cur_attr464 self.include_definition_filled = True465 def load(self, dom_node):466 for element in dom_node.childNodes:467 self.load_element(element)468 self.load_attributes(dom_node)469class TExternalLibrary(object):470 def __init__(self):471 self.all_items = []472 self.input_xml_file = ""473 self.input_xml_file_filled = False474 self.params_xml_file = ""475 self.params_xml_file_filled = False476 self.main_header = ""477 self.main_header_filled = False478 self.defines = []479 def load_element(self, element):480 if element.nodeName == "define":481 new_element = TDefine()482 new_element.load(element)483 self.defines.append(new_element)484 return True485 return False486 def load_attributes(self, dom_node):487 if dom_node.hasAttribute("input_xml_file"):488 cur_attr = dom_node.getAttribute("input_xml_file")489 self.input_xml_file = cur_attr490 self.input_xml_file_filled = True491 if dom_node.hasAttribute("params_xml_file"):492 cur_attr = dom_node.getAttribute("params_xml_file")493 self.params_xml_file = cur_attr494 self.params_xml_file_filled = True495 if dom_node.hasAttribute("main_header"):496 cur_attr = dom_node.getAttribute("main_header")497 self.main_header = cur_attr498 self.main_header_filled = True499 def load(self, dom_node):500 for element in dom_node.childNodes:501 self.load_element(element)502 self.load_attributes(dom_node)503class TExternalEnumeration(object):504 def __init__(self):505 self.all_items = []506 self.name = ""507 self.name_filled = False508 self.underlying_type = ""509 self.underlying_type_filled = False510 def load_element(self, element):511 return False512 def load_attributes(self, dom_node):513 if dom_node.hasAttribute("name"):514 cur_attr = dom_node.getAttribute("name")515 self.name = cur_attr516 self.name_filled = True517 if dom_node.hasAttribute("underlying_type"):518 cur_attr = dom_node.getAttribute("underlying_type")519 self.underlying_type = cur_attr520 self.underlying_type_filled = True521 def load(self, dom_node):522 for element in dom_node.childNodes:523 self.load_element(element)524 self.load_attributes(dom_node)525class TApiInclude(object):526 def __init__(self):527 self.all_items = []528 self.path = ""529 self.path_filled = False530 self.use_content_without_root_namespaces = False531 self.use_content_without_root_namespaces_filled = False532 def load_element(self, element):533 return False534 def load_attributes(self, dom_node):535 if dom_node.hasAttribute("path"):536 cur_attr = dom_node.getAttribute("path")537 self.path = cur_attr538 self.path_filled = True539 if dom_node.hasAttribute("use_content_without_root_namespaces"):540 cur_attr = dom_node.getAttribute("use_content_without_root_namespaces")541 self.use_content_without_root_namespaces = string_to_bool(cur_attr)542 self.use_content_without_root_namespaces_filled = True543 def load(self, dom_node):544 for element in dom_node.childNodes:545 self.load_element(element)546 self.load_attributes(dom_node)547class TEnumerationItem(object):548 def __init__(self):549 self.all_items = []550 self.name = ""551 self.name_filled = False552 self.value = ""553 self.value_filled = False554 self.implementation_name = ""555 self.implementation_name_filled = False556 self.documentations = []557 def load_element(self, element):558 if element.nodeName == "documentation":559 new_element = TGenericDocumentation()560 new_element.load(element)561 self.documentations.append(new_element)562 return True563 return False564 def load_attributes(self, dom_node):565 if dom_node.hasAttribute("name"):566 cur_attr = dom_node.getAttribute("name")567 self.name = cur_attr568 self.name_filled = True569 if dom_node.hasAttribute("value"):570 cur_attr = dom_node.getAttribute("value")571 self.value = cur_attr572 self.value_filled = True573 if dom_node.hasAttribute("implementation_name"):574 cur_attr = dom_node.getAttribute("implementation_name")575 self.implementation_name = cur_attr576 self.implementation_name_filled = True577 def load(self, dom_node):578 for element in dom_node.childNodes:579 self.load_element(element)580 self.load_attributes(dom_node)581class TEnumeration(object):582 def __init__(self):583 self.all_items = []584 self.name = ""585 self.name_filled = False586 self.underlying_type = ""587 self.underlying_type_filled = False588 self.use_strong_implementation_enum = False589 self.use_strong_implementation_enum_filled = False590 self.implementation_type = ""591 self.implementation_type_filled = False592 self.implementation_header = ""593 self.implementation_header_filled = False594 self.documentations = []595 self.items = []596 def load_element(self, element):597 if element.nodeName == "documentation":598 new_element = TDocumentation()599 new_element.load(element)600 self.documentations.append(new_element)601 return True602 if element.nodeName == "item":603 new_element = TEnumerationItem()604 new_element.load(element)605 self.items.append(new_element)606 return True607 return False608 def load_attributes(self, dom_node):609 if dom_node.hasAttribute("name"):610 cur_attr = dom_node.getAttribute("name")611 self.name = cur_attr612 self.name_filled = True613 if dom_node.hasAttribute("underlying_type"):614 cur_attr = dom_node.getAttribute("underlying_type")615 self.underlying_type = cur_attr616 self.underlying_type_filled = True617 if dom_node.hasAttribute("use_strong_implementation_enum"):618 cur_attr = dom_node.getAttribute("use_strong_implementation_enum")619 self.use_strong_implementation_enum = string_to_bool(cur_attr)620 self.use_strong_implementation_enum_filled = True621 if dom_node.hasAttribute("implementation_type"):622 cur_attr = dom_node.getAttribute("implementation_type")623 self.implementation_type = cur_attr624 self.implementation_type_filled = True625 if dom_node.hasAttribute("implementation_header"):626 cur_attr = dom_node.getAttribute("implementation_header")627 self.implementation_header = cur_attr628 self.implementation_header_filled = True629 def load(self, dom_node):630 for element in dom_node.childNodes:631 self.load_element(element)632 self.load_attributes(dom_node)633class TTemplate(object):634 def __init__(self):635 self.all_items = []636 self.wrap_csharp_templates = True637 self.wrap_csharp_templates_filled = False638 self.arguments = []639 self.instantiations = []640 self.classes = []641 def load_element(self, element):642 if element.nodeName == "argument":643 new_element = TArgument()644 new_element.load(element)645 self.arguments.append(new_element)646 return True647 if element.nodeName == "instantiation":648 new_element = TInstantiation()649 new_element.load(element)650 self.instantiations.append(new_element)651 return True652 if element.nodeName == "class":653 new_element = TClass()654 new_element.load(element)655 self.classes.append(new_element)656 return True657 return False658 def load_attributes(self, dom_node):659 if dom_node.hasAttribute("wrap_csharp_templates"):660 cur_attr = dom_node.getAttribute("wrap_csharp_templates")661 self.wrap_csharp_templates = string_to_bool(cur_attr)662 self.wrap_csharp_templates_filled = True663 def load(self, dom_node):664 for element in dom_node.childNodes:665 self.load_element(element)666 self.load_attributes(dom_node)667class TInstantiation(object):668 def __init__(self):669 self.all_items = []670 self.typedef_name = ""671 self.typedef_name_filled = False672 self.implementation_class_name = ""673 self.implementation_class_name_filled = False674 self.documentations = []675 self.arguments = []676 def load_element(self, element):677 if element.nodeName == "documentation":678 new_element = TDocumentation()679 new_element.load(element)680 self.documentations.append(new_element)681 return True682 if element.nodeName == "argument":683 new_element = TInstantiationArgument()684 new_element.load(element)685 self.arguments.append(new_element)686 return True687 return False688 def load_attributes(self, dom_node):689 if dom_node.hasAttribute("typedef_name"):690 cur_attr = dom_node.getAttribute("typedef_name")691 self.typedef_name = cur_attr692 self.typedef_name_filled = True693 if dom_node.hasAttribute("implementation_class_name"):694 cur_attr = dom_node.getAttribute("implementation_class_name")695 self.implementation_class_name = cur_attr696 self.implementation_class_name_filled = True697 def load(self, dom_node):698 for element in dom_node.childNodes:699 self.load_element(element)700 self.load_attributes(dom_node)701class TInstantiationArgument(object):702 def __init__(self):703 self.all_items = []704 self.name = ""705 self.name_filled = False706 self.value = ""707 self.value_filled = False708 def load_element(self, element):709 return False710 def load_attributes(self, dom_node):711 if dom_node.hasAttribute("name"):712 cur_attr = dom_node.getAttribute("name")713 self.name = cur_attr714 self.name_filled = True715 if dom_node.hasAttribute("value"):716 cur_attr = dom_node.getAttribute("value")717 self.value = cur_attr718 self.value_filled = True719 def load(self, dom_node):720 for element in dom_node.childNodes:721 self.load_element(element)722 self.load_attributes(dom_node)723class TTypedef(object):724 def __init__(self):725 self.all_items = []726 self.name = ""727 self.name_filled = False728 self.type_name = ""729 self.type_name_filled = False730 self.documentations = []731 def load_element(self, element):732 if element.nodeName == "documentation":733 new_element = TGenericDocumentation()734 new_element.load(element)735 self.documentations.append(new_element)736 return True737 return False738 def load_attributes(self, dom_node):739 if dom_node.hasAttribute("name"):740 cur_attr = dom_node.getAttribute("name")741 self.name = cur_attr742 self.name_filled = True743 if dom_node.hasAttribute("type"):744 cur_attr = dom_node.getAttribute("type")745 self.type_name = cur_attr746 self.type_name_filled = True747 def load(self, dom_node):748 for element in dom_node.childNodes:749 self.load_element(element)750 self.load_attributes(dom_node)751class TConstant(object):752 def __init__(self):753 self.all_items = []754 self.name = ""755 self.name_filled = False756 self.type_name = ""757 self.type_name_filled = False758 self.is_builtin = False759 self.is_builtin_filled = False760 self.value = ""761 self.value_filled = False762 self.documentations = []763 def load_element(self, element):764 if element.nodeName == "documentation":765 new_element = TGenericDocumentation()766 new_element.load(element)767 self.documentations.append(new_element)768 return True769 return False770 def load_attributes(self, dom_node):771 if dom_node.hasAttribute("name"):772 cur_attr = dom_node.getAttribute("name")773 self.name = cur_attr774 self.name_filled = True775 if dom_node.hasAttribute("type"):776 cur_attr = dom_node.getAttribute("type")777 self.type_name = cur_attr778 self.type_name_filled = True779 if dom_node.hasAttribute("is_builtin"):780 cur_attr = dom_node.getAttribute("is_builtin")781 self.is_builtin = string_to_bool(cur_attr)782 self.is_builtin_filled = True783 if dom_node.hasAttribute("value"):784 cur_attr = dom_node.getAttribute("value")785 self.value = cur_attr786 self.value_filled = True787 def load(self, dom_node):788 for element in dom_node.childNodes:789 self.load_element(element)790 self.load_attributes(dom_node)791class TClass(object):792 def __init__(self):793 self.all_items = []794 self.name = ""795 self.name_filled = False796 self.base = ""797 self.base_filled = False798 self.implementation_class_name = ""799 self.implementation_class_name_filled = False800 self.snippet_type = ""801 self.snippet_type_filled = False802 self.abstract = False803 self.abstract_filled = False804 self.implementation_class_header = ""805 self.implementation_class_header_filled = False806 self.lifecycle = TLifecycle.reference_counted807 self.lifecycle_filled = False808 self.requires_cast_to_base = False809 self.requires_cast_to_base_filled = False810 self.pointer_access = False811 self.pointer_access_filled = False812 self.exception = False813 self.exception_filled = False814 self.exception_code = 1000815 self.exception_code_filled = False816 self.exception_copy_by_value = "new {implementation_type}(exception_object)"817 self.exception_copy_by_value_filled = False818 self.template_line = ""819 self.template_line_filled = False820 self.typedef_name = ""821 self.typedef_name_filled = False822 self.copy_or_add_ref_noexcept = False823 self.copy_or_add_ref_noexcept_filled = False824 self.delete_or_release_noexcept = True825 self.delete_or_release_noexcept_filled = False826 self.overload_suffix_mode = TOverloadSuffixMode.Notify827 self.overload_suffix_mode_filled = False828 self.wrap_name = "{class_name}{wrap_suffix}"829 self.wrap_name_filled = False830 self.generate_copy_constructor = True831 self.generate_copy_constructor_filled = False832 self.impl_2_c = ""833 self.impl_2_c_filled = False834 self.c_2_impl = ""835 self.c_2_impl_filled = False836 self.custom_cast_to_base = ""837 self.custom_cast_to_base_filled = False838 self.custom_down_cast = ""839 self.custom_down_cast_filled = False840 self.down_cast = True841 self.down_cast_filled = False842 self.generate_tests = True843 self.generate_tests_filled = False844 self.documentations = []845 self.include_headers = []846 self.methods_prologs = []847 self.enumerations = []848 self.constructors = []849 self.properties = []850 self.methods = []851 self.indexers = []852 self.callbacks = []853 self.mapped_types = []854 self.lifecycle_extensions = []855 self.constants = []856 self.typedefs = []857 def load_element(self, element):858 if element.nodeName == "documentation":859 new_element = TDocumentation()860 new_element.load(element)861 self.documentations.append(new_element)862 return True863 if element.nodeName == "include_header":864 new_element = THeaderInclude()865 new_element.load(element)866 self.include_headers.append(new_element)867 return True868 if element.nodeName == "methods_prolog":869 new_element = TProlog()870 new_element.load(element)871 self.methods_prologs.append(new_element)872 return True873 if element.nodeName == "enumeration":874 new_element = TEnumeration()875 new_element.load(element)876 self.enumerations.append(new_element)877 return True878 if element.nodeName == "constructor":879 new_element = TConstructor()880 new_element.load(element)881 self.constructors.append(new_element)882 return True883 if element.nodeName == "property":884 new_element = TProperty()885 new_element.load(element)886 self.properties.append(new_element)887 return True888 if element.nodeName == "method":889 new_element = TMethod()890 new_element.load(element)891 self.methods.append(new_element)892 return True893 if element.nodeName == "indexer":894 new_element = TIndexer()895 new_element.load(element)896 self.indexers.append(new_element)897 return True898 if element.nodeName == "callback":899 new_element = TCallback()900 new_element.load(element)901 self.callbacks.append(new_element)902 return True903 if element.nodeName == "mapped_type":904 new_element = TMappedType()905 new_element.load(element)906 self.mapped_types.append(new_element)907 return True908 if element.nodeName == "lifecycle_extension":909 new_element = TLifecycleExtension()910 new_element.load(element)911 self.lifecycle_extensions.append(new_element)912 return True913 if element.nodeName == "constant":914 new_element = TConstant()915 new_element.load(element)916 self.constants.append(new_element)917 return True918 if element.nodeName == "typedef":919 new_element = TTypedef()920 new_element.load(element)921 self.typedefs.append(new_element)922 return True923 return False924 def load_attributes(self, dom_node):925 if dom_node.hasAttribute("name"):926 cur_attr = dom_node.getAttribute("name")927 self.name = cur_attr928 self.name_filled = True929 if dom_node.hasAttribute("base"):930 cur_attr = dom_node.getAttribute("base")931 self.base = cur_attr932 self.base_filled = True933 if dom_node.hasAttribute("implementation_class_name"):934 cur_attr = dom_node.getAttribute("implementation_class_name")935 self.implementation_class_name = cur_attr936 self.implementation_class_name_filled = True937 if dom_node.hasAttribute("snippet_type"):938 cur_attr = dom_node.getAttribute("snippet_type")939 self.snippet_type = cur_attr940 self.snippet_type_filled = True941 if dom_node.hasAttribute("abstract"):942 cur_attr = dom_node.getAttribute("abstract")943 self.abstract = string_to_bool(cur_attr)944 self.abstract_filled = True945 if dom_node.hasAttribute("implementation_class_header"):946 cur_attr = dom_node.getAttribute("implementation_class_header")947 self.implementation_class_header = cur_attr948 self.implementation_class_header_filled = True949 if dom_node.hasAttribute("lifecycle"):950 cur_attr = dom_node.getAttribute("lifecycle")951 self.lifecycle = TLifecycle.load(cur_attr)952 self.lifecycle_filled = True953 if dom_node.hasAttribute("requires_cast_to_base"):954 cur_attr = dom_node.getAttribute("requires_cast_to_base")955 self.requires_cast_to_base = string_to_bool(cur_attr)956 self.requires_cast_to_base_filled = True957 if dom_node.hasAttribute("pointer_access"):958 cur_attr = dom_node.getAttribute("pointer_access")959 self.pointer_access = string_to_bool(cur_attr)960 self.pointer_access_filled = True961 if dom_node.hasAttribute("exception"):962 cur_attr = dom_node.getAttribute("exception")963 self.exception = string_to_bool(cur_attr)964 self.exception_filled = True965 if dom_node.hasAttribute("exception_code"):966 cur_attr = dom_node.getAttribute("exception_code")967 self.exception_code = string_to_int(cur_attr)968 self.exception_code_filled = True969 if dom_node.hasAttribute("exception_copy_by_value"):970 cur_attr = dom_node.getAttribute("exception_copy_by_value")971 self.exception_copy_by_value = cur_attr972 self.exception_copy_by_value_filled = True973 if dom_node.hasAttribute("template_line"):974 cur_attr = dom_node.getAttribute("template_line")975 self.template_line = cur_attr976 self.template_line_filled = True977 if dom_node.hasAttribute("typedef_name"):978 cur_attr = dom_node.getAttribute("typedef_name")979 self.typedef_name = cur_attr980 self.typedef_name_filled = True981 if dom_node.hasAttribute("copy_or_add_ref_noexcept"):982 cur_attr = dom_node.getAttribute("copy_or_add_ref_noexcept")983 self.copy_or_add_ref_noexcept = string_to_bool(cur_attr)984 self.copy_or_add_ref_noexcept_filled = True985 if dom_node.hasAttribute("delete_or_release_noexcept"):986 cur_attr = dom_node.getAttribute("delete_or_release_noexcept")987 self.delete_or_release_noexcept = string_to_bool(cur_attr)988 self.delete_or_release_noexcept_filled = True989 if dom_node.hasAttribute("overload_suffix_mode"):990 cur_attr = dom_node.getAttribute("overload_suffix_mode")991 self.overload_suffix_mode = TOverloadSuffixMode.load(cur_attr)992 self.overload_suffix_mode_filled = True993 if dom_node.hasAttribute("wrap_name"):994 cur_attr = dom_node.getAttribute("wrap_name")995 self.wrap_name = cur_attr996 self.wrap_name_filled = True997 if dom_node.hasAttribute("generate_copy_constructor"):998 cur_attr = dom_node.getAttribute("generate_copy_constructor")999 self.generate_copy_constructor = string_to_bool(cur_attr)1000 self.generate_copy_constructor_filled = True1001 if dom_node.hasAttribute("impl_2_c"):1002 cur_attr = dom_node.getAttribute("impl_2_c")1003 self.impl_2_c = cur_attr1004 self.impl_2_c_filled = True1005 if dom_node.hasAttribute("c_2_impl"):1006 cur_attr = dom_node.getAttribute("c_2_impl")1007 self.c_2_impl = cur_attr1008 self.c_2_impl_filled = True1009 if dom_node.hasAttribute("custom_cast_to_base"):1010 cur_attr = dom_node.getAttribute("custom_cast_to_base")1011 self.custom_cast_to_base = cur_attr1012 self.custom_cast_to_base_filled = True1013 if dom_node.hasAttribute("custom_down_cast"):1014 cur_attr = dom_node.getAttribute("custom_down_cast")1015 self.custom_down_cast = cur_attr1016 self.custom_down_cast_filled = True1017 if dom_node.hasAttribute("down_cast"):1018 cur_attr = dom_node.getAttribute("down_cast")1019 self.down_cast = string_to_bool(cur_attr)1020 self.down_cast_filled = True1021 if dom_node.hasAttribute("generate_tests"):1022 cur_attr = dom_node.getAttribute("generate_tests")1023 self.generate_tests = string_to_bool(cur_attr)1024 self.generate_tests_filled = True1025 def load(self, dom_node):1026 for element in dom_node.childNodes:1027 self.load_element(element)1028 self.load_attributes(dom_node)1029class TCallback(object):1030 def __init__(self):1031 self.all_items = []1032 self.lifecycle = TLifecycle.reference_counted1033 self.lifecycle_filled = False1034 self.copy_or_add_ref_noexcept = False1035 self.copy_or_add_ref_noexcept_filled = False1036 self.delete_or_release_noexcept = True1037 self.delete_or_release_noexcept_filled = False1038 self.implementation_class_name = ""1039 self.implementation_class_name_filled = False1040 self.implementation_class_header = ""1041 self.implementation_class_header_filled = False1042 def load_element(self, element):1043 return False1044 def load_attributes(self, dom_node):1045 if dom_node.hasAttribute("lifecycle"):1046 cur_attr = dom_node.getAttribute("lifecycle")1047 self.lifecycle = TLifecycle.load(cur_attr)1048 self.lifecycle_filled = True1049 if dom_node.hasAttribute("copy_or_add_ref_noexcept"):1050 cur_attr = dom_node.getAttribute("copy_or_add_ref_noexcept")1051 self.copy_or_add_ref_noexcept = string_to_bool(cur_attr)1052 self.copy_or_add_ref_noexcept_filled = True1053 if dom_node.hasAttribute("delete_or_release_noexcept"):1054 cur_attr = dom_node.getAttribute("delete_or_release_noexcept")1055 self.delete_or_release_noexcept = string_to_bool(cur_attr)1056 self.delete_or_release_noexcept_filled = True1057 if dom_node.hasAttribute("implementation_class_name"):1058 cur_attr = dom_node.getAttribute("implementation_class_name")1059 self.implementation_class_name = cur_attr1060 self.implementation_class_name_filled = True1061 if dom_node.hasAttribute("implementation_class_header"):1062 cur_attr = dom_node.getAttribute("implementation_class_header")1063 self.implementation_class_header = cur_attr1064 self.implementation_class_header_filled = True1065 def load(self, dom_node):1066 for element in dom_node.childNodes:1067 self.load_element(element)1068 self.load_attributes(dom_node)1069class TConstructorBase(object):1070 def __init__(self):1071 self.all_items = []1072 self.name = ""1073 self.name_filled = False1074 self.return_copy_or_add_ref = False1075 self.return_copy_or_add_ref_filled = False1076 self.noexcept = False1077 self.noexcept_filled = False1078 self.documentations = []1079 self.arguments = []1080 self.implementation_codes = []1081 def load_element(self, element):1082 if element.nodeName == "documentation":1083 new_element = TDocumentation()1084 new_element.load(element)1085 self.documentations.append(new_element)1086 return True1087 if element.nodeName == "argument":1088 new_element = TArgument()1089 new_element.load(element)1090 self.arguments.append(new_element)1091 return True1092 if element.nodeName == "implementation_code":1093 new_element = TImplementationCode()1094 new_element.load(element)1095 self.implementation_codes.append(new_element)1096 return True1097 return False1098 def load_attributes(self, dom_node):1099 if dom_node.hasAttribute("name"):1100 cur_attr = dom_node.getAttribute("name")1101 self.name = cur_attr1102 self.name_filled = True1103 if dom_node.hasAttribute("return_copy_or_add_ref"):1104 cur_attr = dom_node.getAttribute("return_copy_or_add_ref")1105 self.return_copy_or_add_ref = string_to_bool(cur_attr)1106 self.return_copy_or_add_ref_filled = True1107 if dom_node.hasAttribute("noexcept"):1108 cur_attr = dom_node.getAttribute("noexcept")1109 self.noexcept = string_to_bool(cur_attr)1110 self.noexcept_filled = True1111 def load(self, dom_node):1112 for element in dom_node.childNodes:1113 self.load_element(element)1114 self.load_attributes(dom_node)1115class TConstructor(TConstructorBase):1116 def __init__(self):1117 super().__init__()1118 self.explicit = False1119 self.explicit_filled = False1120 def load_element(self, element):1121 if super().load_element(element):1122 return True1123 return False1124 def load_attributes(self, dom_node):1125 super().load_attributes(dom_node)1126 if dom_node.hasAttribute("explicit"):1127 cur_attr = dom_node.getAttribute("explicit")1128 self.explicit = string_to_bool(cur_attr)1129 self.explicit_filled = True1130 def load(self, dom_node):1131 for element in dom_node.childNodes:1132 self.load_element(element)1133 self.load_attributes(dom_node)1134class TImplementationCode(object):1135 def __init__(self):1136 self.all_items = []1137 def load_element(self, element):1138 if element.nodeType == element.TEXT_NODE:1139 cur_texts = [text.strip() for text in element.data.split('\n')]1140 first = True1141 for text in cur_texts:1142 if first and self.all_items and type(self.all_items[-1]) is str:1143 self.all_items[-1] += text1144 else:1145 self.all_items.append(text)1146 first = False1147 return True1148 return False1149 def load_attributes(self, dom_node):1150 pass1151 def load(self, dom_node):1152 for element in dom_node.childNodes:1153 self.load_element(element)1154 self.load_attributes(dom_node)1155class TProlog(object):1156 def __init__(self):1157 self.all_items = []1158 def load_element(self, element):1159 if element.nodeType == element.TEXT_NODE:1160 cur_texts = [text.strip() for text in element.data.split('\n')]1161 first = True1162 for text in cur_texts:1163 if first and self.all_items and type(self.all_items[-1]) is str:1164 self.all_items[-1] += text1165 else:1166 self.all_items.append(text)1167 first = False1168 return True1169 return False1170 def load_attributes(self, dom_node):1171 pass1172 def load(self, dom_node):1173 for element in dom_node.childNodes:1174 self.load_element(element)1175 self.load_attributes(dom_node)1176class TMethodBase(TConstructorBase):1177 def __init__(self):1178 super().__init__()1179 self.return_type = ""1180 self.return_type_filled = False1181 self.return_is_builtin = False1182 self.return_is_builtin_filled = False1183 self.overload_suffix = ""1184 self.overload_suffix_filled = False1185 self.impl_2_c = "new {implementation_type}({expression})"1186 self.impl_2_c_filled = False1187 self.implementation_name = ""1188 self.implementation_name_filled = False1189 self.setter_field_name = ""1190 self.setter_field_name_filled = False1191 self.getter_field_name = ""1192 self.getter_field_name_filled = False1193 self.sharp_marshal_return_as = ""1194 self.sharp_marshal_return_as_filled = False1195 self.prologs = []1196 def load_element(self, element):1197 if super().load_element(element):1198 return True1199 if element.nodeName == "prolog":1200 new_element = TProlog()1201 new_element.load(element)1202 self.prologs.append(new_element)1203 return True1204 return False1205 def load_attributes(self, dom_node):1206 super().load_attributes(dom_node)1207 if dom_node.hasAttribute("return"):1208 cur_attr = dom_node.getAttribute("return")1209 self.return_type = cur_attr1210 self.return_type_filled = True1211 if dom_node.hasAttribute("return_is_builtin"):1212 cur_attr = dom_node.getAttribute("return_is_builtin")1213 self.return_is_builtin = string_to_bool(cur_attr)1214 self.return_is_builtin_filled = True1215 if dom_node.hasAttribute("overload_suffix"):1216 cur_attr = dom_node.getAttribute("overload_suffix")1217 self.overload_suffix = cur_attr1218 self.overload_suffix_filled = True1219 if dom_node.hasAttribute("impl_2_c"):1220 cur_attr = dom_node.getAttribute("impl_2_c")1221 self.impl_2_c = cur_attr1222 self.impl_2_c_filled = True1223 if dom_node.hasAttribute("implementation_name"):1224 cur_attr = dom_node.getAttribute("implementation_name")1225 self.implementation_name = cur_attr1226 self.implementation_name_filled = True1227 if dom_node.hasAttribute("setter_field_name"):1228 cur_attr = dom_node.getAttribute("setter_field_name")1229 self.setter_field_name = cur_attr1230 self.setter_field_name_filled = True1231 if dom_node.hasAttribute("getter_field_name"):1232 cur_attr = dom_node.getAttribute("getter_field_name")1233 self.getter_field_name = cur_attr1234 self.getter_field_name_filled = True1235 if dom_node.hasAttribute("sharp_marshal_return_as"):1236 cur_attr = dom_node.getAttribute("sharp_marshal_return_as")1237 self.sharp_marshal_return_as = cur_attr1238 self.sharp_marshal_return_as_filled = True1239 def load(self, dom_node):1240 for element in dom_node.childNodes:1241 self.load_element(element)1242 self.load_attributes(dom_node)1243class TMethod(TMethodBase):1244 def __init__(self):1245 super().__init__()1246 self.const = False1247 self.const_filled = False1248 self.static = False1249 self.static_filled = False1250 def load_element(self, element):1251 if super().load_element(element):1252 return True1253 return False1254 def load_attributes(self, dom_node):1255 super().load_attributes(dom_node)1256 if dom_node.hasAttribute("const"):1257 cur_attr = dom_node.getAttribute("const")1258 self.const = string_to_bool(cur_attr)1259 self.const_filled = True1260 if dom_node.hasAttribute("static"):1261 cur_attr = dom_node.getAttribute("static")1262 self.static = string_to_bool(cur_attr)1263 self.static_filled = True1264 def load(self, dom_node):1265 for element in dom_node.childNodes:1266 self.load_element(element)1267 self.load_attributes(dom_node)1268class TIndexerBase(object):1269 def __init__(self):1270 self.all_items = []1271 self.name = ""1272 self.name_filled = False1273 self.return_copy_or_add_ref = False1274 self.return_copy_or_add_ref_filled = False1275 self.noexcept = False1276 self.noexcept_filled = False1277 self.documentations = []1278 self.arguments = []1279 self.implementation_codes = []1280 def load_element(self, element):1281 if element.nodeName == "documentation":1282 new_element = TDocumentation()1283 new_element.load(element)1284 self.documentations.append(new_element)1285 return True1286 if element.nodeName == "argument":1287 new_element = TArgument()1288 new_element.load(element)1289 self.arguments.append(new_element)1290 return True1291 if element.nodeName == "implementation_code":1292 new_element = TImplementationCode()1293 new_element.load(element)1294 self.implementation_codes.append(new_element)1295 return True1296 return False1297 def load_attributes(self, dom_node):1298 if dom_node.hasAttribute("name"):1299 cur_attr = dom_node.getAttribute("name")1300 self.name = cur_attr1301 self.name_filled = True1302 if dom_node.hasAttribute("return_copy_or_add_ref"):1303 cur_attr = dom_node.getAttribute("return_copy_or_add_ref")1304 self.return_copy_or_add_ref = string_to_bool(cur_attr)1305 self.return_copy_or_add_ref_filled = True1306 if dom_node.hasAttribute("noexcept"):1307 cur_attr = dom_node.getAttribute("noexcept")1308 self.noexcept = string_to_bool(cur_attr)1309 self.noexcept_filled = True1310 def load(self, dom_node):1311 for element in dom_node.childNodes:1312 self.load_element(element)1313 self.load_attributes(dom_node)1314class TIndexer(TIndexerBase):1315 def __init__(self):1316 super().__init__()1317 self.impl_2_c = "new {implementation_type}({expression})"1318 self.impl_2_c_filled = False1319 self.sharp_marshal_return_as = ""1320 self.sharp_marshal_return_as_filled = False1321 self.indexed_set_type = ""1322 self.indexed_set_type_filled = False1323 self.indexed_get_type = ""1324 self.indexed_get_type_filled = False1325 self.indexed_is_builtin = False1326 self.indexed_is_builtin_filled = False1327 self.set_impl = "{expression} = value;"1328 self.set_impl_filled = False1329 def load_element(self, element):1330 if super().load_element(element):1331 return True1332 return False1333 def load_attributes(self, dom_node):1334 super().load_attributes(dom_node)1335 if dom_node.hasAttribute("impl_2_c"):1336 cur_attr = dom_node.getAttribute("impl_2_c")1337 self.impl_2_c = cur_attr1338 self.impl_2_c_filled = True1339 if dom_node.hasAttribute("sharp_marshal_return_as"):1340 cur_attr = dom_node.getAttribute("sharp_marshal_return_as")1341 self.sharp_marshal_return_as = cur_attr1342 self.sharp_marshal_return_as_filled = True1343 if dom_node.hasAttribute("indexed_set_type"):1344 cur_attr = dom_node.getAttribute("indexed_set_type")1345 self.indexed_set_type = cur_attr1346 self.indexed_set_type_filled = True1347 if dom_node.hasAttribute("indexed_get_type"):1348 cur_attr = dom_node.getAttribute("indexed_get_type")1349 self.indexed_get_type = cur_attr1350 self.indexed_get_type_filled = True1351 if dom_node.hasAttribute("indexed_is_builtin"):1352 cur_attr = dom_node.getAttribute("indexed_is_builtin")1353 self.indexed_is_builtin = string_to_bool(cur_attr)1354 self.indexed_is_builtin_filled = True1355 if dom_node.hasAttribute("set_impl"):1356 cur_attr = dom_node.getAttribute("set_impl")1357 self.set_impl = cur_attr1358 self.set_impl_filled = True1359 def load(self, dom_node):1360 for element in dom_node.childNodes:1361 self.load_element(element)1362 self.load_attributes(dom_node)1363class TFunction(TMethodBase):1364 def __init__(self):1365 super().__init__()1366 self.implementation_header = ""1367 self.implementation_header_filled = False1368 def load_element(self, element):1369 if super().load_element(element):1370 return True1371 return False1372 def load_attributes(self, dom_node):1373 super().load_attributes(dom_node)1374 if dom_node.hasAttribute("implementation_header"):1375 cur_attr = dom_node.getAttribute("implementation_header")1376 self.implementation_header = cur_attr1377 self.implementation_header_filled = True1378 def load(self, dom_node):1379 for element in dom_node.childNodes:1380 self.load_element(element)1381 self.load_attributes(dom_node)1382class TArgument(object):1383 def __init__(self):1384 self.all_items = []1385 self.name = ""1386 self.name_filled = False1387 self.type_name = ""1388 self.type_name_filled = False1389 self.is_builtin = False1390 self.is_builtin_filled = False1391 self.c_2_impl = "static_cast<{implementation_type}*>({expression})"1392 self.c_2_impl_filled = False1393 self.c_2_impl_mode = TC2ImplMode.default1394 self.c_2_impl_mode_filled = False1395 self.sharp_marshal_as = ""1396 self.sharp_marshal_as_filled = False1397 self.documentations = []1398 def load_element(self, element):1399 if element.nodeName == "documentation":1400 new_element = TGenericDocumentation()1401 new_element.load(element)1402 self.documentations.append(new_element)1403 return True1404 return False1405 def load_attributes(self, dom_node):1406 if dom_node.hasAttribute("name"):1407 cur_attr = dom_node.getAttribute("name")1408 self.name = cur_attr1409 self.name_filled = True1410 if dom_node.hasAttribute("type"):1411 cur_attr = dom_node.getAttribute("type")1412 self.type_name = cur_attr1413 self.type_name_filled = True1414 if dom_node.hasAttribute("is_builtin"):1415 cur_attr = dom_node.getAttribute("is_builtin")1416 self.is_builtin = string_to_bool(cur_attr)1417 self.is_builtin_filled = True1418 if dom_node.hasAttribute("c_2_impl"):1419 cur_attr = dom_node.getAttribute("c_2_impl")1420 self.c_2_impl = cur_attr1421 self.c_2_impl_filled = True1422 if dom_node.hasAttribute("c_2_impl_mode"):1423 cur_attr = dom_node.getAttribute("c_2_impl_mode")1424 self.c_2_impl_mode = TC2ImplMode.load(cur_attr)1425 self.c_2_impl_mode_filled = True1426 if dom_node.hasAttribute("sharp_marshal_as"):1427 cur_attr = dom_node.getAttribute("sharp_marshal_as")1428 self.sharp_marshal_as = cur_attr1429 self.sharp_marshal_as_filled = True1430 def load(self, dom_node):1431 for element in dom_node.childNodes:1432 self.load_element(element)1433 self.load_attributes(dom_node)1434class TLifecycleExtension(object):1435 def __init__(self):1436 self.all_items = []1437 self.name = ""1438 self.name_filled = False1439 self.wrap_name = ""1440 self.wrap_name_filled = False1441 self.lifecycle = None1442 self.lifecycle_filled = False1443 self.down_cast = False1444 self.down_cast_filled = False1445 self.cast_tos = []1446 self.cast_froms = []1447 def load_element(self, element):1448 if element.nodeName == "cast_to":1449 new_element = TCastTo()1450 new_element.load(element)1451 self.cast_tos.append(new_element)1452 return True1453 if element.nodeName == "cast_from":1454 new_element = TCastFrom()1455 new_element.load(element)1456 self.cast_froms.append(new_element)1457 return True1458 return False1459 def load_attributes(self, dom_node):1460 if dom_node.hasAttribute("name"):1461 cur_attr = dom_node.getAttribute("name")1462 self.name = cur_attr1463 self.name_filled = True1464 if dom_node.hasAttribute("wrap_name"):1465 cur_attr = dom_node.getAttribute("wrap_name")1466 self.wrap_name = cur_attr1467 self.wrap_name_filled = True1468 if dom_node.hasAttribute("lifecycle"):1469 cur_attr = dom_node.getAttribute("lifecycle")1470 self.lifecycle = TLifecycle.load(cur_attr)1471 self.lifecycle_filled = True1472 if dom_node.hasAttribute("down_cast"):1473 cur_attr = dom_node.getAttribute("down_cast")1474 self.down_cast = string_to_bool(cur_attr)1475 self.down_cast_filled = True1476 def load(self, dom_node):1477 for element in dom_node.childNodes:1478 self.load_element(element)1479 self.load_attributes(dom_node)1480class TCastTo(object):1481 def __init__(self):1482 self.all_items = []1483 self.implicit = True1484 self.implicit_filled = False1485 self.target_type = ""1486 self.target_type_filled = False1487 self.cast_method = "To{target_type}"1488 self.cast_method_filled = False1489 def load_element(self, element):1490 return False1491 def load_attributes(self, dom_node):1492 if dom_node.hasAttribute("implicit"):1493 cur_attr = dom_node.getAttribute("implicit")1494 self.implicit = string_to_bool(cur_attr)1495 self.implicit_filled = True1496 if dom_node.hasAttribute("target_type"):1497 cur_attr = dom_node.getAttribute("target_type")1498 self.target_type = cur_attr1499 self.target_type_filled = True1500 if dom_node.hasAttribute("cast_method"):1501 cur_attr = dom_node.getAttribute("cast_method")1502 self.cast_method = cur_attr1503 self.cast_method_filled = True1504 def load(self, dom_node):1505 for element in dom_node.childNodes:1506 self.load_element(element)1507 self.load_attributes(dom_node)1508class TCastFrom(object):1509 def __init__(self):1510 self.all_items = []1511 self.source_type = ""1512 self.source_type_filled = False1513 def load_element(self, element):1514 return False1515 def load_attributes(self, dom_node):1516 if dom_node.hasAttribute("source_type"):1517 cur_attr = dom_node.getAttribute("source_type")1518 self.source_type = cur_attr1519 self.source_type_filled = True1520 def load(self, dom_node):1521 for element in dom_node.childNodes:1522 self.load_element(element)1523 self.load_attributes(dom_node)1524class THeaderInclude(object):1525 def __init__(self):1526 self.all_items = []1527 self.file = ""1528 self.file_filled = False1529 self.system = False1530 self.system_filled = False1531 def load_element(self, element):1532 return False1533 def load_attributes(self, dom_node):1534 if dom_node.hasAttribute("file"):1535 cur_attr = dom_node.getAttribute("file")1536 self.file = cur_attr1537 self.file_filled = True1538 if dom_node.hasAttribute("system"):1539 cur_attr = dom_node.getAttribute("system")1540 self.system = string_to_bool(cur_attr)1541 self.system_filled = True1542 def load(self, dom_node):1543 for element in dom_node.childNodes:1544 self.load_element(element)1545 self.load_attributes(dom_node)1546class TDefine(object):1547 def __init__(self):1548 self.all_items = []1549 self.value = ""1550 self.value_filled = False1551 def load_element(self, element):1552 return False1553 def load_attributes(self, dom_node):1554 if dom_node.hasAttribute("value"):1555 cur_attr = dom_node.getAttribute("value")1556 self.value = cur_attr1557 self.value_filled = True1558 def load(self, dom_node):1559 for element in dom_node.childNodes:1560 self.load_element(element)1561 self.load_attributes(dom_node)1562class TProperty(object):1563 def __init__(self):1564 self.all_items = []1565 self.name = ""1566 self.name_filled = False1567 self.type_name = ""1568 self.type_name_filled = False1569 self.set_prefix = "Set"1570 self.set_prefix_filled = False1571 self.get_prefix = "Get"1572 self.get_prefix_filled = False1573 self.get_const = True1574 self.get_const_filled = False1575 self.set_argument_name = ""1576 self.set_argument_name_filled = False1577 self.is_builtin = False1578 self.is_builtin_filled = False1579 self.set_c_2_impl = "static_cast<{implementation_type}>({expression})"1580 self.set_c_2_impl_filled = False1581 self.set_c_2_impl_mode = TC2ImplMode.default1582 self.set_c_2_impl_mode_filled = False1583 self.get_impl_2_c = "new {implementation_type}({expression})"1584 self.get_impl_2_c_filled = False1585 self.set_argument_type = ""1586 self.set_argument_type_filled = False1587 self.return_type = ""1588 self.return_type_filled = False1589 self.return_copy_or_add_ref = False1590 self.return_copy_or_add_ref_filled = False1591 self.field_name = ""1592 self.field_name_filled = False1593 self.generate_test = True1594 self.generate_test_filled = False1595 self.documentations = []1596 def load_element(self, element):1597 if element.nodeName == "documentation":1598 new_element = TDocumentation()1599 new_element.load(element)1600 self.documentations.append(new_element)1601 return True1602 return False1603 def load_attributes(self, dom_node):1604 if dom_node.hasAttribute("name"):1605 cur_attr = dom_node.getAttribute("name")1606 self.name = cur_attr1607 self.name_filled = True1608 if dom_node.hasAttribute("type"):1609 cur_attr = dom_node.getAttribute("type")1610 self.type_name = cur_attr1611 self.type_name_filled = True1612 if dom_node.hasAttribute("set_prefix"):1613 cur_attr = dom_node.getAttribute("set_prefix")1614 self.set_prefix = cur_attr1615 self.set_prefix_filled = True1616 if dom_node.hasAttribute("get_prefix"):1617 cur_attr = dom_node.getAttribute("get_prefix")1618 self.get_prefix = cur_attr1619 self.get_prefix_filled = True1620 if dom_node.hasAttribute("get_const"):1621 cur_attr = dom_node.getAttribute("get_const")1622 self.get_const = string_to_bool(cur_attr)1623 self.get_const_filled = True1624 if dom_node.hasAttribute("set_argument_name"):1625 cur_attr = dom_node.getAttribute("set_argument_name")1626 self.set_argument_name = cur_attr1627 self.set_argument_name_filled = True1628 if dom_node.hasAttribute("is_builtin"):1629 cur_attr = dom_node.getAttribute("is_builtin")1630 self.is_builtin = string_to_bool(cur_attr)1631 self.is_builtin_filled = True1632 if dom_node.hasAttribute("set_c_2_impl"):1633 cur_attr = dom_node.getAttribute("set_c_2_impl")1634 self.set_c_2_impl = cur_attr1635 self.set_c_2_impl_filled = True1636 if dom_node.hasAttribute("set_c_2_impl_mode"):1637 cur_attr = dom_node.getAttribute("set_c_2_impl_mode")1638 self.set_c_2_impl_mode = TC2ImplMode.load(cur_attr)1639 self.set_c_2_impl_mode_filled = True1640 if dom_node.hasAttribute("get_impl_2_c"):1641 cur_attr = dom_node.getAttribute("get_impl_2_c")1642 self.get_impl_2_c = cur_attr1643 self.get_impl_2_c_filled = True1644 if dom_node.hasAttribute("set_argument_type"):1645 cur_attr = dom_node.getAttribute("set_argument_type")1646 self.set_argument_type = cur_attr1647 self.set_argument_type_filled = True1648 if dom_node.hasAttribute("return_type"):1649 cur_attr = dom_node.getAttribute("return_type")1650 self.return_type = cur_attr1651 self.return_type_filled = True1652 if dom_node.hasAttribute("return_copy_or_add_ref"):1653 cur_attr = dom_node.getAttribute("return_copy_or_add_ref")1654 self.return_copy_or_add_ref = string_to_bool(cur_attr)1655 self.return_copy_or_add_ref_filled = True1656 if dom_node.hasAttribute("field_name"):1657 cur_attr = dom_node.getAttribute("field_name")1658 self.field_name = cur_attr1659 self.field_name_filled = True1660 if dom_node.hasAttribute("generate_test"):1661 cur_attr = dom_node.getAttribute("generate_test")1662 self.generate_test = string_to_bool(cur_attr)1663 self.generate_test_filled = True1664 def load(self, dom_node):1665 for element in dom_node.childNodes:1666 self.load_element(element)1667 self.load_attributes(dom_node)1668class TPropertySetPrefix(object):1669 def __init__(self):1670 self.all_items = []1671 self.value = "Set"1672 self.value_filled = False1673 def load_element(self, element):1674 return False1675 def load_attributes(self, dom_node):1676 if dom_node.hasAttribute("value"):1677 cur_attr = dom_node.getAttribute("value")1678 self.value = cur_attr1679 self.value_filled = True1680 def load(self, dom_node):1681 for element in dom_node.childNodes:1682 self.load_element(element)1683 self.load_attributes(dom_node)1684class TPropertyGetPrefix(object):1685 def __init__(self):1686 self.all_items = []1687 self.value = "Get"1688 self.value_filled = False1689 def load_element(self, element):1690 return False1691 def load_attributes(self, dom_node):1692 if dom_node.hasAttribute("value"):1693 cur_attr = dom_node.getAttribute("value")1694 self.value = cur_attr1695 self.value_filled = True1696 def load(self, dom_node):1697 for element in dom_node.childNodes:1698 self.load_element(element)1699 self.load_attributes(dom_node)1700class TPropertyGetConst(object):1701 def __init__(self):1702 self.all_items = []1703 self.value = True1704 self.value_filled = False1705 def load_element(self, element):1706 return False1707 def load_attributes(self, dom_node):1708 if dom_node.hasAttribute("value"):1709 cur_attr = dom_node.getAttribute("value")1710 self.value = string_to_bool(cur_attr)1711 self.value_filled = True1712 def load(self, dom_node):1713 for element in dom_node.childNodes:1714 self.load_element(element)1715 self.load_attributes(dom_node)1716class TMappedTypeItem(object):1717 def __init__(self):1718 self.all_items = []1719 self.wrap_type = ""1720 self.wrap_type_filled = False1721 self.argument_wrap_type = ""1722 self.argument_wrap_type_filled = False1723 self.wrap_2_c = "static_cast<{c_type}>({expression})"1724 self.wrap_2_c_filled = False1725 self.c_2_wrap = "static_cast<{wrap_type}>({expression})"1726 self.c_2_wrap_filled = False1727 self.include_headers = []1728 def load_element(self, element):1729 if element.nodeName == "include_header":1730 new_element = THeaderInclude()1731 new_element.load(element)1732 self.include_headers.append(new_element)1733 return True1734 return False1735 def load_attributes(self, dom_node):1736 if dom_node.hasAttribute("wrap_type"):1737 cur_attr = dom_node.getAttribute("wrap_type")1738 self.wrap_type = cur_attr1739 self.wrap_type_filled = True1740 if dom_node.hasAttribute("argument_wrap_type"):1741 cur_attr = dom_node.getAttribute("argument_wrap_type")1742 self.argument_wrap_type = cur_attr1743 self.argument_wrap_type_filled = True1744 if dom_node.hasAttribute("wrap_2_c"):1745 cur_attr = dom_node.getAttribute("wrap_2_c")1746 self.wrap_2_c = cur_attr1747 self.wrap_2_c_filled = True1748 if dom_node.hasAttribute("c_2_wrap"):1749 cur_attr = dom_node.getAttribute("c_2_wrap")1750 self.c_2_wrap = cur_attr1751 self.c_2_wrap_filled = True1752 def load(self, dom_node):1753 for element in dom_node.childNodes:1754 self.load_element(element)1755 self.load_attributes(dom_node)1756class TSharpMappedTypeItem(TMappedTypeItem):1757 def __init__(self):1758 super().__init__()1759 self.marshal_as = ""1760 self.marshal_as_filled = False1761 def load_element(self, element):1762 if super().load_element(element):1763 return True1764 return False1765 def load_attributes(self, dom_node):1766 super().load_attributes(dom_node)1767 if dom_node.hasAttribute("marshal_as"):1768 cur_attr = dom_node.getAttribute("marshal_as")1769 self.marshal_as = cur_attr1770 self.marshal_as_filled = True1771 def load(self, dom_node):1772 for element in dom_node.childNodes:1773 self.load_element(element)1774 self.load_attributes(dom_node)1775class TMappedType(object):1776 def __init__(self):1777 self.all_items = []1778 self.name = ""1779 self.name_filled = False1780 self.c_type = ""1781 self.c_type_filled = False1782 self.implementation_type = ""1783 self.implementation_type_filled = False1784 self.wrap_type = ""1785 self.wrap_type_filled = False1786 self.argument_wrap_type = ""1787 self.argument_wrap_type_filled = False1788 self.snippet_type = ""1789 self.snippet_type_filled = False1790 self.wrap_2_c = "static_cast<{c_type}>({expression})"1791 self.wrap_2_c_filled = False1792 self.c_2_wrap = "static_cast<{wrap_type}>({expression})"1793 self.c_2_wrap_filled = False1794 self.c_2_impl = "static_cast<{implementation_type}>({expression})"1795 self.c_2_impl_filled = False1796 self.impl_2_c = "static_cast<{c_type}>({expression})"1797 self.impl_2_c_filled = False1798 self.include_headers = []1799 self.cpps = []1800 self.sharps = []1801 def load_element(self, element):1802 if element.nodeName == "include_header":1803 new_element = THeaderInclude()1804 new_element.load(element)1805 self.include_headers.append(new_element)1806 return True1807 if element.nodeName == "cpp":1808 new_element = TMappedTypeItem()1809 new_element.load(element)1810 self.cpps.append(new_element)1811 return True1812 if element.nodeName == "sharp":1813 new_element = TSharpMappedTypeItem()1814 new_element.load(element)1815 self.sharps.append(new_element)1816 return True1817 return False1818 def load_attributes(self, dom_node):1819 if dom_node.hasAttribute("name"):1820 cur_attr = dom_node.getAttribute("name")1821 self.name = cur_attr1822 self.name_filled = True1823 if dom_node.hasAttribute("c_type"):1824 cur_attr = dom_node.getAttribute("c_type")1825 self.c_type = cur_attr1826 self.c_type_filled = True1827 if dom_node.hasAttribute("implementation_type"):1828 cur_attr = dom_node.getAttribute("implementation_type")1829 self.implementation_type = cur_attr1830 self.implementation_type_filled = True1831 if dom_node.hasAttribute("wrap_type"):1832 cur_attr = dom_node.getAttribute("wrap_type")1833 self.wrap_type = cur_attr1834 self.wrap_type_filled = True1835 if dom_node.hasAttribute("argument_wrap_type"):1836 cur_attr = dom_node.getAttribute("argument_wrap_type")1837 self.argument_wrap_type = cur_attr1838 self.argument_wrap_type_filled = True1839 if dom_node.hasAttribute("snippet_type"):1840 cur_attr = dom_node.getAttribute("snippet_type")1841 self.snippet_type = cur_attr1842 self.snippet_type_filled = True1843 if dom_node.hasAttribute("wrap_2_c"):1844 cur_attr = dom_node.getAttribute("wrap_2_c")1845 self.wrap_2_c = cur_attr1846 self.wrap_2_c_filled = True1847 if dom_node.hasAttribute("c_2_wrap"):1848 cur_attr = dom_node.getAttribute("c_2_wrap")1849 self.c_2_wrap = cur_attr1850 self.c_2_wrap_filled = True1851 if dom_node.hasAttribute("c_2_impl"):1852 cur_attr = dom_node.getAttribute("c_2_impl")1853 self.c_2_impl = cur_attr1854 self.c_2_impl_filled = True1855 if dom_node.hasAttribute("impl_2_c"):1856 cur_attr = dom_node.getAttribute("impl_2_c")1857 self.impl_2_c = cur_attr1858 self.impl_2_c_filled = True1859 def load(self, dom_node):1860 for element in dom_node.childNodes:1861 self.load_element(element)1862 self.load_attributes(dom_node)1863def load(dom_node):1864 for root_element in [root for root in dom_node.childNodes if root.localName == "api"]:1865 root_params = TBeautifulCapiRoot()1866 root_params.load(root_element)...

Full Screen

Full Screen

load_attributes.py

Source:load_attributes.py Github

copy

Full Screen

...44 Description: Test loading the ignore entries.45 Arguments:46 """47 self.args_array["-i"] = "test/unit/check_log/testfiles/loadignore.txt"48 check_log.load_attributes(self.log, self.args_array)49 self.assertEqual(self.log.ignore, ["this is a test ignore entry"])50 def test_load_regex(self):51 """Function: test_load_regex52 Description: Test loading the regex statement.53 Arguments:54 """55 self.args_array["-F"] = "test/unit/check_log/testfiles/loadregex.txt"56 check_log.load_attributes(self.log, self.args_array)57 self.assertEqual(self.log.regex, "\\d{4}\\-\\d{2}\\-\\d{2}")58 def test_load_marker(self):59 """Function: test_load_marker60 Description: Test loading the log marker.61 Arguments:62 """63 self.args_array["-m"] = "test/unit/check_log/testfiles/loadmarker.txt"64 check_log.load_attributes(self.log, self.args_array)65 self.assertEqual(self.log.marker, "This is a test marker")66 def test_set_predicate(self):67 """Function: test_set_predicate68 Description: Test setting the predicate.69 Arguments:70 """71 self.args_array["-k"] = "and"72 check_log.load_attributes(self.log, self.args_array)73 self.assertEqual(self.log.predicate, all)74 def test_load_keyword(self):75 """Function: test_load_keyword76 Description: Test loading keyword.77 Arguments:78 """79 self.args_array["-S"] = "testkeyword"80 check_log.load_attributes(self.log, self.args_array)81 self.assertEqual(self.log.keyword, ["testkeyword"])82if __name__ == "__main__":...

Full Screen

Full Screen

dataset.py

Source:dataset.py Github

copy

Full Screen

1import multiprocessing2import logging3import pickle4import math5import os6import utils7class Dataset:8 """9 Class holding info about the dataset that is needed to calculate PMI.10 """11 def __init__(self, args, single_counter, joint_counter):12 self.args = args13 self.single_counter = single_counter14 self.joint_counter = joint_counter15 self.number_tokens = sum(single_counter.values())16 def PMI_all_words(self, word):17 """18 Returns a dictionary of words in the dataset and associated pmi with the give `word`.19 The dictionary returned is sorted by pmi.20 """21 if word not in self.single_counter:22 logger = logging.getLogger('logger')23 logger.error('Word {} is not present in dataset or is stop word or rare word.')24 exit()25 else:26 pmi_dict = {w2:self.PMI(word, w2) for w2 in self.single_counter.keys()}27 pmi_dict_sorted = {word:pmi for word,pmi in sorted(pmi_dict.items(), key=lambda item: item[1], reverse=True)}28 return pmi_dict_sorted29 def PMI(self, w1, w2):30 return utils.pmi_from_counts(self.single_counter[w1], self.single_counter[w2],31 self.joint_counter[frozenset({w1, w2})], self.number_tokens)32 def save(self, path):33 with open(path, 'wb') as save_file:34 pickle.dump(vars(self), save_file)35def load_dataset(path):36 logger = logging.getLogger('logger')37 if not os.path.exists(path):38 logger.error('File path {} does not exist, cannot load.'.format(path))39 with open(path, 'rb') as load_file:40 load_attributes = pickle.load(load_file)41 return Dataset(load_attributes['args'],42 load_attributes['single_counter'],...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful