summaryrefslogtreecommitdiffstatshomepage
path: root/py/obj.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-18 22:59:24 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-18 22:59:24 +0100
commitb11b85adaac9ac2e460647e59f951f5086cd2d4e (patch)
treec0c2e5b3159cc7e6455e9614ce93c5e432029428 /py/obj.c
parenta8f5d15fc6f2ee988e028ce8a5fc9f50c17309f4 (diff)
downloadmicropython-b11b85adaac9ac2e460647e59f951f5086cd2d4e.tar.gz
micropython-b11b85adaac9ac2e460647e59f951f5086cd2d4e.zip
py: Allow to pass buffer protocol flags to get_buffer helper funcs.
Diffstat (limited to 'py/obj.c')
-rw-r--r--py/obj.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/py/obj.c b/py/obj.c
index e0a712cb01..4b72514476 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -357,20 +357,20 @@ mp_obj_t mp_identity(mp_obj_t self) {
}
MP_DEFINE_CONST_FUN_OBJ_1(mp_identity_obj, mp_identity);
-bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo) {
+bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, int flags) {
mp_obj_type_t *type = mp_obj_get_type(obj);
if (type->buffer_p.get_buffer == NULL) {
return false;
}
- int ret = type->buffer_p.get_buffer(obj, bufinfo, MP_BUFFER_READ);
+ int ret = type->buffer_p.get_buffer(obj, bufinfo, flags);
if (ret != 0 || bufinfo->buf == NULL) {
return false;
}
return true;
}
-void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo) {
- if (!mp_get_buffer(obj, bufinfo)) {
+void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, int flags) {
+ if (!mp_get_buffer(obj, bufinfo, flags)) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "object with buffer protocol required"));
}
}