[vala/0.40] codegen: Always emit constants with initializer-list



commit 2e6361ddfa98529ae114240ac768824608c39026
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Dec 8 10:41:50 2018 +0100

    codegen: Always emit constants with initializer-list
    
    generate_constant_declaration() handles both definition and declaration.
    
    This is important when using --use-header where the actual definition
    would never be written and we ended up with an "extern const ..." in the
    header only.
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/81

 codegen/valaccodebasemodule.vala | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 4240e7147..1ad8badc4 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -616,6 +616,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                if (sym.source_reference != null) {
                        sym.source_reference.file.used = true;
                }
+               // constants with initializer-list are special
+               if (sym is Constant && ((Constant) sym).value is InitializerList) {
+                       return false;
+               }
                if (sym.external_package || (!decl_space.is_header && CodeContext.get ().use_header && 
!sym.is_internal_symbol ())) {
                        // add feature test macros
                        foreach (unowned string feature_test_macro in get_ccode_feature_test_macros 
(sym).split (",")) {


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