posix.vapi: signal is allowed to be null (restoring the original handler)
[vala-lang.git] / vala / valasourcereference.vala
blobfd3a0808f3c75bd542217b142c843bd9b09fbca4
1 /* valasourcereference.vala
3 * Copyright (C) 2006-2008 Jürg Billeter
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * Author:
20 * Jürg Billeter <j@bitron.ch>
23 using GLib;
25 /**
26 * Represents a reference to a location in a source file.
28 public class Vala.SourceReference {
29 /**
30 * The source file to be referenced.
32 public weak SourceFile file { get; set; }
34 /**
35 * The first line number of the referenced source code.
37 public int first_line { get; set; }
39 /**
40 * The first column number of the referenced source code.
42 public int first_column { get; set; }
44 /**
45 * The last line number of the referenced source code.
47 public int last_line { get; set; }
49 /**
50 * The last column number of the referenced source code.
52 public int last_column { get; set; }
54 /**
55 * The text describing the referenced source code.
57 public string comment { get; set; }
59 /**
60 * Creates a new source reference.
62 * @param file a source file
63 * @param first_line first line number
64 * @param first_column first column number
65 * @param last_line last line number
66 * @param last_column last column number
67 * @return newly created source reference
69 public SourceReference (SourceFile _file, int _first_line = 0, int _first_column = 0, int _last_line = 0, int _last_column = 0) {
70 file = _file;
71 first_line = _first_line;
72 first_column = _first_column;
73 last_line = _last_line;
74 last_column = _last_column;
77 /**
78 * Creates a new commented source reference.
80 * @param file a source file
81 * @param first_line first line number
82 * @param first_column first column number
83 * @param last_line last line number
84 * @param last_column last column number
85 * @param comment code comment
86 * @return newly created source reference
88 public SourceReference.with_comment (SourceFile _file, int _first_line, int _first_column, int _last_line, int _last_column, string? _comment) {
89 file = _file;
90 first_line = _first_line;
91 first_column = _first_column;
92 last_line = _last_line;
93 last_column = _last_column;
94 comment = _comment;
97 /**
98 * Returns a string representation of this source reference.
100 * @return human-readable string
102 public string to_string () {
103 return ("%s:%d.%d-%d.%d".printf (file.get_relative_filename (), first_line, first_column, last_line, last_column));