vala r1898 - in trunk: . gobject
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1898 - in trunk: . gobject
- Date: Fri, 24 Oct 2008 14:47:06 +0000 (UTC)
Author: juergbi
Date: Fri Oct 24 14:47:05 2008
New Revision: 1898
URL: http://svn.gnome.org/viewvc/vala?rev=1898&view=rev
Log:
2008-10-24 JÃrg Billeter <j bitron ch>
* gobject/Makefile.am:
* gobject/valaccodedynamicsignalmodule.vala:
* gobject/valaccodegenerator.vala:
* gobject/valaccodemodule.vala:
* gobject/valadbusmodule.vala:
* gobject/valagobjectmodule.vala:
* gobject/valagobjectsignalmodule.vala:
Add GObjectSignalModule
Added:
trunk/gobject/valagobjectsignalmodule.vala (contents, props changed)
- copied, changed from r1880, /trunk/gobject/valaccodegeneratorsignal.vala
Removed:
trunk/gobject/valaccodegeneratorsignal.vala
Modified:
trunk/ChangeLog
trunk/gobject/Makefile.am
trunk/gobject/valaccodedynamicsignalmodule.vala
trunk/gobject/valaccodegenerator.vala
trunk/gobject/valaccodemodule.vala
trunk/gobject/valadbusmodule.vala
trunk/gobject/valagobjectmodule.vala
Modified: trunk/gobject/Makefile.am
==============================================================================
--- trunk/gobject/Makefile.am (original)
+++ trunk/gobject/Makefile.am Fri Oct 24 14:47:05 2008
@@ -20,7 +20,6 @@
valaccodedynamicsignalmodule.vala \
valaccodeelementaccessmodule.vala \
valaccodegenerator.vala \
- valaccodegeneratorsignal.vala \
valaccodegeneratorsourcefile.vala \
valaccodegeneratorstruct.vala \
valaccodeinvocationexpressionmodule.vala \
@@ -33,6 +32,7 @@
valagobjectclassmodule.vala \
valagobjectinterfacemodule.vala \
valagobjectmodule.vala \
+ valagobjectsignalmodule.vala \
valainterfaceregisterfunction.vala \
valatyperegisterfunction.vala \
$(NULL)
Modified: trunk/gobject/valaccodedynamicsignalmodule.vala
==============================================================================
--- trunk/gobject/valaccodedynamicsignalmodule.vala (original)
+++ trunk/gobject/valaccodedynamicsignalmodule.vala Fri Oct 24 14:47:05 2008
@@ -124,8 +124,8 @@
// FIXME should only be done once per marshaller
var register_call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_g_object_register_marshaller"));
- codegen.generate_marshaller (node.get_parameters (), node.return_type, true);
- register_call.add_argument (new CCodeIdentifier (codegen.get_marshaller_function (node.get_parameters (), node.return_type, null, true)));
+ head.generate_marshaller (node.get_parameters (), node.return_type, true);
+ register_call.add_argument (new CCodeIdentifier (head.get_marshaller_function (node.get_parameters (), node.return_type, null, true)));
register_call.add_argument (new CCodeIdentifier ("G_TYPE_NONE"));
var add_call = new CCodeFunctionCall (new CCodeIdentifier ("dbus_g_proxy_add_signal"));
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Fri Oct 24 14:47:05 2008
@@ -153,6 +153,7 @@
head = new GObjectModule (this, head);
head = new GObjectClassModule (this, head);
head = new GObjectInterfaceModule (this, head);
+ head = new GObjectSignalModule (this, head);
head = new DBusModule (this, head);
predefined_marshal_set = new HashSet<string> (str_hash, str_equal);
@@ -998,6 +999,10 @@
current_return_type = null;
}
+ public override void visit_signal (Signal sig) {
+ head.visit_signal (sig);
+ }
+
public override void visit_constructor (Constructor c) {
current_method_inner_error = false;
in_constructor = true;
Modified: trunk/gobject/valaccodemodule.vala
==============================================================================
--- trunk/gobject/valaccodemodule.vala (original)
+++ trunk/gobject/valaccodemodule.vala Fri Oct 24 14:47:05 2008
@@ -64,6 +64,10 @@
next.visit_method (m);
}
+ public virtual void visit_signal (Signal sig) {
+ next.visit_signal (sig);
+ }
+
public virtual void visit_creation_method (CreationMethod m) {
next.visit_creation_method (m);
}
@@ -143,4 +147,12 @@
public virtual string get_dynamic_signal_disconnect_wrapper_name (DynamicSignal node) {
return next.get_dynamic_signal_disconnect_wrapper_name (node);
}
+
+ public virtual void generate_marshaller (Gee.List<FormalParameter> params, DataType return_type, bool dbus = false) {
+ next.generate_marshaller (params, return_type, dbus);
+ }
+
+ public virtual string get_marshaller_function (Gee.List<FormalParameter> params, DataType return_type, string? prefix = null, bool dbus = false) {
+ return next.get_marshaller_function (params, return_type, prefix, dbus);
+ }
}
Modified: trunk/gobject/valadbusmodule.vala
==============================================================================
--- trunk/gobject/valadbusmodule.vala (original)
+++ trunk/gobject/valadbusmodule.vala Fri Oct 24 14:47:05 2008
@@ -534,12 +534,12 @@
dbus_methods.append ("{ (GCallback) ");
dbus_methods.append (generate_dbus_wrapper (m, bindable));
dbus_methods.append (", ");
- dbus_methods.append (codegen.get_marshaller_function (parameters, codegen.bool_type, null, true));
+ dbus_methods.append (head.get_marshaller_function (parameters, codegen.bool_type, null, true));
dbus_methods.append (", ");
dbus_methods.append (blob_len.to_string ());
dbus_methods.append (" },\n");
- codegen.generate_marshaller (parameters, codegen.bool_type, true);
+ head.generate_marshaller (parameters, codegen.bool_type, true);
long start = blob.len;
Modified: trunk/gobject/valagobjectmodule.vala
==============================================================================
--- trunk/gobject/valagobjectmodule.vala (original)
+++ trunk/gobject/valagobjectmodule.vala Fri Oct 24 14:47:05 2008
@@ -213,7 +213,7 @@
csignew.add_argument (new CCodeConstant ("NULL"));
csignew.add_argument (new CCodeConstant ("NULL"));
- string marshaller = codegen.get_marshaller_function (sig.get_parameters (), sig.return_type);
+ string marshaller = head.get_marshaller_function (sig.get_parameters (), sig.return_type);
var marshal_arg = new CCodeIdentifier (marshaller);
csignew.add_argument (marshal_arg);
Copied: trunk/gobject/valagobjectsignalmodule.vala (from r1880, /trunk/gobject/valaccodegeneratorsignal.vala)
==============================================================================
--- /trunk/gobject/valaccodegeneratorsignal.vala (original)
+++ trunk/gobject/valagobjectsignalmodule.vala Fri Oct 24 14:47:05 2008
@@ -1,4 +1,4 @@
-/* valaccodegeneratorsignal.vala
+/* valagobjectsignalmodule.vala
*
* Copyright (C) 2006-2008 JÃrg Billeter, Raffaele Sandrini
*
@@ -23,7 +23,11 @@
using GLib;
-public class Vala.CCodeGenerator {
+public class Vala.GObjectSignalModule : CCodeModule {
+ public GObjectSignalModule (CCodeGenerator codegen, CCodeModule? next) {
+ base (codegen, next);
+ }
+
private string get_marshaller_type_name (DataType t, bool dbus = false) {
if (t is PointerType || t.type_parameter != null) {
return ("POINTER");
@@ -33,7 +37,7 @@
if (dbus) {
return ("BOXED");
} else {
- if (((ArrayType) t).element_type.data_type == string_type.data_type) {
+ if (((ArrayType) t).element_type.data_type == codegen.string_type.data_type) {
return ("BOXED_INT");
} else {
return ("POINTER_INT");
@@ -56,12 +60,12 @@
}
}
- public string get_marshaller_function (Gee.List<FormalParameter> params, DataType return_type, string? prefix = null, bool dbus = false) {
+ public override string get_marshaller_function (Gee.List<FormalParameter> params, DataType return_type, string? prefix = null, bool dbus = false) {
var signature = get_marshaller_signature (params, return_type, dbus);
string ret;
if (prefix == null) {
- if (predefined_marshal_set.contains (signature)) {
+ if (codegen.predefined_marshal_set.contains (signature)) {
prefix = "g_cclosure_marshal";
} else {
prefix = "g_cclosure_user_marshal";
@@ -86,7 +90,7 @@
return "gpointer";
} else if (t is VoidType) {
return "void";
- } else if (t.data_type == string_type.data_type) {
+ } else if (t.data_type == codegen.string_type.data_type) {
return "const char*";
} else if (t.data_type is Class || t.data_type is Interface) {
return "gpointer";
@@ -141,25 +145,25 @@
// parent_symbol may be null for late bound signals
if (sig.parent_symbol != null) {
var dt = sig.parent_symbol as TypeSymbol;
- if (!dt.is_subtype_of (gobject_type)) {
+ if (!dt.is_subtype_of (codegen.gobject_type)) {
sig.error = true;
Report.error (sig.source_reference, "Only classes and interfaces deriving from GLib.Object support signals. `%s' does not derive from GLib.Object.".printf (dt.get_full_name ()));
return;
}
}
- sig.accept_children (this);
+ sig.accept_children (codegen);
generate_marshaller (sig.get_parameters (), sig.return_type);
}
- public void generate_marshaller (Gee.List<FormalParameter> params, DataType return_type, bool dbus = false) {
+ public override void generate_marshaller (Gee.List<FormalParameter> params, DataType return_type, bool dbus = false) {
string signature;
int n_params, i;
/* check whether a signal with the same signature already exists for this source file (or predefined) */
signature = get_marshaller_signature (params, return_type, dbus);
- if (predefined_marshal_set.contains (signature) || user_marshal_set.contains (signature)) {
+ if (codegen.predefined_marshal_set.contains (signature) || codegen.user_marshal_set.contains (signature)) {
return;
}
@@ -173,7 +177,7 @@
signal_marshaller.add_parameter (new CCodeFormalParameter ("invocation_hint", "gpointer"));
signal_marshaller.add_parameter (new CCodeFormalParameter ("marshal_data", "gpointer"));
- source_signal_marshaller_declaration.append (signal_marshaller.copy ());
+ codegen.source_signal_marshaller_declaration.append (signal_marshaller.copy ());
var marshaller_body = new CCodeBlock ();
@@ -250,7 +254,7 @@
if (dbus) {
get_value_function = "g_value_get_boxed";
} else {
- if (((ArrayType) p.parameter_type).element_type.data_type == string_type.data_type) {
+ if (((ArrayType) p.parameter_type).element_type.data_type == codegen.string_type.data_type) {
get_value_function = "g_value_get_boxed";
} else {
get_value_function = "g_value_get_pointer";
@@ -286,7 +290,7 @@
if (dbus) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_boxed"));
} else {
- if (((ArrayType) return_type).element_type.data_type == string_type.data_type) {
+ if (((ArrayType) return_type).element_type.data_type == codegen.string_type.data_type) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_boxed"));
} else {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
@@ -296,7 +300,7 @@
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
} else if (return_type is ErrorType) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
- } else if (return_type.data_type == string_type.data_type) {
+ } else if (return_type.data_type == codegen.string_type.data_type) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_string"));
} else if (return_type.data_type is Class || return_type.data_type is Interface) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_take_object"));
@@ -315,8 +319,8 @@
signal_marshaller.block = marshaller_body;
- source_signal_marshaller_definition.append (signal_marshaller);
- user_marshal_set.add (signature);
+ codegen.source_signal_marshaller_definition.append (signal_marshaller);
+ codegen.user_marshal_set.add (signature);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]