Exemplo n.º 1
0
        public override void write(CCodeWriter writer)
        {
            call.write_inner(writer);
            writer.write_string(" (");

            bool first = true;

            foreach (CCodeExpression expr in arguments)
            {
                if (!first)
                {
                    writer.write_string(", ");
                }
                else
                {
                    first = false;
                }

                if (expr != null)
                {
                    expr.write(writer);
                }
            }

            writer.write_string(")");
        }
Exemplo n.º 2
0
        public override void write(CCodeWriter writer)
        {
            writer.write_string("{");

            bool first = true;

            foreach (CCodeExpression expr in initializers)
            {
                if (!first)
                {
                    writer.write_string(", ");
                }
                else
                {
                    first = false;
                }

                if (expr != null)
                {
                    expr.write(writer);
                }
            }

            writer.write_string("}");
        }
Exemplo n.º 3
0
 public override void write(CCodeWriter writer)
 {
     container.write_inner(writer);
     writer.write_string("[");
     index.write(writer);
     writer.write_string("]");
 }
Exemplo n.º 4
0
 public override void write(CCodeWriter writer)
 {
     writer.write_indent();
     writer.write_string(name);
     writer.write_string(":");
     writer.write_newline();
 }
Exemplo n.º 5
0
 public void write(CCodeWriter writer)
 {
     if (array)
     {
         writer.write_string("[");
         if (array_length != null)
         {
             array_length.write(writer);
         }
         writer.write_string("]");
     }
 }
Exemplo n.º 6
0
		public override void write(CCodeWriter writer) {
			writer.write_string(name);
			if (modifiers.HasFlag(CCodeModifiers.DEPRECATED)) {
				// FIXME Requires GCC 6.0 to work at this place
				// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47043
				//writer.write_string (" G_GNUC_DEPRECATED");
			}
			if (value != null) {
				writer.write_string(" = ");
				value.write(writer);
			}
		}
Exemplo n.º 7
0
 public override void write(CCodeWriter writer)
 {
     inner.write_inner(writer);
     if (is_pointer)
     {
         writer.write_string("->");
     }
     else
     {
         writer.write_string(".");
     }
     writer.write_string(member_name);
 }
Exemplo n.º 8
0
 public override void write(CCodeWriter writer)
 {
     writer.write_string("G_GNUC_BEGIN_");
     writer.write_string(section_type.ToString());
     writer.write_newline();
     foreach (CCodeNode node in get_children())
     {
         node.write_combined(writer);
     }
     writer.write_string("G_GNUC_END_");
     writer.write_string(section_type.ToString());
     writer.write_newline();
 }
Exemplo n.º 9
0
 public override void write(CCodeWriter writer)
 {
     if (!ellipsis)
     {
         writer.write_string(type_name);
         writer.write_string(" ");
         writer.write_string(name);
     }
     else
     {
         writer.write_string("...");
     }
 }
Exemplo n.º 10
0
        public override void write_initialization(CCodeWriter writer)
        {
            if (initializer != null && !init0)
            {
                writer.write_indent(line);

                writer.write_string(name);
                writer.write_string(" = ");
                initializer.write(writer);

                writer.write_string(";");
                writer.write_newline();
            }
        }
Exemplo n.º 11
0
        public override void write_declaration(CCodeWriter writer)
        {
            writer.write_string("(*");
            writer.write_string(name);
            writer.write_string(") (");

            bool has_args         = (modifiers.HasFlag(CCodeModifiers.PRINTF) || modifiers.HasFlag(CCodeModifiers.SCANF));
            int  i                = 0;
            int  format_arg_index = -1;
            int  args_index       = -1;

            foreach (CCodeParameter param in parameters)
            {
                if (i > 0)
                {
                    writer.write_string(", ");
                }
                param.write(writer);
                if (param.modifiers.HasFlag(CCodeModifiers.FORMAT_ARG))
                {
                    format_arg_index = i;
                }
                if (has_args && param.ellipsis)
                {
                    args_index = i;
                }
                else if (has_args && param.type_name == "va_list" && format_arg_index < 0)
                {
                    format_arg_index = i - 1;
                }
                i++;
            }

            writer.write_string(")");

            if (modifiers.HasFlag(CCodeModifiers.DEPRECATED))
            {
                writer.write_string(" G_GNUC_DEPRECATED");
            }

            if (modifiers.HasFlag(CCodeModifiers.PRINTF))
            {
                format_arg_index = (format_arg_index >= 0 ? format_arg_index + 1 : args_index);
                writer.write_string(" G_GNUC_PRINTF(%d,%d)".printf(format_arg_index, args_index + 1));
            }
            else if (modifiers.HasFlag(CCodeModifiers.SCANF))
            {
                format_arg_index = (format_arg_index >= 0 ? format_arg_index + 1 : args_index);
                writer.write_string(" G_GNUC_SCANF(%d,%d)".printf(format_arg_index, args_index + 1));
            }
            else if (format_arg_index >= 0)
            {
                writer.write_string(" G_GNUC_FORMAT(%d)".printf(format_arg_index + 1));
            }
        }
