]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vapigen: add support for member access based default values
authorEvan Nemerson <evan@coeus-group.com>
Fri, 2 Apr 2010 18:41:49 +0000 (11:41 -0700)
committerEvan Nemerson <evan@coeus-group.com>
Fri, 2 Apr 2010 18:41:49 +0000 (11:41 -0700)
vapigen/valagidlparser.vala

index d0831128f426a2eab8b95021c857fe027755f7b8..6d3e03d6b65858e28da565f5562f7dd52a5c7971 100644 (file)
@@ -1779,6 +1779,8 @@ public class Vala.GIdlParser : CodeVisitor {
                                                        p.default_expression = new BooleanLiteral (true, param_type.source_reference);
                                                } else if (val == "false") {
                                                        p.default_expression = new BooleanLiteral (false, param_type.source_reference);
+                                               } else if (val == "") {
+                                                       p.default_expression = new StringLiteral ("\"\"", param_type.source_reference);
                                                } else {
                                                        unowned string endptr;
                                                        unowned string val_end = val.offset (val.len ());
@@ -1791,7 +1793,13 @@ public class Vala.GIdlParser : CodeVisitor {
                                                                if ((long)endptr == (long)val_end) {
                                                                        p.default_expression = new RealLiteral (val, param_type.source_reference);
                                                                } else {
-                                                                       p.default_expression = new StringLiteral ("\"%s\"".printf (val), param_type.source_reference);
+                                                                       if (val.has_prefix ("\"") && val.has_suffix ("\"")) {
+                                                                               p.default_expression = new StringLiteral (val, param_type.source_reference);
+                                                                       } else {
+                                                                               foreach (var member in val.split (".")) {
+                                                                                       p.default_expression = new MemberAccess (p.default_expression, member, param_type.source_reference);
+                                                                               }
+                                                                       }
                                                                }
                                                        }
                                                }