Exemplo n.º 1
0
        /// <summary>
        /// Add the specified source file to the context. Only .vala, .vapi, .gs,
        /// and .c extensions are supported.
        ///
        /// <param name="filename">a filename</param>
        /// <param name="is_source">true to force adding the file as .vala or .gs</param>
        /// <param name="cmdline">true if the file came from the command line.</param>
        /// <returns>false if the file is not recognized or the file does not exist</returns>
        /// </summary>
        public bool add_source_filename(string filename, bool is_source = false, bool cmdline = false)
        {
            if (!File.Exists(filename))
            {
                Report.error(null, "%s not found".printf(filename));
                return(false);
            }

            var rpath = Path.GetFullPath(filename);

            if (is_source || filename.EndsWith(".vala") || filename.EndsWith(".gs"))
            {
                var source_file = new SourceFile(this, SourceFileType.SOURCE, rpath, null, cmdline);
                source_file.Relative_filename = filename;

                // import the GLib namespace by default (namespace of backend-specific standard library)
                var ns_ref = new UsingDirective(new UnresolvedSymbol(null, "GLib", null));
                source_file.add_using_directive(ns_ref);
                root.add_using_directive(ns_ref);

                add_source_file(source_file);
            }
            else if (filename.EndsWith(".vapi") || filename.EndsWith(".gir"))
            {
                var source_file = new SourceFile(this, SourceFileType.PACKAGE, rpath, null, cmdline);
                source_file.Relative_filename = filename;

                add_source_file(source_file);
            }
            else if (filename.EndsWith(".c"))
            {
                add_c_source_file(rpath);
            }
            else if (filename.EndsWith(".h"))
            {
                /* Ignore */
            }
            else
            {
                Report.error(null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf(filename));
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Visit operation called for using directives.
 ///
 /// <param name="ns">a using directive</param>
 /// </summary>
 public virtual void visit_using_directive(UsingDirective ns)
 {
 }