vala r1637 - in trunk: . compiler vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1637 - in trunk: . compiler vala
- Date: Mon, 23 Jun 2008 12:50:45 +0000 (UTC)
Author: juergbi
Date: Mon Jun 23 12:50:45 2008
New Revision: 1637
URL: http://svn.gnome.org/viewvc/vala?rev=1637&view=rev
Log:
2008-06-23 JÃrg Billeter <j bitron ch>
* vala/valagenieparser.vala:
* vala/valanamespacereference.vala:
* vala/valasourcefile.vala:
* compiler/valacompiler.vala:
Import members of the GLib namespace by default, fixes bug 539596
Modified:
trunk/ChangeLog
trunk/compiler/valacompiler.vala
trunk/vala/valagenieparser.vala
trunk/vala/valanamespacereference.vala
trunk/vala/valasourcefile.vala
Modified: trunk/compiler/valacompiler.vala
==============================================================================
--- trunk/compiler/valacompiler.vala (original)
+++ trunk/compiler/valacompiler.vala Mon Jun 23 12:50:45 2008
@@ -198,7 +198,12 @@
if (FileUtils.test (source, FileTest.EXISTS)) {
var rpath = realpath (source);
if (source.has_suffix (".vala") || source.has_suffix (".gs")) {
- context.add_source_file (new SourceFile (context, rpath));
+ var source_file = new SourceFile (context, rpath);
+
+ // import the GLib namespace by default (namespace of backend-specific standard library)
+ source_file.add_using_directive (new NamespaceReference ("GLib"));
+
+ context.add_source_file (source_file);
} else if (source.has_suffix (".vapi")) {
context.add_source_file (new SourceFile (context, rpath, true));
} else if (source.has_suffix (".c")) {
Modified: trunk/vala/valagenieparser.vala
==============================================================================
--- trunk/vala/valagenieparser.vala (original)
+++ trunk/vala/valagenieparser.vala Mon Jun 23 12:50:45 2008
@@ -44,9 +44,6 @@
string class_name;
- /* we need to know whether to automatically add these using directives */
- bool has_uses_glib;
-
/* hack needed to know if any part of an expression is a lambda one */
bool current_expr_is_lambda;
@@ -72,7 +69,6 @@
construct {
tokens = new TokenInfo[BUFFER_SIZE];
- has_uses_glib = false;
class_name = null;
current_expr_is_lambda = false;
}
@@ -2344,10 +2340,6 @@
var ns_ref = new NamespaceReference (sym.name, get_src (begin));
scanner.source_file.add_using_directive (ns_ref);
-
- if (sym.name == "GLib") {
- has_uses_glib = true;
- }
}
void parse_using_directives () throws ParseError {
@@ -2373,11 +2365,6 @@
}
}
- if (!has_uses_glib) {
- var ns_ref = new NamespaceReference ("GLib", get_src (begin));
- scanner.source_file.add_using_directive (ns_ref);
- }
-
}
Symbol parse_class_declaration (Gee.List<Attribute>? attrs) throws ParseError {
Modified: trunk/vala/valanamespacereference.vala
==============================================================================
--- trunk/vala/valanamespacereference.vala (original)
+++ trunk/vala/valanamespacereference.vala Mon Jun 23 12:50:45 2008
@@ -1,6 +1,6 @@
/* valanamespacereference.vala
*
- * Copyright (C) 2006-2007 JÃrg Billeter
+ * Copyright (C) 2006-2008 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
@@ -43,9 +43,9 @@
* @param source_reference reference to source code
* @return newly created namespace reference
*/
- public NamespaceReference (string name, SourceReference source_reference) {
- this.source_reference = source_reference;
+ public NamespaceReference (string name, SourceReference? source_reference = null) {
this.name = name;
+ this.source_reference = source_reference;
}
public override void accept (CodeVisitor visitor) {
Modified: trunk/vala/valasourcefile.vala
==============================================================================
--- trunk/vala/valasourcefile.vala (original)
+++ trunk/vala/valasourcefile.vala Mon Jun 23 12:50:45 2008
@@ -108,6 +108,12 @@
* @param ns reference to namespace
*/
public void add_using_directive (NamespaceReference ns) {
+ foreach (NamespaceReference using_directive in using_directives) {
+ if (using_directive.name == ns.name) {
+ // ignore duplicates
+ return;
+ }
+ }
using_directives.add (ns);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]