mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[python] matplotlib: make pyplot a submodule of matplotlib
This commit is contained in:
@@ -134,11 +134,13 @@ port_src += $(addprefix python/port/,\
|
||||
mod/ion/modion_table.cpp \
|
||||
mod/kandinsky/modkandinsky.cpp \
|
||||
mod/kandinsky/modkandinsky_table.c \
|
||||
mod/matplotlib/modpyplot.cpp \
|
||||
mod/matplotlib/modpyplot_table.c \
|
||||
mod/matplotlib/plot_controller.cpp \
|
||||
mod/matplotlib/plot_store.cpp \
|
||||
mod/matplotlib/plot_view.cpp \
|
||||
mod/matplotlib/modmatplotlib.cpp \
|
||||
mod/matplotlib/modmatplotlib_table.c \
|
||||
mod/matplotlib/pyplot/modpyplot.cpp \
|
||||
mod/matplotlib/pyplot/modpyplot_table.c \
|
||||
mod/matplotlib/pyplot/plot_controller.cpp \
|
||||
mod/matplotlib/pyplot/plot_store.cpp \
|
||||
mod/matplotlib/pyplot/plot_view.cpp \
|
||||
mod/time/modtime.c \
|
||||
mod/time/modtime_table.c \
|
||||
mod/turtle/modturtle.cpp \
|
||||
|
||||
@@ -81,7 +81,9 @@ Q(grid)
|
||||
Q(grid)
|
||||
Q(hist)
|
||||
Q(plot)
|
||||
Q(matplotlib)
|
||||
Q(matplotlib.pyplot)
|
||||
Q(pyplot)
|
||||
Q(scatter)
|
||||
Q(show)
|
||||
Q(text)
|
||||
|
||||
13
python/port/mod/matplotlib/modmatplotlib.cpp
Normal file
13
python/port/mod/matplotlib/modmatplotlib.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
extern "C" {
|
||||
#include "modmatplotlib.h"
|
||||
#include "pyplot/modpyplot.h"
|
||||
}
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
// Internal functions
|
||||
|
||||
mp_obj_t modmatplotlib___init__() {
|
||||
modpyplot___init__();
|
||||
return mp_const_none;
|
||||
}
|
||||
3
python/port/mod/matplotlib/modmatplotlib.h
Normal file
3
python/port/mod/matplotlib/modmatplotlib.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <py/obj.h>
|
||||
|
||||
mp_obj_t modmatplotlib___init__();
|
||||
18
python/port/mod/matplotlib/modmatplotlib_table.c
Normal file
18
python/port/mod/matplotlib/modmatplotlib_table.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "modmatplotlib.h"
|
||||
|
||||
extern const mp_obj_module_t modpyplot_module;
|
||||
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(modmatplotlib___init___obj, modmatplotlib___init__);
|
||||
|
||||
STATIC const mp_rom_map_elem_t modmatplotlib_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_matplotlib) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___init__), MP_ROM_PTR(&modmatplotlib___init___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_pyplot), MP_ROM_PTR(&modpyplot_module) }
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(modmatplotlib_module_globals, modmatplotlib_module_globals_table);
|
||||
|
||||
const mp_obj_module_t modmatplotlib_module = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t*)&modmatplotlib_module_globals,
|
||||
};
|
||||
33
python/port/mod/matplotlib/pyplot/modpyplot_table.c
Normal file
33
python/port/mod/matplotlib/pyplot/modpyplot_table.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#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_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,
|
||||
};
|
||||
@@ -130,6 +130,7 @@ typedef long mp_off_t;
|
||||
|
||||
extern const struct _mp_obj_module_t modion_module;
|
||||
extern const struct _mp_obj_module_t modkandinsky_module;
|
||||
extern const struct _mp_obj_module_t modmatplotlib_module;
|
||||
extern const struct _mp_obj_module_t modpyplot_module;
|
||||
extern const struct _mp_obj_module_t modtime_module;
|
||||
extern const struct _mp_obj_module_t modturtle_module;
|
||||
@@ -137,6 +138,7 @@ extern const struct _mp_obj_module_t modturtle_module;
|
||||
#define MICROPY_PORT_BUILTIN_MODULES \
|
||||
{ MP_ROM_QSTR(MP_QSTR_ion), MP_ROM_PTR(&modion_module) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_kandinsky), MP_ROM_PTR(&modkandinsky_module) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_matplotlib), MP_ROM_PTR(&modmatplotlib_module) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_matplotlib_dot_pyplot), MP_ROM_PTR(&modpyplot_module) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&modtime_module) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_turtle), MP_ROM_PTR(&modturtle_module) }, \
|
||||
|
||||
@@ -20,7 +20,7 @@ extern "C" {
|
||||
#include "py/stackctrl.h"
|
||||
#include "mphalport.h"
|
||||
#include "mod/turtle/modturtle.h"
|
||||
#include "mod/matplotlib/modpyplot.h"
|
||||
#include "mod/matplotlib/pyplot/modpyplot.h"
|
||||
}
|
||||
|
||||
static MicroPython::ScriptProvider * sScriptProvider = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user