[vala] codegen: Generate async ready functions only if needed
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Generate async ready functions only if needed
- Date: Tue, 21 Dec 2010 20:32:02 +0000 (UTC)
commit 51a2d381d8041b7beb562ced04a72400bc4ff703
Author: Jürg Billeter <j bitron ch>
Date: Tue Dec 21 21:24:13 2010 +0100
codegen: Generate async ready functions only if needed
codegen/valaccodebasemodule.vala | 4 ++++
codegen/valaccodemethodcallmodule.vala | 2 +-
codegen/valagasyncmodule.vala | 13 ++++++++++---
codegen/valagdbusclientmodule.vala | 2 +-
4 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index bc7af35..d6592e9 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5910,6 +5910,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public virtual void add_simple_check (CodeNode node, bool always_fails = false) {
}
+ public virtual string generate_ready_function (Method m) {
+ return "";
+ }
+
public CCodeExpression? get_cvalue (Expression expr) {
if (expr.target_value == null) {
return null;
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 0ba0e4e..f1ec0d8 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -580,7 +580,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (m != null && m.coroutine) {
if (expr.is_yield_expression) {
// asynchronous call
- in_arg_map.set (get_param_pos (-1), new CCodeIdentifier (current_method.get_cname () + "_ready"));
+ in_arg_map.set (get_param_pos (-1), new CCodeIdentifier (generate_ready_function (current_method)));
in_arg_map.set (get_param_pos (-0.9), new CCodeIdentifier ("data"));
}
}
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index 816cb38..783cd14 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -360,7 +360,6 @@ public class Vala.GAsyncModule : GSignalModule {
append_function (generate_free_function (m));
generate_async_function (m);
generate_finish_function (m);
- append_function (generate_ready_function (m));
// append the _co function
base.visit_method (m);
@@ -483,12 +482,18 @@ public class Vala.GAsyncModule : GSignalModule {
pop_context ();
}
- CCodeFunction generate_ready_function (Method m) {
+ public override string generate_ready_function (Method m) {
// generate ready callback handler
+
var dataname = Symbol.lower_case_to_camel_case (m.get_cname ()) + "Data";
var readyfunc = new CCodeFunction (m.get_cname () + "_ready", "void");
+ if (!add_wrapper (readyfunc.name)) {
+ // wrapper already defined
+ return readyfunc.name;
+ }
+
readyfunc.add_parameter (new CCodeParameter ("source_object", "GObject*"));
readyfunc.add_parameter (new CCodeParameter ("_res_", "GAsyncResult*"));
readyfunc.add_parameter (new CCodeParameter ("_user_data_", "gpointer"));
@@ -510,7 +515,9 @@ public class Vala.GAsyncModule : GSignalModule {
readyfunc.block = readyblock;
- return readyfunc;
+ append_function (readyfunc);
+
+ return readyfunc.name;
}
public override void generate_virtual_method_declaration (Method m, CCodeFile decl_space, CCodeStruct type_struct) {
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index f81320f..e1be9ba 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -254,7 +254,7 @@ public class Vala.GDBusClientModule : GDBusModule {
if (bus_get_proxy_async || conn_get_proxy_async) {
if (expr.is_yield_expression) {
// asynchronous call
- ccall.add_argument (new CCodeIdentifier (current_method.get_cname () + "_ready"));
+ ccall.add_argument (new CCodeIdentifier (generate_ready_function (current_method)));
ccall.add_argument (new CCodeIdentifier ("data"));
}
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]