~ubuntu-branches/ubuntu/utopic/castle-game-engine/utopic

« back to all changes in this revision

Viewing changes to doc/pasdoc/html/CastleScript.TCasScriptFunction.html

  • Committer: Package Import Robot
  • Author(s): Abou Al Montacir
  • Date: 2013-04-27 18:06:40 UTC
  • Revision ID: package-import@ubuntu.com-20130427180640-eink4nmwzuivez1c
Tags: upstream-4.0.1
ImportĀ upstreamĀ versionĀ 4.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
 
2
<html>
 
3
<head>
 
4
<title>Castle Game Engine: CastleScript: Class TCasScriptFunction</title>
 
5
<meta name="generator" content="PasDoc 0.12.1">
 
6
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
 
7
<link rel="StyleSheet" type="text/css" href="pasdoc.css">
 
8
</head>
 
9
<body>
 
10
<table class="container"><tr><td class="navigation">
 
11
<h2>Castle Game Engine</h2><p><a href="introduction.html" class="navigation">Introduction</a></p><p><a href="AllUnits.html" class="navigation">Units</a></p><p><a href="ClassHierarchy.html" class="navigation">Class Hierarchy</a></p><p><a href="AllClasses.html" class="navigation">Classes, Interfaces, Objects and Records</a></p><p><a href="AllTypes.html" class="navigation">Types</a></p><p><a href="AllVariables.html" class="navigation">Variables</a></p><p><a href="AllConstants.html" class="navigation">Constants</a></p><p><a href="AllFunctions.html" class="navigation">Functions and Procedures</a></p><p><a href="AllIdentifiers.html" class="navigation">Identifiers</a></p></td><td class="content">
 
12
<a name="TCasScriptFunction"></a><h1 class="cio">Class TCasScriptFunction</h1>
 
13
<table class="sections wide_list">
 
14
<tr>
 
15
<td><a class="section" href="#PasDoc-Description">Description</a></td><td><a class="section" href="#PasDoc-Hierarchy">Hierarchy</a></td><td>Fields</td><td><a class="section" href="#PasDoc-Methods">Methods</a></td><td><a class="section" href="#PasDoc-Properties">Properties</a></td></tr></table>
 
16
<a name="PasDoc-Description"></a><h2 class="unit">Unit</h2>
 
17
<p class="unitlink">
 
18
<a  href="CastleScript.html">CastleScript</a></p>
 
19
<h2 class="declaration">Declaration</h2>
 
20
<p class="declaration">
 
21
<code>type TCasScriptFunction = class(<a class="normal" href="CastleScript.TCasScriptExpression.html">TCasScriptExpression</a>)</code></p>
 
22
<h2 class="description">Description</h2>
 
23
<div class="nodescription">no description available, TCasScriptExpression description follows</div><a name="PasDoc-Hierarchy"></a><h2 class="hierarchy">Hierarchy</h2>
 
24
<ul class="hierarchy"><li class="ancestor">TObject</li>
 
25
<li class="ancestor"><a class="normal" href="CastleScript.TCasScriptExpression.html">TCasScriptExpression</a></li>
 
26
<li class="thisitem">TCasScriptFunction</li></ul><h2 class="overview">Overview</h2>
 
27
<a name="PasDoc-Methods"></a><h3 class="summary">Methods</h3>
 
28
<table class="summary wide_list">
 
29
<tr class="list">
 
30
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
31
<td class="itemcode"><code>constructor <b><a  href="CastleScript.TCasScriptFunction.html#Create">Create</a></b>(AArgs: <a  href="CastleScript.TCasScriptExpressionList.html">TCasScriptExpressionList</a>); overload;</code></td>
 
32
</tr>
 
33
<tr class="list2">
 
34
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
35
<td class="itemcode"><code>constructor <b><a  href="CastleScript.TCasScriptFunction.html#Create">Create</a></b>(const AArgs: array of <a  href="CastleScript.TCasScriptExpression.html">TCasScriptExpression</a>); overload;</code></td>
 
