1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
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">
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">
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>
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">
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>
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>
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>
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>
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>
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>
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>
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>
62
<a name="PasDoc-Properties"></a><h3 class="summary">Properties</h3>
63
<table class="summary wide_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>
69
<h2 class="description">Description</h2>
70
<h3 class="detail">Methods</h3>
71
<table class="detail wide_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>
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.
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>
88
<table class="detail wide_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>
96
<table class="detail wide_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>
104
<table class="detail wide_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>
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.
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 "norma" functions.</p>
116
<table class="detail wide_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>
123
Short function name, for the parser. This is the name of the function for use in expressions like "function_name(arg_1, arg_2 ... , arg_n)".
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>
128
<table class="detail wide_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>
135
Function name when used as an infix operator.
137
<p>Empty string ('') if no such name for this function. This is returned by default implementation of this in this class.
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> <> ''. For now.
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.
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 "function_name(arguments)". So this is an exception, and if there will be a need, I shall fix this (probably by introducing some third field, like PrefixOperatorName ?)
149
<ol class="paragraph_spacing">
150
<li value="1"><p> Function that can be used as infix operator (i.e. has <code>InfixOperatorName</code> <> '') is not necessary binary operator, i.e. <code>InfixOperatorName</code> <> '' 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 ˆ and > 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> <> '' and <code>InfixOperatorName</code> <> ''. E.g. <a class="normal" href="CastleScriptCoreFunctions.TCasScriptPower.html">TCasScriptPower</a> can be used as "Power(3, 1.5)" or "3 ˆ 1.5".</p></li>
157
<table class="detail wide_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>
164
Specify which arguments are calculated before function handler is called.
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.
168
<p>If this is >= 0, then arguments with index >= 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.
170
<p>This is particularly suited for implementing control-flow instructions, like "if" and "while", as normal functions inside <a class="normal" href="CastleScript.html">CastleScript</a>. For example, "if" will have <code>GreedyArgumentsCalculation</code> = 1, so the first argument (condition) will be calculated, but the execution of 2nd or 3rd argument ("then" code or "else" code) will be left to the handler.</p>
173
<table class="detail wide_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>
180
Which arguments should be assignable by this function.
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.
184
<p>This is actually checked by CheckArguments, called from constructors.</p>
187
<h3 class="detail">Properties</h3>
188
<table class="detail wide_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>
195
Function arguments. Don't modify this list after function is created (although you can modify values inside arguments).</p>
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>
200
</td></tr></table></body></html>