4
4
abstract type Codec end
5
5
6
6
abstract type Mode end
7
- struct ReadMode <: Mode end
8
- struct WriteMode <: Mode end
7
+ struct Read <: Mode end
8
+ struct Write <: Mode end
9
9
10
10
primitive type ProcCode 8 end
11
11
const PROC_INIT = reinterpret (ProcCode, 0x00 )
@@ -17,28 +17,28 @@ const PROC_FINISH = reinterpret(ProcCode, 0x02)
17
17
# -----
18
18
19
19
"""
20
- start(::Type{ReadMode }, codec::Codec, source::IO)::Void
20
+ start(::Type{Read }, codec::Codec, source::IO)::Void
21
21
22
22
Start transcoding using `codec` with read mode.
23
23
24
24
This method will be called only once before calling `process` first time.
25
25
26
26
Implementing this method is optional; there is a default method that does nothing.
27
27
"""
28
- function start (:: Type{ReadMode } , :: Codec , :: IO )
28
+ function start (:: Type{Read } , :: Codec , :: IO )
29
29
return nothing
30
30
end
31
31
32
32
"""
33
- start(::Type{WriteMode }, codec::Codec, sink::IO)::Void
33
+ start(::Type{Write }, codec::Codec, sink::IO)::Void
34
34
35
35
Start transcoding using `codec` with write mode.
36
36
37
37
This method will be called only once before calling `process` first time.
38
38
39
39
Implementing this method is optional; there is a default method that does nothing.
40
40
"""
41
- function start (:: Type{WriteMode } , :: Codec , :: IO )
41
+ function start (:: Type{Write } , :: Codec , :: IO )
42
42
return nothing
43
43
end
44
44
47
47
# -------
48
48
49
49
"""
50
- process(::Type{ReadMode }, codec::Codec, source::IO, output::Ptr{UInt8}, nbytes::Int)::Tuple{Int,ProcCode}
50
+ process(::Type{Read }, codec::Codec, source::IO, output::Ptr{UInt8}, nbytes::Int)::Tuple{Int,ProcCode}
51
51
52
52
Transcode data using `codec` with read mode.
53
53
@@ -72,12 +72,12 @@ malfomed data from `source`. However, this method must not throw `EOFError`
72
72
when reading data from `source`. Also note that it is responsible for this
73
73
method to release resources allocated by `codec` when an exception happens.
74
74
"""
75
- function process (:: Type{ReadMode } , codec:: Codec , stream:: IO , data:: Ptr{UInt8} , nbytes:: Int )
75
+ function process (:: Type{Read } , codec:: Codec , stream:: IO , data:: Ptr{UInt8} , nbytes:: Int )
76
76
error (" codec $(codec) does not implement read mode" )
77
77
end
78
78
79
79
"""
80
- process(::Type{WriteMode }, codec::Codec, sink::IO, input::Ptr{UInt8}, nbytes::Int)::Tuple{Int,ProcCode}
80
+ process(::Type{Write }, codec::Codec, sink::IO, input::Ptr{UInt8}, nbytes::Int)::Tuple{Int,ProcCode}
81
81
82
82
Transcode data using `codec` with write mode.
83
83
@@ -86,7 +86,7 @@ Transcode data using `codec` with write mode.
86
86
87
87
This method reads some data from `input` and write the transcoded bytes to `sink`.
88
88
"""
89
- function process (:: Type{WriteMode } , codec:: Codec , stream:: IO , data:: Ptr{UInt8} , nbytes:: Int )
89
+ function process (:: Type{Write } , codec:: Codec , stream:: IO , data:: Ptr{UInt8} , nbytes:: Int )
90
90
error (" codec $(codec) does not implement write mode" )
91
91
end
92
92
95
95
# ------
96
96
97
97
"""
98
- finish(::Type{ReadMode }, codec::Codec, source::IO)::Void
98
+ finish(::Type{Read }, codec::Codec, source::IO)::Void
99
99
100
100
Finish transcoding using `codec` with read mode.
101
101
102
102
This method will be called only once after calling `process` last time.
103
103
104
104
Implementing this method is optional; there is a default method that does nothing.
105
105
"""
106
- function finish (:: Type{ReadMode } , :: Codec , :: IO )
106
+ function finish (:: Type{Read } , :: Codec , :: IO )
107
107
return nothing
108
108
end
109
109
110
110
"""
111
- finish(::Type{WriteMode }, codec::Codec, sink::IO)::Void
111
+ finish(::Type{Write }, codec::Codec, sink::IO)::Void
112
112
113
113
Finish transcoding using `codec` with write mode.
114
114
115
115
This method will be called only once after calling `process` last time.
116
116
117
117
Implementing this method is optional; there is a default method that does nothing.
118
118
"""
119
- function finish (:: Type{WriteMode } , :: Codec , :: IO )
119
+ function finish (:: Type{Write } , :: Codec , :: IO )
120
120
return nothing
121
121
end
0 commit comments