[vala/staging: 3/10] codegen: Allow to associate CCodeFile to actual SourceFile



commit ffc53c4a46455db8ce1bd8cdbb1a48a720c582e3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Feb 23 20:19:31 2019 +0100

    codegen: Allow to associate CCodeFile to actual SourceFile

 ccode/valaccodefile.vala         | 6 ++++++
 codegen/valaccodebasemodule.vala | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/ccode/valaccodefile.vala b/ccode/valaccodefile.vala
index e98d84bd0..6a8ae8ce3 100644
--- a/ccode/valaccodefile.vala
+++ b/ccode/valaccodefile.vala
@@ -24,6 +24,8 @@
 public class Vala.CCodeFile {
        public bool is_header { get; set; }
 
+       public weak SourceFile? file { get; private set; }
+
        Set<string> features = new HashSet<string> (str_hash, str_equal);
        Set<string> declarations = new HashSet<string> (str_hash, str_equal);
        Set<string> includes = new HashSet<string> (str_hash, str_equal);
@@ -36,6 +38,10 @@ public class Vala.CCodeFile {
        CCodeFragment constant_declaration = new CCodeFragment ();
        CCodeFragment type_member_definition = new CCodeFragment ();
 
+       public CCodeFile (SourceFile? source_file = null) {
+               file = source_file;
+       }
+
        public bool add_declaration (string name) {
                if (name in declarations) {
                        return true;
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index de0bae868..0cb9cf96f 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -759,7 +759,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
        }
 
        public override void visit_source_file (SourceFile source_file) {
-               cfile = new CCodeFile ();
+               cfile = new CCodeFile (source_file);
 
                user_marshal_set = new HashSet<string> (str_hash, str_equal);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]