Remove skeletal modselect from extmod and just put it in stmhal.

This commit is contained in:
Damien George 2014-08-26 17:18:12 +01:00
parent e2a618615d
commit 013d53c0b4
10 changed files with 36 additions and 93 deletions

View File

@ -1,74 +0,0 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 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 <assert.h>
#include <string.h>
#include <stdint.h>
#include "mpconfig.h"
#include "misc.h"
#include "nlr.h"
#include "qstr.h"
#include "obj.h"
#include "runtime.h"
#include "objtuple.h"
#include "binary.h"
#if MICROPY_PY_SELECT
/// \module select - Provides select function to wait for events on a stream
///
/// This module provides the select function.
// This is just a skeleton. Individual functions must be implemented by a port.
// For the following, specific types don't matter, only addresses.
struct _dummy_t;
extern struct _dummy_t mp_select_select_obj;
extern struct _dummy_t mp_select_poll_obj;
STATIC const mp_map_elem_t mp_module_select_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_select) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_select_select_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_poll), (mp_obj_t)&mp_select_poll_obj },
};
STATIC const mp_obj_dict_t mp_module_select_globals = {
.base = {&mp_type_dict},
.map = {
.all_keys_are_qstrs = 1,
.table_is_fixed_array = 1,
.used = MP_ARRAY_SIZE(mp_module_select_globals_table),
.alloc = MP_ARRAY_SIZE(mp_module_select_globals_table),
.table = (mp_map_elem_t*)mp_module_select_globals_table,
},
};
const mp_obj_module_t mp_module_select = {
.base = { &mp_type_module },
.name = MP_QSTR_select,
.globals = (mp_obj_dict_t*)&mp_module_select_globals,
};
#endif // MICROPY_PY_SELECT

View File

@ -89,4 +89,3 @@ extern struct _dummy_t mp_sys_stderr_obj;
// extmod modules
extern const mp_obj_module_t mp_module_uctypes;
extern const mp_obj_module_t mp_module_zlibd;
extern const mp_obj_module_t mp_module_select;

View File

@ -200,9 +200,6 @@ STATIC const mp_map_elem_t mp_builtin_module_table[] = {
#if MICROPY_PY_ZLIBD
{ MP_OBJ_NEW_QSTR(MP_QSTR_zlibd), (mp_obj_t)&mp_module_zlibd },
#endif
#if MICROPY_PY_SELECT
{ MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_module_select },
#endif
// extra builtin modules as defined by a port
MICROPY_PORT_BUILTIN_MODULES

View File

@ -390,10 +390,6 @@ typedef double mp_float_t;
#define MICROPY_PY_ZLIBD (0)
#endif
#ifndef MICROPY_PY_SELECT
#define MICROPY_PY_SELECT (0)
#endif
/*****************************************************************************/
/* Hooks for a port to add builtins */

View File

@ -112,7 +112,6 @@ PY_O_BASENAME = \
pfenv_printf.o \
../extmod/moductypes.o \
../extmod/modzlibd.o \
../extmod/modselect.o \
# prepend the build destination prefix to the py object files
PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME))

View File

@ -463,11 +463,3 @@ Q(deleter)
Q(zlibd)
Q(decompress)
#endif
#if MICROPY_PY_SELECT
Q(select)
Q(poll)
Q(register)
Q(unregister)
Q(modify)
#endif

View File

@ -37,7 +37,9 @@
#include "objlist.h"
#include "pybioctl.h"
/// \moduleref select
/// \module select - Provides select function to wait for events on a stream
///
/// This module provides the select function.
typedef struct _poll_obj_t {
mp_obj_t obj;
@ -278,3 +280,26 @@ STATIC mp_obj_t select_poll(void) {
return poll;
}
MP_DEFINE_CONST_FUN_OBJ_0(mp_select_poll_obj, select_poll);
STATIC const mp_map_elem_t mp_module_select_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_select) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_select_select_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_poll), (mp_obj_t)&mp_select_poll_obj },
};
STATIC const mp_obj_dict_t mp_module_select_globals = {
.base = {&mp_type_dict},
.map = {
.all_keys_are_qstrs = 1,
.table_is_fixed_array = 1,
.used = MP_ARRAY_SIZE(mp_module_select_globals_table),
.alloc = MP_ARRAY_SIZE(mp_module_select_globals_table),
.table = (mp_map_elem_t*)mp_module_select_globals_table,
},
};
const mp_obj_module_t mp_module_select = {
.base = { &mp_type_module },
.name = MP_QSTR_select,
.globals = (mp_obj_dict_t*)&mp_module_select_globals,
};

View File

@ -57,7 +57,6 @@
#define MICROPY_PY_IO_FILEIO (1)
#define MICROPY_PY_UCTYPES (1)
#define MICROPY_PY_ZLIBD (1)
#define MICROPY_PY_SELECT (1)
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)
@ -76,6 +75,7 @@ extern const struct _mp_obj_module_t os_module;
extern const struct _mp_obj_module_t pyb_module;
extern const struct _mp_obj_module_t stm_module;
extern const struct _mp_obj_module_t time_module;
extern const struct _mp_obj_module_t mp_module_select;
#if MICROPY_PY_WIZNET5K
extern const struct _mp_obj_module_t mp_module_wiznet5k;
@ -89,6 +89,7 @@ extern const struct _mp_obj_module_t mp_module_wiznet5k;
{ MP_OBJ_NEW_QSTR(MP_QSTR_pyb), (mp_obj_t)&pyb_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_stm), (mp_obj_t)&stm_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_select), (mp_obj_t)&mp_module_select }, \
MICROPY_PY_WIZNET5K_DEF \
// extra constants

View File

@ -28,6 +28,7 @@ extern const mp_obj_module_t os_module;
extern const mp_obj_module_t pyb_module;
extern const mp_obj_module_t stm_module;
extern const mp_obj_module_t time_module;
extern const mp_obj_module_t mp_module_select;
// additional helper functions exported by the modules

View File

@ -269,6 +269,13 @@ Q(localtime)
Q(mktime)
Q(sleep)
// for select module
Q(select)
Q(poll)
Q(register)
Q(unregister)
Q(modify)
// for input
Q(input)