Skip to content
Snippets Groups Projects
Select Git revision
  • 1559a978100762efd84666befd134d5975ae8d4b
  • wip-bootstrap default
  • dualcore
  • ch3/leds
  • ch3/time
  • master
6 results

qstrdefs.h

Blame
  • modsys.c 7.13 KiB
    /*
     * This file is part of the Micro Python project, http://micropython.org/
     *
     * The MIT License (MIT)
     *
     * Copyright (c) 2013, 2014 Damien P. George
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy
     * of this software and associated documentation files (the "Software"), to deal
     * in the Software without restriction, including without limitation the rights
     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     * copies of the Software, and to permit persons to whom the Software is
     * furnished to do so, subject to the following conditions:
     *
     * The above copyright notice and this permission notice shall be included in
     * all copies or substantial portions of the Software.
     *
     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     * THE SOFTWARE.
     */
    
    #include "py/mpstate.h"
    #include "py/nlr.h"
    #include "py/builtin.h"
    #include "py/objlist.h"
    #include "py/objtuple.h"
    #include "py/objstr.h"
    #include "py/objint.h"
    #include "py/stream.h"
    
    #if MICROPY_PY_SYS
    
    #include "genhdr/mpversion.h"
    
    /// \module sys - system specific functions
    
    // defined per port; type of these is irrelevant, just need pointer
    extern struct _mp_dummy_t mp_sys_stdin_obj;
    extern struct _mp_dummy_t mp_sys_stdout_obj;
    extern struct _mp_dummy_t mp_sys_stderr_obj;
    
    #if MICROPY_PY_IO
    const mp_print_t mp_sys_stdout_print = {&mp_sys_stdout_obj, (mp_print_strn_t)mp_stream_write};
    #endif
    
    /// \constant version - Python language version that this implementation conforms to, as a string
    STATIC const MP_DEFINE_STR_OBJ(version_obj, "3.4.0");
    
    /// \constant version_info - Python language version that this implementation conforms to, as a tuple of ints
    #define I(n) MP_OBJ_NEW_SMALL_INT(n)
    // TODO: CPython is now at 5-element array, but save 2 els so far...
    STATIC const mp_obj_tuple_t mp_sys_version_info_obj = {{&mp_type_tuple}, 3, {I(3), I(4), I(0)}};
    
    // sys.implementation object
    // this holds the MicroPython version
    STATIC const mp_obj_tuple_t mp_sys_implementation_version_info_obj = {
        {&mp_type_tuple},
        3,
        { I(MICROPY_VERSION_MAJOR), I(MICROPY_VERSION_MINOR), I(MICROPY_VERSION_MICRO) }
    };
    #if MICROPY_PY_ATTRTUPLE
    STATIC const qstr impl_fields[] = { MP_QSTR_name, MP_QSTR_version };
    STATIC MP_DEFINE_ATTRTUPLE(
        mp_sys_implementation_obj,
        impl_fields,