]> git.xonotic.org Git - xonotic/xonotic.wiki.git/blob - NewQC.textile
(Commit created by redmine exporter script from page "NewQC" version 13)
[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 |_.definition|_.meaning|
23 |<code>float foo(void)</code>|     function|
24 |<code>float foo*(void)</code>|    function pointer|
25 |<code>.float foo(void)</code>|    member: method/function pointer|
26 |<code>..float foo(void)</code>| member: method/function pointer returning .float|
27 |<code>..*float .foo(void)</code>| Member function returning pointer to float field
28 |<code>.*float foo*(void)</code>|  function pointer returning .float|
29 |<code>.*float</code>|             fieldpointer|
30 |<code>.*float foo(void)</code>|   fieldpointer: method/function pointer|
31 |<code>.*.float foo(void)</code>|  fieldpointer: method/function pointer returning .float|
32
33 Additionally, at places where the definition of members or global functions is not allowed, they will be treated like fieldpointers.
34 So inside parameterlists or a functionbody the list is as follows:
35
36 |_.definition|_.meaning|
37 |<code>float foo(void)</code>|     *function pointer*|
38 |<code>float foo*(void)</code>|    function pointer|
39 |<code>.float foo(void)</code>|    *fieldpointer: method/function pointer*|
40 |<code>..float foo(void)</code>|/2. *fieldpointer: method/function pointer returning .float*|
41 |<code>..*float foo(void)</code>|
42 |<code>.*float foo*(void)</code>|  function pointer returning .float|
43 |<code>.*float</code>|             fieldpointer|
44 |<code>.*float foo(void)</code>|   fieldpointer: method/function pointer|
45 |<code>.*.float foo(void)</code>|  fieldpointer: method/function pointer returning .float|
46
47 h2. Function definitions:
48
49 The old-style QC way of defining functions will not be supported, so
50 <pre>void(float x) something = { ... }</pre>
51 becomes
52 <pre>void something(float x) { ... }</pre>
53 which is the most common way to define functions in the xonotic code already anyway.
54
55 h2. Constants:
56
57 From now on, the code
58 <pre>float x = 3</pre>
59 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.
60 To create a constant use:
61 <pre>const float x = 3</pre>