Use C++ language supported 'nullptr' (#13944)

This commit is contained in:
Scott Lahteine
2019-05-09 11:45:55 -05:00
committed by GitHub
parent e53d7e5517
commit ad4ffa1d2f
70 changed files with 670 additions and 668 deletions

View File

@ -302,7 +302,7 @@ void InvadersGame::game_screen() {
if (invader_count && !random(0, 20)) {
// Find a free bullet
laser_t *b = NULL;
laser_t *b = nullptr;
LOOP_L_N(i, COUNT(bullet)) if (!bullet[i].v) { b = &bullet[i]; break; }
if (b) {
// Pick a random shooter and update the bullet

View File

@ -136,7 +136,7 @@ void MenuItemBase::edit(strfunc_t strfunc, loadfunc_t loadfunc) {
if (ui.should_draw())
draw_edit_screen(editLabel, strfunc(ui.encoderPosition + minEditValue));
if (ui.lcd_clicked || (liveEdit && ui.should_draw())) {
if (editValue != NULL) loadfunc(editValue, ui.encoderPosition + minEditValue);
if (editValue != nullptr) loadfunc(editValue, ui.encoderPosition + minEditValue);
if (callbackFunc && (liveEdit || ui.lcd_clicked)) (*callbackFunc)();
if (ui.use_click()) ui.goto_previous_screen();
}
@ -300,7 +300,7 @@ void MarlinUI::_synchronize() {
// Display the synchronize screen with a custom message
// ** This blocks the command queue! **
void MarlinUI::synchronize(PGM_P const msg/*=NULL*/) {
void MarlinUI::synchronize(PGM_P const msg/*=nullptr*/) {
static const char moving[] PROGMEM = MSG_MOVING;
sync_message = msg ? msg : moving;
_synchronize();
@ -445,7 +445,7 @@ void _lcd_draw_homing() {
//
bool ui_selection; // = false
void set_ui_selection(const bool sel) { ui_selection = sel; }
void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string/*=NULL*/, PGM_P const suff/*=NULL*/) {
void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
if (ui.encoderPosition) {
ui_selection = int16_t(ui.encoderPosition) > 0;
ui.encoderPosition = 0;

View File

@ -70,14 +70,14 @@ DECLARE_MENU_EDIT_TYPE(uint32_t, long5_25, ftostr5rj, 0.04f ); // 123
typedef void (*selectFunc_t)();
void draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string, PGM_P const suff);
void set_ui_selection(const bool sel);
void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=NULL, PGM_P const suff=NULL);
inline void do_select_screen_yn(selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=NULL, PGM_P const suff=NULL) {
void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr);
inline void do_select_screen_yn(selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr) {
do_select_screen(PSTR(MSG_YES), PSTR(MSG_NO), yesFunc, noFunc, pref, string, suff);
}
void draw_edit_screen(PGM_P const pstr, const char* const value=NULL);
void draw_edit_screen(PGM_P const pstr, const char* const value=nullptr);
void draw_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char);
void draw_menu_item_static(const uint8_t row, PGM_P const pstr, const bool center=true, const bool invert=false, const char *valstr=NULL);
void draw_menu_item_static(const uint8_t row, PGM_P const pstr, const bool center=true, const bool invert=false, const char *valstr=nullptr);
void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm);
FORCE_INLINE void draw_menu_item_back(const bool sel, const uint8_t row, PGM_P const pstr) { draw_menu_item(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]); }
FORCE_INLINE void draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data) { _draw_menu_item_edit(sel, row, pstr, data, false); }
@ -187,7 +187,7 @@ class TMenuItem : MenuItemBase {
static void load(void *ptr, const int16_t value) { *((type_t*)ptr) = unscale(value); }
static char* to_string(const int16_t value) { return NAME::strfunc(unscale(value)); }
public:
static void action_edit(PGM_P const pstr, type_t * const ptr, const type_t minValue, const type_t maxValue, const screenFunc_t callback=NULL, const bool live=false) {
static void action_edit(PGM_P const pstr, type_t * const ptr, const type_t minValue, const type_t maxValue, const screenFunc_t callback=nullptr, const bool live=false) {
// Make sure minv and maxv fit within int16_t
const int16_t minv = MAX(scale(minValue), INT16_MIN),
maxv = MIN(scale(maxValue), INT16_MAX);
@ -218,7 +218,7 @@ DECLARE_MENU_EDIT_ITEM(long5_25);
class MenuItem_bool {
public:
static void action_edit(PGM_P const pstr, bool* ptr, const screenFunc_t callbackFunc=NULL);
static void action_edit(PGM_P const pstr, bool* ptr, const screenFunc_t callbackFunc=nullptr);
};
////////////////////////////////////////////

View File

@ -610,7 +610,7 @@ void menu_backlash();
PSTR(MSG_BUTTON_INIT), PSTR(MSG_BUTTON_CANCEL),
[]{ ui.completion_feedback(settings.init_eeprom()); },
ui.goto_previous_screen,
PSTR(MSG_INIT_EEPROM), NULL, PSTR("?")
PSTR(MSG_INIT_EEPROM), nullptr, PSTR("?")
);
}

View File

@ -102,7 +102,7 @@ static inline void menu_level_bed_corners() {
#else
MSG_NEXT_CORNER
#endif
), NULL, PSTR("?")
), nullptr, PSTR("?")
);
}

View File

@ -367,7 +367,7 @@ void menu_pause_option() {
// ADVANCED_PAUSE_FEATURE message screens
//
void _lcd_pause_message(PGM_P const msg1, PGM_P const msg2=NULL, PGM_P const msg3=NULL) {
void _lcd_pause_message(PGM_P const msg1, PGM_P const msg2=nullptr, PGM_P const msg3=nullptr) {
START_SCREEN();
STATIC_ITEM_P(pause_header(), true, true);
STATIC_ITEM_P(msg1);
@ -516,7 +516,7 @@ FORCE_INLINE screenFunc_t ap_message_screen(const PauseMessage message) {
case PAUSE_MESSAGE_STATUS:
default: break;
}
return NULL;
return nullptr;
}
void lcd_pause_show_message(

View File

@ -101,7 +101,7 @@
}
void menu_abort_confirm() {
do_select_screen(PSTR(MSG_BUTTON_STOP), PSTR(MSG_BACK), lcd_abort_job, ui.goto_previous_screen, PSTR(MSG_STOP_PRINT), NULL, PSTR("?"));
do_select_screen(PSTR(MSG_BUTTON_STOP), PSTR(MSG_BACK), lcd_abort_job, ui.goto_previous_screen, PSTR(MSG_STOP_PRINT), nullptr, PSTR("?"));
}
#endif // MACHINE_CAN_STOP
@ -189,10 +189,10 @@ void menu_main() {
}
else {
#if PIN_EXISTS(SD_DETECT)
MENU_ITEM(function, MSG_NO_CARD, NULL);
MENU_ITEM(function, MSG_NO_CARD, nullptr);
#else
MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21"));
MENU_ITEM(function, MSG_SD_RELEASED, NULL);
MENU_ITEM(function, MSG_SD_RELEASED, nullptr);
#endif
}
#endif // !HAS_ENCODER_WHEEL && SDSUPPORT
@ -276,10 +276,10 @@ void menu_main() {
}
else {
#if PIN_EXISTS(SD_DETECT)
MENU_ITEM(function, MSG_NO_CARD, NULL);
MENU_ITEM(function, MSG_NO_CARD, nullptr);
#else
MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21"));
MENU_ITEM(function, MSG_SD_RELEASED, NULL);
MENU_ITEM(function, MSG_SD_RELEASED, nullptr);
#endif
}
#endif // HAS_ENCODER_WHEEL && SDSUPPORT

View File

@ -259,7 +259,7 @@ void menu_mixer_vtools_reset_confirm() {
ui.return_to_status();
},
ui.goto_previous_screen,
PSTR(MSG_RESET_VTOOLS), NULL, PSTR("?")
PSTR(MSG_RESET_VTOOLS), nullptr, PSTR("?")
);
}