-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmodexample.c
213 lines (185 loc) · 8.3 KB
/
modexample.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*
* This file was generated by micropython-extmod-generator
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Module Author
*
* 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.
*/
#if MICROPY_PY_EXAMPLE
// def func_a()
STATIC mp_obj_t mod_example_func_a(void) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_example_func_a_obj, mod_example_func_a);
// def func_b(arg1)
STATIC mp_obj_t mod_example_func_b(mp_obj_t arg1) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_example_func_b_obj, mod_example_func_b);
// def func_c(arg1, arg2) -> None
STATIC mp_obj_t mod_example_func_c(mp_obj_t arg1, mp_obj_t arg2) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_example_func_c_obj, mod_example_func_c);
// def func_d(arg1, arg2, arg3) -> int
STATIC mp_obj_t mod_example_func_d(mp_obj_t arg1, mp_obj_t arg2, mp_obj_t arg3) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_example_func_d_obj, mod_example_func_d);
// def func_e(arg1, arg2, arg3, arg4) -> str
STATIC mp_obj_t mod_example_func_e(size_t n_args, const mp_obj_t *args) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_example_func_e_obj, 4, 4, mod_example_func_e);
// def func_f(arg1, arg2: int, arg3, arg4, arg5: int=123) -> bytes
STATIC mp_obj_t mod_example_func_f(size_t n_args, const mp_obj_t *args) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_example_func_f_obj, 4, 5, mod_example_func_f);
// def func_g(arg1, arg2, arg3: str='test', arg4=None)
STATIC mp_obj_t mod_example_func_g(size_t n_args, const mp_obj_t *args) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_example_func_g_obj, 2, 4, mod_example_func_g);
// def func_h(arg1, arg2, arg3, *args)
STATIC mp_obj_t mod_example_func_h(size_t n_args, const mp_obj_t *args) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mod_example_func_h_obj, 3, mod_example_func_h);
// def func_i(arg1, arg2, **kwargs)
STATIC mp_obj_t mod_example_func_i(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_example_func_i_obj, 2, mod_example_func_i);
// class Class(object):
typedef struct _mp_obj_Class_t {
mp_obj_base_t base;
} mp_obj_Class_t;
// def Class.__init__(self, arg1, arg2)
STATIC mp_obj_t mod_example_Class_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 2, 2, false);
mp_obj_Class_t *o = m_new_obj(mp_obj_Class_t);
o->base.type = type;
return MP_OBJ_FROM_PTR(o);
}
// def Class.func_a(self)
STATIC mp_obj_t mod_example_Class_func_a(mp_obj_t self) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_example_Class_func_a_obj, mod_example_Class_func_a);
// def Class.func_b(self, arg1)
STATIC mp_obj_t mod_example_Class_func_b(mp_obj_t self, mp_obj_t arg1) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_example_Class_func_b_obj, mod_example_Class_func_b);
// def Class.func_c(self, arg1, arg2) -> None
STATIC mp_obj_t mod_example_Class_func_c(mp_obj_t self, mp_obj_t arg1, mp_obj_t arg2) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(mod_example_Class_func_c_obj, mod_example_Class_func_c);
// def Class.func_d(self, arg1, arg2, arg3) -> int
STATIC mp_obj_t mod_example_Class_func_d(size_t n_args, const mp_obj_t *args) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_example_Class_func_d_obj, 4, 4, mod_example_Class_func_d);
// def Class.func_e(self, arg1, arg2, arg3, arg4) -> str
STATIC mp_obj_t mod_example_Class_func_e(size_t n_args, const mp_obj_t *args) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_example_Class_func_e_obj, 5, 5, mod_example_Class_func_e);
// def Class.func_f(self, arg1, arg2: int, arg3, arg4, arg5: int=123) -> bytes
STATIC mp_obj_t mod_example_Class_func_f(size_t n_args, const mp_obj_t *args) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_example_Class_func_f_obj, 5, 6, mod_example_Class_func_f);
// def Class.func_g(self, arg1, arg2, arg3: str='test', arg4=None)
STATIC mp_obj_t mod_example_Class_func_g(size_t n_args, const mp_obj_t *args) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_example_Class_func_g_obj, 3, 5, mod_example_Class_func_g);
// def Class.func_h(self, arg1, arg2, arg3, *args)
STATIC mp_obj_t mod_example_Class_func_h(size_t n_args, const mp_obj_t *args) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(mod_example_Class_func_h_obj, 4, mod_example_Class_func_h);
// def Class.func_i(self, arg1, arg2, **kwargs)
STATIC mp_obj_t mod_example_Class_func_i(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_example_Class_func_i_obj, 3, mod_example_Class_func_i);
// Class stuff
STATIC const mp_rom_map_elem_t mod_example_Class_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_func_a), MP_ROM_PTR(&mod_example_Class_func_a_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_b), MP_ROM_PTR(&mod_example_Class_func_b_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_c), MP_ROM_PTR(&mod_example_Class_func_c_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_d), MP_ROM_PTR(&mod_example_Class_func_d_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_e), MP_ROM_PTR(&mod_example_Class_func_e_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_f), MP_ROM_PTR(&mod_example_Class_func_f_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_g), MP_ROM_PTR(&mod_example_Class_func_g_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_h), MP_ROM_PTR(&mod_example_Class_func_h_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_i), MP_ROM_PTR(&mod_example_Class_func_i_obj) },
};
STATIC MP_DEFINE_CONST_DICT(mod_example_Class_locals_dict, mod_example_Class_locals_dict_table);
STATIC const mp_obj_type_t mod_example_Class_type = {
{ &mp_type_type },
.name = MP_QSTR_Class,
.make_new = mod_example_Class_make_new,
.locals_dict = (void*)&mod_example_Class_locals_dict,
};
// module stuff
STATIC const mp_rom_map_elem_t mp_module_example_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_example) },
{ MP_ROM_QSTR(MP_QSTR_func_a), MP_ROM_PTR(&mod_example_func_a_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_b), MP_ROM_PTR(&mod_example_func_b_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_c), MP_ROM_PTR(&mod_example_func_c_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_d), MP_ROM_PTR(&mod_example_func_d_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_e), MP_ROM_PTR(&mod_example_func_e_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_f), MP_ROM_PTR(&mod_example_func_f_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_g), MP_ROM_PTR(&mod_example_func_g_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_h), MP_ROM_PTR(&mod_example_func_h_obj) },
{ MP_ROM_QSTR(MP_QSTR_func_i), MP_ROM_PTR(&mod_example_func_i_obj) },
{ MP_ROM_QSTR(MP_QSTR_Class), MP_ROM_PTR(&mod_example_Class_type) },
};
STATIC MP_DEFINE_CONST_DICT(mp_module_example_globals, mp_module_example_globals_table);
const mp_obj_module_t mp_module_example = {
.base = { &mp_type_module },
.name = MP_QSTR_example,
.globals = (mp_obj_dict_t*)&mp_module_example_globals,
};
#endif // MICROPY_PY_EXAMPLE