Skip to content

Commit

Permalink
update clang api
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongfq committed Sep 22, 2024
1 parent b46e0b2 commit fc08d04
Show file tree
Hide file tree
Showing 16 changed files with 554 additions and 278 deletions.
303 changes: 264 additions & 39 deletions addons/clang/library/clang/Cursor.lua

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions addons/clang/library/clang/Cursor/SourceLocation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@

---
---@class clang.Cursor.SourceLocation
---@field column integer
---@field line integer
---@field path string
---@field line integer
---@field column integer
local SourceLocation = {}

---@return any
function SourceLocation:__gc() end

---@return any
function SourceLocation:__olua_move() end

return SourceLocation
9 changes: 3 additions & 6 deletions addons/clang/library/clang/Cursor/SourceRange.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@

---
---@class clang.Cursor.SourceRange
---@field endColumn integer
---@field endLine integer
---@field path string
---@field startColumn integer
---@field startLine integer
---@field startColumn integer
---@field endLine integer
---@field endColumn integer
local SourceRange = {}

---@return any
function SourceRange:__gc() end

---@return any
function SourceRange:__olua_move() end

return SourceRange
4 changes: 2 additions & 2 deletions addons/clang/library/clang/File.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

---
---@class clang.File : clang.IndexError
---@field fileName string Retrieve the complete file and path name of the given file.
---@field fileTime integer Retrieve the last modification time of the given file.
---@field name string Retrieve the complete file and path name of the given file.
---@field realPathName string Returns the real path name of `file`. <br><br>An empty string may be returned. Use `clang_getFileName()` in that case.
---@field time integer Retrieve the last modification time of the given file.
local File = {}

---@param f clang.File
Expand Down
16 changes: 9 additions & 7 deletions addons/clang/library/clang/Index.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
---An "index" that consists of a set of translation units that would
---typically be linked together into an executable or library.
---@class clang.Index : clang.IndexError
---@field globalOptions integer
---@field globalOptions integer Gets the general options associated with a CXIndex. <br><br>This function allows to obtain the final option values used by libclang after specifying the option policies via CXChoice enumerators. <br><br>\returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that are associated with the given CXIndex object.
local Index = {}

---@param cls string
Expand All @@ -16,9 +16,6 @@ function Index:as(cls) end
---@return clang.TranslationUnit
function Index:create(path) end

---@return integer
function Index:getGlobalOptions() end

---Same as `clang_parseTranslationUnit2`, but returns
---the `CXTranslationUnit` instead of an error code. In case of an error this
---routine returns a `NULL` `CXTranslationUnit`, without further detailed
Expand All @@ -30,9 +27,14 @@ function Index:getGlobalOptions() end
---@overload fun(self: clang.Index, path: string, args: string[]): clang.TranslationUnit
function Index:parse(path, args, options) end

---@param options integer
function Index:setGlobalOptions(options) end

---Sets the invocation emission path option in a CXIndex.
---
---This function is DEPRECATED. Set CXIndexOptions::InvocationEmissionPath and
---call clang_createIndexWithOptions() instead.
---
---The invocation emission path specifies a path which will contain log
---files for certain libclang invocations. A null value (default) implies that
---libclang invocations are not logged..
---@param path string
function Index:setInvocationEmissionPathOption(path) end

Expand Down
3 changes: 0 additions & 3 deletions addons/clang/library/clang/IndexError.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ function IndexError:__index() end
---@return any
function IndexError:__newindex() end

---@return any
function IndexError:__olua_move() end

return IndexError
14 changes: 9 additions & 5 deletions addons/clang/library/clang/Module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@

---
---@class clang.Module : clang.IndexError
---@field astFile clang.File
---@field fullName string
---@field isSystem integer
---@field name string
---@field parent clang.Module
---@field astFile clang.File \param Module a module object. <br><br>\returns the module file where the provided module object came from.
---@field fullName string \param Module a module object. <br><br>\returns the full name of the module, e.g. "std.vector".
---@field name string \param Module a module object. <br><br>\returns the name of the module, e.g. for the 'std.vector' sub-module it will return "vector".
---@field parent clang.Module \param Module a module object. <br><br>\returns the parent of a sub-module or NULL if the given module is top-level, e.g. for 'std.vector' it will return the 'std' module.
local Module = {}

