From: Jesse van den Kieboom Date: Sat, 4 Jan 2014 13:51:52 +0000 (+0100) Subject: girwriter: Derive gir namespace from base name X-Git-Tag: 0.23.2~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4eb9670fd04c457a00f76da42c7c51928cf63b91;p=thirdparty%2Fvala.git girwriter: Derive gir namespace from base name Instead of using the full filename specified by --gir to derive the gir namespace, this patch uses only the base name of the file specified by --gir. https://bugzilla.gnome.org/show_bug.cgi?id=721452 --- diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala index 8356afab3..f6da0add6 100644 --- a/codegen/valagirwriter.vala +++ b/codegen/valagirwriter.vala @@ -141,7 +141,7 @@ public class Vala.GIRWriter : CodeVisitor { * @param context a code context * @param filename a relative or absolute filename */ - public void write_file (CodeContext context, string directory, string gir_namespace, string gir_version, string package) { + public void write_file (CodeContext context, string directory, string gir_filename, string gir_namespace, string gir_version, string package) { this.context = context; this.directory = directory; this.gir_namespace = gir_namespace; @@ -159,7 +159,7 @@ public class Vala.GIRWriter : CodeVisitor { indent--; buffer.append_printf ("\n"); - string filename = "%s%c%s-%s.gir".printf (directory, Path.DIR_SEPARATOR, gir_namespace, gir_version); + string filename = "%s%c%s".printf (directory, Path.DIR_SEPARATOR, gir_filename); stream = FileStream.open (filename, "w"); if (stream == null) { Report.error (null, "unable to open `%s' for writing".printf (filename)); diff --git a/compiler/valacompiler.vala b/compiler/valacompiler.vala index 8c7f507b3..16b55f22d 100644 --- a/compiler/valacompiler.vala +++ b/compiler/valacompiler.vala @@ -351,14 +351,15 @@ class Vala.Compiler { if (library != null) { if (gir != null) { - long gir_len = gir.length; - int last_hyphen = gir.last_index_of_char ('-'); + string gir_base = Path.get_basename(gir); + long gir_len = gir_base.length; + int last_hyphen = gir_base.last_index_of_char ('-'); - if (last_hyphen == -1 || !gir.has_suffix (".gir")) { + if (last_hyphen == -1 || !gir_base.has_suffix (".gir")) { Report.error (null, "GIR file name `%s' is not well-formed, expected NAME-VERSION.gir".printf (gir)); } else { - string gir_namespace = gir.substring (0, last_hyphen); - string gir_version = gir.substring (last_hyphen + 1, gir_len - last_hyphen - 5); + string gir_namespace = gir_base.substring (0, last_hyphen); + string gir_version = gir_base.substring (last_hyphen + 1, gir_len - last_hyphen - 5); gir_version.canon ("0123456789.", '?'); if (gir_namespace == "" || gir_version == "" || !gir_version[0].isdigit () || gir_version.contains ("?")) { Report.error (null, "GIR file name `%s' is not well-formed, expected NAME-VERSION.gir".printf (gir)); @@ -371,7 +372,7 @@ class Vala.Compiler { gir_directory = context.directory; } - gir_writer.write_file (context, gir_directory, gir_namespace, gir_version, library); + gir_writer.write_file (context, gir_directory, gir, gir_namespace, gir_version, library); } }