36
</tr>
 
37
<tr class="list">
 
38
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
39
<td class="itemcode"><code>destructor <b><a  href="CastleScript.TCasScriptFunction.html#Destroy">Destroy</a></b>; override;</code></td>
 
40
</tr>
 
41
<tr class="list2">
 
42
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
43
<td class="itemcode"><code>class function <b><a  href="CastleScript.TCasScriptFunction.html#Name">Name</a></b>: string; virtual;</code></td>
 
44
</tr>
 
45
<tr class="list">
 
46
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
47
<td class="itemcode"><code>class function <b><a  href="CastleScript.TCasScriptFunction.html#ShortName">ShortName</a></b>: string; virtual; abstract;</code></td>
 
48
</tr>
 
49
<tr class="list2">
 
50
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
51
<td class="itemcode"><code>class function <b><a  href="CastleScript.TCasScriptFunction.html#InfixOperatorName">InfixOperatorName</a></b>: string; virtual;</code></td>
 
52
</tr>
 
53
<tr class="list">
 
54
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
55
<td class="itemcode"><code>class function <b><a  href="CastleScript.TCasScriptFunction.html#GreedyArgumentsCalculation">GreedyArgumentsCalculation</a></b>: Integer; virtual;</code></td>
 
56
</tr>
 
57
<tr class="list2">
 
58
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
59
<td class="itemcode"><code>class function <b><a  href="CastleScript.TCasScriptFunction.html#ArgumentMustBeAssignable">ArgumentMustBeAssignable</a></b>(const Index: Integer): boolean; virtual;</code></td>
 
60
</tr>
 
61
</table>
 
62
<a name="PasDoc-Properties"></a><h3 class="summary">Properties</h3>
 
63
<table class="summary wide_list">
 
64
<tr class="list">
 
65
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
66
<td class="itemcode"><code>property <b><a  href="CastleScript.TCasScriptFunction.html#Args">Args</a></b>: <a  href="CastleScript.TCasScriptExpressionList.html">TCasScriptExpressionList</a> read FArgs;</code></td>
 
67
</tr>
 
68
</table>
 
69
<h2 class="description">Description</h2>
 
70
<h3 class="detail">Methods</h3>
 
71
<table class="detail wide_list">
 
72
<tr class="list">
 
73
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
74
<td class="itemcode"><a name="Create"></a><code>constructor <b>Create</b>(AArgs: <a  href="CastleScript.TCasScriptExpressionList.html">TCasScriptExpressionList</a>); overload;</code></td>
 
75
</tr>
 
76
<tr><td colspan="2">
 
77
<p>
 
78
Constructor initializing Args from given <a class="normal" href="CastleScript.TCasScriptExpressionList.html">TCasScriptExpressionList</a>. AArgs list contents is copied, i.e. AArgs refence is not stored or freed by <a class="normal" href="CastleScript.TCasScriptFunction.html">TCasScriptFunction</a>. But items on AArags are not copied recursively, we copy references from AArags items, and so we become their owners.
 
79
 
 
80
<p></p>
 
81
<h6 class="description_section">Exceptions raised</h6>
 
82
<dl class="exceptions_raised">
 
83
<dt><a class="normal" href="CastleScript.ECasScriptFunctionArgumentsError.html">ECasScriptFunctionArgumentsError</a></dt>
 
84
<dd>if you specified invalid number of arguments for this function.</dd>
 
85
</dl>
 
86
</td></tr>
 
87
</table>
 
88
<table class="detail wide_list">
 
89
<tr class="list">
 
90
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
91
<td class="itemcode"><a name="Create"></a><code>constructor <b>Create</b>(const AArgs: array of <a  href="CastleScript.TCasScriptExpression.html">TCasScriptExpression</a>); overload;</code></td>
 
92
</tr>
 
93
<tr><td colspan="2">
 
94
&nbsp;</td></tr>
 
