Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
d00d8ac9
Commit
d00d8ac9
authored
10 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Use mp_uint_t where appropriate in stream functions.
parent
e294bee4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/stream.c
+7
-7
7 additions, 7 deletions
py/stream.c
with
7 additions
and
7 deletions
py/stream.c
+
7
−
7
View file @
d00d8ac9
...
...
@@ -60,7 +60,7 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in);
#define STREAM_CONTENT_TYPE(stream) (((stream)->is_text) ? &mp_type_str : &mp_type_bytes)
STATIC
mp_obj_t
stream_read
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
stream_read
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
struct
_mp_obj_base_t
*
o
=
(
struct
_mp_obj_base_t
*
)
args
[
0
];
if
(
o
->
type
->
stream_p
==
NULL
||
o
->
type
->
stream_p
->
read
==
NULL
)
{
// CPython: io.UnsupportedOperation, OSError subclass
...
...
@@ -215,7 +215,7 @@ STATIC mp_obj_t stream_write_method(mp_obj_t self_in, mp_obj_t arg) {
return
mp_stream_write
(
self_in
,
bufinfo
.
buf
,
bufinfo
.
len
);
}
STATIC
mp_obj_t
stream_readinto
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
stream_readinto
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
struct
_mp_obj_base_t
*
o
=
(
struct
_mp_obj_base_t
*
)
args
[
0
];
if
(
o
->
type
->
stream_p
==
NULL
||
o
->
type
->
stream_p
->
read
==
NULL
)
{
// CPython: io.UnsupportedOperation, OSError subclass
...
...
@@ -254,12 +254,12 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in) {
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_OSError
,
"Operation not supported"
));
}
in
t
total_size
=
0
;
mp_uint_
t
total_size
=
0
;
vstr_t
*
vstr
=
vstr_new_size
(
DEFAULT_BUFFER_SIZE
);
char
*
p
=
vstr_str
(
vstr
);
int
error
;
int
current_read
=
DEFAULT_BUFFER_SIZE
;
mp_uint_t
current_read
=
DEFAULT_BUFFER_SIZE
;
while
(
true
)
{
int
error
;
mp_uint_t
out_sz
=
o
->
type
->
stream_p
->
read
(
self_in
,
p
,
current_read
,
&
error
);
if
(
out_sz
==
MP_STREAM_ERROR
)
{
if
(
is_nonblocking_error
(
error
))
{
...
...
@@ -296,7 +296,7 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in) {
}
// Unbuffered, inefficient implementation of readline() for raw I/O files.
STATIC
mp_obj_t
stream_unbuffered_readline
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
stream_unbuffered_readline
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
struct
_mp_obj_base_t
*
o
=
(
struct
_mp_obj_base_t
*
)
args
[
0
];
if
(
o
->
type
->
stream_p
==
NULL
||
o
->
type
->
stream_p
->
read
==
NULL
)
{
// CPython: io.UnsupportedOperation, OSError subclass
...
...
@@ -315,13 +315,13 @@ STATIC mp_obj_t stream_unbuffered_readline(uint n_args, const mp_obj_t *args) {
vstr
=
vstr_new
();
}
int
error
;
while
(
max_size
==
-
1
||
max_size
--
!=
0
)
{
char
*
p
=
vstr_add_len
(
vstr
,
1
);
if
(
p
==
NULL
)
{
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_MemoryError
,
"out of memory"
));
}
int
error
;
mp_uint_t
out_sz
=
o
->
type
->
stream_p
->
read
(
o
,
p
,
1
,
&
error
);
if
(
out_sz
==
MP_STREAM_ERROR
)
{
if
(
is_nonblocking_error
(
error
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment