Skip to content

Commit 3cef7c8

Browse files
committed
implement gcc.Location.__hash__
1 parent 979759a commit 3cef7c8

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

gcc-python-location.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
Copyright 2011, 2012 David Malcolm <[email protected]>
3-
Copyright 2011, 2012 Red Hat, Inc.
2+
Copyright 2011, 2012, 2013 David Malcolm <[email protected]>
3+
Copyright 2011, 2012, 2013 Red Hat, Inc.
44
55
This is free software: you can redistribute it and/or modify it
66
under the terms of the GNU General Public License as published by
@@ -158,6 +158,12 @@ PyGccLocation_richcompare(PyObject *o1, PyObject *o2, int op)
158158
return result_obj;
159159
}
160160

161+
long
162+
PyGccLocation_hash(struct PyGccLocation * self)
163+
{
164+
return self->loc.inner;
165+
}
166+
161167
PyObject *
162168
PyGccLocation_New(gcc_location loc)
163169
{

gcc-python-wrappers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ PyGccLocation_str(struct PyGccLocation * self);
141141
PyObject *
142142
PyGccLocation_richcompare(PyObject *o1, PyObject *o2, int op);
143143

144+
long
145+
PyGccLocation_hash(struct PyGccLocation * self);
146+
144147
/* gcc-python-cfg.c: */
145148
PyObject *
146149
PyGccBasicBlock_repr(struct PyGccBasicBlock * self);

generate-location-c.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Copyright 2011, 2012 David Malcolm <[email protected]>
2-
# Copyright 2011, 2012 Red Hat, Inc.
1+
# Copyright 2011, 2012, 2013 David Malcolm <[email protected]>
2+
# Copyright 2011, 2012, 2013 Red Hat, Inc.
33
#
44
# This is free software: you can redistribute it and/or modify it
55
# under the terms of the GNU General Public License as published by
@@ -71,6 +71,7 @@ def generate_location():
7171
struct_name = 'PyGccLocation',
7272
tp_new = 'PyType_GenericNew',
7373
tp_getset = getsettable.identifier,
74+
tp_hash = '(hashfunc)PyGccLocation_hash',
7475
tp_repr = '(reprfunc)PyGccLocation_repr',
7576
tp_str = '(reprfunc)PyGccLocation_str',
7677
tp_richcompare = 'PyGccLocation_richcompare',

0 commit comments

Comments
 (0)