mirror of
https://github.com/AdaCore/langkit.git
synced 2026-02-12 12:28:12 -08:00
Python API: add __eq__ and __hash__ to analysis context/unit classes
So that different Python wrapper for the same analysis context/unit behave more like a single one: only identity (id(obj)) should differ. Change-Id: I94ca1e978081b074c0050fa4dae0931985b2659c TN: P407-015
This commit is contained in:
@@ -149,6 +149,12 @@ class AnalysisContext(object):
|
||||
_destroy_analysis_context(self._c_value)
|
||||
super(AnalysisContext, self).__init__()
|
||||
|
||||
def __eq__(self, other):
|
||||
return self._c_value == other._c_value
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self._c_value)
|
||||
|
||||
def get_from_file(self, filename, charset=None, reparse=False,
|
||||
with_trivia=False):
|
||||
${py_doc('langkit.get_unit_from_file', 8)}
|
||||
@@ -224,6 +230,12 @@ class AnalysisUnit(object):
|
||||
_unit_decref(self._c_value)
|
||||
super(AnalysisUnit, self).__init__()
|
||||
|
||||
def __eq__(self, other):
|
||||
return self._c_value == other._c_value
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self._c_value)
|
||||
|
||||
def reparse(self, buffer=None, charset=None):
|
||||
${py_doc('langkit.unit_reparse_generic', 8)}
|
||||
if buffer is None:
|
||||
|
||||
Reference in New Issue
Block a user