[vala/wip/attributes: 28/31] codewriter: Do not use C specific methods of code nodes
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 28/31] codewriter: Do not use C specific methods of code nodes
- Date: Wed, 27 Jul 2011 18:32:33 +0000 (UTC)
commit 5470e4b2e13892edc1c2c7907692935fd2d29c3b
Author: Luca Bruno <lucabru src gnome org>
Date: Wed Jul 6 09:55:52 2011 +0200
codewriter: Do not use C specific methods of code nodes
tests/gir/bug651773.test | 2 +-
vala/valacodewriter.vala | 628 +++++-----------------------------------------
2 files changed, 59 insertions(+), 571 deletions(-)
---
diff --git a/tests/gir/bug651773.test b/tests/gir/bug651773.test
index e4dbdf9..7f499de 100644
--- a/tests/gir/bug651773.test
+++ b/tests/gir/bug651773.test
@@ -20,5 +20,5 @@ Input:
Output:
-[CCode (cheader_filename = "test.h", array_length_pos = 0.1, array_length_type = "gsize")]
+[CCode (array_length_pos = 0.1, array_length_type = "gsize", cheader_filename = "test.h")]
public static unowned uint8[] get_array ();
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index a8a62c9..1baf545 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -138,24 +138,6 @@ public class Vala.CodeWriter : CodeVisitor {
return;
}
- write_indent ();
- write_string ("[CCode (cprefix = \"%s\", lower_case_cprefix = \"%s\"".printf (ns.get_cprefix (), ns.get_lower_case_cprefix ()));
-
- if (ns.source_reference != null && ns.parent_symbol == context.root) {
- // Set GIR information only for the main namespace of the file.
- if (ns.source_reference.file.gir_namespace != null) {
- write_string (", ");
- write_string ("gir_namespace = \"%s\"".printf (ns.source_reference.file.gir_namespace));
- }
- if (ns.source_reference.file.gir_version != null) {
- write_string(", ");
- write_string ("gir_version = \"%s\"".printf (ns.source_reference.file.gir_version));
- }
- }
-
- write_string (")]");
- write_newline ();
-
write_attributes (ns);
write_indent ();
@@ -182,56 +164,22 @@ public class Vala.CodeWriter : CodeVisitor {
write_newline ();
}
- private string get_cheaders (Symbol cl) {
- bool first = true;
+ private string get_cheaders (Symbol sym) {
string cheaders = "";
- if (type != CodeWriterType.FAST) {
- foreach (string cheader in cl.get_cheader_filenames ()) {
- if (header_to_override != null &&
- cheader == header_to_override) {
- cheader = override_header;
- }
- if (first) {
- cheaders = cheader;
- first = false;
- } else {
- cheaders = "%s,%s".printf (cheaders, cheader);
- }
+ if (type != CodeWriterType.FAST && !sym.external_package) {
+ cheaders = sym.get_attribute_string ("CCode", "cheader_filename") ?? "";
+ if (cheaders == "" && sym.parent_symbol != null && sym.parent_symbol != context.root) {
+ cheaders = get_cheaders (sym.parent_symbol);
}
- }
- return cheaders;
- }
-
- private void emit_deprecated_attribute (Symbol symbol) {
- if (symbol.deprecated) {
- write_indent ();
- write_string ("[Deprecated");
- var since = symbol.deprecated_since;
- var replacement = symbol.replacement;
-
- if (since != null || replacement != null) {
- write_string (" (");
- if (since != null) {
- write_string ("since = \"%s\"".printf (since));
- }
- if (since != null && replacement != null) {
- write_string (", ");
- }
- if (replacement != null) {
- write_string ("replacement = \"%s\"".printf (replacement));
- }
- write_string (")");
+ if (cheaders == "" && sym.source_reference != null && !sym.external_package) {
+ cheaders = sym.source_reference.file.get_cinclude_filename ();
}
- write_string ("]");
- }
- }
- private void emit_experimental_attribute (Symbol symbol) {
- if (symbol.experimental) {
- write_indent ();
- write_string ("[Experimental]");
- write_newline ();
+ if (header_to_override != null) {
+ cheaders = cheaders.replace (header_to_override, override_header).replace (",,", ",");
+ }
}
+ return cheaders;
}
public override void visit_class (Class cl) {
@@ -243,70 +191,6 @@ public class Vala.CodeWriter : CodeVisitor {
return;
}
- if (cl.is_compact) {
- write_indent ();
- write_string ("[Compact]");
- write_newline ();
- }
-
- if (cl.is_immutable) {
- write_indent ();
- write_string ("[Immutable]");
- write_newline ();
- }
-
- emit_deprecated_attribute (cl);
- emit_experimental_attribute (cl);
-
- write_indent ();
-
- write_string ("[CCode (");
-
- if (cl.is_reference_counting () && type != CodeWriterType.FAST) {
- if (cl.base_class == null || cl.base_class.get_ref_function () == null || cl.base_class.get_ref_function () != cl.get_ref_function ()) {
- write_string ("ref_function = \"%s\", ".printf (cl.get_ref_function ()));
- if (cl.ref_function_void) {
- write_string ("ref_function_void = true, ");
- }
- }
- if (cl.base_class == null || cl.base_class.get_unref_function () == null || cl.base_class.get_unref_function () != cl.get_unref_function ()) {
- write_string ("unref_function = \"%s\", ".printf (cl.get_unref_function ()));
- }
- } else {
- if (cl.get_dup_function () != null) {
- write_string ("copy_function = \"%s\", ".printf (cl.get_dup_function ()));
- }
- if (cl.get_free_function () != cl.get_default_free_function ()) {
- write_string ("free_function = \"%s\", ".printf (cl.get_free_function ()));
- }
- }
-
- if (cl.get_cname () != cl.get_default_cname ()) {
- write_string ("cname = \"%s\", ".printf (cl.get_cname ()));
- }
- if (cl.const_cname != null) {
- write_string ("const_cname = \"%s\", ".printf (cl.const_cname));
- }
-
- if (cl.get_lower_case_cprefix () != "%s_".printf (cl.get_lower_case_cname (null))) {
- write_string ("cprefix = \"%s\", ".printf (cl.get_lower_case_cprefix ()));
- }
-
- if (cl.type_check_function != null) {
- write_string ("type_check_function = \"%s\", ".printf (cl.type_check_function ));
- }
-
- if (cl.get_type_id () != cl.get_default_type_id ()) {
- write_string ("type_id = \"%s\", ".printf (cl.get_type_id ()));
- }
-
- if (cl.get_param_spec_function () != cl.get_default_param_spec_function ()) {
- write_string ("param_spec_function = \"%s\", ".printf (cl.get_param_spec_function ()));
- }
-
- write_string ("cheader_filename = \"%s\")]".printf (get_cheaders(cl)));
- write_newline ();
-
write_attributes (cl);
write_indent ();
@@ -413,58 +297,6 @@ public class Vala.CodeWriter : CodeVisitor {
return;
}
- if (st.is_immutable) {
- write_indent ();
- write_string ("[Immutable]");
- write_newline ();
- }
-
- emit_deprecated_attribute (st);
- emit_experimental_attribute (st);
-
- write_indent ();
-
- write_string ("[CCode (");
-
- if (st.get_cname () != st.get_default_cname ()) {
- write_string ("cname = \"%s\", ".printf (st.get_cname ()));
- }
-
- if (!st.has_type_id) {
- write_string ("has_type_id = false, ");
- } else if (!st.is_simple_type () && st.get_type_id () != "G_TYPE_POINTER") {
- write_string ("type_id = \"%s\", ".printf (st.get_type_id ()));
- }
-
- if (!st.has_copy_function) {
- write_string ("has_copy_function = false, ");
- }
-
- if (!st.has_destroy_function) {
- write_string ("has_destroy_function = false, ");
- }
-
- write_string ("cheader_filename = \"%s\")]".printf (get_cheaders(st)));
- write_newline ();
-
- if (st.is_simple_type ()) {
- write_indent ();
- write_string ("[SimpleType]");
- write_newline ();
- }
-
- if (st.is_integer_type ()) {
- write_indent ();
- write_string ("[IntegerType (rank = %d)]".printf (st.get_rank ()));
- write_newline ();
- }
-
- if (st.is_floating_type ()) {
- write_indent ();
- write_string ("[FloatingType (rank = %d)]".printf (st.get_rank ()));
- write_newline ();
- }
-
write_attributes (st);
write_indent ();
@@ -503,22 +335,6 @@ public class Vala.CodeWriter : CodeVisitor {
return;
}
- emit_deprecated_attribute (iface);
- emit_experimental_attribute (iface);
-
- write_indent ();
-
- write_string ("[CCode (cheader_filename = \"%s\"".printf (get_cheaders(iface)));
- if (iface.get_lower_case_csuffix () != iface.get_default_lower_case_csuffix ())
- write_string (", lower_case_csuffix = \"%s\"".printf (iface.get_lower_case_csuffix ()));
- if (iface.get_type_cname () != iface.get_default_type_cname ())
- write_string (", type_cname = \"%s\"".printf (iface.get_type_cname ()));
- if (iface.get_type_id () != iface.get_default_type_id ())
- write_string (", type_id = \"%s\"".printf (iface.get_type_id ()));
-
- write_string (")]");
- write_newline ();
-
write_attributes (iface);
write_indent ();
@@ -584,28 +400,6 @@ public class Vala.CodeWriter : CodeVisitor {
return;
}
- emit_deprecated_attribute (en);
- emit_experimental_attribute (en);
-
- write_indent ();
-
- write_string ("[CCode (cprefix = \"%s\", ".printf (en.get_cprefix ()));
-
- if (!en.has_type_id) {
- write_string ("has_type_id = false, ");
- }
-
- if (en.get_cname () != en.get_default_cname ()) {
- write_string ("cname = \"%s\", ".printf (en.get_cname ()));
- }
-
- write_string ("cheader_filename = \"%s\")]".printf (get_cheaders(en)));
-
- if (en.is_flags) {
- write_indent ();
- write_string ("[Flags]");
- }
-
write_attributes (en);
write_indent ();
@@ -623,10 +417,8 @@ public class Vala.CodeWriter : CodeVisitor {
write_newline ();
}
- if (ev.get_cname () != ev.get_default_cname ()) {
- write_indent ();
- write_string ("[CCode (cname = \"%s\")]".printf (ev.get_cname ()));
- }
+ write_attributes (ev);
+
write_indent ();
write_identifier (ev.name);
@@ -665,13 +457,6 @@ public class Vala.CodeWriter : CodeVisitor {
return;
}
- emit_deprecated_attribute (edomain);
- emit_experimental_attribute (edomain);
-
- write_indent ();
-
- write_string ("[CCode (cprefix = \"%s\", cheader_filename = \"%s\")]".printf (edomain.get_cprefix (), get_cheaders(edomain)));
-
write_attributes (edomain);
write_indent ();
@@ -689,10 +474,8 @@ public class Vala.CodeWriter : CodeVisitor {
write_newline ();
}
- if (ecode.get_cname () != ecode.get_default_cname ()) {
- write_indent ();
- write_string ("[CCode (cname = \"%s\")]".printf (ecode.get_cname ()));
- }
+ write_attributes (ecode);
+
write_indent ();
write_identifier (ecode.name);
}
@@ -723,29 +506,7 @@ public class Vala.CodeWriter : CodeVisitor {
return;
}
- emit_deprecated_attribute (c);
- emit_experimental_attribute (c);
-
- bool custom_cname = (c.get_cname () != c.get_default_cname ());
- bool custom_cheaders = (c.parent_symbol is Namespace);
- if (custom_cname || custom_cheaders) {
- write_indent ();
- write_string ("[CCode (");
-
- if (custom_cname) {
- write_string ("cname = \"%s\"".printf (c.get_cname ()));
- }
-
- if (custom_cheaders) {
- if (custom_cname) {
- write_string (", ");
- }
-
- write_string ("cheader_filename = \"%s\"".printf (get_cheaders(c)));
- }
-
- write_string (")]");
- }
+ write_attributes (c);
write_indent ();
write_accessibility (c);
@@ -772,78 +533,7 @@ public class Vala.CodeWriter : CodeVisitor {
return;
}
- emit_deprecated_attribute (f);
- emit_experimental_attribute (f);
-
- bool custom_cname = (f.get_cname () != f.get_default_cname ());
- bool custom_ctype = (f.get_ctype () != null);
- bool custom_cheaders = (f.parent_symbol is Namespace);
- bool custom_array_length_cname = (f.get_array_length_cname () != null);
- bool custom_array_length_type = (f.array_length_type != null);
- if (custom_cname || custom_ctype || custom_cheaders || custom_array_length_cname || custom_array_length_type || (f.no_array_length && f.variable_type is ArrayType)) {
- write_indent ();
- write_string ("[CCode (");
-
- if (custom_cname) {
- write_string ("cname = \"%s\"".printf (f.get_cname ()));
- }
-
- if (custom_ctype) {
- if (custom_cname) {
- write_string (", ");
- }
-
- write_string ("type = \"%s\"".printf (f.get_ctype ()));
- }
-
- if (custom_cheaders) {
- if (custom_cname || custom_ctype) {
- write_string (", ");
- }
-
- write_string ("cheader_filename = \"%s\"".printf (get_cheaders(f)));
- }
-
- if (f.variable_type is ArrayType) {
- if (f.no_array_length) {
- if (custom_cname || custom_ctype || custom_cheaders) {
- write_string (", ");
- }
-
- write_string ("array_length = false");
-
- if (f.array_null_terminated) {
- write_string (", array_null_terminated = true");
- }
- } else {
- if (custom_array_length_cname) {
- if (custom_cname || custom_ctype || custom_cheaders) {
- write_string (", ");
- }
-
- write_string ("array_length_cname = \"%s\"".printf (f.get_array_length_cname ()));
- }
-
- if (custom_array_length_type) {
- if (custom_cname || custom_ctype || custom_cheaders || custom_array_length_cname) {
- write_string (", ");
- }
-
- write_string ("array_length_type = \"%s\"".printf (f.array_length_type));
- }
- }
- } else if (f.variable_type is DelegateType) {
- if (f.no_delegate_target) {
- if (custom_cname || custom_ctype || custom_cheaders) {
- write_string (", ");
- }
-
- write_string ("delegate_target = false");
- }
- }
-
- write_string (")]");
- }
+ write_attributes (f);
write_indent ();
write_accessibility (f);
@@ -883,11 +573,6 @@ public class Vala.CodeWriter : CodeVisitor {
}
}
- // equality comparison with 3 digit precision
- private bool float_equal (double d1, double d2) {
- return ((int) (d1 * 1000)) == ((int) (d2 * 1000));
- }
-
private void write_params (List<Parameter> params) {
write_string ("(");
@@ -902,46 +587,7 @@ public class Vala.CodeWriter : CodeVisitor {
continue;
}
-
- var ccode_params = new StringBuilder ();
- var separator = "";
-
- if (!float_equal (param.cparameter_position, i)) {
- ccode_params.append_printf ("%spos = %g", separator, param.cparameter_position);
- separator = ", ";
- }
- if (param.ctype != null) {
- ccode_params.append_printf ("%stype = \"%s\"", separator, param.ctype);
- separator = ", ";
- }
- if (param.no_array_length && param.variable_type is ArrayType) {
- ccode_params.append_printf ("%sarray_length = false", separator);
- separator = ", ";
- }
- if (param.array_null_terminated && param.variable_type is ArrayType) {
- ccode_params.append_printf ("%sarray_null_terminated = true", separator);
- separator = ", ";
- }
- if (param.array_length_type != null && param.variable_type is ArrayType) {
- ccode_params.append_printf ("%sarray_length_type = \"%s\"", separator, param.array_length_type);
- separator = ", ";
- }
- if (param.get_array_length_cname () != null && param.variable_type is ArrayType) {
- ccode_params.append_printf ("%sarray_length_cname = \"%s\"", separator, param.get_array_length_cname ());
- separator = ", ";
- }
- if (!float_equal (param.carray_length_parameter_position, i + 0.1)) {
- ccode_params.append_printf ("%sarray_length_pos = %g", separator, param.carray_length_parameter_position);
- separator = ", ";
- }
- if (!float_equal (param.cdelegate_target_parameter_position, i + 0.1)) {
- ccode_params.append_printf ("%sdelegate_target_pos = %g", separator, param.cdelegate_target_parameter_position);
- separator = ", ";
- }
-
- if (ccode_params.len > 0) {
- write_string ("[CCode (%s)] ".printf (ccode_params.str));
- }
+ write_attributes (param);
if (param.params_array) {
write_string ("params ");
@@ -987,22 +633,7 @@ public class Vala.CodeWriter : CodeVisitor {
return;
}
- emit_deprecated_attribute (cb);
- emit_experimental_attribute (cb);
-
- write_indent ();
-
- write_string ("[CCode (cheader_filename = \"%s\"".printf (get_cheaders(cb)));
-
- if (!cb.has_target) {
- write_string (", has_target = false");
- } else if (!float_equal (cb.cinstance_parameter_position, -2)) {
- write_string (", instance_pos = %g".printf (cb.cinstance_parameter_position));
- } else if (cb.array_length_type != null) {
- write_string (", array_length_type = \"%s\"".printf (cb.array_length_type));
- }
-
- write_string (")]");
+ write_attributes (cb);
write_indent ();
@@ -1063,121 +694,7 @@ public class Vala.CodeWriter : CodeVisitor {
}
}
- if (m.get_attribute ("NoWrapper") != null) {
- write_indent ();
- write_string ("[NoWrapper]");
- }
- if (m.get_attribute ("NoThrow") != null) {
- write_indent ();
- write_string ("[NoThrow]");
- }
- if (m.returns_modified_pointer) {
- write_indent ();
- write_string ("[ReturnsModifiedPointer]");
- }
- if (m.get_attribute ("DestroysInstance") != null) {
- write_indent ();
- write_string ("[DestroysInstance]");
- }
- if (m.printf_format) {
- write_indent ();
- write_string ("[PrintfFormat]");
- }
- if (m.scanf_format) {
- write_indent ();
- write_string ("[ScanfFormat]");
- }
- if (m.get_attribute ("Print") != null) {
- write_indent ();
- write_string ("[Print]");
- }
- if (m.get_attribute ("NoReturn") != null) {
- write_indent ();
- write_string ("[NoReturn]");
- }
- if (m.get_attribute ("Diagnostics") != null) {
- write_indent ();
- write_string ("[Diagnostics]");
- }
-
- emit_deprecated_attribute (m);
- emit_experimental_attribute (m);
-
- var ccode_params = new StringBuilder ();
- var separator = "";
-
- if (m.get_cname () != m.get_default_cname ()) {
- ccode_params.append_printf ("%scname = \"%s\"", separator, m.get_cname ());
- separator = ", ";
- }
- if (m.parent_symbol is Namespace || get_cheaders (m) != get_cheaders (m.parent_symbol)) {
- ccode_params.append_printf ("%scheader_filename = \"%s\"", separator, get_cheaders(m));
- separator = ", ";
- }
- if (!float_equal (m.cinstance_parameter_position, 0)) {
- ccode_params.append_printf ("%sinstance_pos = %g", separator, m.cinstance_parameter_position);
- separator = ", ";
- }
- if (m.no_array_length && m.return_type is ArrayType) {
- ccode_params.append_printf ("%sarray_length = false", separator);
- separator = ", ";
- }
- if (!float_equal (m.carray_length_parameter_position, -3)) {
- ccode_params.append_printf ("%sarray_length_pos = %g", separator, m.carray_length_parameter_position);
- separator = ", ";
- }
- if (m.array_null_terminated && m.return_type is ArrayType) {
- ccode_params.append_printf ("%sarray_null_terminated = true", separator);
- separator = ", ";
- }
- if (m.array_length_type != null && m.return_type is ArrayType) {
- ccode_params.append_printf ("%sarray_length_type = \"%s\"", separator, m.array_length_type);
- separator = ", ";
- }
- if (!float_equal (m.cdelegate_target_parameter_position, -3)) {
- ccode_params.append_printf ("%sdelegate_target_pos = %g", separator, m.cdelegate_target_parameter_position);
- separator = ", ";
- }
- if (m.vfunc_name != m.name) {
- ccode_params.append_printf ("%svfunc_name = \"%s\"", separator, m.vfunc_name);
- separator = ", ";
- }
- if (m.coroutine && m.get_finish_cname () != m.get_default_finish_cname ()) {
- ccode_params.append_printf ("%sfinish_name = \"%s\"", separator, m.get_finish_cname ());
- separator = ", ";
- }
- if (m.sentinel != m.DEFAULT_SENTINEL) {
- ccode_params.append_printf ("%ssentinel = \"%s\"", separator, m.sentinel);
- separator = ", ";
- }
- if (m.custom_return_type_cname != null) {
- ccode_params.append_printf ("%stype = \"%s\"", separator, m.custom_return_type_cname);
- separator = ", ";
- }
- if (m.simple_generics) {
- ccode_params.append_printf ("%ssimple_generics = true", separator);
- separator = ", ";
- }
-
- var cm = m as CreationMethod;
- if (cm != null) {
- if (!m.has_new_function) {
- ccode_params.append_printf ("%shas_new_function = false", separator);
- separator = ", ";
- }
- if (!m.has_construct_function) {
- ccode_params.append_printf ("%shas_construct_function = false", separator);
- separator = ", ";
- } else if (m.name == ".new" && m.get_real_cname () != cm.get_default_construct_function ()) {
- ccode_params.append_printf ("%sconstruct_function = \"%s\"", separator, m.get_real_cname ());
- separator = ", ";
- }
- }
-
- if (ccode_params.len > 0) {
- write_indent ();
- write_string ("[CCode (%s)]".printf (ccode_params.str));
- }
+ write_attributes (m);
write_indent ();
write_accessibility (m);
@@ -1258,23 +775,7 @@ public class Vala.CodeWriter : CodeVisitor {
return;
}
- emit_deprecated_attribute (prop);
- emit_experimental_attribute (prop);
-
- if (prop.no_accessor_method) {
- write_indent ();
- write_string ("[NoAccessorMethod]");
- }
- if (prop.property_type is ArrayType && prop.no_array_length) {
- write_indent ();
- write_string ("[CCode (array_length = false");
-
- if (prop.array_null_terminated) {
- write_string (", array_null_terminated = true");
- }
-
- write_string (")]");
- }
+ write_attributes (prop);
write_indent ();
write_accessibility (prop);
@@ -1295,17 +796,7 @@ public class Vala.CodeWriter : CodeVisitor {
write_identifier (prop.name);
write_string (" {");
if (prop.get_accessor != null) {
- var ccode_params = new StringBuilder ();
- var separator = "";
-
- if (prop.get_accessor.get_cname () != prop.get_accessor.get_default_cname ()) {
- ccode_params.append_printf ("%scname = \"%s\"", separator, prop.get_accessor.get_cname ());
- separator = ", ";
- }
- if (ccode_params.len > 0) {
- write_indent ();
- write_string ("[CCode (%s)]".printf (ccode_params.str));
- }
+ write_attributes (prop.get_accessor);
write_property_accessor_accessibility (prop.get_accessor);
@@ -1317,17 +808,7 @@ public class Vala.CodeWriter : CodeVisitor {
write_code_block (prop.get_accessor.body);
}
if (prop.set_accessor != null) {
- var ccode_params = new StringBuilder ();
- var separator = "";
-
- if (prop.set_accessor.get_cname () != prop.set_accessor.get_default_cname ()) {
- ccode_params.append_printf ("%scname = \"%s\"", separator, prop.set_accessor.get_cname ());
- separator = ", ";
- }
- if (ccode_params.len > 0) {
- write_indent ();
- write_string ("[CCode (%s)]".printf (ccode_params.str));
- }
+ write_attributes (prop.set_accessor);
write_property_accessor_accessibility (prop.set_accessor);
@@ -1352,13 +833,7 @@ public class Vala.CodeWriter : CodeVisitor {
return;
}
- if (sig.has_emitter) {
- write_indent ();
- write_string ("[HasEmitter]");
- }
-
- emit_deprecated_attribute (sig);
- emit_experimental_attribute (sig);
+ write_attributes (sig);
write_indent ();
write_accessibility (sig);
@@ -2064,37 +1539,50 @@ public class Vala.CodeWriter : CodeVisitor {
}
private void write_attributes (CodeNode node) {
+ bool written_cheaders = false;
+ var sym = node as Symbol;
foreach (Attribute attr in node.attributes) {
- if (!filter_attribute (attr)) {
+ if (!(node is Parameter)) {
write_indent ();
- stream.printf ("[%s", attr.name);
+ }
+ stream.printf ("[%s", attr.name);
- var keys = attr.args.get_keys ();
- if (keys.size != 0) {
- stream.printf (" (");
+ var keys = attr.args.get_keys ();
+ if (keys.size != 0) {
+ stream.printf (" (");
- string separator = "";
- foreach (string arg_name in keys) {
- stream.printf ("%s%s = %s", separator, arg_name, attr.args.get (arg_name));
- separator = ", ";
+ string separator = "";
+ foreach (string arg_name in keys) {
+ if (arg_name == "cheader_filename") {
+ written_cheaders = true;
}
-
- stream.printf (")");
+ stream.printf ("%s%s = %s", separator, arg_name, attr.args.get (arg_name));
+ separator = ", ";
}
- stream.printf ("]");
+ if (type != CodeWriterType.FAST && attr.name == "CCode" && sym != null && !(sym is Namespace) && sym.parent_symbol is Namespace && !written_cheaders) {
+ stream.printf ("%scheader_filename = \"%s\"", separator, get_cheaders (sym));
+ }
+
+ stream.printf (")");
+ }
+ stream.printf ("]");
+ if (node is Parameter) {
+ write_string (" ");
+ } else {
write_newline ();
}
}
- }
-
- private bool filter_attribute (Attribute attr) {
- if (attr.name == "CCode"
- || attr.name == "Compact" || attr.name == "Immutable"
- || attr.name == "SimpleType" || attr.name == "IntegerType" || attr.name == "FloatingType"
- || attr.name == "Flags") {
- return true;
+ if (type != CodeWriterType.FAST && sym != null && !(sym is Namespace) && sym.parent_symbol is Namespace && !written_cheaders) {
+ if (!(sym is Parameter)) {
+ write_indent ();
+ }
+ stream.printf ("[CCode (cheader_filename = \"%s\")]", get_cheaders (sym));
+ if (sym is Parameter) {
+ write_string (" ");
+ } else {
+ write_newline ();
+ }
}
- return false;
}
private void write_accessibility (Symbol sym) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]