12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package jdk.internal.clang; 24 25 import java.foreign.NativeTypes; 26 import java.foreign.Scope; 27 import java.foreign.memory.Pointer; 28 import java.nio.file.Path; 29 import java.nio.file.Paths; 30 import java.util.Objects; 31 32 import static clang.CXString.CXString; 33 import static clang.Index.CXSourceLocation; 34 35 public class SourceLocation { 36 37 private final CXSourceLocation loc; 38 39 SourceLocation(CXSourceLocation loc) { 40 this.loc = loc; 41 } 42 43 @FunctionalInterface 44 private interface LocationFactory { 45 void get(CXSourceLocation loc, Pointer<Pointer<Void>> file, 46 Pointer<Integer> line, Pointer<Integer> column, Pointer<Integer> offset); 47 } 48 49 @SuppressWarnings("unchecked") 50 private Location getLocation(LocationFactory fn) { 51 try (Scope s = Scope.globalScope().fork()) { 52 Pointer<Pointer<Void>> file = s.allocate(NativeTypes.VOID.pointer()); 53 Pointer<Integer> line = s.allocate(NativeTypes.INT); | 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package jdk.internal.clang; 24 25 import java.foreign.NativeTypes; 26 import java.foreign.Scope; 27 import java.foreign.memory.Pointer; 28 import java.nio.file.Path; 29 import java.nio.file.Paths; 30 import java.util.Objects; 31 32 import static clang.CXString_h.CXString; 33 import static clang.Index_h.CXSourceLocation; 34 35 public class SourceLocation { 36 37 private final CXSourceLocation loc; 38 39 SourceLocation(CXSourceLocation loc) { 40 this.loc = loc; 41 } 42 43 @FunctionalInterface 44 private interface LocationFactory { 45 void get(CXSourceLocation loc, Pointer<Pointer<Void>> file, 46 Pointer<Integer> line, Pointer<Integer> column, Pointer<Integer> offset); 47 } 48 49 @SuppressWarnings("unchecked") 50 private Location getLocation(LocationFactory fn) { 51 try (Scope s = Scope.globalScope().fork()) { 52 Pointer<Pointer<Void>> file = s.allocate(NativeTypes.VOID.pointer()); 53 Pointer<Integer> line = s.allocate(NativeTypes.INT); |