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
497660fc
Commit
497660fc
authored
8 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
py/stream: Add mp_stream_close() helper function.
parent
f9dc6440
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/stream.c
+8
-0
8 additions, 0 deletions
py/stream.c
py/stream.h
+1
-0
1 addition, 0 deletions
py/stream.h
with
9 additions
and
0 deletions
py/stream.c
+
8
−
0
View file @
497660fc
...
...
@@ -31,6 +31,7 @@
#include
"py/nlr.h"
#include
"py/objstr.h"
#include
"py/stream.h"
#include
"py/runtime.h"
#if MICROPY_STREAMS_NON_BLOCK
#include
<errno.h>
...
...
@@ -104,6 +105,13 @@ const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) {
return
stream_p
;
}
mp_obj_t
mp_stream_close
(
mp_obj_t
stream
)
{
// TODO: Still consider using ioctl for close
mp_obj_t
dest
[
2
];
mp_load_method
(
stream
,
MP_QSTR_close
,
dest
);
return
mp_call_method_n_kw
(
0
,
0
,
dest
);
}
STATIC
mp_obj_t
stream_read_generic
(
size_t
n_args
,
const
mp_obj_t
*
args
,
byte
flags
)
{
const
mp_stream_p_t
*
stream_p
=
mp_get_stream_raise
(
args
[
0
],
MP_STREAM_OP_READ
);
...
...
This diff is collapsed.
Click to expand it.
py/stream.h
+
1
−
0
View file @
497660fc
...
...
@@ -65,6 +65,7 @@ MP_DECLARE_CONST_FUN_OBJ(mp_stream_ioctl_obj);
#define MP_STREAM_OP_IOCTL (4)
const
mp_stream_p_t
*
mp_get_stream_raise
(
mp_obj_t
self_in
,
int
flags
);
mp_obj_t
mp_stream_close
(
mp_obj_t
stream
);
// Iterator which uses mp_stream_unbuffered_readline_obj
mp_obj_t
mp_stream_unbuffered_iter
(
mp_obj_t
self
);
...
...
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