From 1d049b5f278cad4568fcfd3f2e3cc1c16173e54f Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 23 Jun 2014 15:07:19 -0400 Subject: [PATCH] Ref: add operator==(), operator!=() --- src/gui/Font.cc | 2 +- src/gui/FontManager.cc | 4 ++-- src/lib/include/jes/FileReader.h | 2 +- src/lib/include/jes/Ref.h | 2 ++ src/lib/src/Runtime.cc | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/Font.cc b/src/gui/Font.cc index b3d2ccd..316e17d 100644 --- a/src/gui/Font.cc +++ b/src/gui/Font.cc @@ -30,7 +30,7 @@ namespace jes FT_Set_Pixel_Sizes(m_face, 0, size); GlyphRef x_glyph = load_glyph('x'); - if (x_glyph.is_null()) + if (x_glyph == NULL) { std::cerr << "Could not load 'x' glyph from font" << fname << std::endl; return false; diff --git a/src/gui/FontManager.cc b/src/gui/FontManager.cc index ac448fd..4e031fb 100644 --- a/src/gui/FontManager.cc +++ b/src/gui/FontManager.cc @@ -15,7 +15,7 @@ namespace jes /* Load failsafe font */ m_mono_font = load_font("FreeMono", 20); - if (m_mono_font.is_null()) + if (m_mono_font == NULL) { std::cerr << "Error loading FreeMono font" << std::endl; return false; @@ -27,7 +27,7 @@ namespace jes FontRef FontManager::load_font(const char * fname, size_t size) { PathRef font_path = Runtime::locate(Runtime::FONT, fname); - if (font_path.is_null()) + if (font_path == NULL) return NULL; FontRef font = new Font(); diff --git a/src/lib/include/jes/FileReader.h b/src/lib/include/jes/FileReader.h index a6391cb..baf2aec 100644 --- a/src/lib/include/jes/FileReader.h +++ b/src/lib/include/jes/FileReader.h @@ -24,7 +24,7 @@ namespace jes bool load(const char * fname); unsigned int num_lines() { - if (m_lines.is_null()) + if (m_lines == NULL) { return 0u; } diff --git a/src/lib/include/jes/Ref.h b/src/lib/include/jes/Ref.h index 9629a38..d183b3d 100644 --- a/src/lib/include/jes/Ref.h +++ b/src/lib/include/jes/Ref.h @@ -18,6 +18,8 @@ namespace jes T & operator*() const { return *m_ptr; } T * operator->() const { return m_ptr; } bool is_null() const { return m_ptr == NULL; } + bool operator==(const T * ptr) { return m_ptr == ptr; } + bool operator!=(const T * ptr) { return m_ptr != ptr; } private: void clone_from(const Ref & orig); diff --git a/src/lib/src/Runtime.cc b/src/lib/src/Runtime.cc index 6436739..924e5b8 100644 --- a/src/lib/src/Runtime.cc +++ b/src/lib/src/Runtime.cc @@ -38,7 +38,7 @@ namespace jes break; } - if ((!rv.is_null()) && (rv->exists())) + if ((rv != NULL) && (rv->exists())) return rv; return NULL;