< prev index next >

test/jdk/com/sun/tools/jextract/jclang-ffi/src/jdk/internal/clang/Cursor.java

Print this page

        

@@ -57,19 +57,10 @@
         return LibClang.lib.clang_isCursorDefinition(cursor) != 0;
     }
 
     public boolean isAnonymousStruct() { return LibClang.lib.clang_Cursor_isAnonymous(cursor) != 0; }
 
-    public boolean isAnonymousEnum() {
-        // libclang::clang_Cursor_isAnonymous only applies to struct, not enum
-        return (type().kind() == TypeKind.Enum && spelling().isEmpty());
-    }
-
-    public boolean isAnonymous() {
-        return isAnonymousStruct() || isAnonymousEnum();
-    }
-
     public boolean isMacroFunctionLike() {
         return LibClang.lib.clang_Cursor_isMacroFunctionLike(cursor) != 0;
     }
 
     public String spelling() {

@@ -142,25 +133,21 @@
 
     public CursorKind kind() {
         return CursorKind.valueOf(kind);
     }
 
-    public boolean equals(Cursor other) {
-        return (LibClang.lib.clang_equalCursors(cursor, other.cursor) != 0);
-    }
-
     public Stream<Cursor> children() {
         final ArrayList<Cursor> ar = new ArrayList<>();
         // FIXME: need a way to pass ar down as user data d
         LibClang.lib.clang_visitChildren(cursor, (c, p, d) -> {
             ar.add(new Cursor(c));
             return Index.CXChildVisit_Continue;
         }, Pointer.nullPointer());
         return ar.stream();
     }
 
-    public Stream<Cursor> stream() {
+    public Stream<Cursor> allChildren() {
         return children().flatMap(c -> Stream.concat(Stream.of(c), c.children()));
     }
 
     public String getMangling() {
         return LibClang.CXStrToString(

@@ -168,6 +155,22 @@
     }
 
     public TranslationUnit getTranslationUnit() {
         return new TranslationUnit(LibClang.lib.clang_Cursor_getTranslationUnit(cursor));
     }
+
+    @Override
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+        if (!(other instanceof Cursor)) {
+            return false;
+        }
+        return (LibClang.lib.clang_equalCursors(cursor, ((Cursor)other).cursor) != 0);
+    }
+
+    @Override
+    public int hashCode() {
+        return spelling().hashCode();
+    }
 }
< prev index next >