Merge: Nitsmell : Adding new code smells and print console updated
[nit.git] / lib / core / kernel.nit
index 18dd7ac..6a07060 100644 (file)
@@ -1045,22 +1045,33 @@ universal Char
        #
        #     assert 'A'.is_whitespace  == false
        #     assert ','.is_whitespace  == false
-       #     assert ' '.is_whitespace  == true
+       #     assert ' '.is_whitespace  == true # space
+       #     assert ' '.is_whitespace  == true # non-breaking space
        #     assert '\t'.is_whitespace == true
        fun is_whitespace: Bool
        do
                var i = code_point
-               return i <= 0x20 or i == 0x7F
+               return i <= 0x20 or i == 0x7F or i == 0xA0
        end
 end
 
 # Pointer classes are used to manipulate extern C structures.
 extern class Pointer
+       # C `NULL` pointer
+       new nul `{ return NULL; `}
+
        # Is the address behind this Object at NULL?
        fun address_is_null: Bool `{ return self == NULL; `}
 
        # Free the memory pointed by this pointer
        fun free `{ free(self); `}
+
+       # Use the address value
+       redef fun hash `{ return (long)(intptr_t)self; `}
+
+       # Is equal to any instance pointing to the same address
+       redef fun ==(o) do return o isa Pointer and native_equals(o)
+       private fun native_equals(o: Pointer): Bool `{ return self == o; `}
 end
 
 # Task with a `main` method to be implemented by subclasses