95
</table>
 
96
<table class="detail wide_list">
 
97
<tr class="list">
 
98
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
99
<td class="itemcode"><a name="Destroy"></a><code>destructor <b>Destroy</b>; override;</code></td>
 
100
</tr>
 
101
<tr><td colspan="2">
 
102
&nbsp;</td></tr>
 
103
</table>
 
104
<table class="detail wide_list">
 
105
<tr class="list">
 
106
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
107
<td class="itemcode"><a name="Name"></a><code>class function <b>Name</b>: string; virtual;</code></td>
 
108
</tr>
 
109
<tr><td colspan="2">
 
110
<p>
 
111
Long function name for user. This is possibly with spaces, parenthesis and other funny characters. It will be used in error messages and such to describe this function.
 
112
 
 
113
<p>Default implementation in this class simply returns <a class="normal" href="CastleScript.TCasScriptFunction.html#ShortName">ShortName</a>. This should be suitable for most &quot;norma&quot; functions.</p>
 
114
</td></tr>
 
115
</table>
 
116
<table class="detail wide_list">
 
117
<tr class="list">
 
118
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
119
<td class="itemcode"><a name="ShortName"></a><code>class function <b>ShortName</b>: string; virtual; abstract;</code></td>
 
120
</tr>
 
121
<tr><td colspan="2">
 
122
<p>
 
123
Short function name, for the parser. This is the name of the function for use in expressions like &quot;function_name(arg_1, arg_2 ... , arg_n)&quot;.
 
124
 
 
125
<p>This can be empty string ('') if no such name for this function exists, then the logic to parse this function expressions must be somehow built in the parser (for example, operators use this: they are just normal functions, <a class="normal" href="CastleScript.TCasScriptFunction.html">TCasScriptFunction</a>, with <code>ShortName</code> = '' and special support in the parser).</p>
 
126
</td></tr>
 
127
</table>
 
128
<table class="detail wide_list">
 
129
<tr class="list">
 
130
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
131
<td class="itemcode"><a name="InfixOperatorName"></a><code>class function <b>InfixOperatorName</b>: string; virtual;</code></td>
 
132
</tr>
 
133
<tr><td colspan="2">
 
134
<p>
 
135
Function name when used as an infix operator.
 
136
 
 
137
<p>Empty string ('') if no such name for this function. This is returned by default implementation of this in this class.
 
138
 
 
139
<p>This does require cooperation from the parser to actually work, that is you cannot simply define new operators by registering new <a class="normal" href="CastleScript.TCasScriptFunction.html">TCasScriptFunction</a> with <code>InfixOperatorName</code> &lt;&gt; ''. For now.
 
140
 
 
141
<p>Note that at least one of <a class="normal" href="CastleScript.TCasScriptFunction.html#ShortName">ShortName</a> and <code>InfixOperatorName</code> must not be empty.
 
142
 
 
143
<p>The only exception is the <a class="normal" href="CastleScriptCoreFunctions.TCasScriptNegate.html">TCasScriptNegate</a> function, that is neither infix operator nor a usual function that must be specified as &quot;function_name(arguments)&quot;. So this is an exception, and if there will be a need, I shall fix this (probably by introducing some third field, like PrefixOperatorName ?)
 
144
 
 
145
<p>Note 2 things:
 
146
 
 
147
<p></p>
 
148
 
 
149
<ol class="paragraph_spacing">
 
150
  <li value="1"><p> Function that can be used as infix operator (i.e. has <code>InfixOperatorName</code> &lt;&gt; '') is not necessary binary operator, i.e. <code>InfixOperatorName</code> &lt;&gt; '' does not determine the value of ArgsCount. This way I was able to define infix operators +, -, * etc. that take any number of arguments and operators like &circ; and &gt; that always take 2 arguments.</p></li>
 
