Skip to content

Commit 7492376

Browse files
committed
Revert "Delete specific cxx macroy since mpy 1.26.0. supports cxx"
This reverts commit 7cfafe9.
1 parent 3ad9ebd commit 7492376

File tree

7 files changed

+37
-15
lines changed

7 files changed

+37
-15
lines changed

src/esp_cat_detector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static mp_obj_t cat_detector_del(mp_obj_t self_in) {
3939
self->model = nullptr;
4040
return mp_const_none;
4141
}
42-
static MP_DEFINE_CONST_FUN_OBJ_1(cat_detector_del_obj, cat_detector_del);
42+
static MP_DEFINE_CONST_FUN_OBJ_1_CXX(cat_detector_del_obj, cat_detector_del);
4343

4444
// Get and set methods
4545
static void cat_detector_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest){
@@ -71,7 +71,7 @@ static mp_obj_t cat_detector_detect(mp_obj_t self_in, mp_obj_t framebuffer_obj)
7171
}
7272
return list;
7373
}
74-
static MP_DEFINE_CONST_FUN_OBJ_2(cat_detector_detect_obj, cat_detector_detect);
74+
static MP_DEFINE_CONST_FUN_OBJ_2_CXX(cat_detector_detect_obj, cat_detector_detect);
7575

7676
// Local dict
7777
static const mp_rom_map_elem_t cat_detector_locals_dict_table[] = {

src/esp_coco_detector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static mp_obj_t coco_detector_del(mp_obj_t self_in) {
3939
self->model = nullptr;
4040
return mp_const_none;
4141
}
42-
static MP_DEFINE_CONST_FUN_OBJ_1(coco_detector_del_obj, coco_detector_del);
42+
static MP_DEFINE_CONST_FUN_OBJ_1_CXX(coco_detector_del_obj, coco_detector_del);
4343

4444
// Get and set methods
4545
static void coco_detector_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest){
@@ -72,7 +72,7 @@ static mp_obj_t coco_detector_detect(mp_obj_t self_in, mp_obj_t framebuffer_obj)
7272
}
7373
return list;
7474
}
75-
static MP_DEFINE_CONST_FUN_OBJ_2(coco_detector_detect_obj, coco_detector_detect);
75+
static MP_DEFINE_CONST_FUN_OBJ_2_CXX(coco_detector_detect_obj, coco_detector_detect);
7676

7777
// Local dict
7878
static const mp_rom_map_elem_t coco_detector_locals_dict_table[] = {

src/esp_face_detector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static mp_obj_t face_detector_del(mp_obj_t self_in) {
3838
self->model = nullptr;
3939
return mp_const_none;
4040
}
41-
static MP_DEFINE_CONST_FUN_OBJ_1(face_detector_del_obj, face_detector_del);
41+
static MP_DEFINE_CONST_FUN_OBJ_1_CXX(face_detector_del_obj, face_detector_del);
4242

4343
// Get and set methods
4444
static void face_detector_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest){
@@ -80,7 +80,7 @@ static mp_obj_t face_detector_detect(mp_obj_t self_in, mp_obj_t framebuffer_obj)
8080
}
8181
return list;
8282
}
83-
static MP_DEFINE_CONST_FUN_OBJ_2(face_detector_detect_obj, face_detector_detect);
83+
static MP_DEFINE_CONST_FUN_OBJ_2_CXX(face_detector_detect_obj, face_detector_detect);
8484

