]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
girwriter: Derive gir namespace from base name
authorJesse van den Kieboom <jessevdk@gmail.com>
Sat, 4 Jan 2014 13:51:52 +0000 (14:51 +0100)
committerJesse van den Kieboom <jessevdk@gmail.com>
Sat, 4 Jan 2014 13:54:28 +0000 (14:54 +0100)
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

codegen/valagirwriter.vala
compiler/valacompiler.vala

index 8356afab383dc9b2c0bc132c1019afffb36b66cb..f6da0add6b4b2ab668604e846c863f088988227c 100644 (file)
@@ -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 ("</repository>\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));
index 8c7f507b3e52b0ff3c18c0e2fb6d6492e4c0a798..16b55f22d9ebf601e18cae9533c2ff10387540ae 100644 (file)
@@ -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);
                                        }
                                }