-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sui-framework] Fix framework docgen (#20853)
## Description - We overwrote files more than we needed to, so we now skip writing deps - Added missing stdlib files ## Test plan ποΈ π ποΈ --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] gRPC: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK:
- Loading branch information
Showing
42 changed files
with
4,890 additions
and
1,781 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
title: Module `0x1::address` | ||
--- | ||
|
||
Provides a way to get address length since it's a | ||
platform-specific parameter. | ||
|
||
|
||
- [Function `length`](#0x1_address_length) | ||
|
||
|
||
<pre><code></code></pre> | ||
|
||
|
||
|
||
<a name="0x1_address_length"></a> | ||
|
||
## Function `length` | ||
|
||
Should be converted to a native function. | ||
Current implementation only works for Sui. | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="address.md#0x1_address_length">length</a>(): <a href="u64.md#0x1_u64">u64</a> | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="address.md#0x1_address_length">length</a>(): <a href="u64.md#0x1_u64">u64</a> { | ||
32 | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,324 @@ | ||
--- | ||
title: Module `0x1::bit_vector` | ||
--- | ||
|
||
|
||
|
||
- [Struct `BitVector`](#0x1_bit_vector_BitVector) | ||
- [Constants](#@Constants_0) | ||
- [Function `new`](#0x1_bit_vector_new) | ||
- [Function `set`](#0x1_bit_vector_set) | ||
- [Function `unset`](#0x1_bit_vector_unset) | ||
- [Function `shift_left`](#0x1_bit_vector_shift_left) | ||
- [Function `is_index_set`](#0x1_bit_vector_is_index_set) | ||
- [Function `length`](#0x1_bit_vector_length) | ||
- [Function `longest_set_sequence_starting_at`](#0x1_bit_vector_longest_set_sequence_starting_at) | ||
|
||
|
||
<pre><code></code></pre> | ||
|
||
|
||
|
||
<a name="0x1_bit_vector_BitVector"></a> | ||
|
||
## Struct `BitVector` | ||
|
||
|
||
|
||
<pre><code><b>struct</b> <a href="bit_vector.md#0x1_bit_vector_BitVector">BitVector</a> <b>has</b> <b>copy</b>, drop, store | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Fields</summary> | ||
|
||
|
||
<dl> | ||
<dt> | ||
<code>length: <a href="u64.md#0x1_u64">u64</a></code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
<dt> | ||
<code>bit_field: <a href="vector.md#0x1_vector">vector</a><bool></code> | ||
</dt> | ||
<dd> | ||
|
||
</dd> | ||
</dl> | ||
|
||
|
||
</details> | ||
|
||
<a name="@Constants_0"></a> | ||
|
||
## Constants | ||
|
||
|
||
<a name="0x1_bit_vector_EINDEX"></a> | ||
|
||
The provided index is out of bounds | ||
|
||
|
||
<pre><code><b>const</b> <a href="bit_vector.md#0x1_bit_vector_EINDEX">EINDEX</a>: <a href="u64.md#0x1_u64">u64</a> = 131072; | ||
</code></pre> | ||
|
||
|
||
|
||
<a name="0x1_bit_vector_ELENGTH"></a> | ||
|
||
An invalid length of bitvector was given | ||
|
||
|
||
<pre><code><b>const</b> <a href="bit_vector.md#0x1_bit_vector_ELENGTH">ELENGTH</a>: <a href="u64.md#0x1_u64">u64</a> = 131073; | ||
</code></pre> | ||
|
||
|
||
|
||
<a name="0x1_bit_vector_MAX_SIZE"></a> | ||
|
||
The maximum allowed bitvector size | ||
|
||
|
||
<pre><code><b>const</b> <a href="bit_vector.md#0x1_bit_vector_MAX_SIZE">MAX_SIZE</a>: <a href="u64.md#0x1_u64">u64</a> = 1024; | ||
</code></pre> | ||
|
||
|
||
|
||
<a name="0x1_bit_vector_WORD_SIZE"></a> | ||
|
||
|
||
|
||
<pre><code><b>const</b> <a href="bit_vector.md#0x1_bit_vector_WORD_SIZE">WORD_SIZE</a>: <a href="u64.md#0x1_u64">u64</a> = 1; | ||
</code></pre> | ||
|
||
|
||
|
||
<a name="0x1_bit_vector_new"></a> | ||
|
||
## Function `new` | ||
|
||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_new">new</a>(length: <a href="u64.md#0x1_u64">u64</a>): <a href="bit_vector.md#0x1_bit_vector_BitVector">bit_vector::BitVector</a> | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_new">new</a>(length: <a href="u64.md#0x1_u64">u64</a>): <a href="bit_vector.md#0x1_bit_vector_BitVector">BitVector</a> { | ||
<b>assert</b>!(length > 0, <a href="bit_vector.md#0x1_bit_vector_ELENGTH">ELENGTH</a>); | ||
<b>assert</b>!(<a href="bit_vector.md#0x1_bit_vector_length">length</a> < <a href="bit_vector.md#0x1_bit_vector_MAX_SIZE">MAX_SIZE</a>, <a href="bit_vector.md#0x1_bit_vector_ELENGTH">ELENGTH</a>); | ||
<b>let</b> <b>mut</b> counter = 0; | ||
<b>let</b> <b>mut</b> bit_field = <a href="vector.md#0x1_vector_empty">vector::empty</a>(); | ||
<b>while</b> (counter < length) { | ||
bit_field.push_back(<b>false</b>); | ||
counter = counter + 1; | ||
}; | ||
|
||
<a href="bit_vector.md#0x1_bit_vector_BitVector">BitVector</a> { | ||
length, | ||
bit_field, | ||
} | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x1_bit_vector_set"></a> | ||
|
||
## Function `set` | ||
|
||
Set the bit at <code>bit_index</code> in the <code>bitvector</code> regardless of its previous state. | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_set">set</a>(bitvector: &<b>mut</b> <a href="bit_vector.md#0x1_bit_vector_BitVector">bit_vector::BitVector</a>, bit_index: <a href="u64.md#0x1_u64">u64</a>) | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_set">set</a>(bitvector: &<b>mut</b> <a href="bit_vector.md#0x1_bit_vector_BitVector">BitVector</a>, bit_index: <a href="u64.md#0x1_u64">u64</a>) { | ||
<b>assert</b>!(bit_index < bitvector.bit_field.<a href="bit_vector.md#0x1_bit_vector_length">length</a>(), <a href="bit_vector.md#0x1_bit_vector_EINDEX">EINDEX</a>); | ||
<b>let</b> x = &<b>mut</b> bitvector.bit_field[bit_index]; | ||
*x = <b>true</b>; | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x1_bit_vector_unset"></a> | ||
|
||
## Function `unset` | ||
|
||
Unset the bit at <code>bit_index</code> in the <code>bitvector</code> regardless of its previous state. | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_unset">unset</a>(bitvector: &<b>mut</b> <a href="bit_vector.md#0x1_bit_vector_BitVector">bit_vector::BitVector</a>, bit_index: <a href="u64.md#0x1_u64">u64</a>) | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_unset">unset</a>(bitvector: &<b>mut</b> <a href="bit_vector.md#0x1_bit_vector_BitVector">BitVector</a>, bit_index: <a href="u64.md#0x1_u64">u64</a>) { | ||
<b>assert</b>!(bit_index < bitvector.bit_field.<a href="bit_vector.md#0x1_bit_vector_length">length</a>(), <a href="bit_vector.md#0x1_bit_vector_EINDEX">EINDEX</a>); | ||
<b>let</b> x = &<b>mut</b> bitvector.bit_field[bit_index]; | ||
*x = <b>false</b>; | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x1_bit_vector_shift_left"></a> | ||
|
||
## Function `shift_left` | ||
|
||
Shift the <code>bitvector</code> left by <code>amount</code>. If <code>amount</code> is greater than the | ||
bitvector's length the bitvector will be zeroed out. | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_shift_left">shift_left</a>(bitvector: &<b>mut</b> <a href="bit_vector.md#0x1_bit_vector_BitVector">bit_vector::BitVector</a>, amount: <a href="u64.md#0x1_u64">u64</a>) | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_shift_left">shift_left</a>(bitvector: &<b>mut</b> <a href="bit_vector.md#0x1_bit_vector_BitVector">BitVector</a>, amount: <a href="u64.md#0x1_u64">u64</a>) { | ||
<b>if</b> (amount >= bitvector.length) { | ||
<b>let</b> len = bitvector.bit_field.<a href="bit_vector.md#0x1_bit_vector_length">length</a>(); | ||
<b>let</b> <b>mut</b> i = 0; | ||
<b>while</b> (i < len) { | ||
<b>let</b> elem = &<b>mut</b> bitvector.bit_field[i]; | ||
*elem = <b>false</b>; | ||
i = i + 1; | ||
}; | ||
} <b>else</b> { | ||
<b>let</b> <b>mut</b> i = amount; | ||
|
||
<b>while</b> (i < bitvector.length) { | ||
<b>if</b> (bitvector.<a href="bit_vector.md#0x1_bit_vector_is_index_set">is_index_set</a>(i)) bitvector.<a href="bit_vector.md#0x1_bit_vector_set">set</a>(i - amount) | ||
<b>else</b> bitvector.<a href="bit_vector.md#0x1_bit_vector_unset">unset</a>(i - amount); | ||
i = i + 1; | ||
}; | ||
|
||
i = bitvector.length - amount; | ||
|
||
<b>while</b> (i < bitvector.length) { | ||
<a href="bit_vector.md#0x1_bit_vector_unset">unset</a>(bitvector, i); | ||
i = i + 1; | ||
}; | ||
} | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x1_bit_vector_is_index_set"></a> | ||
|
||
## Function `is_index_set` | ||
|
||
Return the value of the bit at <code>bit_index</code> in the <code>bitvector</code>. <code><b>true</b></code> | ||
represents "1" and <code><b>false</b></code> represents a 0 | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_is_index_set">is_index_set</a>(bitvector: &<a href="bit_vector.md#0x1_bit_vector_BitVector">bit_vector::BitVector</a>, bit_index: <a href="u64.md#0x1_u64">u64</a>): bool | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_is_index_set">is_index_set</a>(bitvector: &<a href="bit_vector.md#0x1_bit_vector_BitVector">BitVector</a>, bit_index: <a href="u64.md#0x1_u64">u64</a>): bool { | ||
<b>assert</b>!(bit_index < bitvector.bit_field.<a href="bit_vector.md#0x1_bit_vector_length">length</a>(), <a href="bit_vector.md#0x1_bit_vector_EINDEX">EINDEX</a>); | ||
bitvector.bit_field[bit_index] | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x1_bit_vector_length"></a> | ||
|
||
## Function `length` | ||
|
||
Return the length (number of usable bits) of this bitvector | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_length">length</a>(bitvector: &<a href="bit_vector.md#0x1_bit_vector_BitVector">bit_vector::BitVector</a>): <a href="u64.md#0x1_u64">u64</a> | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_length">length</a>(bitvector: &<a href="bit_vector.md#0x1_bit_vector_BitVector">BitVector</a>): <a href="u64.md#0x1_u64">u64</a> { | ||
bitvector.bit_field.<a href="bit_vector.md#0x1_bit_vector_length">length</a>() | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> | ||
|
||
<a name="0x1_bit_vector_longest_set_sequence_starting_at"></a> | ||
|
||
## Function `longest_set_sequence_starting_at` | ||
|
||
Returns the length of the longest sequence of set bits starting at (and | ||
including) <code>start_index</code> in the <code>bitvector</code>. If there is no such | ||
sequence, then <code>0</code> is returned. | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_longest_set_sequence_starting_at">longest_set_sequence_starting_at</a>(bitvector: &<a href="bit_vector.md#0x1_bit_vector_BitVector">bit_vector::BitVector</a>, start_index: <a href="u64.md#0x1_u64">u64</a>): <a href="u64.md#0x1_u64">u64</a> | ||
</code></pre> | ||
|
||
|
||
|
||
<details> | ||
<summary>Implementation</summary> | ||
|
||
|
||
<pre><code><b>public</b> <b>fun</b> <a href="bit_vector.md#0x1_bit_vector_longest_set_sequence_starting_at">longest_set_sequence_starting_at</a>(bitvector: &<a href="bit_vector.md#0x1_bit_vector_BitVector">BitVector</a>, start_index: <a href="u64.md#0x1_u64">u64</a>): <a href="u64.md#0x1_u64">u64</a> { | ||
<b>assert</b>!(start_index < bitvector.length, <a href="bit_vector.md#0x1_bit_vector_EINDEX">EINDEX</a>); | ||
<b>let</b> <b>mut</b> index = start_index; | ||
|
||
// Find the greatest index in the <a href="vector.md#0x1_vector">vector</a> such that all indices less than it are set. | ||
<b>while</b> (index < bitvector.length) { | ||
<b>if</b> (!bitvector.<a href="bit_vector.md#0x1_bit_vector_is_index_set">is_index_set</a>(index)) <b>break</b>; | ||
index = index + 1; | ||
}; | ||
|
||
index - start_index | ||
} | ||
</code></pre> | ||
|
||
|
||
|
||
</details> |
Oops, something went wrong.