Beispiel #1
0
        public bool store(string filename, string source_filename, bool write_version, bool line_directives, string begin_decls = null, string end_decls = null)
        {
            var writer = new CCodeWriter(filename, source_filename);

            if (!writer.open(write_version))
            {
                return(false);
            }

            if (!is_header)
            {
                writer.line_directives = line_directives;

                comments.write(writer);
                writer.write_newline();
                include_directives.write(writer);
                writer.write_newline();
                type_declaration.write_combined(writer);
                writer.write_newline();
                type_definition.write_combined(writer);
                writer.write_newline();
                type_member_declaration.write_declaration(writer);
                writer.write_newline();
                type_member_declaration.write(writer);
                writer.write_newline();
                constant_declaration.write_combined(writer);
                writer.write_newline();
                type_member_definition.write(writer);
                writer.write_newline();
            }
            else
            {
                writer.write_newline();

                var once = new CCodeOnceSection(get_define_for_filename(writer.filename));
                once.append(new CCodeNewline());
                once.append(include_directives);
                once.append(new CCodeNewline());

                if (begin_decls != null)
                {
                    once.append(new CCodeIdentifier(begin_decls));
                    once.append(new CCodeNewline());
                }

                once.append(new CCodeNewline());
                once.append(type_declaration);
                once.append(new CCodeNewline());
                once.append(type_definition);
                once.append(new CCodeNewline());
                once.append(type_member_declaration);
                once.append(new CCodeNewline());
                once.append(constant_declaration);
                once.append(new CCodeNewline());

                if (begin_decls != null)
                {
                    once.append(new CCodeIdentifier(end_decls));
                    once.append(new CCodeNewline());
                }

                once.append(new CCodeNewline());
                once.write(writer);
            }

            writer.close();

            return(true);
        }