Exemplo n.º 12
0
        public override void write_declaration(CCodeWriter writer)
        {
            writer.write_string(name);

            if (declarator_suffix != null)
            {
                declarator_suffix.write(writer);
            }

            if (initializer != null && init0)
            {
                writer.write_string(" = ");
                initializer.write(writer);
            }
        }
Exemplo n.º 13
0
 public override void write(CCodeWriter writer)
 {
     writer.write_indent();
     writer.write_string("#define ");
     writer.write_string(name);
     writer.write_string(" ");
     if (replacement != null)
     {
         writer.write_string(replacement);
     }
     else
     {
         replacement_expression.write_inner(writer);
     }
     writer.write_newline();
 }
Exemplo n.º 14
0
 public override void write(CCodeWriter writer)
 {
     writer.write_indent();
     writer.write_string("#ifndef ");
     writer.write_string(define);
     writer.write_newline();
     writer.write_string("#define ");
     writer.write_string(define);
     writer.write_newline();
     foreach (CCodeNode node in get_children())
     {
         node.write_combined(writer);
     }
     writer.write_indent();
     writer.write_string("#endif");
     writer.write_newline();
 }
Exemplo n.º 15
0
 public override void write(CCodeWriter writer)
 {
     if (!writer.bol)
     {
         writer.write_newline();
     }
     writer.write_string("#line %d \"%s\"".printf(line_number, filename));
     writer.write_newline();
 }
Exemplo n.º 16
0
        public override void write_declaration(CCodeWriter writer)
        {
            writer.write_indent();
            writer.write_string("typedef ");

            writer.write_string(type_name);

            writer.write_string(" ");

            declarator.write_declaration(writer);

            if (modifiers.HasFlag(CCodeModifiers.DEPRECATED))
            {
                writer.write_string(" G_GNUC_DEPRECATED");
            }

            writer.write_string(";");
            writer.write_newline();
        }
Exemplo n.º 17
0
        public override void write(CCodeWriter writer)
        {
            writer.write_string("struct ");
            writer.write_string(name);
            writer.write_begin_block();
            foreach (CCodeDeclaration decl in declarations)
            {
                decl.write_declaration(writer);
            }

            writer.write_end_block();
            if (modifiers.HasFlag(CCodeModifiers.DEPRECATED))
            {
                writer.write_string(" G_GNUC_DEPRECATED");
            }
            writer.write_string(";");
            writer.write_newline();
            writer.write_newline();
        }
Exemplo n.º 18
0
 public override void write(CCodeWriter writer)
 {
     writer.write_indent();
     writer.write_string("#include ");
     if (local)
     {
         writer.write_string("\"");
         writer.write_string(filename);
         writer.write_string("\"");
     }
     else
     {
         writer.write_string("<");
         writer.write_string(filename);
         writer.write_string(">");
     }
     writer.write_newline();
 }
Exemplo n.º 19
0
        public override void write(CCodeWriter writer)
        {
            left.write(writer);

            writer.write_string(" ");

            if (Operator == CCodeAssignmentOperator.BITWISE_OR)
            {
                writer.write_string("|");
            }
            else if (Operator == CCodeAssignmentOperator.BITWISE_AND)
            {
                writer.write_string("&");
            }
            else if (Operator == CCodeAssignmentOperator.BITWISE_XOR)
            {
                writer.write_string("^");
            }
            else if (Operator == CCodeAssignmentOperator.ADD)
            {
                writer.write_string("+");
            }
            else if (Operator == CCodeAssignmentOperator.SUB)
            {
                writer.write_string("-");
            }
            else if (Operator == CCodeAssignmentOperator.MUL)
            {
                writer.write_string("*");
            }
            else if (Operator == CCodeAssignmentOperator.DIV)
            {
                writer.write_string("/");
            }
            else if (Operator == CCodeAssignmentOperator.PERCENT)
            {
                writer.write_string("%");
            }
            else if (Operator == CCodeAssignmentOperator.SHIFT_LEFT)
            {
                writer.write_string("<<");
            }
            else if (Operator == CCodeAssignmentOperator.SHIFT_RIGHT)
            {
                writer.write_string(">>");
            }

            writer.write_string("= ");

            right.write(writer);
        }