151
  <li value="2"><p> Function may have both <a class="normal" href="CastleScript.TCasScriptFunction.html#ShortName">ShortName</a> &lt;&gt; '' and <code>InfixOperatorName</code> &lt;&gt; ''. E.g. <a class="normal" href="CastleScriptCoreFunctions.TCasScriptPower.html">TCasScriptPower</a> can be used as &quot;Power(3, 1.5)&quot; or &quot;3 &circ; 1.5&quot;.</p></li>
 
152
</ol>
 
153
 
 
154
<p></p>
 
155
</td></tr>
 
156
</table>
 
157
<table class="detail wide_list">
 
158
<tr class="list">
 
159
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
160
<td class="itemcode"><a name="GreedyArgumentsCalculation"></a><code>class function <b>GreedyArgumentsCalculation</b>: Integer; virtual;</code></td>
 
161
</tr>
 
162
<tr><td colspan="2">
 
163
<p>
 
164
Specify which arguments are calculated before function handler is called.
 
165
 
 
166
<p>If = -1 (default value returned by implementation in this class) then all arguments are greedily calculated, which simply means that all arguments are calculated before executing function handler. This is the usual and expected behavior of normal functions. It's also a prerequisite for most of overloaded things to work, since we need to know types of <i>calculated</i> arguments (<a class="normal" href="CastleScript.TCasScriptValue.html">TCasScriptValue</a> classes) before we choose overloaded handler for function.
 
167
 
 
168
<p>If this is &gt;= 0, then arguments with index &gt;= of this will not be calculated before handler execution. Since their type is unknown, they will match any type in handler's ArgumentClasses. Your handler will receive <code>Nil</code> in their places, and is responsible for calling their Execute on it's own if needed.
 
169
 
 
170
<p>This is particularly suited for implementing control-flow instructions, like &quot;if&quot; and &quot;while&quot;, as normal functions inside <a class="normal" href="CastleScript.html">CastleScript</a>. For example, &quot;if&quot; will have <code>GreedyArgumentsCalculation</code> = 1, so the first argument (condition) will be calculated, but the execution of 2nd or 3rd argument (&quot;then&quot; code or &quot;else&quot; code) will be left to the handler.</p>
 
171
</td></tr>
 
172
</table>
 
173
<table class="detail wide_list">
 
174
<tr class="list">
 
175
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
176
<td class="itemcode"><a name="ArgumentMustBeAssignable"></a><code>class function <b>ArgumentMustBeAssignable</b>(const Index: Integer): boolean; virtual;</code></td>
 
177
</tr>
 
178
<tr><td colspan="2">
 
179
<p>
 
180
Which arguments should be assignable by this function.
 
181
 
 
182
<p>Default implementation in <a class="normal" href="CastleScript.TCasScriptFunction.html">TCasScriptFunction</a> just returns <code>False</code> always. If you're making a function that changes it's argument (like assignment operator, or vector_set, array_set and such) you want to override this.
 
183
 
 
184
<p>This is actually checked by CheckArguments, called from constructors.</p>
 
185
</td></tr>
 
186
</table>
 
187
<h3 class="detail">Properties</h3>
 
188
<table class="detail wide_list">
 
189
<tr class="list">
 
190
<td class="visibility"><a  href="legend.html"><img  src="public.gif" alt="Public" title="Public"></a></td>
 
191
<td class="itemcode"><a name="Args"></a><code>property <b>Args</b>: <a  href="CastleScript.TCasScriptExpressionList.html">TCasScriptExpressionList</a> read FArgs;</code></td>
 
192
</tr>
 
193
<tr><td colspan="2">
 
194
<p>
 
195
Function arguments. Don't modify this list after function is created (although you can modify values inside arguments).</p>
 
196
</td></tr>
 
197
</table>
 
198
<hr noshade size="1"><span class="appinfo"><em>Generated by <a  href="http://pasdoc.sourceforge.net/">PasDoc 0.12.1</a> on 2013-02-04 20:26:52</em>
 
199
</span>
 
200
</td></tr></table></body></html>