-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
124 lines (88 loc) · 2.98 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
Vala/Very Quick Dice Roller
To see README about libvqdr, please see ./src/libvqdr/README
VQDR will consist of two parts, the backend library, and the front end.
The backend libray, libvqdr, provides the logic for parsing dice expression
strings, and doing the calculations needed to perform the dice rolls.
The frontend has yet to be written.
For up-to-date code, go to:
https://launchpad.net/vqdr
BUILDING
-------------
$ mkdir build
$ cd build
$ meson ..
$ ninja
-------------
DICE EXPRESSION SYNTAX
A dice expression is simple.
---- Basics ----
[n]d[m], [n]t[m] - [n] dices with [m] sides.
[e1] [op] [e2] - Use operator [op] on expressions [e1] and [e2]
[func]([e...]) - Use function [func] on the expression(s) [e...]
----------------
HACKING (DEVELOPMENT GUIDELINES)
Please use stardard vala naming convetion. This to make it as easy to read as
passible, and minimise any errors when interating with other libraries.
INDENTATION
Always use two spaces for indentation detween levels.
INTEGER TYPES
Use int[n] types instead of int and long. This to guarentee that the
behviour is the same on all platforms.
TYPE NAMES
All type names should start with a capital letter, and each word in the name
should start with a capital letter. No seperation should be made between
the words in the name.
--- vala ---
class ClownFactory {...}
------------
FUNCTIONS AND METHODS
Function and method namse should has the standard naming convetion of vala:
--- vala ---
void foo_bar (int something);
-----------
* There should be a space befor the paranthesis.
* Use underlines to seperate words in the function name.
It is advicable to have the function names as short as possible, but also
descriptive. Sometimes this leads to a copromise between readability, and
brevity.
VARIABELS
When defining variables use underlines between words:
--- vala ---
string my_fun_string;
-----------
ENUMS
When defining enums, make sure that the 0'th value is invalid, this to avoid
any potential NULL traps.
Always define a last value named _NUM_VAL, this will be used for validation
of data.
--- vala ---
enum Clowns {
INVALID = 0,
BENNY = 1,
CARL,
CRUSTY,
HOMER,
_NUM_VAL;
}
------------
It is advicable to define a to_string method for the enums. To keep track
of the to_string functions cases, it is advicable to add a static assert
to the body of the function to catch problems at compile time.
--- vala ---
enum Clowns {
...,
_NUM_VAL;
public string to_string () {
static_assert (Clowns._NUM_VAL == 4 + 1);
switch (this) {
case (BENNY):
return "BENNY";
case (CARL):
return "CARL";
....
default:
assert_not_reached ();
}
}
}
------------