[Fix] Fix conflicts ._.

This commit is contained in:
Quentin
2020-04-07 14:53:19 +02:00
194 changed files with 4774 additions and 1958 deletions

View File

@@ -1,13 +1,13 @@
// Automatically generated by makemoduledefs.py.
#if (MICROPY_PY_ARRAY)
extern const struct _mp_obj_module_t mp_module_array;
#define MODULE_DEF_MP_QSTR_ARRAY { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mp_module_array) },
extern const struct _mp_obj_module_t mp_module_uarray;
#define MODULE_DEF_MP_QSTR_UARRAY { MP_ROM_QSTR(MP_QSTR_uarray), MP_ROM_PTR(&mp_module_uarray) },
#else
#define MODULE_DEF_MP_QSTR_ARRAY
#define MODULE_DEF_MP_QSTR_UARRAY
#endif
#define MICROPY_REGISTERED_MODULES \
MODULE_DEF_MP_QSTR_ARRAY \
MODULE_DEF_MP_QSTR_UARRAY \
// MICROPY_REGISTERED_MODULES

View File

@@ -1,4 +0,0 @@
// This file was generated by py/makeversionhdr.py
#define MICROPY_GIT_TAG "v1.11-dirty"
#define MICROPY_GIT_HASH "6f75c4f3c-dirty"
#define MICROPY_BUILD_DATE "2019-08-21"

View File

@@ -1,33 +0,0 @@
#include "modpyplot.h"
STATIC MP_DEFINE_CONST_FUN_OBJ_0(modpyplot___init___obj, modpyplot___init__);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_arrow_obj, 4, 4, modpyplot_arrow);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_axis_obj, 0, 1, modpyplot_axis);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_bar_obj, 2, 4, modpyplot_bar);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_grid_obj, 0, 1, modpyplot_grid);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_hist_obj, 1, 2, modpyplot_hist);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_plot_obj, 1, 2, modpyplot_plot);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(modpyplot_scatter_obj, modpyplot_scatter);
STATIC MP_DEFINE_CONST_FUN_OBJ_0(modpyplot_show_obj, modpyplot_show);
STATIC MP_DEFINE_CONST_FUN_OBJ_3(modpyplot_text_obj, modpyplot_text);
STATIC const mp_rom_map_elem_t modpyplot_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_matplotlib_dot_pyplot) },
{ MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&modpyplot___init___obj) },
{ MP_ROM_QSTR(MP_QSTR_arrow), MP_ROM_PTR(&modpyplot_arrow_obj) },
{ MP_ROM_QSTR(MP_QSTR_axis), MP_ROM_PTR(&modpyplot_axis_obj) },
{ MP_ROM_QSTR(MP_QSTR_bar), MP_ROM_PTR(&modpyplot_bar_obj) },
{ MP_ROM_QSTR(MP_QSTR_grid), MP_ROM_PTR(&modpyplot_grid_obj) },
{ MP_ROM_QSTR(MP_QSTR_hist), MP_ROM_PTR(&modpyplot_hist_obj) },
{ MP_ROM_QSTR(MP_QSTR_plot), MP_ROM_PTR(&modpyplot_plot_obj) },
{ MP_ROM_QSTR(MP_QSTR_scatter), MP_ROM_PTR(&modpyplot_scatter_obj) },
{ MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&modpyplot_show_obj) },
{ MP_ROM_QSTR(MP_QSTR_text), MP_ROM_PTR(&modpyplot_text_obj) },
};
STATIC MP_DEFINE_CONST_DICT(modpyplot_module_globals, modpyplot_module_globals_table);
const mp_obj_module_t modpyplot_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&modpyplot_module_globals,
};

View File

