MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / handle_member_definition

Function handle_member_definition

tools/PythonExtensionChecker.py:71–215  ·  view source on GitHub ↗

Matches a doxygen member definition (mdef) to a Cython pxd file. This tries to ensure that all C++ functions are wrapped and have an equivalent in the Python wrapper. Parameters ---------- mdef : breathe.parser.compound.memberdefTypeSub A doxygen entry pxd_class :

(mdef, pxd_class, cnt)

Source from the content-addressed store, hash-verified

69
70# Matching to match doxygen methods to Cython pxd functions
71def handle_member_definition(mdef, pxd_class, cnt):
72 """ Matches a doxygen member definition (mdef) to a Cython pxd file.
73
74 This tries to ensure that all C++ functions are wrapped and have an
75 equivalent in the Python wrapper.
76
77 Parameters
78 ----------
79 mdef : breathe.parser.compound.memberdefTypeSub
80 A doxygen entry
81 pxd_class : autowrap.PXDParser.CppClassDecl
82 A PXD class file as parsed by autowrap
83 cnt :
84 A count object to keep track of how many functions we wrapped
85 """
86
87 tres = TestResult()
88 protection = mdef.get_prot() # DoxProtectionKind: public, protected, private, package
89 kind = mdef.get_kind() # DoxMemberKind: define property event variable typedef enum function signal prototype friend dcop slot
90
91 if not protection in "public protected private package".split(" "):
92 raise Exception("Error; something is wrong")
93
94 if not kind in "variable enum function define property event typedef signal prototype friend dcop slot".split(" "):
95 raise Exception("Error; something is wrong")
96
97 # Only match public enums, variables, functions
98 if protection in "protected private package".split(" "):
99 tres.setPassed(True)
100 elif kind in "define property event typedef signal prototype friend dcop slot".split(" "):
101 tres.setPassed(True)
102 elif kind == "enum" and protection == "public":
103 cnt.public_enums_total += 1
104 cython_file = parse_pxd_file(pxd_class.pxd_path)
105 found = False
106 for klass in cython_file:
107
108 if hasattr(klass[0], "name") and klass[0].name == mdef.get_name():
109 found = True
110 break
111
112 # Sometimes we rename things in pyOpenMS for sanity (and namespace consistency) sake
113 # E.g. OpenMS::PercolatorOutfile::ScoreType becomes PercolatorOutfile_ScoreType
114 # and we have to go back to the full cname. However, the doxygen name needs to be inferred
115 if hasattr(klass[0], "cname") and klass[0].cname.endswith(mdef.get_name()):
116 assumed_fullname = mdef.compoundname + "::" + mdef.get_name()
117 if (assumed_fullname == klass[0].cname):
118 found = True
119 break
120 else:
121 print ("Something went wrong, %s is not equal to %s" % (assumed_fullname, klass[0].cname))
122
123 if not found:
124 tres.setPassed(False)
125 tres.setMessage("TODO: Found enum in C++ but not in pxd: %s %s %s" % (mdef.kind, mdef.prot, mdef.name))
126 cnt.public_enums_missing += 1
127 comp_name = mdef.parent_doxy_file.compound.get_compoundname()
128 internal_file_name = mdef.parent_doxy_file.getInternalFileName()

Callers 1

checkPythonPxdHeaderFunction · 0.85

Calls 11

setPassedMethod · 0.95
setMessageMethod · 0.95
getMessageMethod · 0.95
parse_pxd_fileFunction · 0.90
TestResultClass · 0.85
ExceptionClass · 0.85
getInternalFileNameMethod · 0.80
resolve_return_typeMethod · 0.80
splitMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected