odin-blend2d

Odin bindings to Blend2D
Log | Files | Refs | README | LICENSE

CXSourceLocation.odin (9355B)


      1 /*===-- clang-c/CXSourceLocation.h - C Index Source Location ------*- C -*-===*\
      2 |*                                                                            *|
      3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
      4 |* Exceptions.                                                                *|
      5 |* See https://llvm.org/LICENSE.txt for license information.                  *|
      6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
      7 |*                                                                            *|
      8 |*===----------------------------------------------------------------------===*|
      9 |*                                                                            *|
     10 |* This header provides the interface to C Index source locations.            *|
     11 |*                                                                            *|
     12 \*===----------------------------------------------------------------------===*/
     13 package libclang
     14 
     15 import "core:c"
     16 
     17 _ :: c
     18 
     19 when ODIN_OS == .Windows {
     20     @(extra_linker_flags="/NODEFAULTLIB:libcmt")
     21     foreign import lib {
     22         "system:ntdll.lib",
     23         "system:ucrt.lib",
     24         "system:msvcrt.lib",
     25         "system:legacy_stdio_definitions.lib",
     26         "system:kernel32.lib",
     27         "system:user32.lib",
     28         "system:advapi32.lib",
     29         "system:shell32.lib",
     30         "system:ole32.lib",
     31         "system:oleaut32.lib",
     32         "system:uuid.lib",
     33         "system:ws2_32.lib",
     34         "system:version.lib",
     35         "system:oldnames.lib",
     36         "libclang.lib",
     37 	}
     38 } else {
     39     foreign import lib "system:clang"
     40 }
     41 
     42 // LLVM_CLANG_C_CXSOURCE_LOCATION_H :: 
     43 
     44 /**
     45 * Identifies a specific source location within a translation
     46 * unit.
     47 *
     48 * Use clang_getExpansionLocation() or clang_getSpellingLocation()
     49 * to map a source location to a particular file, line, and column.
     50 */
     51 Source_Location :: struct {
     52 	ptr_data: [2]rawptr,
     53 	int_data: c.uint,
     54 }
     55 
     56 /**
     57 * Identifies a half-open character range in the source code.
     58 *
     59 * Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
     60 * starting and end locations from a source range, respectively.
     61 */
     62 Source_Range :: struct {
     63 	ptr_data:       [2]rawptr,
     64 	begin_int_data: c.uint,
     65 	end_int_data:   c.uint,
     66 }
     67 
     68 /**
     69 * Identifies an array of ranges.
     70 */
     71 Source_Range_List :: struct {
     72 	/** The number of ranges in the \c ranges array. */
     73 	count: c.uint,
     74 
     75 	/**
     76 	* An array of \c CXSourceRanges.
     77 	*/
     78 	ranges: ^Source_Range,
     79 }
     80 
     81 @(default_calling_convention="c", link_prefix="clang_")
     82 foreign lib {
     83 	/**
     84 	* Retrieve a NULL (invalid) source location.
     85 	*/
     86 	getNullLocation :: proc() -> Source_Location ---
     87 
     88 	/**
     89 	* Determine whether two source locations, which must refer into
     90 	* the same translation unit, refer to exactly the same point in the source
     91 	* code.
     92 	*
     93 	* \returns non-zero if the source locations refer to the same location, zero
     94 	* if they refer to different locations.
     95 	*/
     96 	equalLocations :: proc(loc1: Source_Location, loc2: Source_Location) -> c.uint ---
     97 
     98 	/**
     99 	* Determine for two source locations if the first comes
    100 	* strictly before the second one in the source code.
    101 	*
    102 	* \returns non-zero if the first source location comes
    103 	* strictly before the second one, zero otherwise.
    104 	*/
    105 	isBeforeInTranslationUnit :: proc(loc1: Source_Location, loc2: Source_Location) -> c.uint ---
    106 
    107 	/**
    108 	* Returns non-zero if the given source location is in a system header.
    109 	*/
    110 	Location_isInSystemHeader :: proc(location: Source_Location) -> c.int ---
    111 
    112 	/**
    113 	* Returns non-zero if the given source location is in the main file of
    114 	* the corresponding translation unit.
    115 	*/
    116 	Location_isFromMainFile :: proc(location: Source_Location) -> c.int ---
    117 
    118 	/**
    119 	* Retrieve a NULL (invalid) source range.
    120 	*/
    121 	getNullRange :: proc() -> Source_Range ---
    122 
    123 	/**
    124 	* Retrieve a source range given the beginning and ending source
    125 	* locations.
    126 	*/
    127 	getRange :: proc(begin: Source_Location, end: Source_Location) -> Source_Range ---
    128 
    129 	/**
    130 	* Determine whether two ranges are equivalent.
    131 	*
    132 	* \returns non-zero if the ranges are the same, zero if they differ.
    133 	*/
    134 	equalRanges :: proc(range1: Source_Range, range2: Source_Range) -> c.uint ---
    135 
    136 	/**
    137 	* Returns non-zero if \p range is null.
    138 	*/
    139 	Range_isNull :: proc(range: Source_Range) -> c.int ---
    140 
    141 	/**
    142 	* Retrieve the file, line, column, and offset represented by
    143 	* the given source location.
    144 	*
    145 	* If the location refers into a macro expansion, retrieves the
    146 	* location of the macro expansion.
    147 	*
    148 	* \param location the location within a source file that will be decomposed
    149 	* into its parts.
    150 	*
    151 	* \param file [out] if non-NULL, will be set to the file to which the given
    152 	* source location points.
    153 	*
    154 	* \param line [out] if non-NULL, will be set to the line to which the given
    155 	* source location points.
    156 	*
    157 	* \param column [out] if non-NULL, will be set to the column to which the given
    158 	* source location points.
    159 	*
    160 	* \param offset [out] if non-NULL, will be set to the offset into the
    161 	* buffer to which the given source location points.
    162 	*/
    163 	getExpansionLocation :: proc(location: Source_Location, file: ^File, line: ^c.uint, column: ^c.uint, offset: ^c.uint) ---
    164 
    165 	/**
    166 	* Retrieve the file, line and column represented by the given source
    167 	* location, as specified in a # line directive.
    168 	*
    169 	* Example: given the following source code in a file somefile.c
    170 	*
    171 	* \code
    172 	* #123 "dummy.c" 1
    173 	*
    174 	* static int func(void)
    175 	* {
    176 	*     return 0;
    177 	* }
    178 	* \endcode
    179 	*
    180 	* the location information returned by this function would be
    181 	*
    182 	* File: dummy.c Line: 124 Column: 12
    183 	*
    184 	* whereas clang_getExpansionLocation would have returned
    185 	*
    186 	* File: somefile.c Line: 3 Column: 12
    187 	*
    188 	* \param location the location within a source file that will be decomposed
    189 	* into its parts.
    190 	*
    191 	* \param filename [out] if non-NULL, will be set to the filename of the
    192 	* source location. Note that filenames returned will be for "virtual" files,
    193 	* which don't necessarily exist on the machine running clang - e.g. when
    194 	* parsing preprocessed output obtained from a different environment. If
    195 	* a non-NULL value is passed in, remember to dispose of the returned value
    196 	* using \c clang_disposeString() once you've finished with it. For an invalid
    197 	* source location, an empty string is returned.
    198 	*
    199 	* \param line [out] if non-NULL, will be set to the line number of the
    200 	* source location. For an invalid source location, zero is returned.
    201 	*
    202 	* \param column [out] if non-NULL, will be set to the column number of the
    203 	* source location. For an invalid source location, zero is returned.
    204 	*/
    205 	getPresumedLocation :: proc(location: Source_Location, filename: ^String, line: ^c.uint, column: ^c.uint) ---
    206 
    207 	/**
    208 	* Legacy API to retrieve the file, line, column, and offset represented
    209 	* by the given source location.
    210 	*
    211 	* This interface has been replaced by the newer interface
    212 	* #clang_getExpansionLocation(). See that interface's documentation for
    213 	* details.
    214 	*/
    215 	getInstantiationLocation :: proc(location: Source_Location, file: ^File, line: ^c.uint, column: ^c.uint, offset: ^c.uint) ---
    216 
    217 	/**
    218 	* Retrieve the file, line, column, and offset represented by
    219 	* the given source location.
    220 	*
    221 	* If the location refers into a macro instantiation, return where the
    222 	* location was originally spelled in the source file.
    223 	*
    224 	* \param location the location within a source file that will be decomposed
    225 	* into its parts.
    226 	*
    227 	* \param file [out] if non-NULL, will be set to the file to which the given
    228 	* source location points.
    229 	*
    230 	* \param line [out] if non-NULL, will be set to the line to which the given
    231 	* source location points.
    232 	*
    233 	* \param column [out] if non-NULL, will be set to the column to which the given
    234 	* source location points.
    235 	*
    236 	* \param offset [out] if non-NULL, will be set to the offset into the
    237 	* buffer to which the given source location points.
    238 	*/
    239 	getSpellingLocation :: proc(location: Source_Location, file: ^File, line: ^c.uint, column: ^c.uint, offset: ^c.uint) ---
    240 
    241 	/**
    242 	* Retrieve the file, line, column, and offset represented by
    243 	* the given source location.
    244 	*
    245 	* If the location refers into a macro expansion, return where the macro was
    246 	* expanded or where the macro argument was written, if the location points at
    247 	* a macro argument.
    248 	*
    249 	* \param location the location within a source file that will be decomposed
    250 	* into its parts.
    251 	*
    252 	* \param file [out] if non-NULL, will be set to the file to which the given
    253 	* source location points.
    254 	*
    255 	* \param line [out] if non-NULL, will be set to the line to which the given
    256 	* source location points.
    257 	*
    258 	* \param column [out] if non-NULL, will be set to the column to which the given
    259 	* source location points.
    260 	*
    261 	* \param offset [out] if non-NULL, will be set to the offset into the
    262 	* buffer to which the given source location points.
    263 	*/
    264 	getFileLocation :: proc(location: Source_Location, file: ^File, line: ^c.uint, column: ^c.uint, offset: ^c.uint) ---
    265 
    266 	/**
    267 	* Retrieve a source location representing the first character within a
    268 	* source range.
    269 	*/
    270 	getRangeStart :: proc(range: Source_Range) -> Source_Location ---
    271 
    272 	/**
    273 	* Retrieve a source location representing the last character within a
    274 	* source range.
    275 	*/
    276 	getRangeEnd :: proc(range: Source_Range) -> Source_Location ---
    277 
    278 	/**
    279 	* Destroy the given \c CXSourceRangeList.
    280 	*/
    281 	disposeSourceRangeList :: proc(ranges: ^Source_Range_List) ---
    282 }