]> git.xonotic.org Git - xonotic/xonotic.wiki.git/blob - NewQC.textile
(Commit created by redmine exporter script from page "NewQC" version 15)
[xonotic/xonotic.wiki.git] / NewQC.textile
1 h1. New QC Syntax
2
3 It is possible that at some point we decide to switch QC-compiler which requires some changes to the code.
4
5 h2. Clean syntax:
6
7 In fteqcc there are some ambiguities regarding fieldpointers, function pointers, and field-return-types etc.
8 A clean syntax is needed, *SUGGESTIONS ARE WELCOME*, my(blub's) current suggestion is:
9
10 |_.definition|_.meaning|
11 |<code>float foo(void)</code>|     function|
12 |<code>float foo*(void)</code>|    function pointer|
13 |<code>.float foo(void)</code>|    member: method/function pointer|
14 |<code>..float foo(void)</code>|/2. member: method/function pointer returning .float|
15 |<code>..*float foo(void)</code>|
16 |<code>.*float foo*(void)</code>|  function pointer returning .float|
17 |<code>.*float</code>|             fieldpointer|
18 |<code>.*float foo(void)</code>|   fieldpointer: method/function pointer|
19 |<code>.*.float foo(void)</code>|  fieldpointer: method/function pointer returning .float|
20
21
22 Additionally, at places where the definition of members or global functions is not allowed, they will be treated like fieldpointers.
23 So inside parameterlists or a functionbody the list is as follows:
24
25 |_.definition|_.meaning|
26 |<code>float foo(void)</code>|     *function pointer*|
27 |<code>float foo*(void)</code>|    function pointer|
28 |<code>.float foo(void)</code>|    *fieldpointer: method/function pointer*|
29 |<code>..float foo(void)</code>|/2. *fieldpointer: method/function pointer returning .float*|
30 |<code>..*float foo(void)</code>|
31 |<code>.*float foo*(void)</code>|  function pointer returning .float|
32 |<code>.*float</code>|             fieldpointer|
33 |<code>.*float foo(void)</code>|   fieldpointer: method/function pointer|
34 |<code>.*.float foo(void)</code>|  fieldpointer: method/function pointer returning .float|
35
36 h2. Function definitions:
37
38 The old-style QC way of defining functions will not be supported, so
39 <pre>void(float x) something = { ... }</pre>
40 becomes
41 <pre>void something(float x) { ... }</pre>
42 which is the most common way to define functions in the xonotic code already anyway.
43
44 h2. Constants:
45
46 From now on, the code
47 <pre>float x = 3</pre>
48 does what the first instinct tells you: it creates a global with the initial value 3. Contrary to old QC, where it created a constant.
49 To create a constant use:
50 <pre>const float x = 3</pre>
51
52 h2. Extendable functions:
53
54 Since menuQC has some funny macro: ACCUMULATE_FUNCTIONS, it seemed like a nice syntactical sugar to allow the following:
55
56 <pre>float myfunc() extendable
57 {
58     float mylocal = 3;
59 }
60
61 /* other code */
62
63 float myfunc()
64 {
65     mylocal += 5;
66     if (mylocal > 20)
67         return mylocal;
68 }
69
70 /* optionally: */
71 float myfunc() final
72 {
73     return 3;
74 }
75 </pre>