Index: vala/valamember.vala =================================================================== --- vala/valamember.vala (revision 524) +++ vala/valamember.vala (working copy) @@ -27,35 +27,7 @@ * Represents a general class member. */ public class Vala.Member : Symbol { - private Gee.List cheader_filenames = new ArrayList (); - public override void accept (CodeVisitor! visitor) { visitor.visit_member (this); } - - public override Collection get_cheader_filenames () { - if (cheader_filenames.size == 0) { - /* default to header filenames of the namespace */ - foreach (string filename in parent_symbol.get_cheader_filenames ()) { - add_cheader_filename (filename); - } - - if (cheader_filenames.size == 0 && source_reference != null && !source_reference.file.pkg) { - // don't add default include directives for VAPI files - cheader_filenames.add (source_reference.file.get_cinclude_filename ()); - } - } - return new ReadOnlyCollection (cheader_filenames); - } - - - /** - * Adds a filename to the list of C header filenames users of this data - * type must include. - * - * @param filename a C header filename - */ - public void add_cheader_filename (string! filename) { - cheader_filenames.add (filename); - } } Index: vala/valafield.vala =================================================================== --- vala/valafield.vala (revision 524) +++ vala/valafield.vala (working copy) @@ -102,8 +102,13 @@ } return cname; } - - private void set_cname (string! cname) { + + /** + * Sets the name of this field as it is used in C code. + * + * @param cname the name to be used in C code + */ + public void set_cname (string! cname) { this.cname = cname; } Index: vala/valanamespace.vala =================================================================== --- vala/valanamespace.vala (revision 524) +++ vala/valanamespace.vala (working copy) @@ -44,8 +44,6 @@ private string cprefix; private string lower_case_cprefix; - private Gee.List cheader_filenames = new ArrayList (); - private Gee.List namespaces = new ArrayList (); /** @@ -288,10 +286,6 @@ this.lower_case_cprefix = cprefix; } - public override Collection get_cheader_filenames () { - return new ReadOnlyCollection (cheader_filenames); - } - /** * Returns the C header filename of this namespace. * @@ -318,8 +312,8 @@ * @param cheader_filename header filename */ public void set_cheader_filename (string! cheader_filename) { - cheader_filenames = new ArrayList (); - cheader_filenames.add (cheader_filename); + clear_cheader_filenames (); + add_cheader_filename (cheader_filename); } private void process_ccode_attribute (Attribute! a) { @@ -332,7 +326,7 @@ if (a.has_argument ("cheader_filename")) { var val = a.get_string ("cheader_filename"); foreach (string filename in val.split (",")) { - cheader_filenames.add (filename); + add_cheader_filename (filename); } } } Index: vala/valadatatype.vala =================================================================== --- vala/valadatatype.vala (revision 524) +++ vala/valadatatype.vala (working copy) @@ -37,8 +37,6 @@ */ public MemberAccessibility access; - private Gee.List cheader_filenames = new ArrayList (); - private Pointer pointer_type; /* holds the array types of this type; each rank is a separate one */ @@ -179,32 +177,7 @@ return null; } - public override Collection get_cheader_filenames () { - if (cheader_filenames.size == 0) { - /* default to header filenames of the namespace */ - foreach (string filename in parent_symbol.get_cheader_filenames ()) { - add_cheader_filename (filename); - } - - if (cheader_filenames.size == 0 && source_reference != null && !source_reference.file.pkg) { - // don't add default include directives for VAPI files - cheader_filenames.add (source_reference.file.get_cinclude_filename ()); - } - } - return new ReadOnlyCollection (cheader_filenames); - } - /** - * Adds a filename to the list of C header filenames users of this data - * type must include. - * - * @param filename a C header filename - */ - public void add_cheader_filename (string! filename) { - cheader_filenames.add (filename); - } - - /** * Returns the pointer type of this data type. * * @return pointer-type for this data type Index: vala/valainterfacewriter.vala =================================================================== --- vala/valainterfacewriter.vala (revision 532) +++ vala/valainterfacewriter.vala (working copy) @@ -59,6 +59,40 @@ stream = null; } + [NoArrayLength] // XXX working arround invokation bug with attrs = null + private void write_ccode_attribute (Symbol! s, string[] attrs) { + String ccode_params = new String (); + + if (s.has_custom_cheaders ()) { + ccode_params.append ("cheader_filename = \""); + var prefix_length = ccode_params.len; + + foreach (string cheader in s.get_cheader_filenames ()) { + if (ccode_params.len > prefix_length) + ccode_params.append_c (','); + + ccode_params.append (cheader); + } + + ccode_params.append_c ('\"'); + } + + if (null != attrs) { + for (int i = 0; null != attrs[i]; i += 2) { + if (ccode_params.len > 0) + ccode_params.append (", "); + + ccode_params.append_printf ("%s = \"%s\"", attrs[i], attrs[i + 1]); + } + } + + if (ccode_params.len > 0) { + write_indent (); + write_string ("[CCode (%s)]".printf (ccode_params.str)); + write_newline (); + } + } + public override void visit_namespace (Namespace! ns) { if (ns.pkg) { return; @@ -69,10 +103,14 @@ return; } - write_indent (); - write_string ("[CCode (cprefix = \"%s\", lower_case_cprefix = \"%s\")]".printf (ns.get_cprefix (), ns.get_lower_case_cprefix ())); - write_newline (); + var ccode_params = new string[] { + "lower_case_cprefix", ns.get_lower_case_cprefix (), + "cprefix", ns.get_cprefix (), + null + }; + write_ccode_attribute (ns, ccode_params); + write_indent (); write_string ("namespace "); write_identifier (ns.name); @@ -93,21 +131,8 @@ return; } - write_indent (); + write_ccode_attribute (cl, null); - var first = true; - string cheaders; - foreach (string cheader in cl.get_cheader_filenames ()) { - if (first) { - cheaders = cheader; - first = false; - } else { - cheaders = "%s,%s".printf (cheaders, cheader); - } - } - write_string ("[CCode (cheader_filename = \"%s\")]".printf (cheaders)); - write_newline (); - write_indent (); write_string ("public "); if (cl.is_abstract) { @@ -184,21 +209,8 @@ write_string ("]"); } - write_indent (); + write_ccode_attribute (st, null); - var first = true; - string cheaders; - foreach (string cheader in st.get_cheader_filenames ()) { - if (first) { - cheaders = cheader; - first = false; - } else { - cheaders = "%s,%s".printf (cheaders, cheader); - } - } - write_string ("[CCode (cheader_filename = \"%s\")]".printf (cheaders)); - write_newline (); - write_indent (); write_string ("public struct "); write_identifier (st.name); @@ -219,21 +231,8 @@ return; } - write_indent (); + write_ccode_attribute (iface, null); - var first = true; - string cheaders; - foreach (string cheader in iface.get_cheader_filenames ()) { - if (first) { - cheaders = cheader; - first = false; - } else { - cheaders = "%s,%s".printf (cheaders, cheader); - } - } - write_string ("[CCode (cheader_filename = \"%s\")]".printf (cheaders)); - write_newline (); - write_indent (); write_string ("public "); write_string ("interface "); @@ -285,20 +284,9 @@ return; } - write_indent (); + var ccode_params = new string[] { "cprefix", en.get_cprefix (), null }; + write_ccode_attribute (en, ccode_params); - var first = true; - string cheaders; - foreach (string cheader in en.get_cheader_filenames ()) { - if (first) { - cheaders = cheader; - first = false; - } else { - cheaders = "%s,%s".printf (cheaders, cheader); - } - } - write_string ("[CCode (cprefix = \"%s\", cheader_filename = \"%s\")]".printf (en.get_cprefix (), cheaders)); - write_indent (); write_string ("public enum "); write_identifier (en.name); @@ -322,6 +310,8 @@ return; } + write_ccode_attribute (c, null); + write_indent (); write_string ("public const "); @@ -428,7 +418,9 @@ if (cb.access == MemberAccessibility.PRIVATE) { return; } - + + write_ccode_attribute (cb, null); + write_indent (); write_string ("public static delegate "); @@ -487,23 +479,21 @@ write_string ("[InstanceByReference]"); } - var ccode_params = new String (); - var separator = ""; + var ccode_params = new string[5]; + ccode_params.length = 0; if (m.get_cname () != m.get_default_cname ()) { - ccode_params.append_printf ("%scname = \"%s\"", separator, m.get_cname ()); - separator = ", "; + string cname = m.get_cname (); // XXX work arround ownership bug + ccode_params[ccode_params.length++] = "cname"; + ccode_params[ccode_params.length++] = cname; } if (m.sentinel != m.DEFAULT_SENTINEL) { - ccode_params.append_printf ("%ssentinel = \"%s\"", separator, m.sentinel); - separator = ", "; + ccode_params[ccode_params.length++] = "sentinel"; + ccode_params[ccode_params.length++] = m.sentinel; } - if (ccode_params.len > 0) { - write_indent (); - write_string ("[CCode (%s)]".printf (ccode_params.str)); - } - + write_ccode_attribute (m, ccode_params); + write_indent (); write_string ("public"); Index: vala/valasymbol.vala =================================================================== --- vala/valasymbol.vala (revision 524) +++ vala/valasymbol.vala (working copy) @@ -145,6 +145,9 @@ return ""; } + private Gee.List cheader_filenames = new ArrayList (); + private bool custom_cheaders = false; + /** * Returns a list of C header filenames users of this symbol must * include. @@ -152,10 +155,49 @@ * @return list of C header filenames for this symbol */ public virtual Collection get_cheader_filenames () { - return new ReadOnlyCollection (); + if (cheader_filenames.size == 0) { + /* default to header filenames of the namespace */ + if (null != parent_symbol) { + foreach (string filename in parent_symbol.get_cheader_filenames ()) { + add_cheader_filename (filename); + } + } + + if (cheader_filenames.size == 0 && source_reference != null && !source_reference.file.pkg) { + // don't add default include directives for VAPI files + add_cheader_filename (source_reference.file.get_cinclude_filename ()); + } else { + custom_cheaders = false; + } + } + return new ReadOnlyCollection (cheader_filenames); } + protected void clear_cheader_filenames () { + cheader_filenames.clear (); + } + /** + * Adds a filename to the list of C header filenames users of this data + * type must include. + * + * @param filename a C header filename + */ + public void add_cheader_filename (string! filename) { + cheader_filenames.add (filename); + custom_cheaders = true; + } + + /** + * Checks whether custom C header filename have been added to this data type. + * + * @return true if custom C header filename have been added + */ + public bool has_custom_cheaders() { + return custom_cheaders; + } + + /** * Converts a string from CamelCase to lower_case. * * @param camel_case a string in camel case Index: ChangeLog =================================================================== --- ChangeLog (revision 532) +++ ChangeLog (working copy) @@ -375,6 +375,22 @@ 2007-08-17 Mathias Hasselmann + * vala/valadatatype.vala, vala/valamember.vala, + vala/valanamespace.vala: remove cheader_filename handling + which is in Vala.Symbol now + * vala/valasymbol.vala: unify handling of cheader_filenames list + * vala/valafield.vala: make set_cname public + * vala/valainterfacewriter.vala: unify writing of CCode attribute to + generate cheader_filename parameters when needed and generate that + symbol for delegates + * vapigen/valagidlparser.vala: consider CCode.cheader_filename for + callbacks, methods and structs. consider CCode.cname for fields. + * vapi/packages/libglade-2.0/libglade-2.0.metadata, + vapi/libglade-2.0.vala: correct C header declarations and rename + AccelInfo.signal to signal_name (with a cname attribute this time) + +2007-08-17 Mathias Hasselmann + * vapi/libglade-2.0.vala: revert last change: the field really is called "signal" name as figured out by gidlgen - for almost five years now Index: vapigen/valagidlparser.vala =================================================================== --- vapigen/valagidlparser.vala (revision 524) +++ vapigen/valagidlparser.vala (working copy) @@ -226,11 +226,16 @@ private Callback parse_callback (IdlNodeFunction! f_node) { weak IdlNode node = (IdlNode) f_node; + var cb = new Callback (node.name, parse_param (f_node.result), current_source_reference); + cb.access = MemberAccessibility.PUBLIC; + var attributes = get_attributes (node.name); if (attributes != null) { foreach (string attr in attributes) { var nv = attr.split ("=", 2); - if (nv[0] == "hidden") { + if (nv[0] == "cheader_filename") { + cb.add_cheader_filename (eval (nv[1])); + } else if (nv[0] == "hidden") { if (eval (nv[1]) == "1") { return null; } @@ -238,9 +243,6 @@ } } - var cb = new Callback (node.name, parse_param (f_node.result), current_source_reference); - cb.access = MemberAccessibility.PUBLIC; - foreach (weak IdlNodeParam param in f_node.parameters) { weak IdlNode param_node = (IdlNode) param; @@ -858,6 +860,8 @@ if (nv[0] == "name") { m.set_cname (m.name); m.name = eval (nv[1]); + } else if (nv[0] == "cheader_filename") { + m.add_cheader_filename (eval (nv[1])); } else if (nv[0] == "hidden") { if (eval (nv[1]) == "1") { return null; @@ -1040,6 +1044,9 @@ return null; } + var field = new Field (node.name, type, null, current_source_reference); + field.access = MemberAccessibility.PUBLIC; + var attributes = get_attributes ("%s.%s".printf (current_data_type.get_cname (), node.name)); if (attributes != null) { foreach (string attr in attributes) { @@ -1056,17 +1063,17 @@ if (eval (nv[1]) == "0") { type.takes_ownership = true; } + } else if (nv[0] == "name") { + field.set_cname (field.name); + field.name = eval (nv[1]); } } } - + if (current_type_symbol_set != null) { current_type_symbol_set.add (node.name); } - var field = new Field (node.name, type, null, current_source_reference); - field.access = MemberAccessibility.PUBLIC; - return field; } Index: vapi/packages/libglade-2.0/libglade-2.0.metadata =================================================================== --- vapi/packages/libglade-2.0/libglade-2.0.metadata (revision 524) +++ vapi/packages/libglade-2.0/libglade-2.0.metadata (working copy) @@ -1,2 +1,34 @@ Glade cheader_filename="glade/glade.h" +GladeAccelInfo.signal name="signal_name" +GladeNewFunc cheader_filename="glade/glade-build.h" +GladeBuildChildrenFunc cheader_filename="glade/glade-build.h" +GladeFindInternalChildFunc cheader_filename="glade/glade-build.h" +GladeApplyCustomPropFunc cheader_filename="glade/glade-build.h" + +GladeProperty cheader_filename="glade/glade-build.h" +GladeSignalInfo cheader_filename="glade/glade-build.h" +GladeAtkActionInfo cheader_filename="glade/glade-build.h" +GladeAtkRelationInfo cheader_filename="glade/glade-build.h" +GladeAccelInfo cheader_filename="glade/glade-build.h" +GladeWidgetInfo cheader_filename="glade/glade-build.h" +GladeChildInfo cheader_filename="glade/glade-build.h" +GladeInterface cheader_filename="glade/glade-build.h" + +glade_register_widget cheader_filename="glade/glade-build.h" +glade_register_custom_prop cheader_filename="glade/glade-build.h" +glade_xml_set_toplevel cheader_filename="glade/glade-build.h" +glade_xml_ensure_accel cheader_filename="glade/glade-build.h" +glade_xml_handle_widget_prop cheader_filename="glade/glade-build.h" +glade_xml_set_packing_property cheader_filename="glade/glade-build.h" +glade_xml_build_widget cheader_filename="glade/glade-build.h" +glade_xml_handle_internal_child cheader_filename="glade/glade-build.h" +glade_xml_set_common_params cheader_filename="glade/glade-build.h" +glade_xml_set_value_from_string cheader_filename="glade/glade-build.h" +glade_standard_build_widget cheader_filename="glade/glade-build.h" +glade_standard_build_children cheader_filename="glade/glade-build.h" +glade_enum_from_string cheader_filename="glade/glade-build.h" +glade_flags_from_string cheader_filename="glade/glade-build.h" +glade_module_check_version cheader_filename="glade/glade-build.h" +glade_module_register_widgets cheader_filename="glade/glade-build.h" +