Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
489d5c4b
Commit
489d5c4b
authored
May 30, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added eq and hash to source descriptors
parent
4e70c07a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+15
-0
No files found.
Cython/Compiler/Scanning.py
View file @
489d5c4b
...
@@ -206,6 +206,9 @@ def initial_compile_time_env():
...
@@ -206,6 +206,9 @@ def initial_compile_time_env():
#------------------------------------------------------------------
#------------------------------------------------------------------
class
SourceDescriptor
:
class
SourceDescriptor
:
"""
A SourceDescriptor should be considered immutable.
"""
def
__str__
(
self
):
def
__str__
(
self
):
assert
False
# To catch all places where a descriptor is used directly as a filename
assert
False
# To catch all places where a descriptor is used directly as a filename
...
@@ -237,6 +240,12 @@ class FileSourceDescriptor(SourceDescriptor):
...
@@ -237,6 +240,12 @@ class FileSourceDescriptor(SourceDescriptor):
def
get_filenametable_entry
(
self
):
def
get_filenametable_entry
(
self
):
return
self
.
filename
return
self
.
filename
def
__eq__
(
self
,
other
):
return
isinstance
(
other
,
FileSourceDescriptor
)
and
self
.
filename
==
other
.
filename
def
__hash__
(
self
):
return
hash
(
self
.
filename
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
"<FileSourceDescriptor:%s>"
%
self
.
filename
return
"<FileSourceDescriptor:%s>"
%
self
.
filename
...
@@ -258,6 +267,12 @@ class StringSourceDescriptor(SourceDescriptor):
...
@@ -258,6 +267,12 @@ class StringSourceDescriptor(SourceDescriptor):
def
get_filenametable_entry
(
self
):
def
get_filenametable_entry
(
self
):
return
"stringsource"
return
"stringsource"
def
__hash__
(
self
):
return
hash
(
self
.
name
)
def
__eq__
(
self
,
other
):
return
isinstance
(
other
,
StringSourceDescriptor
)
and
self
.
name
==
other
.
name
def
__repr__
(
self
):
def
__repr__
(
self
):
return
"<StringSourceDescriptor:%s>"
%
self
.
name
return
"<StringSourceDescriptor:%s>"
%
self
.
name
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment