From 7966116eeff1a65de4a139a1f504bed23f023d18 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Sat, 12 Jan 2008 14:26:48 +0000 Subject: [PATCH] rename Callback to Delegate 2008-01-12 Juerg Billeter * vala/Makefile.am, vala/parser.y, vala/vala.h, vala/valaattributeprocessor.vala, vala/valacodecontext.vala, vala/valacodegenerator.vala, vala/valacodevisitor.vala, vala/valadatatype.vala, vala/valadelegate.vala, vala/valadelegatetype.vala, vala/valainterfacewriter.vala, vala/valanamespace.vala, vala/valanulltype.vala, vala/valasemanticanalyzer.vala, vala/valasignal.vala, vala/valasymbolresolver.vala, gobject/valaccodegenerator.vala, gobject/valaccodegeneratorinvocationexpression.vala, vapigen/valagidlparser.vala: rename Callback to Delegate svn path=/trunk/; revision=836 --- ChangeLog | 13 +++++++++++++ gobject/valaccodegenerator.vala | 4 ++-- .../valaccodegeneratorinvocationexpression.vala | 2 +- vala/Makefile.am | 2 +- vala/parser.y | 12 ++++++------ vala/vala.h | 2 +- vala/valaattributeprocessor.vala | 6 +++--- vala/valacodecontext.vala | 6 +++--- vala/valacodegenerator.vala | 4 ++-- vala/valacodevisitor.vala | 8 ++++---- vala/valadatatype.vala | 2 +- vala/{valacallback.vala => valadelegate.vala} | 16 ++++++++-------- vala/valadelegatetype.vala | 6 +++--- vala/valainterfacewriter.vala | 2 +- vala/valanamespace.vala | 18 +++++++++--------- vala/valanulltype.vala | 2 +- vala/valasemanticanalyzer.vala | 22 +++++++++++----------- vala/valasignal.vala | 22 +++++++++++----------- vala/valasymbolresolver.vala | 10 +++++----- vapigen/valagidlparser.vala | 12 ++++++------ 20 files changed, 92 insertions(+), 79 deletions(-) rename vala/{valacallback.vala => valadelegate.vala} (93%) diff --git a/ChangeLog b/ChangeLog index 6fe1f77..066a1af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2008-01-12 Jürg Billeter + * vala/Makefile.am, vala/parser.y, vala/vala.h, + vala/valaattributeprocessor.vala, vala/valacodecontext.vala, + vala/valacodegenerator.vala, vala/valacodevisitor.vala, + vala/valadatatype.vala, vala/valadelegate.vala, + vala/valadelegatetype.vala, vala/valainterfacewriter.vala, + vala/valanamespace.vala, vala/valanulltype.vala, + vala/valasemanticanalyzer.vala, vala/valasignal.vala, + vala/valasymbolresolver.vala, gobject/valaccodegenerator.vala, + gobject/valaccodegeneratorinvocationexpression.vala, + vapigen/valagidlparser.vala: rename Callback to Delegate + +2008-01-12 Jürg Billeter + * vapi/packages/gstreamer-0.10/: add some missing ellipsis and out parameter metadata for gst_structure and gst_element functions, patch by Andrea Del Signore diff --git a/gobject/valaccodegenerator.vala b/gobject/valaccodegenerator.vala index 041a110..2b06eb8 100644 --- a/gobject/valaccodegenerator.vala +++ b/gobject/valaccodegenerator.vala @@ -298,7 +298,7 @@ public class Vala.CCodeGenerator : CodeGenerator { } } - public override void visit_callback (Callback! cb) { + public override void visit_delegate (Delegate! cb) { cb.accept_children (this); var cfundecl = new CCodeFunctionDeclarator (cb.get_cname ()); @@ -2825,7 +2825,7 @@ public class Vala.CCodeGenerator : CodeGenerator { return null; } - public override CodeBinding create_callback_binding (Callback! node) { + public override CodeBinding create_delegate_binding (Delegate! node) { return null; } diff --git a/gobject/valaccodegeneratorinvocationexpression.vala b/gobject/valaccodegeneratorinvocationexpression.vala index ef69f89..f4b8c0d 100644 --- a/gobject/valaccodegeneratorinvocationexpression.vala +++ b/gobject/valaccodegeneratorinvocationexpression.vala @@ -225,7 +225,7 @@ public class Vala.CCodeGenerator { var param = params_it.get (); ellipsis = param.ellipsis; if (!ellipsis) { - if (param.type_reference.data_type is Callback) { + if (param.type_reference.data_type is Delegate) { cexpr = new CCodeCastExpression (cexpr, param.type_reference.data_type.get_cname ()); } else { if (!param.no_array_length && param.type_reference.data_type is Array) { diff --git a/vala/Makefile.am b/vala/Makefile.am index 4d6c49f..0e40990 100644 --- a/vala/Makefile.am +++ b/vala/Makefile.am @@ -29,7 +29,6 @@ libvalacore_la_VALASOURCES = \ valablock.vala \ valabooleanliteral.vala \ valabreakstatement.vala \ - valacallback.vala \ valacastexpression.vala \ valacatchclause.vala \ valacharacterliteral.vala \ @@ -47,6 +46,7 @@ libvalacore_la_VALASOURCES = \ valacreationmethod.vala \ valadatatype.vala \ valadeclarationstatement.vala \ + valadelegate.vala \ valadelegatetype.vala \ valadestructor.vala \ valadostatement.vala \ diff --git a/vala/parser.y b/vala/parser.y index 1b24456..8ac31b9 100644 --- a/vala/parser.y +++ b/vala/parser.y @@ -2519,7 +2519,7 @@ namespace_member_declaration | struct_declaration | interface_declaration | enum_declaration - | callback_declaration + | delegate_declaration | constant_declaration { /* skip declarations with errors */ @@ -3751,7 +3751,7 @@ enum_method_declaration } ; -callback_declaration +delegate_declaration : comment opt_attributes opt_access_modifier opt_modifiers DELEGATE type identifier opt_name_specifier opt_type_parameter_list OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS opt_throws_declaration SEMICOLON { ValaSourceReference *src; @@ -3784,12 +3784,12 @@ callback_declaration } src = src_com(@7, $1); - ValaCallback *cb = vala_code_context_create_callback (context, name, $6, src); + ValaDelegate *cb = vala_code_context_create_delegate (context, name, $6, src); g_free (name); g_object_unref ($6); g_object_unref (src); - vala_namespace_add_callback (VALA_NAMESPACE (parent_symbol), cb); + vala_namespace_add_delegate (VALA_NAMESPACE (parent_symbol), cb); vala_source_file_add_node (current_source_file, VALA_CODE_NODE (cb)); g_object_unref (parent_symbol); @@ -3800,14 +3800,14 @@ callback_declaration if ($9 != NULL) { for (l = $9; l != NULL; l = l->next) { - vala_callback_add_type_parameter (cb, l->data); + vala_delegate_add_type_parameter (cb, l->data); g_object_unref (l->data); } g_list_free ($9); } if ($11 != NULL) { for (l = $11; l != NULL; l = l->next) { - vala_callback_add_parameter (cb, l->data); + vala_delegate_add_parameter (cb, l->data); g_object_unref (l->data); } g_list_free ($11); diff --git a/vala/vala.h b/vala/vala.h index 2e242fd..8f5e21f 100644 --- a/vala/vala.h +++ b/vala/vala.h @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/vala/valaattributeprocessor.vala b/vala/valaattributeprocessor.vala index d6a2f07..9d924a0 100644 --- a/vala/valaattributeprocessor.vala +++ b/vala/valaattributeprocessor.vala @@ -1,6 +1,6 @@ /* valaattributeprocessor.vala * - * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini + * Copyright (C) 2006-2008 Jürg Billeter, Raffaele Sandrini * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -82,8 +82,8 @@ public class Vala.AttributeProcessor : CodeVisitor { prop.process_attributes (); } - public override void visit_callback (Callback! cb) { - cb.process_attributes (); + public override void visit_delegate (Delegate! d) { + d.process_attributes (); } public override void visit_constant (Constant! c) { diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala index e789b77..ab10c87 100644 --- a/vala/valacodecontext.vala +++ b/vala/valacodecontext.vala @@ -407,9 +407,9 @@ public class Vala.CodeContext : Object { return node; } - public Callback! create_callback (string name, DataType return_type, SourceReference source_reference = null) { - var node = new Callback (name, return_type, source_reference); - node.code_binding = codegen.create_callback_binding (node); + public Delegate! create_delegate (string name, DataType return_type, SourceReference source_reference = null) { + var node = new Delegate (name, return_type, source_reference); + node.code_binding = codegen.create_delegate_binding (node); return node; } diff --git a/vala/valacodegenerator.vala b/vala/valacodegenerator.vala index 59638d3..ae8f91c 100644 --- a/vala/valacodegenerator.vala +++ b/vala/valacodegenerator.vala @@ -1,6 +1,6 @@ /* valacodegenerator.vala * - * Copyright (C) 2007 Jürg Billeter + * Copyright (C) 2007-2008 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -58,7 +58,7 @@ public class Vala.CodeGenerator : CodeVisitor { return null; } - public virtual CodeBinding create_callback_binding (Callback! node) { + public virtual CodeBinding create_delegate_binding (Delegate! node) { return null; } diff --git a/vala/valacodevisitor.vala b/vala/valacodevisitor.vala index f674104..5c55f66 100644 --- a/vala/valacodevisitor.vala +++ b/vala/valacodevisitor.vala @@ -1,6 +1,6 @@ /* valacodevisitor.vala * - * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini + * Copyright (C) 2006-2008 Jürg Billeter, Raffaele Sandrini * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -84,11 +84,11 @@ public abstract class Vala.CodeVisitor : Object { } /** - * Visit operation called for callbacks. + * Visit operation called for delegates. * - * @param cb a callback + * @param d a delegate */ - public virtual void visit_callback (Callback! cb) { + public virtual void visit_delegate (Delegate! d) { } /** diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala index 7a38974..81e6412 100644 --- a/vala/valadatatype.vala +++ b/vala/valadatatype.vala @@ -347,7 +347,7 @@ public class Vala.DataType : CodeNode { (data_type != null && ( data_type.is_reference_type () || data_type is Array || - data_type is Callback || + data_type is Delegate || data_type.get_attribute ("PointerType") != null))) { return true; } diff --git a/vala/valacallback.vala b/vala/valadelegate.vala similarity index 93% rename from vala/valacallback.vala rename to vala/valadelegate.vala index 2c28d06..87c4e39 100644 --- a/vala/valacallback.vala +++ b/vala/valadelegate.vala @@ -1,6 +1,6 @@ -/* valacallback.vala +/* valadelegate.vala * - * Copyright (C) 2006-2007 Jürg Billeter + * Copyright (C) 2006-2008 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,7 +26,7 @@ using Gee; /** * Represents a function callback type. */ -public class Vala.Callback : Typesymbol { +public class Vala.Delegate : Typesymbol { /** * The return type of this callback. */ @@ -53,14 +53,14 @@ public class Vala.Callback : Typesymbol { private DataType _return_type; /** - * Creates a new callback. + * Creates a new delegate. * - * @param name callback type name + * @param name delegate type name * @param return_type return type * @param source reference to source code - * @return newly created callback + * @return newly created delegate */ - public Callback (construct string name, construct DataType return_type, construct SourceReference source_reference = null) { + public Delegate (construct string name, construct DataType return_type, construct SourceReference source_reference = null) { } /** @@ -138,7 +138,7 @@ public class Vala.Callback : Typesymbol { } public override void accept (CodeVisitor! visitor) { - visitor.visit_callback (this); + visitor.visit_delegate (this); } public override void accept_children (CodeVisitor! visitor) { diff --git a/vala/valadelegatetype.vala b/vala/valadelegatetype.vala index afe0019..8230f52 100644 --- a/vala/valadelegatetype.vala +++ b/vala/valadelegatetype.vala @@ -1,6 +1,6 @@ /* valadelegatetype.vala * - * Copyright (C) 2007 Jürg Billeter + * Copyright (C) 2007-2008 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,9 +27,9 @@ using Gee; * The type of an instance of a delegate. */ public class Vala.DelegateType : DataType { - public Callback delegate_symbol { get; set; } + public Delegate delegate_symbol { get; set; } - public DelegateType (construct Callback delegate_symbol) { + public DelegateType (construct Delegate delegate_symbol) { } public override bool is_invokable () { diff --git a/vala/valainterfacewriter.vala b/vala/valainterfacewriter.vala index 0404f1e..b9f1fd7 100644 --- a/vala/valainterfacewriter.vala +++ b/vala/valainterfacewriter.vala @@ -450,7 +450,7 @@ public class Vala.InterfaceWriter : CodeVisitor { write_string (")"); } - public override void visit_callback (Callback! cb) { + public override void visit_delegate (Delegate! cb) { if (cb.source_reference != null && cb.source_reference.file.pkg) { return; } diff --git a/vala/valanamespace.vala b/vala/valanamespace.vala index c9df52a..ef4653a 100644 --- a/vala/valanamespace.vala +++ b/vala/valanamespace.vala @@ -1,6 +1,6 @@ /* valanamespace.vala * - * Copyright (C) 2006-2007 Jürg Billeter + * Copyright (C) 2006-2008 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -36,7 +36,7 @@ public class Vala.Namespace : Symbol { private Gee.List interfaces = new ArrayList (); private Gee.List structs = new ArrayList (); private Gee.List enums = new ArrayList (); - private Gee.List callbacks = new ArrayList (); + private Gee.List delegates = new ArrayList (); private Gee.List constants = new ArrayList (); private Gee.List fields = new ArrayList (); private Gee.List methods = new ArrayList (); @@ -119,13 +119,13 @@ public class Vala.Namespace : Symbol { } /** - * Adds the specified callback to this namespace. + * Adds the specified delegate to this namespace. * - * @param cb a callback + * @param d a delegate */ - public void add_callback (Callback! cb) { - callbacks.add (cb); - scope.add (cb.name, cb); + public void add_delegate (Delegate! d) { + delegates.add (d); + scope.add (d.name, d); } /** @@ -224,8 +224,8 @@ public class Vala.Namespace : Symbol { st.accept (visitor); } - foreach (Callback cb in callbacks) { - cb.accept (visitor); + foreach (Delegate d in delegates) { + d.accept (visitor); } foreach (Constant c in constants) { diff --git a/vala/valanulltype.vala b/vala/valanulltype.vala index f8b97aa..4dcf18c 100644 --- a/vala/valanulltype.vala +++ b/vala/valanulltype.vala @@ -45,7 +45,7 @@ public class Vala.NullType : ReferenceType { if (target_type.data_type.is_reference_type () || target_type.data_type is Array || - target_type.data_type is Callback) { + target_type.data_type is Delegate) { return !(CodeContext.is_non_null_enabled ()); } diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index 97e961e..11e174a 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -290,8 +290,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor { current_symbol = current_symbol.parent_symbol; } - public override void visit_callback (Callback! cb) { - cb.accept_children (this); + public override void visit_delegate (Delegate! d) { + d.accept_children (this); } public override void visit_constant (Constant! c) { @@ -682,9 +682,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } if (decl.initializer.symbol_reference is Method && - decl.type_reference.data_type is Callback) { + decl.type_reference.data_type is Delegate) { var m = (Method) decl.initializer.symbol_reference; - var cb = (Callback) decl.type_reference.data_type; + var cb = (Delegate) decl.type_reference.data_type; /* check whether method matches callback type */ if (!cb.matches_method (m)) { @@ -2397,7 +2397,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { break; } } - } else if (type.data_type is Callback) { + } else if (type.data_type is Delegate) { if (!callback_found) { callback_found = true; if (class_or_iface_found || type_param_found || ref_struct_found || val_struct_found || enum_found) { @@ -2498,7 +2498,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { in_instance_method = is_in_constructor (); } - var cb = (Callback) ((DelegateType) l.expected_type).delegate_symbol; + var cb = (Delegate) ((DelegateType) l.expected_type).delegate_symbol; l.method = new Method (get_lambda_name (), cb.return_type); l.method.instance = cb.instance && in_instance_method; l.method.owner = current_symbol.scope; @@ -2579,7 +2579,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { if (ma.symbol_reference is Signal) { var sig = (Signal) ma.symbol_reference; - a.right.expected_type = new DelegateType (sig.get_callback ()); + a.right.expected_type = new DelegateType (sig.get_delegate ()); } else { a.right.expected_type = ma.static_type; } @@ -2685,9 +2685,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor { var decl = (VariableDeclarator) ma.symbol_reference; if (a.right.symbol_reference is Method && - decl.type_reference.data_type is Callback) { + decl.type_reference.data_type is Delegate) { var m = (Method) a.right.symbol_reference; - var cb = (Callback) decl.type_reference.data_type; + var cb = (Delegate) decl.type_reference.data_type; /* check whether method matches callback type */ if (!cb.matches_method (m)) { @@ -2706,9 +2706,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor { var f = (Field) ma.symbol_reference; if (a.right.symbol_reference is Method && - f.type_reference.data_type is Callback) { + f.type_reference.data_type is Delegate) { var m = (Method) a.right.symbol_reference; - var cb = (Callback) f.type_reference.data_type; + var cb = (Delegate) f.type_reference.data_type; /* check whether method matches callback type */ if (!cb.matches_method (m)) { diff --git a/vala/valasignal.vala b/vala/valasignal.vala index b63a70d..f22015c 100644 --- a/vala/valasignal.vala +++ b/vala/valasignal.vala @@ -1,6 +1,6 @@ /* valasignal.vala * - * Copyright (C) 2006-2007 Jürg Billeter + * Copyright (C) 2006-2008 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -44,7 +44,7 @@ public class Vala.Signal : Member, Lockable { public bool has_emitter { get; set; } private Gee.List parameters = new ArrayList (); - private Callback generated_callback; + private Delegate generated_delegate; private string cname; @@ -78,14 +78,14 @@ public class Vala.Signal : Member, Lockable { } /** - * Returns generated callback to be used for signal handlers. + * Returns generated delegate to be used for signal handlers. * - * @return callback + * @return delegate */ - public Callback! get_callback () { - if (generated_callback == null) { - generated_callback = new Callback (null, return_type); - generated_callback.instance = true; + public Delegate! get_delegate () { + if (generated_delegate == null) { + generated_delegate = new Delegate (null, return_type); + generated_delegate.instance = true; ReferenceType sender_type; if (parent_symbol is Class) { @@ -94,14 +94,14 @@ public class Vala.Signal : Member, Lockable { sender_type = new InterfaceType ((Interface) parent_symbol); } var sender_param = new FormalParameter ("sender", sender_type); - generated_callback.add_parameter (sender_param); + generated_delegate.add_parameter (sender_param); foreach (FormalParameter! param in parameters) { - generated_callback.add_parameter (param); + generated_delegate.add_parameter (param); } } - return generated_callback; + return generated_delegate; } /** diff --git a/vala/valasymbolresolver.vala b/vala/valasymbolresolver.vala index eaf9d52..0872f3d 100644 --- a/vala/valasymbolresolver.vala +++ b/vala/valasymbolresolver.vala @@ -109,7 +109,7 @@ public class Vala.SymbolResolver : CodeVisitor { current_scope = current_scope.parent_scope; } - public override void visit_callback (Callback! cb) { + public override void visit_delegate (Delegate! cb) { current_scope = cb.scope; cb.accept_children (this); @@ -231,8 +231,8 @@ public class Vala.SymbolResolver : CodeVisitor { if (sym is TypeParameter) { type.type_parameter = (TypeParameter) sym; } else if (sym is Typesymbol) { - if (sym is Callback) { - type = new DelegateType ((Callback) sym); + if (sym is Delegate) { + type = new DelegateType ((Delegate) sym); } else { type.data_type = (Typesymbol) sym; } @@ -254,8 +254,8 @@ public class Vala.SymbolResolver : CodeVisitor { return new InvalidType (); } if (sym is Typesymbol) { - if (sym is Callback) { - type = new DelegateType ((Callback) sym); + if (sym is Delegate) { + type = new DelegateType ((Delegate) sym); } else { type.data_type = (Typesymbol) sym; } diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala index 322d7ff..20a6556 100644 --- a/vapigen/valagidlparser.vala +++ b/vapigen/valagidlparser.vala @@ -77,8 +77,8 @@ public class Vala.GIdlParser : CodeVisitor { visit_type (en); } - public override void visit_callback (Callback! cb) { - visit_type (cb); + public override void visit_delegate (Delegate! d) { + visit_type (d); } private void visit_type (Typesymbol! t) { @@ -219,12 +219,12 @@ public class Vala.GIdlParser : CodeVisitor { foreach (weak IdlNode node in module.entries) { if (node.type == IdlNodeTypeId.CALLBACK) { - var cb = parse_callback ((IdlNodeFunction) node); + var cb = parse_delegate ((IdlNodeFunction) node); if (cb == null) { continue; } cb.name = fix_type_name (cb.name, ns); - ns.add_callback (cb); + ns.add_delegate (cb); current_source_file.add_node (cb); } else if (node.type == IdlNodeTypeId.STRUCT) { parse_struct ((IdlNodeStruct) node, ns, module); @@ -270,7 +270,7 @@ public class Vala.GIdlParser : CodeVisitor { return ns; } - private Callback parse_callback (IdlNodeFunction! f_node) { + private Delegate parse_delegate (IdlNodeFunction! f_node) { weak IdlNode node = (IdlNode) f_node; var attributes = get_attributes (node.name); @@ -285,7 +285,7 @@ public class Vala.GIdlParser : CodeVisitor { } } - var cb = new Callback (node.name, parse_param (f_node.result), current_source_reference); + var cb = new Delegate (node.name, parse_param (f_node.result), current_source_reference); cb.access = SymbolAccessibility.PUBLIC; foreach (weak IdlNodeParam param in f_node.parameters) { -- 2.7.4