@@ -88,8 +88,7 @@ mp_obj_t modpyplot_arrow(size_t n_args, const mp_obj_t *args) {
assert(sPlotStore != nullptr);
KDColor color = Palette::nextDataColor(&paletteIndex);
sPlotStore->addSegment(args[0], args[1], mp_obj_new_float(mp_obj_get_float(args[0])+mp_obj_get_float(args[2])), mp_obj_new_float(mp_obj_get_float(args[1])+mp_obj_get_float(args[3])), color, true); // TODO: use float_binary_op
sPlotStore->addSegment(args[0], args[1], mp_obj_float_binary_op(MP_BINARY_OP_INPLACE_ADD, mp_obj_get_float(args[0]), args[2]), mp_obj_float_binary_op(MP_BINARY_OP_INPLACE_ADD, mp_obj_get_float(args[1]), args[3]), color, true);
return mp_const_none;
}
@@ -183,13 +182,23 @@ mp_obj_t modpyplot_bar(size_t n_args, const mp_obj_t *args) {
KDColor color = Palette::nextDataColor(&paletteIndex);
for (size_t i=0; i<xLength; i++) {
mp_float_t iH = mp_obj_get_float(hItems[hLength > 1 ? i : 0]);
mp_float_t iW = mp_obj_get_float(wItems[wLength > 1 ? i : 0]);
mp_float_t iB = mp_obj_get_float(bItems[bLength > 1 ? i : 0]);
mp_float_t iX = mp_obj_get_float(xItems[i])-iW/2.0;
mp_float_t iYStart = iH < 0.0 ? iB : iB + iH;
mp_float_t iYEnd = iH < 0.0 ? iB + iH : iB;
sPlotStore->addRect(mp_obj_new_float(iX), mp_obj_new_float(iX+iW), mp_obj_new_float(iYStart), mp_obj_new_float(iYEnd), color); // TODO: use float_binary_op?
mp_obj_t iH = hItems[hLength > 1 ? i : 0];
mp_obj_t iW = wItems[wLength > 1 ? i : 0];
mp_obj_t iB = bItems[bLength > 1 ? i : 0];
mp_obj_t iX = xItems[i];
float iWf = mp_obj_get_float(iW);
float iXf = mp_obj_get_float(iX);
mp_obj_t rectLeft = mp_obj_new_float(iXf - iWf/2.0f);
mp_obj_t rectRight = mp_obj_new_float(iXf + iWf/2.0f);
mp_obj_t rectBottom = iB;
mp_obj_t rectTop = mp_obj_float_binary_op(MP_BINARY_OP_INPLACE_ADD, mp_obj_get_float(iH), iB);
if (mp_obj_get_float(iH) < 0.0) {
mp_obj_t temp = rectTop;
rectTop = rectBottom;
rectBottom = temp;
}
sPlotStore->addRect(rectLeft, rectRight, rectTop, rectBottom, color);
}
return mp_const_none;
}
@@ -229,6 +238,8 @@ mp_obj_t modpyplot_hist(size_t n_args, const mp_obj_t *args) {
mp_float_t min = mp_obj_get_float(xItems[0]);
mp_float_t max = mp_obj_get_float(xItems[xLength - 1]);
// TODO: memory optimization
// Don't create a list of edges, compute the edge on the go if not present?
mp_obj_t * edgeItems;
size_t nBins;
// bin arg
@@ -252,7 +263,7 @@ mp_obj_t modpyplot_hist(size_t n_args, const mp_obj_t *args) {
}
// Fill the bin edges list
for (int i = 0; i < nBins+1; i++) {
for (size_t i = 0; i < nBins+1; i++) {
edgeItems[i] = mp_obj_new_float(min+i*binWidth);
}
}
@@ -323,7 +334,7 @@ mp_obj_t modpyplot_plot(size_t n_args, const mp_obj_t *args) {
// Create the default xItems: [0, 1, 2,...]
xItems = m_new(mp_obj_t, length);
for (int i = 0; i < length; i++) {
for (size_t i = 0; i < length; i++) {
xItems[i] = mp_obj_new_float((float)i);
}
} else {

View File

@@ -62,7 +62,7 @@ T PlotStore::ListIterator<T>::operator*() {
};
void checkFloatType(mp_obj_t * elements, size_t nbOfElements) {
for (int i = 0; i < nbOfElements; i++) {
for (size_t i = 0; i < nbOfElements; i++) {
// TODO: we don't take advantage of the fact that we extracted the value at the sametime... Maybe change the way things are done, build the c objects in addItem instead of allocating them on the python heap? Or use float array in python?
mp_float_t value;
if (!mp_obj_get_float_maybe(elements[i], &value)) {

View File

@@ -119,8 +119,6 @@ typedef uintptr_t mp_uint_t; // must be pointer size
typedef long mp_off_t;
#define SEEK_CUR 1
// extra built in names to add to the global namespace
#define MICROPY_PORT_BUILTINS \
{ MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj }, \

View File

@@ -30,7 +30,7 @@ MicroPython::ExecutionEnvironment * MicroPython::ExecutionEnvironment::currentEx
return sCurrentExecutionEnvironment;
}
void MicroPython::ExecutionEnvironment::runCode(const char * str) {
bool MicroPython::ExecutionEnvironment::runCode(const char * str) {
assert(sCurrentExecutionEnvironment == nullptr);
sCurrentExecutionEnvironment = this;
@@ -38,6 +38,7 @@ void MicroPython::ExecutionEnvironment::runCode(const char * str) {
* for the exception handling (because of print). */
mp_hal_set_interrupt_char((int)Ion::Keyboard::Key::Back);
bool runSucceeded = true;
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
mp_lexer_t *lex = mp_lexer_new_from_str_len(0, str, strlen(str), false);
@@ -45,10 +46,11 @@ void MicroPython::ExecutionEnvironment::runCode(const char * str) {
* to be fed lines and not files. */
// TODO: add a parameter when other input types (file, eval) are required
mp_parse_tree_t pt = mp_parse(lex, MP_PARSE_SINGLE_INPUT);
mp_obj_t module_fun = mp_compile(&pt, lex->source_name, MP_EMIT_OPT_NONE, true);
mp_obj_t module_fun = mp_compile(&pt, lex->source_name, true);
mp_call_function_0(module_fun);
nlr_pop();
} else { // Uncaught exception
runSucceeded = false;
/* mp_obj_print_exception is supposed to handle error printing. However,
* because we want to print custom information, we copied and modified the
* content of mp_obj_print_exception instead of calling it. */
@@ -69,7 +71,7 @@ void MicroPython::ExecutionEnvironment::runCode(const char * str) {
#endif
// the block name can be NULL if it's unknown
qstr block = values[i + 2];
if (block == MP_QSTR_NULL) {
if (block == MP_QSTRnull) {
mp_print_str(&mp_plat_print, "\n");
} else {
mp_printf(&mp_plat_print, ", in %q\n", block);
@@ -93,6 +95,7 @@ void MicroPython::ExecutionEnvironment::runCode(const char * str) {
assert(sCurrentExecutionEnvironment == this);
sCurrentExecutionEnvironment = nullptr;
return runSucceeded;
}
void MicroPython::ExecutionEnvironment::interrupt() {

View File

@@ -17,7 +17,7 @@ class ExecutionEnvironment {
public:
ExecutionEnvironment() {}
static ExecutionEnvironment * currentExecutionEnvironment();
void runCode(const char * );
bool runCode(const char * );
virtual const char * inputText(const char * prompt) { return nullptr; }
// Sandbox