---@param cls string
---@return any
function Module:as(cls) end

---\param Module a module object.
---
---@return integer # s non-zero if the module is a system one.
function Module:isSystem() end

---@return clang.Module
function Module:shared_from_this() end

Expand Down
49 changes: 38 additions & 11 deletions addons/clang/library/clang/TranslationUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

---A single translation unit, which resides in an index.
---@class clang.TranslationUnit : clang.IndexError
---@field cursor clang.Cursor
---@field defaultReparseOptions integer
---@field defaultSaveOptions integer
---@field diagnosticSetFromTU clang.Diagnostic[]
---@field diagnostics clang.Diagnostic[]
---@field name string
---@field suspendTranslationUnit integer
---@field cursor clang.Cursor Retrieve the cursor that represents the given translation unit. <br><br>The translation unit cursor can be used to start traversing the various declarations within the given translation unit.
---@field defaultReparseOptions integer Returns the set of flags that is suitable for reparsing a translation unit. <br><br>The set of flags returned provide options for `clang_reparseTranslationUnit()` by default. The returned flag set contains an unspecified set of optimizations geared toward common uses of reparsing. The set of optimizations enabled may change from one version to the next.
---@field defaultSaveOptions integer Returns the set of flags that is suitable for saving a translation unit. <br><br>The set of flags returned provide options for `clang_saveTranslationUnit()` by default. The returned flag set contains an unspecified set of options that save translation units with the most commonly-requested data.
---@field diagnosticSetFromTU clang.Diagnostic[] Retrieve a diagnostic associated with the given CXDiagnosticSet. <br><br>\param Diags the CXDiagnosticSet to query. \param Index the zero-based diagnostic number to retrieve. <br><br>\returns the requested diagnostic. This diagnostic must be freed via a call to `clang_disposeDiagnostic()`.
---@field diagnostics clang.Diagnostic[] Retrieve the unique ID for the given `file`. <br><br>\param file the file to get the ID for. \param outID stores the returned CXFileUniqueID. \returns If there was a failure getting the unique ID, returns non-zero, otherwise returns 0.
---@field name string Get the original translation unit source file name.
---@field suspendTranslationUnit integer Suspend a translation unit in order to free memory associated with it. <br><br>A suspended translation unit uses significantly less memory but on the other side does not support any other calls than `clang_reparseTranslationUnit to` resume it or `clang_disposeTranslationUnit` to dispose it completely.
local TranslationUnit = {}

---@param cls string
Expand Down Expand Up @@ -46,25 +46,52 @@ function TranslationUnit:getFileContents(f) end
---@return boolean
function TranslationUnit:isFileMultipleIncludeGuarded(f) end

---Given a CXFile header file, return the module that contains it, if one
---exists.
---@param file clang.File
---@return clang.Module
function TranslationUnit:moduleForFile(file) end

---\param Module a module object.
---
---@return integer # s the number of top level headers associated with this module.
---@param m clang.Module
---@return integer
function TranslationUnit:numTopLevelHeaders(m) end

---Saves a translation unit into a serialized representation of
---that translation unit on disk.
---
---Any translation unit that was parsed without error can be saved
---into a file. The translation unit can then be deserialized into a
---new `CXTranslationUnit` with `clang_createTranslationUnit()` or,
---if it is an incomplete translation unit that corresponds to a
---header, used as a precompiled header when parsing other translation
---units.
---
---\param TU The translation unit to save.
---
---\param FileName The file to which the translation unit will be saved.
---
---@param options integer # A bitmask of options that affects how the translation unit
---is saved. This should be a bitwise OR of the
---CXSaveTranslationUnit_XXX flags.
---
---@return integer # s A value that will match one of the enumerators of the CXSaveError
---enumeration. Zero (CXSaveError_None) indicates that the translation unit was
---saved successfully, while a non-zero value indicates that a problem occurred.
---@param path string
---@param options integer
---@return integer
function TranslationUnit:saveTranslationUnit(path, options) end

