2008-02-24 Raffaele Sandrini <raffaele@sandrini.ch>
+ * gobject/valaccodegenerator.vala: fix gerror_type handling
+ * vala/valadatatype.vala: pull in get_lower_case_cname from Symbol
+ * vala/valaerrortype.vala: implement get_lower_case_cname and equals
+ * vala/valasemanticanalyzer.vala: use ErrorType (null) for generic
+ catch clauses
+
+2008-02-24 Raffaele Sandrini <raffaele@sandrini.ch>
+
* vapi/bzlib.vapi: add bzip2 binding, patch by Maciej Piechotka
* vapi/Makefile.am: add bzip2
public Typesymbol gtype_type;
public Typesymbol gtypeinstance_type;
public Typesymbol gobject_type;
- public Typesymbol gerror_type;
+ public ErrorType gerror_type;
public Typesymbol glist_type;
public Typesymbol gslist_type;
public Typesymbol gstring_type;
gtype_type = (Typesymbol) glib_ns.scope.lookup ("Type");
gtypeinstance_type = (Typesymbol) glib_ns.scope.lookup ("TypeInstance");
gobject_type = (Typesymbol) glib_ns.scope.lookup ("Object");
- gerror_type = (Typesymbol) glib_ns.scope.lookup ("Error");
+ gerror_type = new ErrorType (null);
glist_type = (Typesymbol) glib_ns.scope.lookup ("List");
gslist_type = (Typesymbol) glib_ns.scope.lookup ("SList");
gstring_type = (Typesymbol) glib_ns.scope.lookup ("StringBuilder");
var cerror_block = new CCodeBlock ();
foreach (CatchClause clause in current_try.get_catch_clauses ()) {
// go to catch clause if error domain matches
- var cgoto_stmt = new CCodeGotoStatement ("__catch%d_%s".printf (current_try_id, clause.type_reference.data_type.get_lower_case_cname ()));
+ var cgoto_stmt = new CCodeGotoStatement ("__catch%d_%s".printf (current_try_id, clause.type_reference.get_lower_case_cname ()));
- if (clause.type_reference.data_type == gerror_type) {
+ if (clause.type_reference.equals (gerror_type)) {
// general catch clause
cerror_block.add_statement (cgoto_stmt);
} else {
clause.accept_children (this);
var cfrag = new CCodeFragment ();
- cfrag.append (new CCodeLabel ("__catch%d_%s".printf (current_try_id, clause.type_reference.data_type.get_lower_case_cname ())));
+ cfrag.append (new CCodeLabel ("__catch%d_%s".printf (current_try_id, clause.type_reference.get_lower_case_cname ())));
var cblock = new CCodeBlock ();
return "const %s%s".printf (t.get_cname (), ptr);
}
+ /**
+ * Returns the C name of this data type in lower case. Words are
+ * separated by underscores.
+ *
+ * @param infix a string to be placed between namespace and data type
+ * name or null
+ * @return the lower case name to be used in C code
+ */
+ public virtual string get_lower_case_cname (string infix = null) {
+ return data_type.get_lower_case_cname (infix);
+ }
+
public override string! to_string () {
string s;
* @return true if this type reference is equal to type2, false
* otherwise
*/
- public bool equals (DataType! type2) {
+ public virtual bool equals (DataType! type2) {
if (type2.transfers_ownership != transfers_ownership) {
return false;
}
public override string get_cname (bool var_type = false, bool const_type = false) {
return "GError*";
}
+
+ public override string get_lower_case_cname (string infix = null) {
+ if (error_domain == null) {
+ if (infix == null) {
+ return "g_error";
+ } else {
+ return "g_%s_error".printf (infix);
+ }
+ } else {
+ return error_domain.get_lower_case_cname (infix);
+ }
+ }
+
+ public override bool equals (DataType! type2) {
+ var et = type2 as ErrorType;
+
+ if (et == null) {
+ return false;
+ }
+
+ return error_domain == et.error_domain;
+ }
}
clause.variable_declarator.type_reference = new ClassType (gerror_type);
clause.body.scope.add (clause.variable_name, clause.variable_declarator);
+ } else {
+ clause.type_reference = new ErrorType (null);
}
clause.accept_children (this);