Skip to content

Commit acb9faa

Browse files
authored
Merge pull request GaijinEntertainment#2118 from GaijinEntertainment/better-rst
merge dima's rst fixes, update docs
2 parents 94549e9 + c58a02b commit acb9faa

10 files changed

Lines changed: 146 additions & 120 deletions

File tree

daslib/rst.das

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ def document_classes(doc_file : file; mods : array<Module?>) {
13221322

13231323
let staticFieldPrefix = "{value.name}`"
13241324
for_each_global(mod) $(gVar) {
1325-
if (string(gVar.name).starts_with(staticFieldPrefix)) {
1325+
if (!gVar.flags.private_variable && string(gVar.name).starts_with(staticFieldPrefix)) {
13261326
var line : array<string>
13271327
push(line, "{value.name}.{string(gVar.name).slice(length(staticFieldPrefix))}")
13281328
push(line, describe_type(gVar._type))

doc/source/stdlib/ast.rst

Lines changed: 68 additions & 68 deletions
Large diffs are not rendered by default.

doc/source/stdlib/ast_boost.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,10 +1027,10 @@ Creates an ``AnnotationDeclaration`` for the named annotation (with optional typ
10271027
Expression generation
10281028
+++++++++++++++++++++
10291029

1030-
* :ref:`convert_to_expression (var value: auto ==const) : auto <function-ast_boost_convert_to_expression__auto__eq__eq_const_0x3a5>`
1031-
* :ref:`convert_to_expression (value: auto ==const; at: LineInfo) : auto <function-ast_boost_convert_to_expression_auto__eq__eq_const_LineInfo_0x39c>`
1032-
* :ref:`convert_to_expression (var value: auto& ==const; at: LineInfo) : auto <function-ast_boost_convert_to_expression__auto_ref___eq__eq_const_LineInfo_0x393>`
1033-
* :ref:`convert_to_expression (value: auto ==const) : auto <function-ast_boost_convert_to_expression_auto__eq__eq_const_0x3aa>`
1030+
* :ref:`convert_to_expression (var value: auto ==const) : auto <function-ast_boost_convert_to_expression__auto__eq__eq_const_0x3a8>`
1031+
* :ref:`convert_to_expression (value: auto ==const; at: LineInfo) : auto <function-ast_boost_convert_to_expression_auto__eq__eq_const_LineInfo_0x39f>`
1032+
* :ref:`convert_to_expression (var value: auto& ==const; at: LineInfo) : auto <function-ast_boost_convert_to_expression__auto_ref___eq__eq_const_LineInfo_0x396>`
1033+
* :ref:`convert_to_expression (value: auto ==const) : auto <function-ast_boost_convert_to_expression_auto__eq__eq_const_0x3ad>`
10341034
* :ref:`make_static_assert_false (text: string; at: LineInfo) : smart_ptr\<ExprStaticAssert\> <function-ast_boost_make_static_assert_false_string_LineInfo>`
10351035
* :ref:`override_method (var str: StructurePtr; name: string; funcName: string) : bool <function-ast_boost_override_method_StructurePtr_string_string>`
10361036
* :ref:`panic_expr_as () : void? <function-ast_boost_panic_expr_as>`
@@ -1039,7 +1039,7 @@ Expression generation
10391039
convert_to_expression
10401040
^^^^^^^^^^^^^^^^^^^^^
10411041

1042-
.. _function-ast_boost_convert_to_expression__auto__eq__eq_const_0x3a5:
1042+
.. _function-ast_boost_convert_to_expression__auto__eq__eq_const_0x3a8:
10431043

10441044
.. das:function:: convert_to_expression(value: auto ==const) : auto
10451045
@@ -1048,15 +1048,15 @@ Converts a runtime value of any supported type to an equivalent AST ``Expression
10481048

10491049
:Arguments: * **value** : auto!
10501050

1051-
.. _function-ast_boost_convert_to_expression_auto__eq__eq_const_LineInfo_0x39c:
1051+
.. _function-ast_boost_convert_to_expression_auto__eq__eq_const_LineInfo_0x39f:
10521052

10531053
.. das:function:: convert_to_expression(value: auto ==const; at: LineInfo) : auto
10541054
1055-
.. _function-ast_boost_convert_to_expression__auto_ref___eq__eq_const_LineInfo_0x393:
1055+
.. _function-ast_boost_convert_to_expression__auto_ref___eq__eq_const_LineInfo_0x396:
10561056

10571057
.. das:function:: convert_to_expression(value: auto& ==const; at: LineInfo) : auto
10581058
1059-
.. _function-ast_boost_convert_to_expression_auto__eq__eq_const_0x3aa:
1059+
.. _function-ast_boost_convert_to_expression_auto__eq__eq_const_0x3ad:
10601060

10611061
.. das:function:: convert_to_expression(value: auto ==const) : auto
10621062

doc/source/stdlib/bitfield_trait.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Iteration
5353
+++++++++
5454

5555
* :ref:`each (argT: auto) : auto <function-bitfield_trait_each_auto_0x16>`
56-
* :ref:`each_bit_name (argT: auto) : auto <function-bitfield_trait_each_bit_name_auto_0x39>`
56+
* :ref:`each_bit_name (argT: auto) : auto <function-bitfield_trait_each_bit_name_auto_0x47>`
5757

5858
.. _function-bitfield_trait_each_auto_0x16:
5959

@@ -64,7 +64,7 @@ Iterates over the names of a bitfield type, yielding each bit as a bitfield valu
6464

6565
:Arguments: * **argT** : auto
6666

67-
.. _function-bitfield_trait_each_bit_name_auto_0x39:
67+
.. _function-bitfield_trait_each_bit_name_auto_0x47:
6868

6969
.. das:function:: each_bit_name(argT: auto) : auto
7070

doc/source/stdlib/builtin.rst

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ Containers
736736
* :ref:`lock_forever (var Tab: table\<auto(keyT);auto(valT)\>|table\<auto(keyT);auto(valT)\>#) : table\<keyT, valT\># <function-builtin_lock_forever_table_ls_autokeyT;autovalT_gr_table_ls_autokeyT;autovalT_gr__hh_>`
737737
* :ref:`modify (var Tab: table\<auto(keyT), auto(valT)\>; at: keyT|keyT#; blk: block\<(p:valT):valT\>) <function-builtin_modify__table_ls_autokeyT,_autovalT_gr__keyTkeyT_hh__block_ls_p_c_valT_c_valT_gr_>`
738738
* :ref:`move_to_local (var a: auto(TT)&) : TT <function-builtin_move_to_local_autoTT_ref__0x428>`
739-
* :ref:`move_to_ref (var a: auto&; var b: auto) : auto <function-builtin_move_to_ref_auto_ref__auto_0x80c>`
739+
* :ref:`move_to_ref (var a: auto&; var b: auto) : auto <function-builtin_move_to_ref_auto_ref__auto_0x813>`
740740
* :ref:`next (var it: iterator\<auto(TT)\>; var value: TT&) : bool <function-builtin_next_iterator_ls_autoTT_gr__TT_ref_>`
741741
* :ref:`nothing (var it: iterator\<auto(TT)\>) : iterator\<TT\> <function-builtin_nothing_iterator_ls_autoTT_gr_>`
742742
* :ref:`pop (var Arr: array\<auto(numT)\>) : auto <function-builtin_pop_array_ls_autonumT_gr_>`
@@ -769,11 +769,11 @@ Containers
769769
* :ref:`sort (var a: array\<auto(TT)\>|array\<auto(TT)\>#; cmp: block\<(x:TT;y:TT):bool\>) : auto <function-builtin_sort_array_ls_autoTT_gr_array_ls_autoTT_gr__hh__block_ls_x_c_TT;y_c_TT_c_bool_gr_>`
770770
* :ref:`sort (var a: auto(TT)[]|auto(TT)[]#) : auto <function-builtin_sort_autoTT_lb__rb_autoTT_lb__rb__hh_>`
771771
* :ref:`sort (var a: auto(TT)[]|auto(TT)[]#; cmp: block\<(x:TT;y:TT):bool\>) : auto <function-builtin_sort_autoTT_lb__rb_autoTT_lb__rb__hh__block_ls_x_c_TT;y_c_TT_c_bool_gr_>`
772-
* :ref:`subarray (a: auto(TT)[]; r: urange) : auto <function-builtin_subarray_autoTT_lb__rb__urange_0x7c2>`
772+
* :ref:`subarray (a: auto(TT)[]; r: urange) : auto <function-builtin_subarray_autoTT_lb__rb__urange_0x7c9>`
773773
* :ref:`subarray (a: array\<auto(TT)\>; r: urange) : auto <function-builtin_subarray_array_ls_autoTT_gr__urange>`
774774
* :ref:`subarray (a: array\<auto(TT)\>; r: range) : auto <function-builtin_subarray_array_ls_autoTT_gr__range>`
775775
* :ref:`subarray (var a: array\<auto(TT)\>; r: range) : auto <function-builtin_subarray__array_ls_autoTT_gr__range>`
776-
* :ref:`subarray (a: auto(TT)[]; r: range) : auto <function-builtin_subarray_autoTT_lb__rb__range_0x7b1>`
776+
* :ref:`subarray (a: auto(TT)[]; r: range) : auto <function-builtin_subarray_autoTT_lb__rb__range_0x7b8>`
777777
* :ref:`to_array (a: auto(TT)[]) : array\<TT\> <function-builtin_to_array_autoTT_lb__rb__0x5e9>`
778778
* :ref:`to_array (var it: iterator\<auto(TT)\>) : array\<TT\> <function-builtin_to_array_iterator_ls_autoTT_gr_>`
779779
* :ref:`to_array_move (var a: auto(TT) ==const) : array\<TT\> <function-builtin_to_array_move__autoTT__eq__eq_const_0x61a>`
@@ -1472,7 +1472,7 @@ Moves the value referenced by `a` onto the stack as a local copy and returns it,
14721472

14731473
:Arguments: * **a** : auto(TT)\ &
14741474

1475-
.. _function-builtin_move_to_ref_auto_ref__auto_0x80c:
1475+
.. _function-builtin_move_to_ref_auto_ref__auto_0x813:
14761476

14771477
.. das:function:: move_to_ref(a: auto&; b: auto) : auto
14781478
@@ -1718,7 +1718,7 @@ Sorts a dynamic array in place in ascending order using the default comparison f
17181718
subarray
17191719
^^^^^^^^
17201720

1721-
.. _function-builtin_subarray_autoTT_lb__rb__urange_0x7c2:
1721+
.. _function-builtin_subarray_autoTT_lb__rb__urange_0x7c9:
17221722

17231723
.. das:function:: subarray(a: auto(TT)[]; r: urange) : auto
17241724
@@ -1741,7 +1741,7 @@ Creates and returns a new dynamic array containing a copy of elements from fixed
17411741

17421742
.. das:function:: subarray(a: array<auto(TT)>; r: range) : auto
17431743
1744-
.. _function-builtin_subarray_autoTT_lb__rb__range_0x7b1:
1744+
.. _function-builtin_subarray_autoTT_lb__rb__range_0x7b8:
17451745

17461746
.. das:function:: subarray(a: auto(TT)[]; r: range) : auto
17471747
@@ -2068,6 +2068,7 @@ Stores a `smart_ptr<void>` `data` into gc0 storage under the specified `name`, a
20682068
Smart ptr infrastructure
20692069
++++++++++++++++++++++++
20702070

2071+
* :ref:`add_ptr_ref (src: auto(TT)?) : smart_ptr\<TT\> <function-builtin_add_ptr_ref_autoTT_q_>`
20712072
* :ref:`add_ptr_ref (src: smart_ptr\<auto(TT)\>) : smart_ptr\<TT\> <function-builtin_add_ptr_ref_smart_ptr_ls_autoTT_gr_>`
20722073
* :ref:`get_const_ptr (src: smart_ptr\<auto(TT)\>) : TT? <function-builtin_get_const_ptr_smart_ptr_ls_autoTT_gr_>`
20732074
* :ref:`get_ptr (var src: smart_ptr\<auto(TT)\> ==const) : TT? <function-builtin_get_ptr__smart_ptr_ls_autoTT_gr___eq__eq_const>`
@@ -2080,14 +2081,26 @@ Smart ptr infrastructure
20802081
* :ref:`smart_ptr_is_valid (dest: smart_ptr\<void\>) : bool <function-builtin_smart_ptr_is_valid_smart_ptr_ls_void_gr_>`
20812082
* :ref:`smart_ptr_use_count (ptr: smart_ptr\<void\>) : uint <function-builtin_smart_ptr_use_count_smart_ptr_ls_void_gr_>`
20822083

2083-
.. _function-builtin_add_ptr_ref_smart_ptr_ls_autoTT_gr_:
20842084

2085-
.. das:function:: add_ptr_ref(src: smart_ptr<auto(TT)>) : smart_ptr<TT>
2085+
add_ptr_ref
2086+
^^^^^^^^^^^
20862087

2087-
Increments the reference count of the smart pointer `src` and returns a new smart_ptr that shares ownership of the same object.
2088+
.. _function-builtin_add_ptr_ref_autoTT_q_:
20882089

2090+
.. das:function:: add_ptr_ref(src: auto(TT)?) : smart_ptr<TT>
20892091
2090-
:Arguments: * **src** : smart_ptr<auto(TT)>
2092+
Wraps a raw pointer ``src`` of type ``TT?`` into a ``smart_ptr<TT>`` by incrementing the reference count.
2093+
Commonly used to bridge AST node fields (which are raw pointers like ``Structure?``, ``Enumeration?``) to API functions that expect ``smart_ptr<T>``.
2094+
The overload accepting ``smart_ptr<auto(TT)>`` adds an additional reference to an existing smart pointer, returning a new ``smart_ptr<TT>`` that shares ownership.
2095+
2096+
2097+
:Arguments: * **src** : auto(TT)?
2098+
2099+
.. _function-builtin_add_ptr_ref_smart_ptr_ls_autoTT_gr_:
2100+
2101+
.. das:function:: add_ptr_ref(src: smart_ptr<auto(TT)>) : smart_ptr<TT>
2102+
2103+
----
20912104

20922105
.. _function-builtin_get_const_ptr_smart_ptr_ls_autoTT_gr_:
20932106

@@ -2880,9 +2893,9 @@ Formats a `uint8` value as a string using the given `format` specifier (followin
28802893
Argument consumption
28812894
++++++++++++++++++++
28822895

2883-
* :ref:`consume_argument (var a: auto(TT)&) : TT& <function-builtin_consume_argument_autoTT_ref__0x843>`
2896+
* :ref:`consume_argument (var a: auto(TT)&) : TT& <function-builtin_consume_argument_autoTT_ref__0x84a>`
28842897

2885-
.. _function-builtin_consume_argument_autoTT_ref__0x843:
2898+
.. _function-builtin_consume_argument_autoTT_ref__0x84a:
28862899

28872900
.. das:function:: consume_argument(a: auto(TT)&) : TT&
28882901
@@ -3195,7 +3208,7 @@ Algorithms
31953208

31963209
* :ref:`count (start: int = 0; step: int = 1) : iterator\<int\> <function-builtin_count_int_int>`
31973210
* :ref:`iter_range (foo: auto) : auto <function-builtin_iter_range_auto_0x591>`
3198-
* :ref:`swap (var a: auto(TT)&; var b: auto(TT)&) : auto <function-builtin_swap_autoTT_ref__autoTT_ref__0x7a9>`
3211+
* :ref:`swap (var a: auto(TT)&; var b: auto(TT)&) : auto <function-builtin_swap_autoTT_ref__autoTT_ref__0x7b0>`
31993212
* :ref:`ucount (start: uint = 0x0; step: uint = 0x1) : iterator\<uint\> <function-builtin_ucount_uint_uint>`
32003213

32013214
.. _function-builtin_count_int_int:
@@ -3218,7 +3231,7 @@ Creates a `range` from `0` to the length of the given iterable `foo`, useful for
32183231

32193232
:Arguments: * **foo** : auto
32203233

3221-
.. _function-builtin_swap_autoTT_ref__autoTT_ref__0x7a9:
3234+
.. _function-builtin_swap_autoTT_ref__autoTT_ref__0x7b0:
32223235

32233236
.. das:function:: swap(a: auto(TT)&; b: auto(TT)&) : auto
32243237

doc/source/stdlib/detail/ast.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@
178178

179179
.. |handmade/method-ast-AstCaptureMacro.captureFunction| replace:: to be documented in |handmade/method-ast-AstCaptureMacro.captureFunction|.rst
180180

181+
.. |handmade/method-ast-AstCaptureMacro.releaseFunction| replace:: to be documented in |handmade/method-ast-AstCaptureMacro.releaseFunction|.rst
182+
181183
.. |handmade/class-ast-AstTypeMacro| replace:: to be documented in |handmade/class-ast-AstTypeMacro|.rst
182184

183185
.. |handmade/method-ast-AstTypeMacro.visit| replace:: to be documented in |handmade/method-ast-AstTypeMacro.visit|.rst

doc/source/stdlib/detail/interfaces.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
.. |detail/method-interfaces-ImplementsMacro.apply| replace:: to be documented in |detail/method-interfaces-ImplementsMacro.apply|.rst
88

9+
.. |detail/method-interfaces-ImplementsMacro.finish| replace:: to be documented in |detail/method-interfaces-ImplementsMacro.finish|.rst
10+
911
.. |detail/class-interfaces-InterfaceAsIs| replace:: to be documented in |detail/class-interfaces-InterfaceAsIs|.rst
1012

1113
.. |detail/method-interfaces-InterfaceAsIs.visitExprIsVariant| replace:: to be documented in |detail/method-interfaces-InterfaceAsIs.visitExprIsVariant|.rst
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
Generates interface bindings for a struct. Creates a proxy class that delegates
22
interface method calls to the struct's own methods, and adds a ``get`InterfaceName``
33
method that lazily constructs the proxy. Applied via ``[implements(InterfaceName)]``.
4+
5+
If the interface inherits from a parent interface (``class IChild : IParent``),
6+
ancestor getters are generated automatically so that ``is``/``as``/``?as`` work
7+
with all ancestor interfaces.
8+
9+
At ``finish`` time, verifies that all abstract interface methods are implemented.
10+
Methods with default bodies in the interface class are optional — the proxy
11+
inherits them via class hierarchy.

doc/source/stdlib/handmade/module-interfaces.rst

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ It provides the ``[interface]`` annotation for defining abstract interfaces
33
with virtual method tables, supporting multiple implementations and dynamic
44
dispatch without class inheritance.
55

6+
**Features:**
7+
8+
- Interface inheritance (``class IChild : IParent``)
9+
- Default method implementations (non-abstract methods)
10+
- Compile-time completeness checking (error 30111 on missing methods)
11+
- ``is``/``as``/``?as`` operators via the ``InterfaceAsIs`` variant macro
12+
613
All functions and symbols are in "interfaces" module, use require to get access to it.
714

815
.. code-block:: das
@@ -15,24 +22,25 @@ Example:
1522
1623
require daslib/interfaces
1724
18-
[interface]
19-
class IGreeter {
20-
def abstract greet(name : string) : string
21-
}
22-
23-
class MyGreeter {
24-
def greet(name : string) : string {
25-
return "Hello, {name}!"
26-
}
27-
}
25+
[interface]
26+
class IGreeter {
27+
def abstract greet(name : string) : string
28+
}
2829
29-
[export]
30-
def main() {
31-
var obj = new MyGreeter()
32-
print("{obj->greet("world")}\n")
33-
unsafe {
34-
delete obj
35-
}
30+
[implements(IGreeter)]
31+
class MyGreeter {
32+
def IGreeter`greet(name : string) : string {
33+
return "Hello, {name}!"
3634
}
37-
// output:
38-
// Hello, world!
35+
}
36+
37+
[export]
38+
def main() {
39+
var obj = new MyGreeter()
40+
var greeter = obj as IGreeter
41+
print("{greeter->greet("world")}\n")
42+
}
43+
// output: Hello, world!
44+
45+
See also: :ref:`Interfaces tutorial <tutorial_interfaces>` for a
46+
complete walkthrough.

doc/source/stdlib/interfaces.rst

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Example:
3838
3939
[implements(IGreeter)]
4040
class MyGreeter {
41-
def MyGreeter() { pass }
4241
def IGreeter`greet(name : string) : string {
4342
return "Hello, {name}!"
4443
}
@@ -98,15 +97,9 @@ If the interface inherits from a parent interface (``class IChild : IParent``),
9897
ancestor getters are generated automatically so that ``is``/``as``/``?as`` work
9998
with all ancestor interfaces.
10099

101-
At compile time, verifies that all abstract interface methods are implemented.
100+
At ``finish`` time, verifies that all abstract interface methods are implemented.
102101
Methods with default bodies in the interface class are optional — the proxy
103102
inherits them via class hierarchy.
104103

105104

106-
+++++++++++++++++++
107-
Private helper
108-
+++++++++++++++++++
109105

110-
.. das:function:: is_interface_struct(st : Structure?)
111-
112-
Returns ``true`` when the structure carries the ``[interface]`` annotation.

0 commit comments

Comments
 (0)