8585
// Local dict
8686
static const mp_rom_map_elem_t face_detector_locals_dict_table[] = {

src/esp_face_recognition.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static mp_obj_t face_recognizer_del(mp_obj_t self_in) {
8080
self->FaceRecognizer = nullptr;
8181
return mp_const_none;
8282
}
83-
static MP_DEFINE_CONST_FUN_OBJ_1(face_recognizer_del_obj, face_recognizer_del);
83+
static MP_DEFINE_CONST_FUN_OBJ_1_CXX(face_recognizer_del_obj, face_recognizer_del);
8484

8585
// Get and set methods
8686
static void face_recognizer_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
@@ -133,7 +133,7 @@ static mp_obj_t face_recognizer_enroll(size_t n_args, const mp_obj_t *pos_args,
133133

134134
return mp_obj_new_int(new_id);
135135
}
136-
static MP_DEFINE_CONST_FUN_OBJ_KW(face_recognizer_enroll_obj, 2, face_recognizer_enroll);
136+
static MP_DEFINE_CONST_FUN_OBJ_KW_CXX(face_recognizer_enroll_obj, 2, face_recognizer_enroll);
137137

138138
// Delete feature method
139139
static mp_obj_t face_recognizer_delete_feature(mp_obj_t self_in, mp_obj_t id) {
@@ -144,7 +144,7 @@ static mp_obj_t face_recognizer_delete_feature(mp_obj_t self_in, mp_obj_t id) {
144144
}
145145
return mp_const_none;
146146
}
147-
static MP_DEFINE_CONST_FUN_OBJ_2(face_recognizer_delete_feature_obj, face_recognizer_delete_feature);
147+
static MP_DEFINE_CONST_FUN_OBJ_2_CXX(face_recognizer_delete_feature_obj, face_recognizer_delete_feature);
148148

149149
// Recognize method
150150
static mp_obj_t face_recognizer_recognize(mp_obj_t self_in, mp_obj_t framebuffer_obj) {
@@ -201,15 +201,15 @@ static mp_obj_t face_recognizer_recognize(mp_obj_t self_in, mp_obj_t framebuffer
201201
}
202202
return list;
203203
}
204-
static MP_DEFINE_CONST_FUN_OBJ_2(face_recognizer_recognize_obj, face_recognizer_recognize);
204+
static MP_DEFINE_CONST_FUN_OBJ_2_CXX(face_recognizer_recognize_obj, face_recognizer_recognize);
205205

206206
// Print Database
207207
static mp_obj_t face_recognizer_print_database(mp_obj_t self_in) {
208208
MP_FaceRecognizer *self = static_cast<MP_FaceRecognizer *>(MP_OBJ_TO_PTR(self_in));
209209
self->FaceRecognizer->print();
210210
return mp_const_none;
211211
}
212-
static MP_DEFINE_CONST_FUN_OBJ_1(face_recognizer_print_database_obj, face_recognizer_print_database);
212+
static MP_DEFINE_CONST_FUN_OBJ_1_CXX(face_recognizer_print_database_obj, face_recognizer_print_database);
213213

214214
// Local dict
215215
static const mp_rom_map_elem_t face_recognizer_locals_dict_table[] = {

src/esp_human_detector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static mp_obj_t human_detector_del(mp_obj_t self_in) {
3737
self->model = nullptr;
3838
return mp_const_none;
3939
}
40-
static MP_DEFINE_CONST_FUN_OBJ_1(human_detector_del_obj, human_detector_del);
40+
static MP_DEFINE_CONST_FUN_OBJ_1_CXX(human_detector_del_obj, human_detector_del);
4141

4242
// Get and set methods
4343
static void human_detector_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
@@ -69,7 +69,7 @@ static mp_obj_t human_detector_detect(mp_obj_t self_in, mp_obj_t framebuffer_obj
6969
}
7070
return list;
7171
}
72-
static MP_DEFINE_CONST_FUN_OBJ_2(human_detector_detect_obj, human_detector_detect);
72+
static MP_DEFINE_CONST_FUN_OBJ_2_CXX(human_detector_detect_obj, human_detector_detect);
7373

7474
// Local dict
7575
static const mp_rom_map_elem_t human_detector_locals_dict_table[] = {

src/esp_imagenet_cls.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static mp_obj_t image_net_del(mp_obj_t self_in) {
3636
self->model = nullptr;
3737
return mp_const_none;
3838
}
39-
static MP_DEFINE_CONST_FUN_OBJ_1(image_net_del_obj, image_net_del);
39+
static MP_DEFINE_CONST_FUN_OBJ_1_CXX(image_net_del_obj, image_net_del);
4040

4141
// Get and set methods
4242
static void image_net_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
@@ -60,7 +60,7 @@ static mp_obj_t image_net_classify(mp_obj_t self_in, mp_obj_t framebuffer_obj) {
6060
}
6161
return list;
6262
}
63-
static MP_DEFINE_CONST_FUN_OBJ_2(image_net_classify_obj, image_net_classify);
63+
static MP_DEFINE_CONST_FUN_OBJ_2_CXX(image_net_classify_obj, image_net_classify);
6464

6565
// Local dict
6666
static const mp_rom_map_elem_t image_net_locals_dict_table[] = {

src/mp_esp_dl.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@ extern const mp_obj_type_t mp_face_recognizer_type;
1616
extern const mp_obj_type_t mp_coco_detector_type;
1717
extern const mp_obj_type_t mp_cat_detector_type;
1818

19+
#define MP_DEFINE_CONST_FUN_OBJ_0_CXX(obj_name, fun_name) \
20+
const mp_obj_fun_builtin_fixed_t obj_name = {.base = &mp_type_fun_builtin_0, .fun = {._0 = fun_name }}
21+
22+
#define MP_DEFINE_CONST_FUN_OBJ_1_CXX(obj_name, fun_name) \
23+
const mp_obj_fun_builtin_fixed_t obj_name = { .base = &mp_type_fun_builtin_1, .fun = {._1 = fun_name }}
24+
25+
#define MP_DEFINE_CONST_FUN_OBJ_2_CXX(obj_name, fun_name) \
26+
const mp_obj_fun_builtin_fixed_t obj_name = { .base = &mp_type_fun_builtin_2, .fun = {._2 = fun_name }}
27+
28+
#define MP_DEFINE_CONST_FUN_OBJ_3_CXX(obj_name, fun_name) \
29+
const mp_obj_fun_builtin_fixed_t obj_name = { .base = &mp_type_fun_builtin_3, .fun = {._3 = fun_name }}
30+
31+
#define MP_DEFINE_CONST_FUN_OBJ_VAR_CXX(obj_name, n_args_min, fun_name) \
32+
const mp_obj_fun_builtin_var_t obj_name = \
33+
{.base = {.type = &mp_type_fun_builtin_var}, .sig = MP_OBJ_FUN_MAKE_SIG(n_args_min, MP_OBJ_FUN_ARGS_MAX, false), .fun = {.var = fun_name}}
34+
#define MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN_CXX(obj_name, n_args_min, n_args_max, fun_name) \
35+
const mp_obj_fun_builtin_var_t obj_name = \
36+
{.base = {.type = &mp_type_fun_builtin_var}, .sig = MP_OBJ_FUN_MAKE_SIG(n_args_min, n_args_max, false), .fun = {.var = fun_name}}
37+
#define MP_DEFINE_CONST_FUN_OBJ_KW_CXX(obj_name, n_args_min, fun_name) \
38+
const mp_obj_fun_builtin_var_t obj_name = \
39+
{.base = {.type = &mp_type_fun_builtin_var}, .sig = MP_OBJ_FUN_MAKE_SIG(n_args_min, MP_OBJ_FUN_ARGS_MAX, true), .fun = {.kw = fun_name}}
40+
1941
#ifdef __cplusplus
2042
}
2143
#endif

0 commit comments

Comments
 (0)