]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
dova: Include dova-base.h/dova-types.h
authorJürg Billeter <j@bitron.ch>
Fri, 16 Jul 2010 16:05:29 +0000 (18:05 +0200)
committerJürg Billeter <j@bitron.ch>
Fri, 16 Jul 2010 16:05:29 +0000 (18:05 +0200)
codegen/valadovaassignmentmodule.vala
codegen/valadovabasemodule.vala
codegen/valadovacontrolflowmodule.vala
codegen/valadovaobjectmodule.vala
codegen/valadovastructmodule.vala
codegen/valadovavaluemodule.vala
compiler/valacompiler.vala
vala/valacodecontext.vala

index 1c400b7f1a447245023328b2777b39d0e6707446..17fcfc563451481880b68a04cd7f13d9fffcfb86 100644 (file)
@@ -161,8 +161,6 @@ internal class Vala.DovaAssignmentModule : DovaMemberAccessModule {
                CCodeExpression rhs = (CCodeExpression) assignment.right.ccodenode;
                CCodeExpression lhs = (CCodeExpression) get_ccodenode (assignment.left);
 
-               source_declarations.add_include ("string.h");
-
                // it is necessary to use memcpy for fixed-length (stack-allocated) arrays
                // simple assignments do not work in C
                var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
index 572270dd7524869a7d104d09b17da1f448966f6f..f67ca336327a0d906c2e82454ed6c2e8cc40d55e 100644 (file)
@@ -241,11 +241,18 @@ internal class Vala.DovaBaseModule : CCodeModule {
 
                header_declarations = new CCodeDeclarationSpace ();
 
-
                source_declarations = new CCodeDeclarationSpace ();
                module_init_fragment = new CCodeFragment ();
                source_type_member_definition = new CCodeFragment ();
 
+               if (context.nostdpkg) {
+                       header_declarations.add_include ("dova-types.h");
+                       source_declarations.add_include ("dova-types.h");
+               } else {
+                       header_declarations.add_include ("dova-base.h");
+                       source_declarations.add_include ("dova-base.h");
+               }
+
                next_temp_var_id = 0;
                variable_name_map.clear ();
 
@@ -1114,7 +1121,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
                        var pointer_type = (PointerType) type;
                        return get_dup_func_expression (pointer_type.base_type, source_reference);
                } else {
-                       source_declarations.add_include ("stddef.h");
                        return new CCodeConstant ("NULL");
                }
        }
@@ -1140,7 +1146,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
                                }
                        }
                        if (unref_function == null) {
-                               source_declarations.add_include ("stddef.h");
                                return new CCodeConstant ("NULL");
                        }
                        return new CCodeIdentifier (unref_function);
@@ -1154,7 +1159,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
                } else if (type is PointerType) {
                        return new CCodeIdentifier ("free");
                } else {
-                       source_declarations.add_include ("stddef.h");
                        return new CCodeConstant ("NULL");
                }
        }
@@ -1179,8 +1183,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
                 * if foo is of static type non-null
                 */
 
