Skip to content

Commit a35f4ce

Browse files
committed
Some more common interfaces
1 parent 18607ee commit a35f4ce

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ObjFileBase.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export ObjectHandle, SectionRef, SymbolRef, debugsections
44

55
export printfield, printentry, printfield_with_color, deref,
66
sectionaddress, sectionoffset, sectionsize, sectionname,
7-
load_strtab, readmeta, StrTab
7+
load_strtab, readmeta, StrTab, symname
88

99
import Base: read, seek, readbytes, position, show
1010

@@ -119,12 +119,17 @@ deref(section::Section) = section
119119
abstract SymbolRef{T<:ObjectHandle}
120120
abstract SymtabEntry{T<:ObjectHandle}
121121

122+
function symname
123+
end
124+
122125
sectionsize(x::SectionRef) = sectionsize(deref(x))
123126
sectionaddress(x::SectionRef) = sectionaddress(deref(x))
124127
sectionoffset(x::SectionRef) = sectionoffset(deref(x))
125128

126129
handleT{T}(::Union{Type{SectionRef{T}}, Type{Section{T}}, Type{SymbolRef{T}},
127130
Type{SymtabEntry{T}}}) = T
131+
Base.read(s::SectionRef, args...) = read(handle(s), args...)
132+
Base.position(s::SectionRef) = position(handle(s)) - sectionoffset(s)
128133

129134
abstract StrTab
130135

@@ -143,6 +148,8 @@ seek{T<:ObjectHandle,S}(oh::T, section::Section{S}) =
143148
(@assert T <: S; seek(oh,sectionoffset(section)))
144149

145150
seek(section::SectionRef) = seek(handle(section), deref(section))
151+
Base.eof(section::SectionRef) = eof(handle(section)) ||
152+
(position(handle(section)) >= sectionoffset(section) + sectionsize(section))
146153

147154
function readbytes{T<:ObjectHandle,S}(oh::T,sec::Section{S})
148155
@assert T <: S

0 commit comments

Comments
 (0)