support main function in root namespace, fixes bug 516950
authorJuerg Billeter <j@bitron.ch>
Sun, 24 Feb 2008 15:49:11 +0000 (15:49 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sun, 24 Feb 2008 15:49:11 +0000 (15:49 +0000)
2008-02-24  Juerg Billeter  <j@bitron.ch>

* vala/valamethod.vala: support main function in root namespace,
  fixes bug 516950

svn path=/trunk/; revision=1051

ChangeLog
vala/valamethod.vala

index eb8b6f6..4649719 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2008-02-24  Jürg Billeter  <j@bitron.ch>
 
+       * vala/valamethod.vala: support main function in root namespace,
+         fixes bug 516950
+
+2008-02-24  Jürg Billeter  <j@bitron.ch>
+
        * vala/valasemanticanalyzer.vala, gobject/valaccodegenerator.vala:
          fix crash when using delegates as properties, fixes bug 517499
 
index 299e78e..ef43e1a 100644 (file)
@@ -296,7 +296,10 @@ public class Vala.Method : Member {
         * @return the name to be used in C code by default
         */
        public virtual string! get_default_cname () {
-               if (name.has_prefix ("_")) {
+               if (name == "main" && parent_symbol.name == null) {
+                       // avoid conflict with generated main function
+                       return "_main";
+               } else if (name.has_prefix ("_")) {
                        return "_%s%s".printf (parent_symbol.get_lower_case_cprefix (), name.offset (1));
                } else {
                        return "%s%s".printf (parent_symbol.get_lower_case_cprefix (), name);