---@return clang.TranslationUnit
function TranslationUnit:shared_from_this() end

---\param Module a module object.
---
---\param Index top level header index (zero-based).
---
---@return clang.File # s the specified top level header associated with the module.
---@param m clang.Module
---@param index integer
---@return clang.File
function TranslationUnit:topLevelHeader(m, index) end

return TranslationUnit
41 changes: 35 additions & 6 deletions addons/clang/library/clang/Type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
---@field exceptionSpecificationType integer Retrieve the exception specification type associated with a function type. This is a value of type CXCursor_ExceptionSpecificationKind. <br><br>If a non-function type is passed in, an error code of -1 is returned.
---@field fields clang.Cursor[] Get the fields of a record type
---@field functionTypeCallingConv clang.CallingConv Retrieve the calling convention associated with a function type. <br><br>If a non-function type is passed in, CXCallingConv_Invalid is returned.
---@field isConstQualified boolean Determine whether a CXType has the "const" qualifier set, without looking through typedefs that may have added "const" at a different level.
---@field isFunctionTypeVariadic boolean Return 1 if the CXType is a variadic function type, and 0 otherwise.
---@field isPOD boolean Return 1 if the CXType is a POD (plain old data) type, and 0 otherwise.
---@field isRestrictQualified boolean Determine whether a CXType has the "restrict" qualifier set, without looking through typedefs that may have added "restrict" at a different level.
---@field isTransparentTagTypedef boolean Determine if a typedef is 'transparent' tag. <br><br>A typedef is considered 'transparent' if it shares a name and spelling location with its underlying tag type, as is the case with the NS_ENUM macro. <br><br>\returns non-zero if transparent and zero otherwise.
---@field isVolatileQualified boolean Determine whether a CXType has the "volatile" qualifier set, without looking through typedefs that may have added "volatile" at a different level.
---@field kind clang.TypeKind The kind of type
---@field kindSpelling string Retrieve the spelling of a given CXTypeKind.
---@field modifiedType clang.Type Return the type that was modified by this attributed type. <br><br>If the type is not an attributed type, an invalid type is returned.
Expand Down Expand Up @@ -83,6 +77,41 @@ function Type:getOffsetOf(field) end
---@return clang.Type
function Type:getTemplateArgument(i) end

---Determine whether a CXType has the "const" qualifier set,
---without looking through typedefs that may have added "const" at a
---different level.
---@return boolean
function Type:isConstQualified() end

---Return 1 if the CXType is a variadic function type, and 0 otherwise.
---@return boolean
function Type:isFunctionTypeVariadic() end

---Return 1 if the CXType is a POD (plain old data) type, and 0
---otherwise.
---@return boolean
function Type:isPOD() end

---Determine whether a CXType has the "restrict" qualifier set,
---without looking through typedefs that may have added "restrict" at a
---different level.
---@return boolean
function Type:isRestrictQualified() end

---Determine if a typedef is 'transparent' tag.
---
---A typedef is considered 'transparent' if it shares a name and spelling
---location with its underlying tag type, as is the case with the NS_ENUM macro.
---
---@return boolean # s non-zero if transparent and zero otherwise.
function Type:isTransparentTagTypedef() end

---Determine whether a CXType has the "volatile" qualifier set,
---without looking through typedefs that may have added "volatile" at
---a different level.
---@return boolean
function Type:isVolatileQualified() end

---@return clang.Type
function Type:shared_from_this() end

Expand Down
1 change: 1 addition & 0 deletions addons/clang/library/clang/TypeKind.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ local TypeKind = {
Float16 = 32,
FunctionNoProto = 110,
FunctionProto = 111,
HLSLAttributedResource = 180,
HLSLResource = 179,
Half = 31,
Ibm128 = 40,
Expand Down
3 changes: 0 additions & 3 deletions addons/clang/library/clang/clang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ local clang = {}
---@return any
function clang:__gc() end

---@return any
function clang:__olua_move() end

---Provides a shared context for creating translation units.
---
---It provides two options:
Expand Down
Loading

0 comments on commit fc08d04

Please sign in to comment.