internal Token(Library.CXToken handle, TranslationUnit tu) { //we dont save the handle here as it will be destroyed when the CXTokenSet id disposed Kind = Library.clang_getTokenKind(handle); Spelling = Library.clang_getTokenSpelling(tu.Handle, handle).ManagedString; Location = tu.ItemFactory.CreateSourceLocation(Library.clang_getTokenLocation(tu.Handle, handle)); Extent = tu.ItemFactory.CreateSourceRange(Library.clang_getTokenExtent(tu.Handle, handle)); }
private unsafe OverriddenCursorSet(Library.CXCursor* handles, uint count, ITranslationUnitItemFactory factory) { _cursors = new List<Cursor>(); for (uint i = 0; i < count; i++) { _cursors.Add(factory.CreateCursor(handles[i])); } }
internal SourceRange(Library.SourceRange handle, ITranslationUnitItemFactory itemFactory) { Debug.Assert(!handle.IsNull); Handle = handle; Start = itemFactory.CreateSourceLocation(Library.clang_getRangeStart(Handle)); End = itemFactory.CreateSourceLocation(Library.clang_getRangeEnd(Handle)); Debug.Assert(Start <= End); Debug.Assert(Start.File == End.File); }
/// <summary> /// Return true if handle represents the expected location /// </summary> /// <param name="handle"></param> /// <param name="expectedFile"></param> /// <param name="expectedOffset"></param> /// <returns></returns> static internal bool IsValid(Library.CXSourceLocation handle, IntPtr expectedFile, int expectedOffset) { IntPtr file = IntPtr.Zero; uint line, column, offset; unsafe { Library.clang_getInstantiationLocation(handle, &file, out line, out column, out offset); } return (file == expectedFile && offset == expectedOffset); }
/// <summary> /// Create a new Cursor object. /// </summary> /// <param name="handle">Handle to a non null cursor obect.</param> /// <param name="itemFactory">TranslationUnit's item factory / item cache.</param> internal Cursor(Library.Cursor handle, ITranslationUnitItemFactory itemFactory) { Debug.Assert(!handle.IsNull); Handle = handle; _itemFactory = itemFactory; Kind = Library.clang_getCursorKind(Handle); Library.CXType typeHandle = Library.clang_getCursorType(Handle); if (typeHandle.IsValid) _type = _itemFactory.CreateType(typeHandle); }
internal unsafe SourceLocation(Library.SourceLocation handle, ITranslationUnitItemFactory itemFactory) { Debug.Assert(!handle.IsNull); Handle = handle; _itemFactory = itemFactory; IntPtr file = IntPtr.Zero; uint line, column, offset; Library.clang_getInstantiationLocation(Handle, &file, out line, out column, out offset); Line = (int)line; Column = (int)column; Offset = (int)offset; if (file != IntPtr.Zero) { File = _itemFactory.CreateFile(file); } }
internal Type(Library.CXType handle, ITranslationUnitItemFactory itemFactory) { Debug.Assert(handle.IsValid); Handle = handle; _itemFactory = itemFactory; }
internal unsafe TokenSetHandle(TranslationUnit tu, Library.Token* toks, uint count) { _tu = tu; _tokens = toks; _count = count; }
internal Comment(Library.CXComment handle) { _handle = handle; }
internal Token(Library.Token handle, TranslationUnit tu) { _tu = tu; Handle = handle; }
private Type ReturnType(Library.CXType t) { return t != null && t.IsValid ? _itemFactory.CreateType(t) : null; }