Ref: add operator==(), operator!=()

This commit is contained in:
Josh Holtrop 2014-06-23 15:07:19 -04:00
parent 8aff635d5f
commit 1d049b5f27
5 changed files with 7 additions and 5 deletions

View File

@ -30,7 +30,7 @@ namespace jes
FT_Set_Pixel_Sizes(m_face, 0, size); FT_Set_Pixel_Sizes(m_face, 0, size);
GlyphRef x_glyph = load_glyph('x'); 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; std::cerr << "Could not load 'x' glyph from font" << fname << std::endl;
return false; return false;

View File

@ -15,7 +15,7 @@ namespace jes
/* Load failsafe font */ /* Load failsafe font */
m_mono_font = load_font("FreeMono", 20); 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; std::cerr << "Error loading FreeMono font" << std::endl;
return false; return false;
@ -27,7 +27,7 @@ namespace jes
FontRef FontManager::load_font(const char * fname, size_t size) FontRef FontManager::load_font(const char * fname, size_t size)
{ {
PathRef font_path = Runtime::locate(Runtime::FONT, fname); PathRef font_path = Runtime::locate(Runtime::FONT, fname);
if (font_path.is_null()) if (font_path == NULL)
return NULL; return NULL;
FontRef font = new Font(); FontRef font = new Font();

View File

@ -24,7 +24,7 @@ namespace jes
bool load(const char * fname); bool load(const char * fname);
unsigned int num_lines() unsigned int num_lines()
{ {
if (m_lines.is_null()) if (m_lines == NULL)
{ {
return 0u; return 0u;
} }

View File

@ -18,6 +18,8 @@ namespace jes
T & operator*() const { return *m_ptr; } T & operator*() const { return *m_ptr; }
T * operator->() const { return m_ptr; } T * operator->() const { return m_ptr; }
bool is_null() const { return m_ptr == NULL; } 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: private:
void clone_from(const Ref<T> & orig); void clone_from(const Ref<T> & orig);

View File

@ -38,7 +38,7 @@ namespace jes
break; break;
} }
if ((!rv.is_null()) && (rv->exists())) if ((rv != NULL) && (rv->exists()))
return rv; return rv;
return NULL; return NULL;