Commit 860ffb0a authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

Convert many object types structs to use C99 tagged initializer syntax.

parent 12e26564
......@@ -99,14 +99,11 @@ static mp_obj_t tuple_getiter(mp_obj_t o_in) {
const mp_obj_type_t tuple_type = {
{ &mp_const_type },
"tuple",
tuple_print, // print
tuple_make_new, // make_new
NULL, // call_n
NULL, // unary_op
tuple_binary_op, // binary_op
tuple_getiter, // getiter
NULL, // iternext
{{NULL, NULL},}, // method list
.print = tuple_print,
.make_new = tuple_make_new,
.binary_op = tuple_binary_op,
.getiter = tuple_getiter,
.methods = {{NULL, NULL},},
};
// the zero-length tuple
......@@ -168,14 +165,8 @@ static mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
static const mp_obj_type_t tuple_it_type = {
{ &mp_const_type },
"tuple_iterator",
NULL, // print
NULL, // make_new
NULL, // call_n
NULL, // unary_op
NULL, // binary_op
NULL, // getiter
tuple_it_iternext,
{{NULL, NULL},}, // method list
.iternext = tuple_it_iternext,
.methods = {{NULL, NULL},},
};
static mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, int cur) {
......
......@@ -25,12 +25,7 @@ static mp_obj_t type_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args)
const mp_obj_type_t mp_const_type = {
{ &mp_const_type },
"type",
type_print, // print
NULL, // make_new
type_call_n, // call_n
NULL, // unary_op
NULL, // binary_op
NULL, // getiter
NULL, // iternext
{{NULL, NULL},}, // method list
.print = type_print,
.call_n = type_call_n,
.methods = {{NULL, NULL},},
};
......@@ -329,14 +329,8 @@ static MP_DEFINE_CONST_FUN_OBJ_1(i2c_obj_stop_obj, i2c_obj_stop);
static const mp_obj_type_t i2c_obj_type = {
{ &mp_const_type },
"I2C",
i2c_obj_print, // print
NULL, // make_new
NULL, // call_n
NULL, // unary_op
NULL, // binary_op
NULL, // getiter
NULL, // iternext
{ // method list
.print = i2c_obj_print,
.methods = {
{ "start", &i2c_obj_start_obj },
{ "write", &i2c_obj_write_obj },
{ "read", &i2c_obj_read_obj },
......
......@@ -107,14 +107,8 @@ static MP_DEFINE_CONST_FUN_OBJ_1(led_obj_off_obj, led_obj_off);
static const mp_obj_type_t led_obj_type = {
{ &mp_const_type },
"Led",
led_obj_print, // print
NULL, // make_new
NULL, // call_n
NULL, // unary_op
NULL, // binary_op
NULL, // getiter
NULL, // iternext
{ // method list
.print = led_obj_print,
.methods = {
{ "on", &led_obj_on_obj },
{ "off", &led_obj_off_obj },
{ NULL, NULL },
......
......@@ -699,7 +699,7 @@ static const mp_obj_type_t file_obj_type = {
NULL, // binary_op
NULL, // getiter
NULL, // iternext
{ // method list
.methods = {
{ "read", &file_obj_read_obj },
{ "write", &file_obj_write_obj },
{ "close", &file_obj_close_obj },
......
......@@ -140,14 +140,8 @@ static MP_DEFINE_CONST_FUN_OBJ_2(servo_obj_angle_obj, servo_obj_angle);
static const mp_obj_type_t servo_obj_type = {
{ &mp_const_type },
"Servo",
servo_obj_print, // print
NULL, // make_new
NULL, // call_n
NULL, // unary_op
NULL, // binary_op
NULL, // getiter
NULL, // iternext
{ // method list
.print = servo_obj_print,
.methods = {
{ "angle", &servo_obj_angle_obj },
{ NULL, NULL },
}
......
......@@ -191,14 +191,14 @@ static MP_DEFINE_CONST_FUN_OBJ_2(test_set_obj, test_set);
static const mp_obj_type_t test_type = {
{ &mp_const_type },
"Test",
test_print, // print
NULL, // make_new
NULL, // call_n
NULL, // unary_op
NULL, // binary_op
NULL, // getiter
NULL, // iternext
{ // method list
.print = test_print,
.make_new = NULL,
.call_n = NULL,
.unary_op = NULL,
.binary_op = NULL,
.getiter = NULL,
.iternext = NULL,
.methods = {
{ "get", &test_get_obj },
{ "set", &test_set_obj },
{ NULL, NULL },
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment