[vala/wip/attributes: 38/100] codegen: Add get_ccode_finish_name
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 38/100] codegen: Add get_ccode_finish_name
- Date: Sat, 2 Jul 2011 12:28:29 +0000 (UTC)
commit 9135fdaf4fc779c059f0b193a060c11bae002f79
Author: Luca Bruno <lucabru src gnome org>
Date: Tue Jun 28 21:13:09 2011 +0200
codegen: Add get_ccode_finish_name
codegen/valaccodebasemodule.vala | 23 +++++++++++++++++++++++
codegen/valaccodemethodcallmodule.vala | 2 +-
codegen/valagasyncmodule.vala | 2 +-
codegen/valagdbusservermodule.vala | 2 +-
codegen/valagtypemodule.vala | 2 +-
5 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 6f4005d..2a87565 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5785,6 +5785,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return get_ccode_attribute(m).vfunc_name;
}
+ public static string get_ccode_finish_name (Method m) {
+ return get_ccode_attribute(m).finish_name;
+ }
+
public override void visit_class (Class cl) {
}
@@ -6350,6 +6354,15 @@ public class Vala.CCodeAttribute : AttributeCache {
}
}
+ public string finish_name {
+ get {
+ if (_finish_name == null) {
+ _finish_name = get_finish_name_for_basename (name);
+ }
+ return _finish_name;
+ }
+ }
+
public bool no_array_length { get; private set; }
public string? array_length_type { get; private set; }
@@ -6375,6 +6388,7 @@ public class Vala.CCodeAttribute : AttributeCache {
private string _default_value;
private double? _pos;
private string _vfunc_name;
+ private string _finish_name;
public CCodeAttribute (CodeNode node) {
this.node = node;
@@ -6421,6 +6435,7 @@ public class Vala.CCodeAttribute : AttributeCache {
_pos = attr.get_double ("pos");
}
_vfunc_name = attr.get_string ("vfunc_name");
+ _finish_name = attr.get_string ("finish_name");
}
}
@@ -7018,4 +7033,12 @@ public class Vala.CCodeAttribute : AttributeCache {
return "";
}
+
+ private string get_finish_name_for_basename (string basename) {
+ string result = basename;
+ if (result.has_suffix ("_async")) {
+ result = result.substring (0, result.length - "_async".length);
+ }
+ return result + "_finish";
+ }
}
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 36696c6..5f6152a 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -78,7 +78,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
// async call
async_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (m)));
- var finish_call = new CCodeFunctionCall (new CCodeIdentifier (m.get_finish_cname ()));
+ var finish_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_finish_name (m)));
if (ma.inner is BaseAccess) {
if (m.base_method != null) {
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index 0d64758..25a6637 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -304,7 +304,7 @@ public class Vala.GAsyncModule : GSignalModule {
decl_space.add_function_declaration (asyncfunc);
- var finishfunc = new CCodeFunction (m.get_finish_cname ());
+ var finishfunc = new CCodeFunction (get_ccode_finish_name (m));
cparam_map = new HashMap<int,CCodeParameter> (direct_hash, direct_equal);
cparam_map.set (get_param_pos (0.1), new CCodeParameter ("_res_", "GAsyncResult*"));
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index f875cae..f07753d 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -108,7 +108,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_name (m)));
ccall.add_argument (new CCodeIdentifier ("self"));
} else {
- ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_finish_cname ()));
+ ccall = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_finish_name (m)));
ccall.add_argument (new CCodeCastExpression (new CCodeIdentifier ("source_object"), get_ccode_name (sym) + "*"));
ccall.add_argument (new CCodeIdentifier ("_res_"));
}
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 7089f4c..319a624 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -1318,7 +1318,7 @@ public class Vala.GTypeModule : GErrorModule {
if (m.coroutine) {
if (m.is_abstract || m.is_virtual) {
- cfunc = new CCodeIdentifier (m.get_finish_cname ());
+ cfunc = new CCodeIdentifier (get_ccode_finish_name (m));
} else {
cfunc = new CCodeIdentifier (m.get_finish_real_cname ());
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]