Skip to content

Commit 5b620f7

Browse files
authored
Merge pull request GaijinEntertainment#1926 from GaijinEntertainment/new-documentation
updating documentation to new generator
2 parents 5c0c547 + fac301e commit 5b620f7

3,144 files changed

Lines changed: 42398 additions & 57310 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

daslib/algorithm.das

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ def lower_bound(a : array<auto(TT)>; f, l : int; val : TT const -&) {
7777
}
7878

7979
def lower_bound(a : array<auto(TT)>; val : TT const -&) {
80+
//! Returns an iterator pointing to the first element in the array that is not less than (i.e. greater or equal to) value, or length(a) if no such element is found.
8081
return lower_bound(a, 0, length(a), val)
8182
}
8283

8384
def lower_bound(a : array<auto(TT)>; f, l : int; value : auto(QQ); less : block<(a : TT const -&, b : QQ) : bool>) {
85+
//! Returns an iterator pointing to the first element in the range [first, last) that is not less than (i.e. greater or equal to) value, or last if no such element is found.
8486
assert(f >= 0 && f <= l, "lower bound first out of range")
8587
assert(l >= f && l <= length(a), "lower bound last out of range")
8688
var count = l - f
@@ -99,10 +101,13 @@ def lower_bound(a : array<auto(TT)>; f, l : int; value : auto(QQ); less : block<
99101
}
100102

101103
def lower_bound(a : array<auto(TT)>; value : auto(QQ); less : block<(a : TT const -&, b : QQ) : bool>) {
104+
//! Returns an iterator pointing to the first element in the array that is not less than (i.e. greater or equal to) value, or length(a) if no such element is found.
102105
return lower_bound(a, 0, length(a), value, less)
103106
}
104107

105108
def binary_search(a : array<auto(TT)>; val : TT const -&) {
109+
//! Returns true if an val appears within the array a.
110+
//! Array a must be sorted.
106111
let first = lower_bound(a, val)
107112
return (first != length(a)) && (!(val < a[first]))
108113
}
@@ -115,12 +120,16 @@ def binary_search(a : array<auto(TT)>; f, last : int; val : TT const -&) {
115120
}
116121

117122
def binary_search(a : array<auto(TT)>; val : TT const -&; less : block<(a, b : TT const -&) : bool>) {
123+
//! Returns true if an val appears within the array a.
124+
//! Array a must be sorted according to the provided less function.
118125
let first = lower_bound(a, val, less)
119126
let last = length(a)
120127
return (first != last) && (!invoke(less, val, a[first]))
121128
}
122129

123130
def binary_search(a : array<auto(TT)>; f, last : int; val : TT const -&; less : block<(a, b : TT const -&) : bool>) {
131+
//! Returns true if an val appears within the range [f, last).
132+
//! Array a must be sorted according to the provided less function.
124133
let first = lower_bound(a, f, last, val, less)
125134
return (first != last) && (!invoke(less, val, a[first]))
126135
}
@@ -129,20 +138,23 @@ def binary_search(a : array<auto(TT)>; f, last : int; val : TT const -&; less :
129138

130139
[expect_any_array(a)]
131140
def reverse(var a) {
141+
//! Reverses the elements of array a in place.
132142
unsafe {
133143
reverse(temp_array(a))
134144
}
135145
}
136146

137147
[expect_any_array(a)]
138148
def combine(a, b) {
149+
//! Returns array of the elements of a and then b.
139150
unsafe {
140151
return combine(temp_array(a), temp_array(b))
141152
}
142153
}
143154

144155
[expect_any_array(a)]
145156
def lower_bound(a; f, l : int; val) {
157+
//! Returns an iterator pointing to the first element in the range [first, last) that is not less than (i.e. greater or equal to) value, or last if no such element is found.
146158
static_if (typeinfo stripped_typename(a[0]) != typeinfo stripped_typename(val)) {
147159
concept_assert(false, "value type {typeinfo stripped_typename(val)} should be the same as array {typeinfo stripped_typename(a)} element type {typeinfo stripped_typename(a[0])}")
148160
return -1
@@ -155,6 +167,7 @@ def lower_bound(a; f, l : int; val) {
155167

156168
[expect_any_array(a)]
157169
def lower_bound(a; val) {
170+
//! Returns an iterator pointing to the first element in the array that is not less than (i.e. greater or equal to) value, or length(a) if no such element is found.
158171
static_if (typeinfo stripped_typename(a[0]) != typeinfo stripped_typename(val)) {
159172
concept_assert(false, "value type {typeinfo stripped_typename(val)} should be the same as array {typeinfo stripped_typename(a)} element type {typeinfo stripped_typename(a[0])}")
160173
return -1
@@ -167,6 +180,7 @@ def lower_bound(a; val) {
167180

168181
[expect_any_array(a)]
169182
def lower_bound(a; f, l : int; val : auto(TT); less : block<(a, b : TT const -&) : bool>) {
183+
//! Returns an iterator pointing to the first element in the range [first, last) that is not less than (i.e. greater or equal to) value, or last if no such element is found.
170184
static_if (typeinfo stripped_typename(a[0]) != typeinfo stripped_typename(val)) {
171185
concept_assert(false, "value type {typeinfo stripped_typename(val)} should be the same as array {typeinfo stripped_typename(a)} element type {typeinfo stripped_typename(a[0])}")
172186
return -1
@@ -179,6 +193,7 @@ def lower_bound(a; f, l : int; val : auto(TT); less : block<(a, b : TT const -&)
179193

180194
[expect_any_array(a)]
181195
def lower_bound(a; val : auto(TT); less : block<(a, b : TT const -&) : bool>) {
196+
//! Returns an iterator pointing to the first element in the array that is not less than (i.e. greater or equal to) value, or length(a) if no such element is found.
182197
static_if (typeinfo stripped_typename(a[0]) != typeinfo stripped_typename(val)) {
183198
concept_assert(false, "value type {typeinfo stripped_typename(val)} should be the same as array {typeinfo stripped_typename(a)} element type {typeinfo stripped_typename(a[0])}")
184199
return -1
@@ -191,6 +206,7 @@ def lower_bound(a; val : auto(TT); less : block<(a, b : TT const -&) : bool>) {
191206

192207
[expect_any_array(a)]
193208
def binary_search(a; val) {
209+
//! Returns true if an val appears within the array a.
194210
static_if (typeinfo stripped_typename(a[0]) != typeinfo stripped_typename(val)) {
195211
concept_assert(false, "value type {typeinfo stripped_typename(val)} should be the same as array {typeinfo stripped_typename(a)} element type {typeinfo stripped_typename(a[0])}")
196212
return -1
@@ -203,6 +219,7 @@ def binary_search(a; val) {
203219

204220
[expect_any_array(a)]
205221
def binary_search(a; f, last : int; val) {
222+
//! Returns true if an val appears within the range [f, last).
206223
static_if (typeinfo stripped_typename(a[0]) != typeinfo stripped_typename(val)) {
207224
concept_assert(false, "value type {typeinfo stripped_typename(val)} should be the same as array {typeinfo stripped_typename(a)} element type {typeinfo stripped_typename(a[0])}")
208225
return -1
@@ -215,6 +232,7 @@ def binary_search(a; f, last : int; val) {
215232

216233
[expect_any_array(a)]
217234
def binary_search(a; val : auto(TT); less : block<(a, b : TT const -&) : bool>) {
235+
//! Returns true if an val appears within the array a.
218236
static_if (typeinfo stripped_typename(a[0]) != typeinfo stripped_typename(val)) {
219237
concept_assert(false, "value type {typeinfo stripped_typename(val)} should be the same as array {typeinfo stripped_typename(a)} element type {typeinfo stripped_typename(a[0])}")
220238
return -1
@@ -227,6 +245,7 @@ def binary_search(a; val : auto(TT); less : block<(a, b : TT const -&) : bool>)
227245

228246
[expect_any_array(a)]
229247
def binary_search(a; f, last : int; val : auto(TT); less : block<(a, b : TT const -&) : bool>) {
248+
//! Returns true if an val appears within the range [f, last).
230249
static_if (typeinfo stripped_typename(a[0]) != typeinfo stripped_typename(val)) {
231250
concept_assert(false, "value type {typeinfo stripped_typename(val)} should be the same as array {typeinfo stripped_typename(a)} element type {typeinfo stripped_typename(a[0])}")
232251
return -1

daslib/archive.das

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class public MemSerializer : Serializer {
2828
pass // writing
2929
}
3030
def MemSerializer(from : array<uint8>) {
31+
//! Initialize the serializer for reading from the given data.
3132
data := from
3233
}
3334
def extractData : array<uint8> {
@@ -75,16 +76,16 @@ class public MemSerializer : Serializer {
7576
//! Sets the last error code.
7677
lastError = code
7778
}
78-
private data : array<uint8>
79-
private readOffset : int
80-
private lastError : string
79+
private data : array<uint8> //! internal data buffer
80+
private readOffset : int //! current reading offset
81+
private lastError : string //! last error code
8182
}
8283

8384
struct public Archive {
8485
//! Archive is a combination of serialization stream, and state (version, and reading status).
85-
version : uint
86-
reading : bool
87-
stream : Serializer?
86+
version : uint //! Version of the archive format.
87+
reading : bool //! True if the archive is for reading, false for writing.
88+
stream : Serializer? //! Serialization stream.
8889
}
8990

9091
def public serialize_raw(var arch : Archive; var value : auto(TT)&) {
@@ -116,6 +117,7 @@ def public serialize(var arch : Archive; var value : auto(TT)&) {
116117

117118
[expect_any_function(value)]
118119
def public serialize(var arch : Archive; var value : auto(TT)&) {
120+
//! Serializes function pointer by its mangled name hash.
119121
if (arch.reading) {
120122
var mnh : uint64
121123
arch |> read_raw(mnh)
@@ -131,19 +133,23 @@ def public serialize(var arch : Archive; var value : auto(TT)&) {
131133
}
132134

133135
def public serialize(var arch : Archive; var value : float3x3) {
136+
//! Serializes float3x3 matrix
134137
arch |> serialize_raw(value)
135138
}
136139

137140
def public serialize(var arch : Archive; var value : float3x4) {
141+
//! Serializes float3x4 matrix
138142
arch |> serialize_raw(value)
139143
}
140144

141145
def public serialize(var arch : Archive; var value : float4x4) {
146+
//! Serializes float4x4 matrix
142147
arch |> serialize_raw(value)
143148
}
144149

145150
[expect_any_struct(value)]
146151
def public serialize(var arch : Archive; var value : auto(TT)&) {
152+
//! Serializes struct by serializing each field.
147153
if (arch.reading) {
148154
delete value
149155
}
@@ -154,6 +160,7 @@ def public serialize(var arch : Archive; var value : auto(TT)&) {
154160

155161
[expect_any_tuple(value)]
156162
def public serialize(var arch : Archive; var value : auto(TT)&) {
163+
//! Serializes tuple by serializing each field.
157164
if (arch.reading) {
158165
delete value
159166
}
@@ -164,6 +171,7 @@ def public serialize(var arch : Archive; var value : auto(TT)&) {
164171

165172
[expect_any_variant(value)]
166173
def public serialize(var arch : Archive; var value : auto(TT)&) {
174+
//! Serializes variant by serializing the index and the active field.
167175
if (arch.reading) {
168176
delete value
169177
var index : int
@@ -181,12 +189,14 @@ def public serialize(var arch : Archive; var value : auto(TT)&) {
181189
}
182190

183191
def public serialize(var arch : Archive; var value : auto(TT)[]) {
192+
//! Serializes array by serializing its length and each element.
184193
for (element in value) {
185194
arch |> _::serialize(element)
186195
}
187196
}
188197

189198
def public serialize(var arch : Archive; var value : array<auto(TT)>) {
199+
//! Serializes array by serializing its length and each element.
190200
if (arch.reading) {
191201
var len : int
192202
unsafe {
@@ -207,6 +217,7 @@ def public serialize(var arch : Archive; var value : array<auto(TT)>) {
207217
}
208218

209219
def public serialize(var arch : Archive; var value : table<auto(KT); auto(VT)>) {
220+
//! Serializes table by serializing its length and each key-value pair.
210221
if (arch.reading) {
211222
var len : int
212223
arch |> read_raw(len)
@@ -228,6 +239,7 @@ def public serialize(var arch : Archive; var value : table<auto(KT); auto(VT)>)
228239
}
229240

230241
def public serialize(var arch : Archive; var value : string&) {
242+
//! Serializes string by serializing its length and characters.
231243
unsafe {
232244
if (arch.reading) {
233245
var len : int
@@ -253,6 +265,7 @@ def public serialize(var arch : Archive; var value : string&) {
253265
}
254266

255267
def public serialize(var arch : Archive; var value : auto(TT)?) {
268+
//! Serializes nullable type by serializing a flag and the value if present.
256269
if (arch.reading) {
257270
value = null
258271
}

daslib/array_boost.das

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require daslib/contracts
1212

1313
[unsafe_operation, template(a), unused_argument(a)]
1414
def private array_helper(var arr : auto implicit ==const; a : auto(TT)) : array<TT -const -#> {
15+
//! helper for temp_array with var argument
1516
var res : array<TT -const -#>
1617
let lenA = _::length(arr)
1718
if (lenA >= 1) {
@@ -24,6 +25,7 @@ def private array_helper(var arr : auto implicit ==const; a : auto(TT)) : array<
2425

2526
[unsafe_operation, template(a), unused_argument(a)]
2627
def private array_helper(arr : auto implicit ==const; a : auto(TT)) : array<TT -const -#> {
28+
//! helper for temp_array with const argument
2729
var res : array<TT -const -#>
2830
let lenA = _::length(arr)
2931
if (lenA >= 1) {
@@ -48,6 +50,11 @@ def public temp_array(var arr : auto implicit ==const) {
4850

4951
[unsafe_operation]
5052
def public temp_array(arr : auto implicit ==const) {
53+
//! Creates temporary array from the given object.
54+
//! Important requirements are:
55+
//! * object memory is linear
56+
//! * each element follows the next one directly, with the stride equal to size of the element
57+
//! * object memory does not change within the lifetime of the returned array
5158
unsafe {
5259
return <- array_helper(arr, decltype(arr[0]))
5360
}
@@ -61,6 +68,11 @@ def empty(v : auto(VecT)) {
6168

6269
[unsafe_operation, template(a), unused_argument(a)]
6370
def public temp_array(var data : auto? ==const; lenA : int; a : auto(TT)) : array<TT -const -#> {
71+
//! creates a temporary array from the given data pointer and length
72+
//! Important requirements are:
73+
//! * data pointer is valid and points to a memory block of at least lenA elements
74+
//! * each element follows the next one directly, with the stride equal to size of the element
75+
//! * data memory does not change within the lifetime of the returned array
6476
var res : array<TT -const -#>
6577
if (lenA >= 1) {
6678
unsafe {
@@ -72,6 +84,11 @@ def public temp_array(var data : auto? ==const; lenA : int; a : auto(TT)) : arra
7284

7385
[unsafe_operation, template(a), unused_argument(a)]
7486
def public temp_array(data : auto? ==const; lenA : int; a : auto(TT)) : array<TT -const -#> const {
87+
//! creates a temporary array from the given data pointer and length
88+
//! Important requirements are:
89+
//! * data pointer is valid and points to a memory block of at least lenA elements
90+
//! * each element follows the next one directly, with the stride equal to size of the element
91+
//! * data memory does not change within the lifetime of the returned array
7592
var res : array<TT -const -#>
7693
if (lenA >= 1) {
7794
unsafe {

daslib/ast_used.das

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,42 @@ require daslib/ast_boost
1010

1111
struct public OnlyUsedTypes {
1212
//! Collection of all structure and enumeration types that are used in the AST.
13-
st : table<Structure?; bool>
14-
en : table<Enumeration?; bool>
13+
st : table<Structure?> //! all structure types used
14+
en : table<Enumeration?> //! all enumeration types used
1515
}
1616

1717
class TypeVisitor : AstVisitor {
18-
usedTypes : OnlyUsedTypes
18+
usedTypes : OnlyUsedTypes //! collected used types
1919
def TypeVisitor {
2020
pass
2121
}
2222
def collect(typ : TypeDeclPtr) {
23-
unsafe {
24-
if (typ.baseType == Type.tStructure) {
25-
if (usedTypes.st |> key_exists(reinterpret<Structure?> typ.structType)) {
26-
return
27-
}
28-
}
29-
if (typ.structType != null) {
30-
usedTypes.st[reinterpret<Structure?> typ.structType] = true
31-
for (fld in typ.structType.fields) {
32-
self->collect(fld._type)
33-
}
23+
if (typ.baseType == Type.tStructure) {
24+
if (usedTypes.st |> key_exists(typ.structType)) {
25+
return
3426
}
35-
if (typ.enumType != null) {
36-
usedTypes.en[reinterpret<Enumeration?> typ.enumType] = true
27+
}
28+
if (typ.structType != null) {
29+
insert(usedTypes.st, typ.structType)
30+
for (fld in typ.structType.fields) {
31+
collect(fld._type)
3732
}
3833
}
34+
if (typ.enumType != null) {
35+
insert(usedTypes.en, typ.enumType)
36+
}
3937
if (typ.firstType != null) {
40-
self->collect(typ.firstType)
38+
collect(typ.firstType)
4139
}
4240
if (typ.secondType != null) {
43-
self->collect(typ.secondType)
41+
collect(typ.secondType)
4442
}
4543
for (arg in typ.argTypes) {
46-
self->collect(arg)
44+
collect(arg)
4745
}
4846
}
4947
def override preVisitTypeDecl(typ : TypeDeclPtr) : void {
50-
self->collect(typ)
48+
collect(typ)
5149
}
5250
}
5351

daslib/coroutines.das

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ require daslib/templates_boost
1111
require daslib/macro_boost
1212
require daslib/defer
1313

14-
typedef Coroutine = iterator<bool>
15-
typedef Coroutines = array<Coroutine>
14+
typedef Coroutine = iterator<bool> //! A coroutine is a generator that yields bool to indicate if it is still running.
1615

16+
typedef Coroutines = array<Coroutine> //! An array of coroutines.
1717

1818
[call_macro(name="yeild_from")]
1919
class private YieldFrom : AstCallMacro {

0 commit comments

Comments
 (0)