vala r2432 - in trunk: . gobject
- From: ryanl svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2432 - in trunk: . gobject
- Date: Thu, 12 Feb 2009 12:48:35 +0000 (UTC)
Author: ryanl
Date: Thu Feb 12 12:48:35 2009
New Revision: 2432
URL: http://svn.gnome.org/viewvc/vala?rev=2432&view=rev
Log:
2009-02-12 Ryan Lortie <desrt desrt ca>
* gobject/valagasyncmodule.vala:
Store the Data structure as the op_res gpointer of the
GSimpleAsyncResult. Emit a function to free it and hook it in.
Modified:
trunk/ChangeLog
trunk/gobject/valagasyncmodule.vala
Modified: trunk/gobject/valagasyncmodule.vala
==============================================================================
--- trunk/gobject/valagasyncmodule.vala (original)
+++ trunk/gobject/valagasyncmodule.vala Thu Feb 12 12:48:35 2009
@@ -28,6 +28,29 @@
base (codegen, next);
}
+ CCodeFunction generate_free_function (Method m) {
+ var dataname = Symbol.lower_case_to_camel_case (m.get_cname ()) + "Data";
+
+ var freefunc = new CCodeFunction (m.get_real_cname () + "_data_free", "void");
+ freefunc.line = function.line;
+ freefunc.modifiers = CCodeModifiers.STATIC;
+ freefunc.add_parameter (new CCodeFormalParameter ("_data", "gpointer"));
+
+ var freeblock = new CCodeBlock ();
+ freefunc.block = freeblock;
+
+ var datadecl = new CCodeDeclaration (dataname + "*");
+ datadecl.add_declarator (new CCodeVariableDeclarator ("data", new CCodeIdentifier ("_data")));
+ freeblock.add_statement (datadecl);
+
+ var freecall = new CCodeFunctionCall (new CCodeIdentifier ("g_slice_free"));
+ freecall.add_argument (new CCodeIdentifier (dataname));
+ freecall.add_argument (new CCodeIdentifier ("data"));
+ freeblock.add_statement (new CCodeExpressionStatement (freecall));
+
+ return freefunc;
+ }
+
public override void visit_method (Method m) {
if (!m.coroutine) {
base.visit_method (m);
@@ -65,6 +88,8 @@
source_type_definition.append (closure_struct);
source_type_declaration.append (new CCodeTypeDefinition ("struct _" + dataname, new CCodeVariableDeclarator (dataname)));
+ source_type_member_definition.append (generate_free_function (m));
+
// generate async function
var asyncfunc = new CCodeFunction (m.get_real_cname () + "_async", "void");
asyncfunc.line = function.line;
@@ -101,6 +126,12 @@
asyncblock.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_async_result"), create_result)));
+ var set_op_res_call = new CCodeFunctionCall (new CCodeIdentifier ("g_simple_async_result_set_op_res_gpointer"));
+ set_op_res_call.add_argument (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "_async_result"));
+ set_op_res_call.add_argument (new CCodeIdentifier ("data"));
+ set_op_res_call.add_argument (new CCodeIdentifier (m.get_real_cname () + "_data_free"));
+ asyncblock.add_statement (new CCodeExpressionStatement (set_op_res_call));
+
if (m.binding == MemberBinding.INSTANCE) {
asyncblock.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("data"), "self"), new CCodeIdentifier ("self"))));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]