Exemplo n.º 20
0
        public override void write(CCodeWriter writer)
        {
            writer.write_indent(line);
            if (modifiers.HasFlag(CCodeModifiers.INTERNAL))
            {
                writer.write_string("G_GNUC_INTERNAL ");
            }
            if (modifiers.HasFlag(CCodeModifiers.STATIC))
            {
                writer.write_string("static ");
            }
            if (modifiers.HasFlag(CCodeModifiers.INLINE))
            {
                writer.write_string("inline ");
            }
            writer.write_string(return_type);
            writer.write_string(" ");
            writer.write_string(name);
            writer.write_string(" (");

            bool has_args         = (modifiers.HasFlag(CCodeModifiers.PRINTF) || modifiers.HasFlag(CCodeModifiers.SCANF));
            int  i                = 0;
            int  format_arg_index = -1;
            int  args_index       = -1;

            foreach (CCodeParameter param in parameters)
            {
                if (i > 0)
                {
                    writer.write_string(", ");
                }
                param.write(writer);
                if (param.modifiers.HasFlag(CCodeModifiers.FORMAT_ARG))
                {
                    format_arg_index = i;
                }
                if (has_args && param.ellipsis)
                {
                    args_index = i;
                }
                else if (has_args && param.type_name == "va_list" && format_arg_index < 0)
                {
                    format_arg_index = i - 1;
                }
                i++;
            }
            if (i == 0)
            {
                writer.write_string("void");
            }

            writer.write_string(")");

            if (is_declaration)
            {
                if (modifiers.HasFlag(CCodeModifiers.DEPRECATED))
                {
                    writer.write_string(" G_GNUC_DEPRECATED");
                }

                if (modifiers.HasFlag(CCodeModifiers.PRINTF))
                {
                    format_arg_index = (format_arg_index >= 0 ? format_arg_index + 1 : args_index);
                    writer.write_string(" G_GNUC_PRINTF(%d,%d)".printf(format_arg_index, args_index + 1));
                }
                else if (modifiers.HasFlag(CCodeModifiers.SCANF))
                {
                    format_arg_index = (format_arg_index >= 0 ? format_arg_index + 1 : args_index);
                    writer.write_string(" G_GNUC_SCANF(%d,%d)".printf(format_arg_index, args_index + 1));
                }
                else if (format_arg_index >= 0)
                {
                    writer.write_string(" G_GNUC_FORMAT(%d)".printf(format_arg_index + 1));
                }

                if (modifiers.HasFlag(CCodeModifiers.CONST))
                {
                    writer.write_string(" G_GNUC_CONST");
                }
                if (modifiers.HasFlag(CCodeModifiers.UNUSED))
                {
                    writer.write_string(" G_GNUC_UNUSED");
                }

                if (modifiers.HasFlag(CCodeModifiers.CONSTRUCTOR))
                {
                    writer.write_string(" __attribute__((constructor))");
                }
                else if (modifiers.HasFlag(CCodeModifiers.DESTRUCTOR))
                {
                    writer.write_string(" __attribute__((destructor))");
                }

                writer.write_string(";");
            }
            else
            {
                block.write(writer);
                writer.write_newline();
            }
            writer.write_newline();
        }
Exemplo n.º 21
0
 public override void write(CCodeWriter writer)
 {
     writer.write_string(name);
 }
Exemplo n.º 22
0
        public override void write_declaration(CCodeWriter writer)
        {
            if ((modifiers & (CCodeModifiers.STATIC | CCodeModifiers.INTERNAL | CCodeModifiers.EXTERN)) != 0)
            {
                // combined declaration and initialization for static and extern variables
                writer.write_indent(line);
                if ((modifiers & CCodeModifiers.INTERNAL) != 0)
                {
                    writer.write_string("G_GNUC_INTERNAL ");
                }
                if ((modifiers & CCodeModifiers.STATIC) != 0)
                {
                    writer.write_string("static ");
                }
                if ((modifiers & CCodeModifiers.VOLATILE) != 0)
                {
                    writer.write_string("volatile ");
                }
                if ((modifiers & CCodeModifiers.EXTERN) != 0 && !has_initializer())
                {
                    writer.write_string("extern ");
                }
                if ((modifiers & CCodeModifiers.THREAD_LOCAL) != 0)
                {
                    writer.write_string("thread_local ");
                }
                writer.write_string(type_name);
                writer.write_string(" ");

                bool _first = true;
                foreach (CCodeDeclarator decl in declarators)
                {
                    if (!_first)
                    {
                        writer.write_string(", ");
                    }
                    else
                    {
                        _first = false;
                    }
                    decl.write(writer);
                }

                writer.write_string(";");
                writer.write_newline();
                return;
            }

            writer.write_indent();
            if ((modifiers & CCodeModifiers.REGISTER) == CCodeModifiers.REGISTER)
            {
                writer.write_string("register ");
            }
            if ((modifiers & CCodeModifiers.VOLATILE) != 0)
            {
                writer.write_string("volatile ");
            }
            writer.write_string(type_name);
            writer.write_string(" ");

            bool first = true;

            foreach (CCodeDeclarator decl in declarators)
            {
                if (!first)
                {
                    writer.write_string(", ");
                }
                else
                {
                    first = false;
                }
                decl.write_declaration(writer);
            }

            if (modifiers.HasFlag(CCodeModifiers.DEPRECATED))
            {
                writer.write_string(" G_GNUC_DEPRECATED");
            }

            writer.write_string(";");
            writer.write_newline();
        }
Exemplo n.º 23
0
 public override void write_inner(CCodeWriter writer)
 {
     writer.write_string("(");
     this.write(writer);
     writer.write_string(")");
 }