vala r1048 - in trunk: . gobject vala
- From: rasa svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1048 - in trunk: . gobject vala
- Date: Sun, 24 Feb 2008 14:34:41 +0000 (GMT)
Author: rasa
Date: Sun Feb 24 14:34:41 2008
New Revision: 1048
URL: http://svn.gnome.org/viewvc/vala?rev=1048&view=rev
Log:
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
Modified:
trunk/ChangeLog
trunk/gobject/valaccodegenerator.vala
trunk/vala/valadatatype.vala
trunk/vala/valaerrortype.vala
trunk/vala/valasemanticanalyzer.vala
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Sun Feb 24 14:34:41 2008
@@ -97,7 +97,7 @@
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;
@@ -223,7 +223,7 @@
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");
@@ -1301,9 +1301,9 @@
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 {
@@ -2141,7 +2141,7 @@
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 ();
Modified: trunk/vala/valadatatype.vala
==============================================================================
--- trunk/vala/valadatatype.vala (original)
+++ trunk/vala/valadatatype.vala Sun Feb 24 14:34:41 2008
@@ -178,6 +178,18 @@
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;
@@ -250,7 +262,7 @@
* @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;
}
Modified: trunk/vala/valaerrortype.vala
==============================================================================
--- trunk/vala/valaerrortype.vala (original)
+++ trunk/vala/valaerrortype.vala Sun Feb 24 14:34:41 2008
@@ -69,4 +69,26 @@
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;
+ }
}
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Sun Feb 24 14:34:41 2008
@@ -1082,6 +1082,8 @@
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]