[vala] Emit line directive when there is no corresponding Vala line
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [vala] Emit line directive when there is no corresponding Vala line
- Date: Wed, 8 Apr 2009 12:37:51 -0400 (EDT)
commit 3a1b5894b7c1f6f22541c2298b9dc9640a9d2da9
Author: Jürg Billeter <j bitron ch>
Date: Wed Apr 8 18:28:27 2009 +0200
Emit line directive when there is no corresponding Vala line
---
ccode/valaccodewriter.vala | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala
index 9549b8c..ff2ead6 100644
--- a/ccode/valaccodewriter.vala
+++ b/ccode/valaccodewriter.vala
@@ -1,6 +1,6 @@
/* valaccodewriter.vala
*
- * Copyright (C) 2006-2008 Jürg Billeter
+ * Copyright (C) 2006-2009 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -49,6 +49,8 @@ public class Vala.CCodeWriter {
private FileStream stream;
private int indent;
+ private int current_line_number = 1;
+ private bool using_line_directive;
/* at begin of line */
private bool _bol = true;
@@ -111,12 +113,20 @@ public class Vala.CCodeWriter {
* Writes tabs according to the current indent level.
*/
public void write_indent (CCodeLineDirective? line = null) {
- if (line_directives && line != null) {
- line.write (this);
+ if (line_directives) {
+ if (line != null) {
+ line.write (this);
+ using_line_directive = true;
+ } else if (using_line_directive) {
+ // no corresponding Vala line, emit line directive for C line
+ write_string ("#line %d \"%s\"".printf (current_line_number + 1, filename));
+ write_newline ();
+ using_line_directive = false;
+ }
}
if (!bol) {
- stream.putc ('\n');
+ write_newline ();
}
for (int i = 0; i < indent; i++) {
@@ -141,6 +151,7 @@ public class Vala.CCodeWriter {
*/
public void write_newline () {
stream.putc ('\n');
+ current_line_number++;
_bol = true;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]