lib/ffi/clang/lib/cursor.rb in ffi-clang-0.2.0 vs lib/ffi/clang/lib/cursor.rb in ffi-clang-0.2.1
- old
+ new
@@ -1,8 +1,9 @@
# Copyright, 2010-2012 by Jari Bakken.
# Copyright, 2013, by Samuel G. D. Williams. <http://www.codeotaku.com>
# Copyright, 2013, by Garry C. Marshall. <http://www.meaningfulname.net>
+# Copyright, 2014, by Masahiro Sano.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -22,15 +23,16 @@
require 'ffi/clang/lib/translation_unit'
require 'ffi/clang/lib/diagnostic'
require 'ffi/clang/lib/comment'
require 'ffi/clang/lib/type'
+require 'ffi/clang/utils'
module FFI
module Clang
module Lib
- enum :kind, [
+ enum :cursor_kind, [
:cursor_unexposed_decl, 1,
:cursor_struct, 2,
:cursor_union, 3,
:cursor_class_decl, 4,
:cursor_enum_decl, 5,
@@ -81,11 +83,11 @@
:cursor_variable_ref, 50,
:cursor_invalid_file, 70,
:cursor_no_decl_found, 71,
:cursor_not_implemented, 72,
:cursor_invalid_code, 73,
- :cursor_first_expr, 100,
+ :cursor_unexposed_expr, 100,
:cursor_decl_ref_expr, 101,
:cursor_member_ref_expr, 102,
:cursor_call_expr, 103,
:cursor_obj_c_message_expr, 104,
:cursor_block_expr, 105,
@@ -202,29 +204,70 @@
:external, 4,
]
class CXCursor < FFI::Struct
layout(
- :kind, :kind,
+ :kind, :cursor_kind,
:xdata, :int,
:data, [:pointer, 3]
)
end
+ class CXVersion < FFI::Struct
+ layout(
+ :major, :int,
+ :minor, :int,
+ :subminor, :int,
+ )
+
+ def major
+ self[:major]
+ end
+
+ def minor
+ self[:minor]
+ end
+
+ def subminor
+ self[:subminor]
+ end
+
+ def version_string
+ [major, minor, subminor].reject{|v| v < 0}.map(&:to_s).join(".")
+ end
+
+ def to_s
+ version_string
+ end
+ end
+
+ class CXPlatformAvailability < FFI::Struct
+ layout(
+ :platform, CXString,
+ :introduced, CXVersion,
+ :deprecated, CXVersion,
+ :obsoleted, CXVersion,
+ :unavailable, :int,
+ :message, CXString,
+ )
+ end
+
enum :cxx_access_specifier, [:invalid, :public, :protected, :private]
attach_function :get_cxx_access_specifier, :clang_getCXXAccessSpecifier, [CXCursor.by_value], :cxx_access_specifier
attach_function :get_enum_value, :clang_getEnumConstantDeclValue, [CXCursor.by_value], :long_long
+ attach_function :get_enum_unsigned_value, :clang_getEnumConstantDeclUnsignedValue, [CXCursor.by_value], :ulong_long
attach_function :is_virtual_base, :clang_isVirtualBase, [CXCursor.by_value], :uint
attach_function :is_dynamic_call, :clang_Cursor_isDynamicCall, [CXCursor.by_value], :uint
if FFI::Clang::Utils.satisfy_version?('3.3')
attach_function :is_variadic, :clang_Cursor_isVariadic, [CXCursor.by_value], :uint
end
attach_function :is_definition, :clang_isCursorDefinition, [CXCursor.by_value], :uint
attach_function :cxx_method_is_static, :clang_CXXMethod_isStatic, [CXCursor.by_value], :uint
attach_function :cxx_method_is_virtual, :clang_CXXMethod_isVirtual, [CXCursor.by_value], :uint
+
if FFI::Clang::Utils.satisfy_version?('3.4')
attach_function :cxx_method_is_pure_virtual, :clang_CXXMethod_isPureVirtual, [CXCursor.by_value], :uint
end
attach_function :cxx_get_access_specifier, :clang_getCXXAccessSpecifier, [CXCursor.by_value], :access_specifier
@@ -232,40 +275,42 @@
attach_function :get_language, :clang_getCursorLanguage, [CXCursor.by_value], :language_kind
attach_function :get_canonical_cursor, :clang_getCanonicalCursor, [CXCursor.by_value], CXCursor.by_value
attach_function :get_cursor_definition, :clang_getCursorDefinition, [CXCursor.by_value], CXCursor.by_value
attach_function :get_specialized_cursor_template, :clang_getSpecializedCursorTemplate, [CXCursor.by_value], CXCursor.by_value
- attach_function :get_template_cursor_kind, :clang_getTemplateCursorKind, [CXCursor.by_value], :kind
+ attach_function :get_template_cursor_kind, :clang_getTemplateCursorKind, [CXCursor.by_value], :cursor_kind
attach_function :get_translation_unit_cursor, :clang_getTranslationUnitCursor, [:CXTranslationUnit], CXCursor.by_value
attach_function :cursor_get_translation_unit, :clang_Cursor_getTranslationUnit, [CXCursor.by_value], :CXTranslationUnit
attach_function :get_null_cursor, :clang_getNullCursor, [], CXCursor.by_value
attach_function :cursor_is_null, :clang_Cursor_isNull, [CXCursor.by_value], :int
+ attach_function :cursor_get_comment_range, :clang_Cursor_getCommentRange, [CXCursor.by_value], CXSourceRange.by_value
attach_function :cursor_get_raw_comment_text, :clang_Cursor_getRawCommentText, [CXCursor.by_value], CXString.by_value
attach_function :cursor_get_parsed_comment, :clang_Cursor_getParsedComment, [CXCursor.by_value], CXComment.by_value
attach_function :get_cursor, :clang_getCursor, [:CXTranslationUnit, CXSourceLocation.by_value], CXCursor.by_value
attach_function :get_cursor_location, :clang_getCursorLocation, [CXCursor.by_value], CXSourceLocation.by_value
attach_function :get_cursor_extent, :clang_getCursorExtent, [CXCursor.by_value], CXSourceRange.by_value
attach_function :get_cursor_display_name, :clang_getCursorDisplayName, [CXCursor.by_value], CXString.by_value
attach_function :get_cursor_spelling, :clang_getCursorSpelling, [CXCursor.by_value], CXString.by_value
attach_function :get_cursor_usr, :clang_getCursorUSR, [CXCursor.by_value], CXString.by_value
+ attach_function :get_cursor_kind_spelling, :clang_getCursorKindSpelling, [:cursor_kind], CXString.by_value
attach_function :are_equal, :clang_equalCursors, [CXCursor.by_value, CXCursor.by_value], :uint
- attach_function :is_declaration, :clang_isDeclaration, [:kind], :uint
- attach_function :is_reference, :clang_isReference, [:kind], :uint
- attach_function :is_expression, :clang_isExpression, [:kind], :uint
- attach_function :is_statement, :clang_isStatement, [:kind], :uint
- attach_function :is_attribute, :clang_isAttribute, [:kind], :uint
- attach_function :is_invalid, :clang_isInvalid, [:kind], :uint
- attach_function :is_translation_unit, :clang_isTranslationUnit, [:kind], :uint
- attach_function :is_preprocessing, :clang_isPreprocessing, [:kind], :uint
- attach_function :is_unexposed, :clang_isUnexposed, [:kind], :uint
+ attach_function :is_declaration, :clang_isDeclaration, [:cursor_kind], :uint
+ attach_function :is_reference, :clang_isReference, [:cursor_kind], :uint
+ attach_function :is_expression, :clang_isExpression, [:cursor_kind], :uint
+ attach_function :is_statement, :clang_isStatement, [:cursor_kind], :uint
+ attach_function :is_attribute, :clang_isAttribute, [:cursor_kind], :uint
+ attach_function :is_invalid, :clang_isInvalid, [:cursor_kind], :uint
+ attach_function :is_translation_unit, :clang_isTranslationUnit, [:cursor_kind], :uint
+ attach_function :is_preprocessing, :clang_isPreprocessing, [:cursor_kind], :uint
+ attach_function :is_unexposed, :clang_isUnexposed, [:cursor_kind], :uint
enum :child_visit_result, [:break, :continue, :recurse]
callback :visit_children_function, [CXCursor.by_value, CXCursor.by_value, :pointer], :child_visit_result
attach_function :visit_children, :clang_visitChildren, [CXCursor.by_value, :visit_children_function, :pointer], :uint
@@ -280,10 +325,29 @@
attach_function :get_cursor_semantic_parent, :clang_getCursorSemanticParent, [CXCursor.by_value], CXCursor.by_value
attach_function :get_cursor_lexical_parent, :clang_getCursorLexicalParent, [CXCursor.by_value], CXCursor.by_value
attach_function :get_cursor_availability, :clang_getCursorAvailability, [CXCursor.by_value], :availability
attach_function :get_cursor_linkage, :clang_getCursorLinkage, [CXCursor.by_value], :linkage_kind
- # attach_function :get_included_file, :clang_getIncludedFile, [CXCursor.by_value], :CXFile
+ attach_function :get_included_file, :clang_getIncludedFile, [CXCursor.by_value], :CXFile
attach_function :get_cursor_hash, :clang_hashCursor, [CXCursor.by_value], :uint
+
+ if FFI::Clang::Utils.satisfy_version?('3.3')
+ attach_function :is_bit_field,:clang_Cursor_isBitField, [CXCursor.by_value], :uint
+ attach_function :get_field_decl_bit_width, :clang_getFieldDeclBitWidth, [CXCursor.by_value], :int
+ end
+
+ attach_function :get_overloaded_decl, :clang_getOverloadedDecl, [CXCursor.by_value, :uint], CXCursor.by_value
+ attach_function :get_num_overloaded_decls, :clang_getNumOverloadedDecls, [CXCursor.by_value], :uint
+
+ attach_function :cursor_get_argument, :clang_Cursor_getArgument, [CXCursor.by_value, :uint], CXCursor.by_value
+ attach_function :cursor_get_num_arguments, :clang_Cursor_getNumArguments, [CXCursor.by_value], :int
+
+ attach_function :get_decl_objc_type_encoding, :clang_getDeclObjCTypeEncoding, [CXCursor.by_value], CXString.by_value
+
+ attach_function :get_cursor_platform_availability, :clang_getCursorPlatformAvailability, [CXCursor.by_value, :pointer, :pointer, :pointer, :pointer, :pointer, :int], :int
+ attach_function :dispose_platform_availability, :clang_disposeCXPlatformAvailability, [:pointer], :void
+
+ attach_function :get_overridden_cursors, :clang_getOverriddenCursors, [CXCursor.by_value, :pointer, :pointer], :void
+ attach_function :dispose_overridden_cursors, :clang_disposeOverriddenCursors, [:pointer], :void
end
end
end