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

@ -889,7 +889,7 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
int ret;
size_t idx = 0;
hd44780_charmap_t pinval;
hd44780_charmap_t *copy_address = NULL;
hd44780_charmap_t *copy_address = nullptr;
pinval.uchar = c;
pinval.idx = -1;
@ -900,7 +900,7 @@ int lcd_put_wchar_max(wchar_t c, pixel_len_t max_length) {
lcd.write((uint8_t)c);
return 1;
}
copy_address = NULL;
copy_address = nullptr;
ret = pf_bsearch_r((void *)g_hd44780_charmap_device, COUNT(g_hd44780_charmap_device), pf_bsearch_cb_comp_hd4map_pgm, (void *)&pinval, &idx);
if (ret >= 0) {
copy_address = (hd44780_charmap_t *)(g_hd44780_charmap_device + idx);

View File

@ -992,7 +992,7 @@ void MarlinUI::draw_status_screen() {
#endif // ADVANCED_PAUSE_FEATURE
void draw_menu_item_static(const uint8_t row, PGM_P pstr, const bool center/*=true*/, const bool invert/*=false*/, const char *valstr/*=NULL*/) {
void draw_menu_item_static(const uint8_t row, PGM_P pstr, const bool center/*=true*/, const bool invert/*=false*/, const char *valstr/*=nullptr*/) {
UNUSED(invert);
int8_t n = LCD_WIDTH;
lcd_moveto(0, row);
@ -1024,10 +1024,10 @@ void MarlinUI::draw_status_screen() {
if (pgm) lcd_put_u8str_P(data); else lcd_put_u8str(data);
}
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*/) {
lcd_moveto(0, 1);
lcd_put_u8str_P(pstr);
if (value != NULL) {
if (value != nullptr) {
lcd_put_wchar(':');
int len = utf8_strlen(value);
const uint8_t valrow = (utf8_strlen_P(pstr) + 1 + len + 1) > (LCD_WIDTH - 2) ? 2 : 1; // Value on the next row if it won't fit

View File

@ -64,10 +64,10 @@ static const font_t* fontgroup_find(font_group_t * root, wchar_t val) {
uxg_fontinfo_t vcmp = {(uint16_t)(val / 128), (uint8_t)(val % 128 + 128), (uint8_t)(val % 128 + 128), 0, 0};
size_t idx = 0;
if (val < 256) return NULL;
if (val < 256) return nullptr;
if (pf_bsearch_r((void*)root->m_fntifo, root->m_fntinfo_num, pf_bsearch_cb_comp_fntifo_pgm, (void*)&vcmp, &idx) < 0)
return NULL;
return nullptr;
memcpy_P(&vcmp, root->m_fntifo + idx, sizeof(vcmp));
return vcmp.fntdata;
@ -114,7 +114,7 @@ static void fontgroup_drawstring(font_group_t *group, const font_t *fnt_default,
}
static bool flag_fontgroup_was_inited = false;
static font_group_t g_fontgroup_root = {NULL, 0};
static font_group_t g_fontgroup_root = { nullptr, 0 };
/**
* @brief check if font is loaded
@ -176,7 +176,7 @@ unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, wchar_t
data.y = y;
data.adv = 0;
data.max_width = max_width;
data.fnt_prev = NULL;
data.fnt_prev = nullptr;
fontgroup_drawwchar(group, fnt_default, ch, (void*)&data, fontgroup_cb_draw_u8g);
u8g_SetFont(pu8g, (const u8g_fntpgm_uint8_t*)fnt_default);
@ -210,7 +210,7 @@ unsigned int uxg_DrawUtf8Str(u8g_t *pu8g, unsigned int x, unsigned int y, const
data.y = y;
data.adv = 0;
data.max_width = max_width;
data.fnt_prev = NULL;
data.fnt_prev = nullptr;
fontgroup_drawstring(group, fnt_default, utf8_msg, read_byte_ram, (void*)&data, fontgroup_cb_draw_u8g);
u8g_SetFont(pu8g, (const u8g_fntpgm_uint8_t*)fnt_default);
@ -244,7 +244,7 @@ unsigned int uxg_DrawUtf8StrP(u8g_t *pu8g, unsigned int x, unsigned int y, PGM_P
data.y = y;
data.adv = 0;
data.max_width = max_width;
data.fnt_prev = NULL;
data.fnt_prev = nullptr;
fontgroup_drawstring(group, fnt_default, utf8_msg, read_byte_rom, (void*)&data, fontgroup_cb_draw_u8g);
u8g_SetFont(pu8g, (const u8g_fntpgm_uint8_t*)fnt_default);

View File

@ -330,7 +330,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
}
// Draw a static line of text in the same idiom as a menu item
void draw_menu_item_static(const uint8_t row, PGM_P pstr, const bool center/*=true*/, const bool invert/*=false*/, const char* valstr/*=NULL*/) {
void draw_menu_item_static(const uint8_t row, PGM_P pstr, const bool center/*=true*/, const bool invert/*=false*/, const char* valstr/*=nullptr*/) {
if (mark_as_selected(row, invert)) {
@ -373,7 +373,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
}
}
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*/) {
const uint8_t labellen = utf8_strlen_P(pstr), vallen = utf8_strlen(value);
bool extra_row = labellen > LCD_WIDTH - 2 - vallen;
@ -410,7 +410,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
}
// If a value is included, print a colon, then print the value right-justified
if (value != NULL) {
if (value != nullptr) {
lcd_put_wchar(':');
if (extra_row) {
// Assume that value is numeric (with no descender)

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("?")
);
}

View File

@ -211,7 +211,7 @@ millis_t next_button_update_ms;
}
}
void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=NULL*/, PGM_P const suff/*=NULL*/) {
void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
const uint8_t plen = utf8_strlen_P(pref), slen = suff ? utf8_strlen_P(suff) : 0;
uint8_t x = 0, y = 0;
if (!string && plen + slen <= LCD_WIDTH) {

View File

@ -419,7 +419,7 @@ public:
static bool lcd_clicked;
static bool use_click();
static void synchronize(PGM_P const msg=NULL);
static void synchronize(PGM_P const msg=nullptr);
static screenFunc_t currentScreen;
static void goto_screen(const screenFunc_t screen, const uint16_t encoder=0, const uint8_t top=0, const uint8_t items=0);
@ -458,7 +458,7 @@ public:
static void ubl_plot(const uint8_t x, const uint8_t inverted_y);
#endif
static void draw_select_screen_prompt(PGM_P const pref, const char * const string=NULL, PGM_P const suff=NULL);
static void draw_select_screen_prompt(PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr);
#elif HAS_SPI_LCD