-               source_declarations.add_include ("stddef.h");
-
                var cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, cvar, new CCodeConstant ("NULL"));
                if (type.type_parameter != null) {
                        if (!(current_type_symbol is Class) || current_class.is_compact) {
@@ -1279,8 +1281,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
                                var alloca_call = new CCodeFunctionCall (new CCodeIdentifier ("alloca"));
                                alloca_call.add_argument (value_size);
 
-                               // memset needs string.h
-                               source_declarations.add_include ("string.h");
                                var memset_call = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
                                memset_call.add_argument (alloca_call);
                                memset_call.add_argument (new CCodeConstant ("0"));
@@ -1300,7 +1300,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
                                vardecl.init0 = true;
                        } else if (local.variable_type.is_reference_type_or_type_parameter () ||
                               local.variable_type.nullable) {
-                               source_declarations.add_include ("stddef.h");
                                vardecl.initializer = new CCodeConstant ("NULL");
                                vardecl.init0 = true;
                        }
@@ -1501,7 +1500,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_boolean_literal (BooleanLiteral expr) {
-               source_declarations.add_include ("stdbool.h");
                expr.ccodenode = new CCodeConstant (expr.value ? "true" : "false");
        }
 
@@ -1552,7 +1550,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_null_literal (NullLiteral expr) {
-               source_declarations.add_include ("stddef.h");
                expr.ccodenode = new CCodeConstant ("NULL");
        }
 
@@ -1711,7 +1708,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
 
                        var ctemp = get_variable_cexpression (decl.name);
 
-                       source_declarations.add_include ("stddef.h");
                        var cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ctemp, new CCodeConstant ("NULL"));
                        if (expression_type.type_parameter != null) {
                                // dup functions are optional for type parameters
@@ -1779,8 +1775,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
                if (expr.symbol_reference == null) {
                        // no creation method
                        if (expr.type_reference.data_type is Struct) {
-                               // memset needs string.h
-                               source_declarations.add_include ("string.h");
                                var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
                                creation_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance));
                                creation_call.add_argument (new CCodeConstant ("0"));
@@ -2425,8 +2419,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public CCodeExpression? default_value_for_type (DataType type, bool initializer_expression) {
-               source_declarations.add_include ("stddef.h");
-
                var st = type.data_type as Struct;
                var array_type = type as ArrayType;
                if (type is GenericType) {
@@ -2436,8 +2428,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
                        var alloca_call = new CCodeFunctionCall (new CCodeIdentifier ("alloca"));
                        alloca_call.add_argument (value_size);
 
-                       // memset needs string.h
-                       source_declarations.add_include ("string.h");
                        var memset_call = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
                        memset_call.add_argument (alloca_call);
                        memset_call.add_argument (new CCodeConstant ("0"));
index 6616dcca7c785fe164df3f3cdd374845d06bbe43..ab142cb85a639452e79be090bd865ed8dc71cb7d 100644 (file)
@@ -1,6 +1,6 @@
 /* valadovacontrolflowmodule.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -79,7 +79,6 @@ internal class Vala.DovaControlFlowModule : DovaMethodModule {
        public override void visit_loop (Loop stmt) {
                stmt.accept_children (codegen);
 
-               source_declarations.add_include ("stdbool.h");
                stmt.ccodenode = new CCodeWhileStatement (new CCodeConstant ("true"), (CCodeStatement) stmt.body.ccodenode);
        }
 
index 5da911c485903916ec18d0475afe921267140b55..ed0173619d6f7b7ec7fdb2411e7134c8549f441f 100644 (file)
@@ -43,8 +43,6 @@ internal class Vala.DovaObjectModule : DovaArrayModule {
                        instance_struct.add_field ("DovaType *", "type");
                        decl_space.add_type_definition (instance_struct);
                } else if (cl == type_class) {
-                       decl_space.add_include ("stdbool.h");
-
                        var value_copy_function = new CCodeFunction ("dova_type_value_copy");
                        value_copy_function.add_parameter (new CCodeFormalParameter ("type", "DovaType *"));
                        value_copy_function.add_parameter (new CCodeFormalParameter ("dest", "void *"));
@@ -367,10 +365,6 @@ internal class Vala.DovaObjectModule : DovaArrayModule {
        }
 
        public CCodeBlock generate_type_get_function (TypeSymbol cl, Class? base_class) {
-               source_declarations.add_include ("stddef.h");
-               // calloc
-               source_declarations.add_include ("stdlib.h");
-
                DataType? base_class_type = null;
                if (base_class != null && cl is Class) {
                        foreach (DataType base_type in ((Class) cl).get_base_types ()) {
@@ -856,10 +850,6 @@ internal class Vala.DovaObjectModule : DovaArrayModule {
                source_declarations.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_priv_struct.name), new CCodeVariableDeclarator ("%sTypePrivate".printf (iface.get_cname ()))));
                source_declarations.add_type_definition (type_priv_struct);
 
-               source_declarations.add_include ("stddef.h");
-               // calloc
-               source_declarations.add_include ("stdlib.h");
-
                var cdecl = new CCodeDeclaration ("DovaType *");
                cdecl.add_declarator (new CCodeVariableDeclarator ("%s_type".printf (iface.get_lower_case_cname ()), new CCodeConstant ("NULL")));
                cdecl.modifiers = CCodeModifiers.STATIC;
@@ -1606,8 +1596,6 @@ internal class Vala.DovaObjectModule : DovaArrayModule {
                        cdecl.add_declarator (new CCodeVariableDeclarator ("this"));
                        vblock.add_statement (cdecl);
 
-                       source_declarations.add_include ("stddef.h");
-
                        var type_get = new CCodeFunctionCall (new CCodeIdentifier (current_class.get_lower_case_cname () + "_type_get"));
                        foreach (var type_param in current_class.get_type_parameters ()) {
                                type_get.add_argument (new CCodeIdentifier ("%s_type".printf (type_param.name.down ())));
index 4cc286bf2f74527528f9312cb0a2e9357be2dbad..f0746b86a84301ddfca5e94079af792c61906b84 100644 (file)
@@ -41,12 +41,10 @@ internal class Vala.DovaStructModule : DovaBaseModule {
 
                if (st.is_boolean_type ()) {
                        // typedef for boolean types
-                       decl_space.add_include ("stdbool.h");
                        st.set_cname ("bool");
                        return;
                } else if (st.is_integer_type ()) {
                        // typedef for integral types
-                       decl_space.add_include ("stdint.h");
                        st.set_cname ("%sint%d_t".printf (st.signed ? "" : "u", st.width));
                        return;
                } else if (st.is_decimal_floating_type ()) {
index f7c29d1bab57a01318561d8d5e456d9a72b8c423..3cef0e937343ce7d21252ff1bc1b4564061565cd 100644 (file)
@@ -358,8 +358,6 @@ internal class Vala.DovaValueModule : DovaObjectModule {
                        return;
                }
 
-               decl_space.add_include ("stdint.h");
-
                generate_class_declaration (type_class, decl_space);
 
                var type_fun = new CCodeFunction ("%s_type_get".printf (st.get_lower_case_cname ()), "DovaType *");
@@ -410,11 +408,6 @@ internal class Vala.DovaValueModule : DovaObjectModule {
        public override void visit_struct (Struct st) {
                base.visit_struct (st);
 
-               source_declarations.add_include ("stddef.h");
-               // calloc
-               source_declarations.add_include ("stdlib.h");
-
-
                var cdecl = new CCodeDeclaration ("int");
                cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_object_offset".printf (st.get_lower_case_cname ()), new CCodeConstant ("0")));
                cdecl.modifiers = CCodeModifiers.STATIC;
index 3c5f7338268f9e94fb5ccb6b4c011d7fc90a77cc..f271c6f48a2615975bf87c3de7157adf22265875 100644 (file)
@@ -255,6 +255,7 @@ class Vala.Compiler {
                } else {
                        Report.error (null, "Unknown profile %s".printf (profile));
                }
+               context.nostdpkg = nostdpkg;
 
                context.entry_point_name = entry_point;
 
index 0bce4bfca513398f02271b92a5c4698486ae9da1..cd32378ba0bb3945e075b0d494ccde4227ac496b 100644 (file)
@@ -149,6 +149,8 @@ public class Vala.CodeContext {
 
        public bool version_header { get; set; }
 
+       public bool nostdpkg { get; set; }
+
        /**
         * Returns true if the target version of glib is greater than or 
         * equal to the specified version.