Skip to content

Commit 66ee734

Browse files
committed
MicroPython: Switch everything else to mp_obj_malloc.
1 parent a75041b commit 66ee734

File tree

21 files changed

+21
-42
lines changed

21 files changed

+21
-42
lines changed

micropython/modules/breakout_as7262/breakout_as7262.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ mp_obj_t BreakoutAS7262_make_new(const mp_obj_type_t *type, size_t n_args, size_
3232
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3333
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3434

35-
self = m_new_obj(breakout_as7262_BreakoutAS7262_obj_t);
36-
self->base.type = &breakout_as7262_BreakoutAS7262_type;
35+
self = mp_obj_malloc(breakout_as7262_BreakoutAS7262_obj_t, &breakout_as7262_BreakoutAS7262_type);
3736

3837
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3938

micropython/modules/breakout_as7343/breakout_as7343.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ mp_obj_t BreakoutAS7343_make_new(const mp_obj_type_t *type, size_t n_args, size_
3232
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3333
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3434

35-
self = m_new_obj(breakout_as7343_BreakoutAS7343_obj_t);
36-
self->base.type = &breakout_as7343_BreakoutAS7343_type;
35+
self = mp_obj_malloc(breakout_as7343_BreakoutAS7343_obj_t, &breakout_as7343_BreakoutAS7343_type);
3736

3837
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3938

micropython/modules/breakout_bh1745/breakout_bh1745.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ mp_obj_t BreakoutBH1745_make_new(const mp_obj_type_t *type, size_t n_args, size_
3030
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3131
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3232

33-
self = m_new_obj(breakout_bh1745_BreakoutBH1745_obj_t);
34-
self->base.type = &breakout_bh1745_BreakoutBH1745_type;
33+
self = mp_obj_malloc(breakout_bh1745_BreakoutBH1745_obj_t, &breakout_bh1745_BreakoutBH1745_type);
3534

3635
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3736

micropython/modules/breakout_bme280/breakout_bme280.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ mp_obj_t BreakoutBME280_make_new(const mp_obj_type_t *type, size_t n_args, size_
3030
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3131
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3232

33-
self = m_new_obj(breakout_bme280_BreakoutBME280_obj_t);
34-
self->base.type = &breakout_bme280_BreakoutBME280_type;
33+
self = mp_obj_malloc(breakout_bme280_BreakoutBME280_obj_t, &breakout_bme280_BreakoutBME280_type);
3534

3635
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3736

micropython/modules/breakout_bme68x/breakout_bme68x.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ mp_obj_t BreakoutBME68X_make_new(const mp_obj_type_t *type, size_t n_args, size_
3131
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3232
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3333

34-
self = m_new_obj(breakout_bme68x_BreakoutBME68X_obj_t);
35-
self->base.type = &breakout_bme68x_BreakoutBME68X_type;
34+
self = mp_obj_malloc(breakout_bme68x_BreakoutBME68X_obj_t, &breakout_bme68x_BreakoutBME68X_type);
3635

3736
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3837

micropython/modules/breakout_bmp280/breakout_bmp280.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ mp_obj_t BreakoutBMP280_make_new(const mp_obj_type_t *type, size_t n_args, size_
3131
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3232
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3333

34-
self = m_new_obj(breakout_bmp280_BreakoutBMP280_obj_t);
35-
self->base.type = &breakout_bmp280_BreakoutBMP280_type;
34+
self = mp_obj_malloc(breakout_bmp280_BreakoutBMP280_obj_t, &breakout_bmp280_BreakoutBMP280_type);
3635

3736
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3837

micropython/modules/breakout_dotmatrix/breakout_dotmatrix.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ mp_obj_t BreakoutDotMatrix_make_new(const mp_obj_type_t *type, size_t n_args, si
3232
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3333
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3434

35-
self = m_new_obj(breakout_dotmatrix_BreakoutDotMatrix_obj_t);
36-
self->base.type = &breakout_dotmatrix_BreakoutDotMatrix_type;
35+
self = mp_obj_malloc(breakout_dotmatrix_BreakoutDotMatrix_obj_t, &breakout_dotmatrix_BreakoutDotMatrix_type);
3736

3837
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3938

micropython/modules/breakout_encoder/breakout_encoder.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ mp_obj_t BreakoutEncoder_make_new(const mp_obj_type_t *type, size_t n_args, size
3232
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3333
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3434

35-
self = m_new_obj(breakout_encoder_BreakoutEncoder_obj_t);
36-
self->base.type = &breakout_encoder_BreakoutEncoder_type;
35+
self = mp_obj_malloc(breakout_encoder_BreakoutEncoder_obj_t, &breakout_encoder_BreakoutEncoder_type);
3736

3837
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3938

micropython/modules/breakout_encoder_wheel/breakout_encoder_wheel.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ mp_obj_t BreakoutEncoderWheel_make_new(const mp_obj_type_t *type, size_t n_args,
3434
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3535
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3636

37-
self = m_new_obj(breakout_encoder_wheel_BreakoutEncoderWheel_obj_t);
38-
self->base.type = &breakout_encoder_wheel_BreakoutEncoderWheel_type;
37+
self = mp_obj_malloc(breakout_encoder_wheel_BreakoutEncoderWheel_obj_t, &breakout_encoder_wheel_BreakoutEncoderWheel_type);
3938

4039
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
4140

micropython/modules/breakout_icp10125/breakout_icp10125.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ mp_obj_t BreakoutICP10125_make_new(const mp_obj_type_t *type, size_t n_args, siz
2929
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3030
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3131

32-
self = m_new_obj(breakout_icp10125_BreakoutICP10125_obj_t);
33-
self->base.type = &breakout_icp10125_BreakoutICP10125_type;
32+
self = mp_obj_malloc(breakout_icp10125_BreakoutICP10125_obj_t, &breakout_icp10125_BreakoutICP10125_type);
3433

3534
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3635

micropython/modules/breakout_ioexpander/breakout_ioexpander.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ mp_obj_t BreakoutIOExpander_make_new(const mp_obj_type_t *type, size_t n_args, s
3232
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3333
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3434

35-
self = m_new_obj(breakout_ioexpander_BreakoutIOExpander_obj_t);
36-
self->base.type = &breakout_ioexpander_BreakoutIOExpander_type;
35+
self = mp_obj_malloc(breakout_ioexpander_BreakoutIOExpander_obj_t, &breakout_ioexpander_BreakoutIOExpander_type);
3736

3837
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3938

micropython/modules/breakout_ltr559/breakout_ltr559.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ mp_obj_t BreakoutLTR559_make_new(const mp_obj_type_t *type, size_t n_args, size_
3131
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3232
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3333

34-
self = m_new_obj(breakout_ltr559_BreakoutLTR559_obj_t);
35-
self->base.type = &breakout_ltr559_BreakoutLTR559_type;
34+
self = mp_obj_malloc(breakout_ltr559_BreakoutLTR559_obj_t, &breakout_ltr559_BreakoutLTR559_type);
3635

3736
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3837

micropython/modules/breakout_matrix11x7/breakout_matrix11x7.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ mp_obj_t BreakoutMatrix11x7_make_new(const mp_obj_type_t *type, size_t n_args, s
3030
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3131
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3232

33-
self = m_new_obj(breakout_matrix11x7_BreakoutMatrix11x7_obj_t);
34-
self->base.type = &breakout_matrix11x7_BreakoutMatrix11x7_type;
33+
self = mp_obj_malloc(breakout_matrix11x7_BreakoutMatrix11x7_obj_t, &breakout_matrix11x7_BreakoutMatrix11x7_type);
3534

3635
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3736

micropython/modules/breakout_mics6814/breakout_mics6814.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ mp_obj_t BreakoutMICS6814_make_new(const mp_obj_type_t *type, size_t n_args, siz
3232
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3333
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3434

35-
self = m_new_obj(breakout_mics6814_BreakoutMICS6814_obj_t);
36-
self->base.type = &breakout_mics6814_BreakoutMICS6814_type;
35+
self = mp_obj_malloc(breakout_mics6814_BreakoutMICS6814_obj_t, &breakout_mics6814_BreakoutMICS6814_type);
3736

3837
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3938

micropython/modules/breakout_msa301/breakout_msa301.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ mp_obj_t BreakoutMSA301_make_new(const mp_obj_type_t *type, size_t n_args, size_
2929
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3030
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3131

32-
self = m_new_obj(breakout_msa301_BreakoutMSA301_obj_t);
33-
self->base.type = &breakout_msa301_BreakoutMSA301_type;
32+
self = mp_obj_malloc(breakout_msa301_BreakoutMSA301_obj_t, &breakout_msa301_BreakoutMSA301_type);
3433

3534
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3635

micropython/modules/breakout_potentiometer/breakout_potentiometer.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ mp_obj_t BreakoutPotentiometer_make_new(const mp_obj_type_t *type, size_t n_args
3232
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3333
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3434

35-
self = m_new_obj(breakout_potentiometer_BreakoutPotentiometer_obj_t);
36-
self->base.type = &breakout_potentiometer_BreakoutPotentiometer_type;
35+
self = mp_obj_malloc(breakout_potentiometer_BreakoutPotentiometer_obj_t, &breakout_potentiometer_BreakoutPotentiometer_type);
3736

3837
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3938

micropython/modules/breakout_rgbmatrix5x5/breakout_rgbmatrix5x5.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ mp_obj_t BreakoutRGBMatrix5x5_make_new(const mp_obj_type_t *type, size_t n_args,
3131
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3232
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3333

34-
self = m_new_obj(breakout_rgbmatrix5x5_BreakoutRGBMatrix5x5_obj_t);
35-
self->base.type = &breakout_rgbmatrix5x5_BreakoutRGBMatrix5x5_type;
34+
self = mp_obj_malloc(breakout_rgbmatrix5x5_BreakoutRGBMatrix5x5_obj_t, &breakout_rgbmatrix5x5_BreakoutRGBMatrix5x5_type);
3635

3736
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3837

micropython/modules/breakout_rtc/breakout_rtc.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ mp_obj_t BreakoutRTC_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
3333
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3434
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3535

36-
self = m_new_obj(breakout_rtc_BreakoutRTC_obj_t);
37-
self->base.type = &breakout_rtc_BreakoutRTC_type;
36+
self = mp_obj_malloc(breakout_rtc_BreakoutRTC_obj_t, &breakout_rtc_BreakoutRTC_type);
3837

3938
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
4039

micropython/modules/breakout_sgp30/breakout_sgp30.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ mp_obj_t BreakoutSGP30_make_new(const mp_obj_type_t *type, size_t n_args, size_t
2929
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3030
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3131

32-
self = m_new_obj(breakout_sgp30_BreakoutSGP30_obj_t);
33-
self->base.type = &breakout_sgp30_BreakoutSGP30_type;
32+
self = mp_obj_malloc(breakout_sgp30_BreakoutSGP30_obj_t, &breakout_sgp30_BreakoutSGP30_type);
3433

3534
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3635

micropython/modules/breakout_trackball/breakout_trackball.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ mp_obj_t BreakoutTrackball_make_new(const mp_obj_type_t *type, size_t n_args, si
3232
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3333
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3434

35-
self = m_new_obj(breakout_trackball_BreakoutTrackball_obj_t);
36-
self->base.type = &breakout_trackball_BreakoutTrackball_type;
35+
self = mp_obj_malloc(breakout_trackball_BreakoutTrackball_obj_t, &breakout_trackball_BreakoutTrackball_type);
3736

3837
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
3938

micropython/modules/pcf85063a/pcf85063a.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ mp_obj_t PCF85063A_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_k
3333
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
3434
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
3535

36-
self = m_new_obj(pcf85063a_PCF85063A_obj_t);
37-
self->base.type = &pcf85063a_PCF85063A_type;
36+
self = mp_obj_malloc(pcf85063a_PCF85063A_obj_t, &pcf85063a_PCF85063A_type);
3837

3938
self->i2c = PimoroniI2C_from_machine_i2c_or_native(args[ARG_i2c].u_obj);
4039

0 commit comments

Comments
 (0)