<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/extmod/vfs.h, branch type_hints</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=type_hints</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=type_hints'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2019-12-04T15:29:57+00:00</updated>
<entry>
<title>protocols: Allow them to be (optionally) type-safe</title>
<updated>2019-12-04T15:29:57+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2019-12-03T20:50:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=238e12123690debaf2cf8488fb2a4d4003a06506'/>
<id>urn:sha1:238e12123690debaf2cf8488fb2a4d4003a06506</id>
<content type='text'>
Protocols are nice, but there is no way for C code to verify whether
a type's "protocol" structure actually implements some particular
protocol.  As a result, you can pass an object that implements the
"vfs" protocol to one that expects the "stream" protocol, and the
opposite of awesomeness ensues.

This patch adds an OPTIONAL (but enabled by default) protocol identifier
as the first member of any protocol structure.  This identifier is
simply a unique QSTR chosen by the protocol designer and used by each
protocol implementer.  When checking for protocol support, instead of
just checking whether the object's type has a non-NULL protocol field,
use `mp_proto_get` which implements the protocol check when possible.

The existing protocols are now named:
    protocol_framebuf
    protocol_i2c
    protocol_pin
    protocol_stream
    protocol_spi
    protocol_vfs
(most of these are unused in CP and are just inherited from MP; vfs and
stream are definitely used though)

I did not find any crashing examples, but here's one to give a flavor of what
is improved, using `micropython_coverage`.  Before the change,
the vfs "ioctl" protocol is invoked, and the result is not intelligible
as json (but it could have resulted in a hard fault, potentially):

    &gt;&gt;&gt; import uos, ujson
    &gt;&gt;&gt; u = uos.VfsPosix('/tmp')
    &gt;&gt;&gt; ujson.load(u)
    Traceback (most recent call last):
      File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    ValueError: syntax error in JSON

After the change, the vfs object is correctly detected as not supporting
the stream protocol:
    &gt;&gt;&gt; ujson.load(p)
    Traceback (most recent call last):
      File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    OSError: stream operation not supported
</content>
</entry>
<entry>
<title>compiles and runs; hangs on import storage;storage.VfsFat.&lt;tab&gt;</title>
<updated>2018-07-14T02:51:10+00:00</updated>
<author>
<name>Dan Halbert</name>
<email>halbert@halwitz.org</email>
</author>
<published>2018-07-14T02:51:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=e2e01efa84d2ed46d004edf48076e4701accc176'/>
<id>urn:sha1:e2e01efa84d2ed46d004edf48076e4701accc176</id>
<content type='text'>
</content>
</entry>
<entry>
<title>WIP: after merge; before testing</title>
<updated>2018-07-11T20:45:30+00:00</updated>
<author>
<name>Dan Halbert</name>
<email>halbert@halwitz.org</email>
</author>
<published>2018-07-11T20:45:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=7c219600a246d8956d0b23ea3f5d125a820e6b6a'/>
<id>urn:sha1:7c219600a246d8956d0b23ea3f5d125a820e6b6a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>extmod/vfs: Introduce a C-level VFS protocol, with fast import_stat.</title>
<updated>2018-06-06T04:33:42+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-06-06T04:24:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=c117effddd1f9ffd902a9712cf0ae7413696dc66'/>
<id>urn:sha1:c117effddd1f9ffd902a9712cf0ae7413696dc66</id>
<content type='text'>
Following other C-level protocols, this VFS protocol is added to help
abstract away implementation details of the underlying VFS in an efficient
way.  As a starting point, the import_stat function is put into this
protocol so that the VFS sub-system does not need to know about every VFS
implementation in order to do an efficient stat for importing files.

In the future it might be worth adding other functions to this protocol.
</content>
</entry>
<entry>
<title>Initial merge of micropython v1.9.2 into circuitpython 2.0.0 (in development) master.</title>
<updated>2017-08-26T02:17:07+00:00</updated>
<author>
<name>Dan Halbert</name>
<email>halbert@halwitz.org</email>
</author>
<published>2017-08-26T02:17:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=ef61b5ecb59e9b4e37e3e3c023c62d583c23eb16'/>
<id>urn:sha1:ef61b5ecb59e9b4e37e3e3c023c62d583c23eb16</id>
<content type='text'>
cpx build compiles and loads and works in repl; test suite not run yet
esp8266 not tested yet
</content>
</entry>
<entry>
<title>all: Unify header guard usage.</title>
<updated>2017-07-18T01:57:39+00:00</updated>
<author>
<name>Alexander Steffen</name>
<email>devel.20.webmeister@spamgourmet.com</email>
</author>
<published>2017-06-29T21:14:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=299bc625864b9e624ed599c94a5f95870516139a'/>
<id>urn:sha1:299bc625864b9e624ed599c94a5f95870516139a</id>
<content type='text'>
The code conventions suggest using header guards, but do not define how
those should look like and instead point to existing files. However, not
all existing files follow the same scheme, sometimes omitting header guards
altogether, sometimes using non-standard names, making it easy to
accidentally pick a "wrong" example.

This commit ensures that all header files of the MicroPython project (that
were not simply copied from somewhere else) follow the same pattern, that
was already present in the majority of files, especially in the py folder.

The rules are as follows.

Naming convention:
* start with the words MICROPY_INCLUDED
* contain the full path to the file
* replace special characters with _

In addition, there are no empty lines before #ifndef, between #ifndef and
one empty line before #endif. #endif is followed by a comment containing
the name of the guard macro.

py/grammar.h cannot use header guards by design, since it has to be
included multiple times in a single C file. Several other files also do not
need header guards as they are only used internally and guaranteed to be
included only once:
* MICROPY_MPHALPORT_H
* mpconfigboard.h
* mpconfigport.h
* mpthreadport.h
* pin_defs_*.h
* qstrdefs*.h
</content>
</entry>
<entry>
<title>Split uos module into os and storage.</title>
<updated>2017-06-27T22:17:30+00:00</updated>
<author>
<name>Scott Shawcroft</name>
<email>scott.shawcroft@gmail.com</email>
</author>
<published>2017-06-27T22:17:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=778e975936b9e892c4f1b85ce73462a0ce6d36d2'/>
<id>urn:sha1:778e975936b9e892c4f1b85ce73462a0ce6d36d2</id>
<content type='text'>
os is a subset of CPython's os. storage contains additional
file system mounting functionality based on UNIX's mount
management.

Fixes #140
</content>
</entry>
<entry>
<title>extmod/vfs: Implement mp_vfs_ilistdir().</title>
<updated>2017-05-10T01:39:28+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-05-05T13:31:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=87283c1974188707b436eebf2a04d4555a26dcca'/>
<id>urn:sha1:87283c1974188707b436eebf2a04d4555a26dcca</id>
<content type='text'>
uos.ilistdir() is the core function, returning an iterator that yields
3-tuples.  uos.listdir() is implemented in terms of ilistdir().
</content>
</entry>
<entry>
<title>extmod: Merge old fsusermount.h header into vfs.h and vfs_fat.h.</title>
<updated>2017-01-30T01:26:08+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-01-29T08:20:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=b697c890096805d9ccaf7553dbff5b82f5332609'/>
<id>urn:sha1:b697c890096805d9ccaf7553dbff5b82f5332609</id>
<content type='text'>
vfs.h is for generic VFS declarations, and vfs_fat.h is for VfsFat
specific things.
</content>
</entry>
<entry>
<title>extmod/vfs: Expose lookup_path_raw as mp_vfs_lookup_path.</title>
<updated>2017-01-30T01:18:35+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-01-29T04:14:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=6eafa544865a5d6dcb18f9161f7a18bd4fb6229f'/>
<id>urn:sha1:6eafa544865a5d6dcb18f9161f7a18bd4fb6229f</id>
<content type='text'>
It can be useful for low-level lookup of paths by ports.
</content>
</entry>
</feed>
