summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2022-09-15 20:46:05 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2022-09-15 20:46:05 +0200
commit67ad727a0b5d9909ed4e80fc93691eee969d0200 (patch)
treefc3202193d480f3d1657d9f907add41622b8f051 /doc
parent841ac8c8c963e6fe0e74f82b7880a7049704bf14 (diff)
downloadvala-67ad727a0b5d9909ed4e80fc93691eee969d0200.tar.gz
manual: Update from wiki.gnome.org
Diffstat (limited to 'doc')
-rw-r--r--doc/manual/manual.xml14
1 files changed, 6 insertions, 8 deletions
diff --git a/doc/manual/manual.xml b/doc/manual/manual.xml
index 939824aa8..102e8681b 100644
--- a/doc/manual/manual.xml
+++ b/doc/manual/manual.xml
@@ -1128,7 +1128,7 @@
<section>
<title>Delegates</title>
<para>A delegate declaration defines a method type: a type that can be invoked, accepting a set of values of certain types, and returning a value of a set type. In Vala, methods are not first-class objects, and as such cannot be created dynamically; however, any method can be considered to be an instance of a delegate's type, provided that the method signature matches that of the delegate. </para>
-<para>Methods are considered to be an immutable reference type. Any method can be referred to by name as an expression returning a reference to that method - this can be assigned to a field (or variable, or parameter), or else invoked directly as a standard method invocation (see <ulink url="http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/Expressions#Invocation_expressions">Expressions/Invocation expressions</ulink>). </para>
+<para>Methods are considered to have an immutable reference type. Any method can be referred to by name as an expression returning a reference to that method - this can be assigned to a field (or variable, or parameter), or else invoked directly as a standard method invocation (see <ulink url="http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/Expressions#Invocation_expressions">Expressions/Invocation expressions</ulink>). </para>
<section>
<title>Types of delegate</title>
@@ -1141,17 +1141,13 @@
<title>Delegate declaration</title>
<para>The syntax for declaring a delegate changes slightly based on what sort of delegate is being declared. This section shows the form for a namespace delegate. Many of the parts of the declaration are common to all types, so sections from here are referenced from class delegates, interface delegates, etc. </para><itemizedlist><listitem override="none">
<para>delegate-declaration:</para><itemizedlist><listitem override="none">
-<para>instance-delegate-declaration</para>
-<para> static-delegate-declaration</para></listitem></itemizedlist>
-<para> instance-delegate-declaration:</para><itemizedlist><listitem override="none">
<para>[ access-modifier ] <emphasis role="strong">delegate</emphasis> return-type qualified-delegate-name <emphasis role="strong">(</emphasis> method-params-list <emphasis role="strong">)</emphasis> [ <emphasis role="strong">throws</emphasis> error-list ] <emphasis role="strong">;</emphasis></para></listitem></itemizedlist>
-<para> static-delegate-declaration:</para><itemizedlist><listitem override="none">
-<para>[ access-modifier ] <emphasis role="strong">static</emphasis> <emphasis role="strong">delegate</emphasis> return-type qualified-delegate-name <emphasis role="strong">(</emphasis> method-params-list <emphasis role="strong">)</emphasis> [ <emphasis role="strong">throws</emphasis> error-list ] <emphasis role="strong">;</emphasis></para></listitem></itemizedlist>
<para> qualified-delegate-name:</para><itemizedlist><listitem override="none">
<para>[ qualified-namespace-name <emphasis role="strong">.</emphasis> ] delegate-name</para></listitem></itemizedlist>
<para> delegate-name:</para><itemizedlist><listitem override="none">
<para>identifier</para></listitem></itemizedlist></listitem></itemizedlist>
<para>Parts of this syntax are based on the respective sections of the method declaration syntax (see <ulink url="http://wiki.gnome.org/Projects/Vala/Manual/Export/Projects/Vala/Manual/Methods#">Methods</ulink> for details). </para>
+<para>By default, delegates are instance delegates. To declare a static delegate, add the annotation <code>[CCode (has_target = false)]</code>; see the examples below. (Static delegates used to be declared by adding the keyword <code>static</code> before <code>delegate</code> instead of using the annotation. This syntax is still accepted by the compiler, but will cause a warning to be given.) </para>
</section>
<section>
@@ -1163,13 +1159,15 @@
<section>
<title>Examples</title>
<para>Defining delegates: </para><programlisting format="linespecific" language="vala" linenumbering="numbered" startinglinenumber="1"><lineannotation><![CDATA[// Static delegate taking two ints, returning void:]]></lineannotation>
-<lineannotation/><token><![CDATA[static]]></token><![CDATA[ ]]><token><![CDATA[void]]></token><![CDATA[ ]]><methodname><![CDATA[DelegateName]]></methodname><![CDATA[ (]]><token><![CDATA[int]]></token><![CDATA[ ]]><methodname><![CDATA[a]]></methodname><![CDATA[, ]]><token><![CDATA[int]]></token><![CDATA[ ]]><methodname><![CDATA[b]]></methodname><![CDATA[);]]>
+<lineannotation/><![CDATA[[]]><methodname><![CDATA[CCode]]></methodname><![CDATA[ (]]><methodname><![CDATA[has_target]]></methodname><![CDATA[ = ]]><token><![CDATA[false]]></token><![CDATA[)]]]>
+<token><![CDATA[void]]></token><![CDATA[ ]]><methodname><![CDATA[DelegateName]]></methodname><![CDATA[ (]]><token><![CDATA[int]]></token><![CDATA[ ]]><methodname><![CDATA[a]]></methodname><![CDATA[, ]]><token><![CDATA[int]]></token><![CDATA[ ]]><methodname><![CDATA[b]]></methodname><![CDATA[);]]>
<lineannotation><![CDATA[// Instance delegate with the same signature:]]></lineannotation>
<lineannotation/><token><![CDATA[void]]></token><![CDATA[ ]]><methodname><![CDATA[DelegateName]]></methodname><![CDATA[ (]]><token><![CDATA[int]]></token><![CDATA[ ]]><methodname><![CDATA[a]]></methodname><![CDATA[, ]]><token><![CDATA[int]]></token><![CDATA[ ]]><methodname><![CDATA[b]]></methodname><![CDATA[);]]>
<lineannotation><![CDATA[// Static delegate which may throw an error:]]></lineannotation>
-<lineannotation/><token><![CDATA[static]]></token><![CDATA[ ]]><token><![CDATA[void]]></token><![CDATA[ ]]><methodname><![CDATA[DelegateName]]></methodname><![CDATA[ () ]]><token><![CDATA[throws]]></token><![CDATA[ ]]><methodname><![CDATA[GLib]]></methodname><![CDATA[.]]><methodname><![CDATA[Error]]></methodname><![CDATA[;]]>
+<lineannotation/><![CDATA[[]]><methodname><![CDATA[CCode]]></methodname><![CDATA[ (]]><methodname><![CDATA[has_target]]></methodname><![CDATA[ = ]]><token><![CDATA[false]]></token><![CDATA[)]]]>
+<token><![CDATA[void]]></token><![CDATA[ ]]><methodname><![CDATA[DelegateName]]></methodname><![CDATA[ () ]]><token><![CDATA[throws]]></token><![CDATA[ ]]><methodname><![CDATA[GLib]]></methodname><![CDATA[.]]><methodname><![CDATA[Error]]></methodname><![CDATA[;]]>
</programlisting>
<para>Invoking delegates, and passing as parameters. </para><programlisting format="linespecific" language="vala" linenumbering="numbered" startinglinenumber="1"><token><![CDATA[void]]></token><![CDATA[ ]]><methodname><![CDATA[f1]]></methodname><![CDATA[(]]><token><![CDATA[int]]></token><![CDATA[ ]]><methodname><![CDATA[a]]></methodname><![CDATA[) { ]]><methodname><![CDATA[stdout]]></methodname><![CDATA[.]]><methodname><![CDATA[printf]]></methodname><![CDATA[(]]><phrase><![CDATA["]]></phrase><phrase><![CDATA[%d]]></phrase><![CDATA[
]]><phrase><![CDATA["]]></phrase><![CDATA[, ]]><methodname><![CDATA[a]]></methodname><![CDATA[); }]]>