Example #1
0
 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));
 }
Example #2
0
 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]));
     }
 }
Example #3
0
 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);
 }
Example #4
0
 /// <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);
 }
Example #5
0
 /// <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);
 }
Example #6
0
 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);
     }
 }
Example #7
0
 internal Type(Library.CXType handle, ITranslationUnitItemFactory itemFactory)
 {
     Debug.Assert(handle.IsValid);
     Handle = handle;
     _itemFactory = itemFactory;
 }
Example #8
0
 internal unsafe TokenSetHandle(TranslationUnit tu, Library.Token* toks, uint count)
 {
     _tu = tu;
     _tokens = toks;
     _count = count;
 }
Example #9
0
 internal Comment(Library.CXComment handle)
 {
     _handle = handle;
 }
Example #10
0
 internal Token(Library.Token handle, TranslationUnit tu)
 {
     _tu = tu;
     Handle = handle;
 }
Example #11
0
File: Type.cs Project: JadeHub/Jade
 private Type ReturnType(Library.CXType t)
 {
     return t != null && t.IsValid ? _itemFactory.CreateType(t) : null;
 }