mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
breaking,checker: disallow initializing private struct fields outside structs module (#21183)
This commit is contained in:
parent
a8d0cdd31b
commit
1a35a783f1
96 changed files with 225 additions and 111 deletions
|
@ -41,7 +41,7 @@ jobs:
|
||||||
- name: Test vsql compilation and examples
|
- name: Test vsql compilation and examples
|
||||||
run: |
|
run: |
|
||||||
echo "Install vsql"
|
echo "Install vsql"
|
||||||
.github/workflows/retry.sh v install elliotchance.vsql ; cd ~/.vmodules/elliotchance/vsql
|
.github/workflows/retry.sh v install https://github.com/ttytm/vsql@temp/vi-ci ; cd ~/.vmodules/vsql
|
||||||
echo "Generate vsql/grammar.v"
|
echo "Generate vsql/grammar.v"
|
||||||
make vsql/grammar.v
|
make vsql/grammar.v
|
||||||
echo "Compile vsql"
|
echo "Compile vsql"
|
||||||
|
@ -53,10 +53,10 @@ jobs:
|
||||||
|
|
||||||
- name: Test discord.v
|
- name: Test discord.v
|
||||||
run: |
|
run: |
|
||||||
echo "Clone https://github.com/DarpHome/discord.v/"
|
echo "Clone https://github.com/DarpHome/discord.v"
|
||||||
.github/workflows/retry.sh git clone https://github.com/DarpHome/discord.v/ discord && cd discord
|
.github/workflows/retry.sh v install https://github.com/ttytm/discord.v@temp/v-ci && cd ~/.vmodules/discord
|
||||||
echo "Checkout last known good commit"
|
# echo "Checkout last known good commit"
|
||||||
git checkout 533485c08f21df91ff62fea9477e7017d21f91c4
|
# git checkout 789de8ad35ee2683fbcd950fc07936f052088d0c
|
||||||
echo "Execute Tests"
|
echo "Execute Tests"
|
||||||
v test .
|
v test .
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ const max_parallel_workers = runtime.nr_jobs()
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct ParserSettings {
|
pub struct ParserSettings {
|
||||||
|
pub:
|
||||||
sequential bool
|
sequential bool
|
||||||
img bool
|
img bool
|
||||||
extra_workers int
|
extra_workers int
|
||||||
|
|
|
@ -11,6 +11,7 @@ pub const default_gravity = 4.9
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct SimParams {
|
pub struct SimParams {
|
||||||
|
pub:
|
||||||
rope_length f64 = sim.default_rope_length
|
rope_length f64 = sim.default_rope_length
|
||||||
bearing_mass f64 = sim.default_bearing_mass
|
bearing_mass f64 = sim.default_bearing_mass
|
||||||
magnet_spacing f64 = sim.default_magnet_spacing
|
magnet_spacing f64 = sim.default_magnet_spacing
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module sim
|
module sim
|
||||||
|
|
||||||
pub struct SimState {
|
pub struct SimState {
|
||||||
mut:
|
pub mut:
|
||||||
position Vector3D
|
position Vector3D
|
||||||
velocity Vector3D
|
velocity Vector3D
|
||||||
accel Vector3D
|
accel Vector3D
|
||||||
|
|
|
@ -4,6 +4,7 @@ import math
|
||||||
|
|
||||||
// Vector3D is a 3D vector
|
// Vector3D is a 3D vector
|
||||||
pub struct Vector3D {
|
pub struct Vector3D {
|
||||||
|
pub:
|
||||||
x f64
|
x f64
|
||||||
y f64
|
y f64
|
||||||
z f64
|
z f64
|
||||||
|
|
|
@ -7,10 +7,10 @@ const max_iterations = 1000
|
||||||
const simulation_delta_t = 0.0005
|
const simulation_delta_t = 0.0005
|
||||||
|
|
||||||
pub struct SimRequest {
|
pub struct SimRequest {
|
||||||
|
pub:
|
||||||
params SimParams
|
params SimParams
|
||||||
state SimState
|
state SimState
|
||||||
pub:
|
id int
|
||||||
id int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SimResult {
|
pub struct SimResult {
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn remap(v f64, min f64, max f64, new_min f64, new_max f64) f64 {
|
||||||
|
|
||||||
// Particle
|
// Particle
|
||||||
pub struct Particle {
|
pub struct Particle {
|
||||||
mut:
|
pub mut:
|
||||||
location vec.Vec2[f64]
|
location vec.Vec2[f64]
|
||||||
velocity vec.Vec2[f64]
|
velocity vec.Vec2[f64]
|
||||||
acceleration vec.Vec2[f64]
|
acceleration vec.Vec2[f64]
|
||||||
|
|
|
@ -7,10 +7,12 @@ import rand
|
||||||
import sokol.sgl
|
import sokol.sgl
|
||||||
|
|
||||||
pub struct SystemConfig {
|
pub struct SystemConfig {
|
||||||
|
pub:
|
||||||
pool int
|
pool int
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct System {
|
pub struct System {
|
||||||
|
pub:
|
||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
mut:
|
mut:
|
||||||
|
|
|
@ -40,11 +40,9 @@ fn new_app() !&App {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_websocker_server() !&websocket.Server {
|
fn new_websocker_server() !&websocket.Server {
|
||||||
mut wss := &websocket.Server{
|
mut logger := &log.Log{}
|
||||||
logger: &log.Log{
|
logger.set_level(.debug)
|
||||||
level: .debug
|
mut wss := websocket.new_server(.ip, 8080, '', logger: logger)
|
||||||
}
|
|
||||||
}
|
|
||||||
wss.on_connect(fn (mut server_client websocket.ServerClient) !bool {
|
wss.on_connect(fn (mut server_client websocket.ServerClient) !bool {
|
||||||
slog('ws.on_connect, server_client.client_key: ${server_client.client_key}')
|
slog('ws.on_connect, server_client.client_key: ${server_client.client_key}')
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -182,6 +182,7 @@ pub fn chunk[T](array []T, size int) [][]T {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WindowAttribute {
|
pub struct WindowAttribute {
|
||||||
|
pub:
|
||||||
size int
|
size int
|
||||||
step int = 1
|
step int = 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,7 @@ pub fn (mut b Benchmark) record_measure(label string) i64 {
|
||||||
// If it is set, the preparation time (compile time) will be shown before the measured runtime.
|
// If it is set, the preparation time (compile time) will be shown before the measured runtime.
|
||||||
@[params]
|
@[params]
|
||||||
pub struct MessageOptions {
|
pub struct MessageOptions {
|
||||||
|
pub:
|
||||||
preparation time.Duration // the duration of the preparation time for the step
|
preparation time.Duration // the duration of the preparation time for the step
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,21 +25,6 @@ fn test_if_string_flag_parses() {
|
||||||
flag.parse(['-flag=value2'], false) or { panic(err) }
|
flag.parse(['-flag=value2'], false) or { panic(err) }
|
||||||
mut values := flag.get_strings() or { panic(err) }
|
mut values := flag.get_strings() or { panic(err) }
|
||||||
assert values == ['value1', 'value2']
|
assert values == ['value1', 'value2']
|
||||||
|
|
||||||
flags := [
|
|
||||||
cli.Flag{
|
|
||||||
flag: .string_array
|
|
||||||
name: 'flag'
|
|
||||||
value: ['a', 'b', 'c']
|
|
||||||
},
|
|
||||||
cli.Flag{
|
|
||||||
flag: .string
|
|
||||||
name: 'flag2'
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
values = flags.get_strings('flag') or { panic(err) }
|
|
||||||
assert values == ['a', 'b', 'c']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_if_bool_flag_parses() {
|
fn test_if_bool_flag_parses() {
|
||||||
|
@ -94,21 +79,6 @@ fn test_if_int_flag_parses() {
|
||||||
flag.parse(['-flag=45'], false) or { panic(err) }
|
flag.parse(['-flag=45'], false) or { panic(err) }
|
||||||
mut values := flag.get_ints() or { panic(err) }
|
mut values := flag.get_ints() or { panic(err) }
|
||||||
assert values == [42, 45]
|
assert values == [42, 45]
|
||||||
|
|
||||||
flags := [
|
|
||||||
cli.Flag{
|
|
||||||
flag: .int_array
|
|
||||||
name: 'flag'
|
|
||||||
value: ['1', '2', '3']
|
|
||||||
},
|
|
||||||
cli.Flag{
|
|
||||||
flag: .int
|
|
||||||
name: 'flag2'
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
values = flags.get_ints('flag') or { panic(err) }
|
|
||||||
assert values == [1, 2, 3]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_if_float_flag_parses() {
|
fn test_if_float_flag_parses() {
|
||||||
|
@ -139,21 +109,6 @@ fn test_if_float_flag_parses() {
|
||||||
flag.parse(['-flag=1.3'], false) or { panic(err) }
|
flag.parse(['-flag=1.3'], false) or { panic(err) }
|
||||||
mut values := flag.get_floats() or { panic(err) }
|
mut values := flag.get_floats() or { panic(err) }
|
||||||
assert values == [3.1, 1.3]
|
assert values == [3.1, 1.3]
|
||||||
|
|
||||||
flags := [
|
|
||||||
cli.Flag{
|
|
||||||
flag: .float_array
|
|
||||||
name: 'flag'
|
|
||||||
value: ['1.1', '2.2', '3.3']
|
|
||||||
},
|
|
||||||
cli.Flag{
|
|
||||||
flag: .float
|
|
||||||
name: 'flag2'
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
values = flags.get_floats('flag') or { panic(err) }
|
|
||||||
assert values == [1.1, 2.2, 3.3]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_if_flag_parses_with_abbrev() {
|
fn test_if_flag_parses_with_abbrev() {
|
||||||
|
|
|
@ -42,6 +42,7 @@ pub fn compress(data []u8) ![]u8 {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct DecompressParams {
|
pub struct DecompressParams {
|
||||||
|
pub:
|
||||||
verify_header_checksum bool = true
|
verify_header_checksum bool = true
|
||||||
verify_length bool = true
|
verify_length bool = true
|
||||||
verify_checksum bool = true
|
verify_checksum bool = true
|
||||||
|
|
|
@ -7,6 +7,7 @@ import os
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct ZipFolderOptions {
|
pub struct ZipFolderOptions {
|
||||||
|
pub:
|
||||||
omit_empty_folders bool
|
omit_empty_folders bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -390,6 +390,7 @@ pub fn default_c_level() int {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct CompressParams {
|
pub struct CompressParams {
|
||||||
|
pub:
|
||||||
compression_level int // 1~22
|
compression_level int // 1~22
|
||||||
nb_threads int = 1 // how many threads will be spawned to compress in parallel
|
nb_threads int = 1 // how many threads will be spawned to compress in parallel
|
||||||
checksum_flag bool = true
|
checksum_flag bool = true
|
||||||
|
@ -422,6 +423,7 @@ pub fn compress(data []u8, params CompressParams) ![]u8 {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct DecompressParams {
|
pub struct DecompressParams {
|
||||||
|
pub:
|
||||||
window_log_max int
|
window_log_max int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ mut:
|
||||||
// DynamicLibLoaderConfig is a configuration for DynamicLibLoader.
|
// DynamicLibLoaderConfig is a configuration for DynamicLibLoader.
|
||||||
@[params]
|
@[params]
|
||||||
pub struct DynamicLibLoaderConfig {
|
pub struct DynamicLibLoaderConfig {
|
||||||
|
pub:
|
||||||
// flags is the flags for dlopen.
|
// flags is the flags for dlopen.
|
||||||
flags int = dl.rtld_lazy
|
flags int = dl.rtld_lazy
|
||||||
// key is the key to register the DynamicLibLoader.
|
// key is the key to register the DynamicLibLoader.
|
||||||
|
|
|
@ -205,6 +205,7 @@ fn overhead_for(c &Chunk) usize {
|
||||||
//
|
//
|
||||||
// Why not `interface?` Interfaces require memory allocation so it is simpler to pass a struct.
|
// Why not `interface?` Interfaces require memory allocation so it is simpler to pass a struct.
|
||||||
pub struct Allocator {
|
pub struct Allocator {
|
||||||
|
pub:
|
||||||
alloc fn (voidptr, usize) (voidptr, usize, u32) = unsafe { nil }
|
alloc fn (voidptr, usize) (voidptr, usize, u32) = unsafe { nil }
|
||||||
remap fn (voidptr, voidptr, usize, usize, bool) voidptr = unsafe { nil }
|
remap fn (voidptr, voidptr, usize, usize, bool) voidptr = unsafe { nil }
|
||||||
free_part fn (voidptr, voidptr, usize, usize) bool = unsafe { nil }
|
free_part fn (voidptr, voidptr, usize, usize) bool = unsafe { nil }
|
||||||
|
|
|
@ -42,6 +42,7 @@ Using these structs, it is possible to change the behavior of the CSV Reader.
|
||||||
The config struct is as follows:
|
The config struct is as follows:
|
||||||
```v ignore
|
```v ignore
|
||||||
pub struct SequentialReaderConfig {
|
pub struct SequentialReaderConfig {
|
||||||
|
pub:
|
||||||
scr_buf voidptr // pointer to the buffer of data
|
scr_buf voidptr // pointer to the buffer of data
|
||||||
scr_buf_len i64 // if > 0 use the RAM pointed by scr_buf as source of data
|
scr_buf_len i64 // if > 0 use the RAM pointed by scr_buf as source of data
|
||||||
file_path string
|
file_path string
|
||||||
|
@ -128,6 +129,7 @@ Using these structs, it is possible to change the behavior of the CSV Reader.
|
||||||
The config struct is as follows:
|
The config struct is as follows:
|
||||||
```v ignore
|
```v ignore
|
||||||
pub struct RandomAccessReaderConfig {
|
pub struct RandomAccessReaderConfig {
|
||||||
|
pub:
|
||||||
scr_buf voidptr // pointer to the buffer of data
|
scr_buf voidptr // pointer to the buffer of data
|
||||||
scr_buf_len i64 // if > 0 use the RAM pointed from scr_buf as source of data
|
scr_buf_len i64 // if > 0 use the RAM pointed from scr_buf as source of data
|
||||||
file_path string
|
file_path string
|
||||||
|
|
|
@ -80,6 +80,7 @@ pub mut:
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct RandomAccessReaderConfig {
|
pub struct RandomAccessReaderConfig {
|
||||||
|
pub:
|
||||||
scr_buf voidptr // pointer to the buffer of data
|
scr_buf voidptr // pointer to the buffer of data
|
||||||
scr_buf_len i64 // if > 0 use the RAM pointed from scr_buf as source of data
|
scr_buf_len i64 // if > 0 use the RAM pointed from scr_buf as source of data
|
||||||
file_path string
|
file_path string
|
||||||
|
@ -344,6 +345,7 @@ pub fn (mut cr RandomAccessReader) get_row(y int) ![]string {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct GetCellConfig {
|
pub struct GetCellConfig {
|
||||||
|
pub:
|
||||||
x int
|
x int
|
||||||
y int
|
y int
|
||||||
}
|
}
|
||||||
|
@ -444,6 +446,7 @@ pub fn (mut cr RandomAccessReader) get_cellt(cfg GetCellConfig) !CellValue {
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
@[params]
|
@[params]
|
||||||
pub struct GetHeaderConf {
|
pub struct GetHeaderConf {
|
||||||
|
pub:
|
||||||
header_row int // row where to inspect the header
|
header_row int // row where to inspect the header
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import os
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct SequentialReaderConfig {
|
pub struct SequentialReaderConfig {
|
||||||
|
pub:
|
||||||
scr_buf voidptr // pointer to the buffer of data
|
scr_buf voidptr // pointer to the buffer of data
|
||||||
scr_buf_len i64 // if > 0 use the RAM pointed by scr_buf as source of data
|
scr_buf_len i64 // if > 0 use the RAM pointed by scr_buf as source of data
|
||||||
file_path string
|
file_path string
|
||||||
|
|
|
@ -52,6 +52,7 @@ mut:
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct ReaderConfig {
|
pub struct ReaderConfig {
|
||||||
|
pub:
|
||||||
delimiter u8 = `,`
|
delimiter u8 = `,`
|
||||||
comment u8 = `#`
|
comment u8 = `#`
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ mut:
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct WriterConfig {
|
pub struct WriterConfig {
|
||||||
|
pub:
|
||||||
use_crlf bool
|
use_crlf bool
|
||||||
delimiter u8 = `,`
|
delimiter u8 = `,`
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,14 @@ import strconv
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct EscapeConfig {
|
pub struct EscapeConfig {
|
||||||
|
pub:
|
||||||
quote bool = true
|
quote bool = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct UnescapeConfig {
|
pub struct UnescapeConfig {
|
||||||
EscapeConfig
|
EscapeConfig
|
||||||
|
pub:
|
||||||
all bool
|
all bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ pub const default_entities_reverse = {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct EscapeConfig {
|
pub struct EscapeConfig {
|
||||||
|
pub:
|
||||||
reverse_entities map[string]string = xml.default_entities_reverse
|
reverse_entities map[string]string = xml.default_entities_reverse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ pub fn escape_text(content string, config EscapeConfig) string {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct UnescapeConfig {
|
pub struct UnescapeConfig {
|
||||||
|
pub:
|
||||||
entities map[string]string = xml.default_entities
|
entities map[string]string = xml.default_entities
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,21 +37,25 @@ pub:
|
||||||
pub type DTDListItem = DTDElement | DTDEntity
|
pub type DTDListItem = DTDElement | DTDEntity
|
||||||
|
|
||||||
pub struct DTDEntity {
|
pub struct DTDEntity {
|
||||||
|
pub:
|
||||||
name string @[required]
|
name string @[required]
|
||||||
value string @[required]
|
value string @[required]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DTDElement {
|
pub struct DTDElement {
|
||||||
|
pub:
|
||||||
name string @[required]
|
name string @[required]
|
||||||
definition []string @[required]
|
definition []string @[required]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DocumentTypeDefinition {
|
pub struct DocumentTypeDefinition {
|
||||||
|
pub:
|
||||||
name string
|
name string
|
||||||
list []DTDListItem
|
list []DTDListItem
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DocumentType {
|
pub struct DocumentType {
|
||||||
|
pub:
|
||||||
name string @[required]
|
name string @[required]
|
||||||
dtd DTDInfo
|
dtd DTDInfo
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,7 @@ pub enum PaintStyle {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct DrawRectParams {
|
pub struct DrawRectParams {
|
||||||
|
pub:
|
||||||
x f32
|
x f32
|
||||||
y f32
|
y f32
|
||||||
w f32
|
w f32
|
||||||
|
|
|
@ -545,6 +545,7 @@ pub enum EndEnum {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct EndOptions {
|
pub struct EndOptions {
|
||||||
|
pub:
|
||||||
how EndEnum
|
how EndEnum
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -270,6 +270,7 @@ pub fn (mut ctx Context) create_image_from_byte_array(b []u8) !Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct StreamingImageConfig {
|
pub struct StreamingImageConfig {
|
||||||
|
pub:
|
||||||
pixel_format gfx.PixelFormat = .rgba8
|
pixel_format gfx.PixelFormat = .rgba8
|
||||||
wrap_u gfx.Wrap = .clamp_to_edge
|
wrap_u gfx.Wrap = .clamp_to_edge
|
||||||
wrap_v gfx.Wrap = .clamp_to_edge
|
wrap_v gfx.Wrap = .clamp_to_edge
|
||||||
|
|
|
@ -166,6 +166,7 @@ pub fn (ctx &Context) set_text_cfg(cfg gx.TextCfg) {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct DrawTextParams {
|
pub struct DrawTextParams {
|
||||||
|
pub:
|
||||||
x int
|
x int
|
||||||
y int
|
y int
|
||||||
text string
|
text string
|
||||||
|
|
|
@ -16,6 +16,7 @@ pub mut:
|
||||||
|
|
||||||
// BufferedReaderConfig are options that can be given to a buffered reader.
|
// BufferedReaderConfig are options that can be given to a buffered reader.
|
||||||
pub struct BufferedReaderConfig {
|
pub struct BufferedReaderConfig {
|
||||||
|
pub:
|
||||||
reader Reader
|
reader Reader
|
||||||
cap int = 128 * 1024 // large for fast reading of big(ish) files
|
cap int = 128 * 1024 // large for fast reading of big(ish) files
|
||||||
retries int = 2 // how many times to retry before assuming the stream ended
|
retries int = 2 // how many times to retry before assuming the stream ended
|
||||||
|
|
|
@ -35,9 +35,9 @@ pub const read_all_grow_len = 1024
|
||||||
// ReadAllConfig allows options to be passed for the behaviour
|
// ReadAllConfig allows options to be passed for the behaviour
|
||||||
// of read_all.
|
// of read_all.
|
||||||
pub struct ReadAllConfig {
|
pub struct ReadAllConfig {
|
||||||
|
pub:
|
||||||
read_to_end_of_stream bool
|
read_to_end_of_stream bool
|
||||||
mut:
|
reader Reader
|
||||||
reader Reader
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// read_all reads all bytes from a reader until either a 0 length read
|
// read_all reads all bytes from a reader until either a 0 length read
|
||||||
|
|
|
@ -5,6 +5,7 @@ import strings
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct StringReaderParams {
|
pub struct StringReaderParams {
|
||||||
|
pub:
|
||||||
// the reader interface
|
// the reader interface
|
||||||
reader ?io.Reader
|
reader ?io.Reader
|
||||||
// initialize the builder with this source string
|
// initialize the builder with this source string
|
||||||
|
|
|
@ -7,6 +7,7 @@ const retries = 10000
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct TempFileOptions {
|
pub struct TempFileOptions {
|
||||||
|
pub:
|
||||||
path string = os.temp_dir()
|
path string = os.temp_dir()
|
||||||
pattern string
|
pattern string
|
||||||
}
|
}
|
||||||
|
@ -40,6 +41,7 @@ pub fn temp_file(tfo TempFileOptions) !(os.File, string) {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct TempDirOptions {
|
pub struct TempDirOptions {
|
||||||
|
pub:
|
||||||
path string = os.temp_dir()
|
path string = os.temp_dir()
|
||||||
pattern string
|
pattern string
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,8 @@ fn test_set_always_flush() {
|
||||||
os.rmdir_all(lfolder) or {}
|
os.rmdir_all(lfolder) or {}
|
||||||
}
|
}
|
||||||
dump(lfolder)
|
dump(lfolder)
|
||||||
mut l := log.Log{
|
mut l := log.Log{}
|
||||||
level: .info
|
l.set_level(.info)
|
||||||
}
|
|
||||||
l.set_full_logpath(lpath1)
|
l.set_full_logpath(lpath1)
|
||||||
l.set_always_flush(true)
|
l.set_always_flush(true)
|
||||||
l.warn('one warning')
|
l.warn('one warning')
|
||||||
|
|
|
@ -117,6 +117,7 @@ pub fn integer_from_u64(value u64) Integer {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct IntegerConfig {
|
pub struct IntegerConfig {
|
||||||
|
pub:
|
||||||
signum int = 1
|
signum int = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ pub fn angle_diff(radian_a f64, radian_b f64) f64 {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct DigitParams {
|
pub struct DigitParams {
|
||||||
|
pub:
|
||||||
base int = 10
|
base int = 10
|
||||||
reverse bool
|
reverse bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ pub enum ShutdownDirection {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct ShutdownConfig {
|
pub struct ShutdownConfig {
|
||||||
|
pub:
|
||||||
how ShutdownDirection = .read_and_write
|
how ShutdownDirection = .read_and_write
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ mut:
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct GetTagsOptions {
|
pub struct GetTagsOptions {
|
||||||
|
pub:
|
||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,10 @@ pub const max_headers = 50
|
||||||
|
|
||||||
// Header represents the key-value pairs in an HTTP header
|
// Header represents the key-value pairs in an HTTP header
|
||||||
pub struct Header {
|
pub struct Header {
|
||||||
mut:
|
pub mut:
|
||||||
// data map[string][]string
|
// data map[string][]string
|
||||||
data [max_headers]HeaderKV
|
data [max_headers]HeaderKV
|
||||||
|
mut:
|
||||||
cur_pos int
|
cur_pos int
|
||||||
// map of lowercase header keys to their original keys
|
// map of lowercase header keys to their original keys
|
||||||
// in order of appearance
|
// in order of appearance
|
||||||
|
@ -352,6 +353,7 @@ pub fn (mut h Header) free() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct HeaderConfig {
|
pub struct HeaderConfig {
|
||||||
|
pub:
|
||||||
key CommonHeader
|
key CommonHeader
|
||||||
value string
|
value string
|
||||||
}
|
}
|
||||||
|
@ -490,6 +492,7 @@ pub fn (mut h Header) delete_custom(key string) {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct HeaderCoerceConfig {
|
pub struct HeaderCoerceConfig {
|
||||||
|
pub:
|
||||||
canonicalize bool
|
canonicalize bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,6 +556,7 @@ pub fn (h Header) contains(key CommonHeader) bool {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct HeaderQueryConfig {
|
pub struct HeaderQueryConfig {
|
||||||
|
pub:
|
||||||
exact bool
|
exact bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,6 +670,7 @@ pub fn (h Header) keys() []string {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct HeaderRenderConfig {
|
pub struct HeaderRenderConfig {
|
||||||
|
pub:
|
||||||
version Version
|
version Version
|
||||||
coerce bool
|
coerce bool
|
||||||
canonicalize bool
|
canonicalize bool
|
||||||
|
|
|
@ -388,6 +388,7 @@ pub:
|
||||||
|
|
||||||
pub struct UnexpectedExtraAttributeError {
|
pub struct UnexpectedExtraAttributeError {
|
||||||
Error
|
Error
|
||||||
|
pub:
|
||||||
attributes []string
|
attributes []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,7 @@ pub fn (mut r Response) set_version(v Version) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ResponseConfig {
|
pub struct ResponseConfig {
|
||||||
|
pub:
|
||||||
version Version = .v1_1
|
version Version = .v1_1
|
||||||
status Status = .ok
|
status Status = .ok
|
||||||
header Header
|
header Header
|
||||||
|
|
|
@ -32,8 +32,9 @@ struct SSLCerts {
|
||||||
|
|
||||||
// SSLConn is the current connection
|
// SSLConn is the current connection
|
||||||
pub struct SSLConn {
|
pub struct SSLConn {
|
||||||
|
pub:
|
||||||
config SSLConnectConfig
|
config SSLConnectConfig
|
||||||
mut:
|
pub mut:
|
||||||
server_fd C.mbedtls_net_context
|
server_fd C.mbedtls_net_context
|
||||||
ssl C.mbedtls_ssl_context
|
ssl C.mbedtls_ssl_context
|
||||||
conf C.mbedtls_ssl_config
|
conf C.mbedtls_ssl_config
|
||||||
|
@ -215,6 +216,7 @@ pub fn (mut l SSLListener) accept() !&SSLConn {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct SSLConnectConfig {
|
pub struct SSLConnectConfig {
|
||||||
|
pub:
|
||||||
verify string // the path to a rootca.pem file, containing trusted CA certificate(s)
|
verify string // the path to a rootca.pem file, containing trusted CA certificate(s)
|
||||||
cert string // the path to a cert.pem file, containing client certificate(s) for the request
|
cert string // the path to a cert.pem file, containing client certificate(s) for the request
|
||||||
cert_key string // the path to a key.pem file, containing private keys for the client certificate(s)
|
cert_key string // the path to a key.pem file, containing private keys for the client certificate(s)
|
||||||
|
|
|
@ -7,8 +7,9 @@ import os
|
||||||
|
|
||||||
// SSLConn is the current connection
|
// SSLConn is the current connection
|
||||||
pub struct SSLConn {
|
pub struct SSLConn {
|
||||||
|
pub:
|
||||||
config SSLConnectConfig
|
config SSLConnectConfig
|
||||||
mut:
|
pub mut:
|
||||||
sslctx &C.SSL_CTX = unsafe { nil }
|
sslctx &C.SSL_CTX = unsafe { nil }
|
||||||
ssl &C.SSL = unsafe { nil }
|
ssl &C.SSL = unsafe { nil }
|
||||||
handle int
|
handle int
|
||||||
|
@ -19,6 +20,7 @@ mut:
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct SSLConnectConfig {
|
pub struct SSLConnectConfig {
|
||||||
|
pub:
|
||||||
verify string // the path to a rootca.pem file, containing trusted CA certificate(s)
|
verify string // the path to a rootca.pem file, containing trusted CA certificate(s)
|
||||||
cert string // the path to a cert.pem file, containing client certificate(s) for the request
|
cert string // the path to a cert.pem file, containing client certificate(s) for the request
|
||||||
cert_key string // the path to a key.pem file, containing private keys for the client certificate(s)
|
cert_key string // the path to a key.pem file, containing private keys for the client certificate(s)
|
||||||
|
|
|
@ -47,6 +47,7 @@ pub mut:
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Mail {
|
pub struct Mail {
|
||||||
|
pub:
|
||||||
from string
|
from string
|
||||||
to string
|
to string
|
||||||
cc string
|
cc string
|
||||||
|
|
|
@ -9,8 +9,7 @@ pub const tcp_default_write_timeout = 30 * time.second
|
||||||
@[heap]
|
@[heap]
|
||||||
pub struct TcpConn {
|
pub struct TcpConn {
|
||||||
pub mut:
|
pub mut:
|
||||||
sock TcpSocket
|
sock TcpSocket
|
||||||
mut:
|
|
||||||
handle int
|
handle int
|
||||||
write_deadline time.Time
|
write_deadline time.Time
|
||||||
read_deadline time.Time
|
read_deadline time.Time
|
||||||
|
@ -312,8 +311,7 @@ pub fn (c TcpConn) str() string {
|
||||||
|
|
||||||
pub struct TcpListener {
|
pub struct TcpListener {
|
||||||
pub mut:
|
pub mut:
|
||||||
sock TcpSocket
|
sock TcpSocket
|
||||||
mut:
|
|
||||||
accept_timeout time.Duration
|
accept_timeout time.Duration
|
||||||
accept_deadline time.Time
|
accept_deadline time.Time
|
||||||
is_blocking bool = true
|
is_blocking bool = true
|
||||||
|
|
|
@ -224,6 +224,7 @@ mut:
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct ListenOptions {
|
pub struct ListenOptions {
|
||||||
|
pub:
|
||||||
backlog int = 128
|
backlog int = 128
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,15 @@ import rand
|
||||||
import crypto.sha1
|
import crypto.sha1
|
||||||
import encoding.base64
|
import encoding.base64
|
||||||
import encoding.binary
|
import encoding.binary
|
||||||
|
import log
|
||||||
|
|
||||||
|
const default_logger = setup_default_logger()
|
||||||
|
|
||||||
|
fn setup_default_logger() &log.Log {
|
||||||
|
mut l := &log.Log{}
|
||||||
|
l.set_level(.info)
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
// htonl64 converts payload length to header bits
|
// htonl64 converts payload length to header bits
|
||||||
fn htonl64(payload_len u64) []u8 {
|
fn htonl64(payload_len u64) []u8 {
|
||||||
|
|
|
@ -43,9 +43,7 @@ pub mut:
|
||||||
panic_on_callback bool // set to true of callbacks can panic
|
panic_on_callback bool // set to true of callbacks can panic
|
||||||
client_state shared ClientState // current state of connection
|
client_state shared ClientState // current state of connection
|
||||||
// logger used to log messages
|
// logger used to log messages
|
||||||
logger &log.Logger = &log.Logger(&log.Log{
|
logger &log.Logger = default_logger
|
||||||
level: .info
|
|
||||||
})
|
|
||||||
resource_name string // name of current resource
|
resource_name string // name of current resource
|
||||||
last_pong_ut i64 // last time in unix time we got a pong message
|
last_pong_ut i64 // last time in unix time we got a pong message
|
||||||
}
|
}
|
||||||
|
@ -84,11 +82,10 @@ pub enum OPCode {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct ClientOpt {
|
pub struct ClientOpt {
|
||||||
|
pub:
|
||||||
read_timeout i64 = 30 * time.second
|
read_timeout i64 = 30 * time.second
|
||||||
write_timeout i64 = 30 * time.second
|
write_timeout i64 = 30 * time.second
|
||||||
logger &log.Logger = &log.Logger(&log.Log{
|
logger &log.Logger = default_logger
|
||||||
level: .info
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// new_client instance a new websocket client
|
// new_client instance a new websocket client
|
||||||
|
|
|
@ -17,9 +17,7 @@ pub mut:
|
||||||
// Server represents a websocket server connection
|
// Server represents a websocket server connection
|
||||||
pub struct Server {
|
pub struct Server {
|
||||||
mut:
|
mut:
|
||||||
logger &log.Logger = &log.Logger(&log.Log{
|
logger &log.Logger = default_logger
|
||||||
level: .info
|
|
||||||
})
|
|
||||||
ls &net.TcpListener = unsafe { nil } // listener used to get incoming connection to socket
|
ls &net.TcpListener = unsafe { nil } // listener used to get incoming connection to socket
|
||||||
accept_client_callbacks []AcceptClientFn // accept client callback functions
|
accept_client_callbacks []AcceptClientFn // accept client callback functions
|
||||||
message_callbacks []MessageEventHandler // new message callback functions
|
message_callbacks []MessageEventHandler // new message callback functions
|
||||||
|
@ -44,9 +42,8 @@ pub mut:
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct ServerOpt {
|
pub struct ServerOpt {
|
||||||
logger &log.Logger = &log.Logger(&log.Log{
|
pub:
|
||||||
level: .info
|
logger &log.Logger = default_logger
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// new_server instance a new websocket server on provided port and route
|
// new_server instance a new websocket server on provided port and route
|
||||||
|
@ -143,13 +140,13 @@ fn (mut s Server) serve_client(mut c Client) ! {
|
||||||
|
|
||||||
// handle_handshake use an existing connection to respond to the handshake for a given key
|
// handle_handshake use an existing connection to respond to the handshake for a given key
|
||||||
pub fn (mut s Server) handle_handshake(mut conn net.TcpConn, key string) !&ServerClient {
|
pub fn (mut s Server) handle_handshake(mut conn net.TcpConn, key string) !&ServerClient {
|
||||||
|
mut logger := &log.Log{}
|
||||||
|
logger.set_level(.debug)
|
||||||
mut c := &Client{
|
mut c := &Client{
|
||||||
is_server: true
|
is_server: true
|
||||||
conn: conn
|
conn: conn
|
||||||
is_ssl: false
|
is_ssl: false
|
||||||
logger: &log.Log{
|
logger: logger
|
||||||
level: .debug
|
|
||||||
}
|
|
||||||
client_state: ClientState{
|
client_state: ClientState{
|
||||||
state: .open
|
state: .open
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ pub fn fd_read(fd int, maxbytes int) (string, int) {
|
||||||
pub struct C.fd_set {}
|
pub struct C.fd_set {}
|
||||||
|
|
||||||
pub struct C.timeval {
|
pub struct C.timeval {
|
||||||
|
pub:
|
||||||
tv_sec u64
|
tv_sec u64
|
||||||
tv_usec u64
|
tv_usec u64
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,7 @@ pub fn cp_all(src string, dst string, overwrite bool) ! {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct MvParams {
|
pub struct MvParams {
|
||||||
|
pub:
|
||||||
overwrite bool = true
|
overwrite bool = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,6 +718,7 @@ pub fn log(s string) {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct MkdirParams {
|
pub struct MkdirParams {
|
||||||
|
pub:
|
||||||
mode u32 = 0o777 // note that the actual mode is affected by the process's umask
|
mode u32 = 0o777 // note that the actual mode is affected by the process's umask
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ struct Winsize {
|
||||||
// Readline is the key struct for reading and holding user input via a terminal.
|
// Readline is the key struct for reading and holding user input via a terminal.
|
||||||
// Example: import readline { Readline }
|
// Example: import readline { Readline }
|
||||||
pub struct Readline {
|
pub struct Readline {
|
||||||
mut:
|
pub mut:
|
||||||
is_raw bool
|
is_raw bool
|
||||||
orig_termios termios.Termios // Linux
|
orig_termios termios.Termios // Linux
|
||||||
current []rune // Line being edited
|
current []rune // Line being edited
|
||||||
|
|
|
@ -83,6 +83,7 @@ pub mut:
|
||||||
// | num_packets | 64 | for push model only, number of packets in the backend ringbuffer |
|
// | num_packets | 64 | for push model only, number of packets in the backend ringbuffer |
|
||||||
@[typedef]
|
@[typedef]
|
||||||
pub struct C.saudio_desc {
|
pub struct C.saudio_desc {
|
||||||
|
pub:
|
||||||
sample_rate int
|
sample_rate int
|
||||||
num_channels int
|
num_channels int
|
||||||
buffer_frames int
|
buffer_frames int
|
||||||
|
|
|
@ -29,6 +29,7 @@ fn empty_cb(mut p PoolProcessor, idx int, task_id int) voidptr {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PoolProcessorConfig {
|
pub struct PoolProcessorConfig {
|
||||||
|
pub:
|
||||||
maxjobs int
|
maxjobs int
|
||||||
callback ThreadCB = empty_cb
|
callback ThreadCB = empty_cb
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import os
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct ZipFolderOptions {
|
pub struct ZipFolderOptions {
|
||||||
|
pub:
|
||||||
omit_empty_folders bool
|
omit_empty_folders bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,7 @@ pub mut:
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
pub:
|
||||||
user_data voidptr
|
user_data voidptr
|
||||||
init_fn ?fn (voidptr)
|
init_fn ?fn (voidptr)
|
||||||
frame_fn ?fn (voidptr)
|
frame_fn ?fn (voidptr)
|
||||||
|
|
|
@ -5,6 +5,7 @@ module time
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct StopWatchOptions {
|
pub struct StopWatchOptions {
|
||||||
|
pub:
|
||||||
auto_start bool = true
|
auto_start bool = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ module time
|
||||||
|
|
||||||
// C.timeval represents a C time value.
|
// C.timeval represents a C time value.
|
||||||
pub struct C.timeval {
|
pub struct C.timeval {
|
||||||
|
pub:
|
||||||
tv_sec u64
|
tv_sec u64
|
||||||
tv_usec u64
|
tv_usec u64
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub fn (t Time) local() Time {
|
||||||
|
|
||||||
// in most systems, these are __quad_t, which is an i64
|
// in most systems, these are __quad_t, which is an i64
|
||||||
pub struct C.timespec {
|
pub struct C.timespec {
|
||||||
mut:
|
pub mut:
|
||||||
tv_sec i64
|
tv_sec i64
|
||||||
tv_nsec i64
|
tv_nsec i64
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ const start_local_time = local_as_unix_time()
|
||||||
|
|
||||||
// in most systems, these are __quad_t, which is an i64
|
// in most systems, these are __quad_t, which is an i64
|
||||||
pub struct C.timespec {
|
pub struct C.timespec {
|
||||||
|
pub:
|
||||||
tv_sec i64
|
tv_sec i64
|
||||||
tv_nsec i64
|
tv_nsec i64
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ const utf8_max = 0x10FFFF
|
||||||
|
|
||||||
// Checker checks a tree of TOML `ast.Value`'s for common errors.
|
// Checker checks a tree of TOML `ast.Value`'s for common errors.
|
||||||
pub struct Checker {
|
pub struct Checker {
|
||||||
|
pub:
|
||||||
scanner &scanner.Scanner = unsafe { nil }
|
scanner &scanner.Scanner = unsafe { nil }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ const utf8_max = 0x10FFFF
|
||||||
|
|
||||||
// Decoder decode special sequences in a tree of TOML `ast.Value`'s.
|
// Decoder decode special sequences in a tree of TOML `ast.Value`'s.
|
||||||
pub struct Decoder {
|
pub struct Decoder {
|
||||||
|
pub:
|
||||||
scanner &scanner.Scanner = unsafe { nil }
|
scanner &scanner.Scanner = unsafe { nil }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,7 @@ fn to_any[T](value T) Any {
|
||||||
|
|
||||||
// DateTime is the representation of an RFC 3339 datetime string.
|
// DateTime is the representation of an RFC 3339 datetime string.
|
||||||
pub struct DateTime {
|
pub struct DateTime {
|
||||||
|
pub:
|
||||||
datetime string
|
datetime string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +214,7 @@ pub fn (dt DateTime) str() string {
|
||||||
|
|
||||||
// Date is the representation of an RFC 3339 date-only string.
|
// Date is the representation of an RFC 3339 date-only string.
|
||||||
pub struct Date {
|
pub struct Date {
|
||||||
|
pub:
|
||||||
date string
|
date string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,6 +225,7 @@ pub fn (d Date) str() string {
|
||||||
|
|
||||||
// Time is the representation of an RFC 3339 time-only string.
|
// Time is the representation of an RFC 3339 time-only string.
|
||||||
pub struct Time {
|
pub struct Time {
|
||||||
|
pub:
|
||||||
time string
|
time string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -289,6 +289,7 @@ pub fn (t &Table) find_method(s &TypeSymbol, name string) !Fn {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct GetEmbedsOptions {
|
pub struct GetEmbedsOptions {
|
||||||
|
pub:
|
||||||
preceding []Type
|
preceding []Type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1512,6 +1512,7 @@ fn (t Table) shorten_user_defined_typenames(original_name string, import_aliases
|
||||||
|
|
||||||
@[minify]
|
@[minify]
|
||||||
pub struct FnSignatureOpts {
|
pub struct FnSignatureOpts {
|
||||||
|
pub:
|
||||||
skip_receiver bool
|
skip_receiver bool
|
||||||
type_only bool
|
type_only bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -740,11 +740,30 @@ or use an explicit `unsafe{ a[..] }`, if you do not want a copy of the slice.',
|
||||||
|
|
||||||
for i, mut field in fields {
|
for i, mut field in fields {
|
||||||
if field.name in inited_fields {
|
if field.name in inited_fields {
|
||||||
if c.mod != type_sym.mod && field.is_deprecated {
|
if c.mod != type_sym.mod {
|
||||||
for init_field in node.init_fields {
|
if !field.is_pub {
|
||||||
if field.name == init_field.name {
|
parts := type_sym.name.split('.')
|
||||||
c.deprecate('field', field.name, field.attrs, init_field.pos)
|
for init_field in node.init_fields {
|
||||||
break
|
if field.name == init_field.name {
|
||||||
|
mod_type := if parts.len > 1 {
|
||||||
|
parts#[-2..].join('.')
|
||||||
|
} else {
|
||||||
|
parts.last()
|
||||||
|
}
|
||||||
|
c.add_error_detail('this will become an error after 2024-05-31')
|
||||||
|
c.warn('initalizing private field `${field.name}` of `${mod_type}`',
|
||||||
|
init_field.pos)
|
||||||
|
// c.error('cannot access private field `${field.name}` on `${mod_type}`', init_field.pos)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if field.is_deprecated {
|
||||||
|
for init_field in node.init_fields {
|
||||||
|
if field.name == init_field.name {
|
||||||
|
c.deprecate('field', field.name, field.attrs, init_field.pos)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
module amod
|
module amod
|
||||||
|
|
||||||
pub struct Xyz {}
|
pub struct Xyz {
|
||||||
|
pub:
|
||||||
|
x int
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Bcg {}
|
pub struct Bcg {
|
||||||
|
x int
|
||||||
|
}
|
||||||
|
|
||||||
|
@[params]
|
||||||
|
pub struct FooParams {
|
||||||
|
bar string
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn foo(opts FooParams) {}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module point
|
module point
|
||||||
|
|
||||||
pub struct Point {
|
pub struct Point {
|
||||||
mut:
|
pub mut:
|
||||||
x int
|
x int
|
||||||
y int
|
y int
|
||||||
}
|
}
|
||||||
|
|
14
vlib/v/checker/tests/struct_field_private_err.out
Normal file
14
vlib/v/checker/tests/struct_field_private_err.out
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
vlib/v/checker/tests/struct_field_private_err.vv:8:2: warning: initalizing private field `x` of `amod.Bcg`
|
||||||
|
6 |
|
||||||
|
7 | _ := amod.Bcg{
|
||||||
|
8 | x: 0
|
||||||
|
| ~~~~
|
||||||
|
9 | }
|
||||||
|
10 |
|
||||||
|
Details: this will become an error after 2024-05-31
|
||||||
|
vlib/v/checker/tests/struct_field_private_err.vv:11:10: warning: initalizing private field `bar` of `amod.FooParams`
|
||||||
|
9 | }
|
||||||
|
10 |
|
||||||
|
11 | amod.foo(bar: 'bar')
|
||||||
|
| ~~~~~~~~~~
|
||||||
|
Details: this will become an error after 2024-05-31
|
11
vlib/v/checker/tests/struct_field_private_err.vv
Normal file
11
vlib/v/checker/tests/struct_field_private_err.vv
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import v.checker.tests.amod
|
||||||
|
|
||||||
|
_ := amod.Xyz{
|
||||||
|
x: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
_ := amod.Bcg{
|
||||||
|
x: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
amod.foo(bar: 'bar')
|
|
@ -41,6 +41,7 @@ pub enum MouseButtons {
|
||||||
end_options := mod_doc.contents['EndOptions']
|
end_options := mod_doc.contents['EndOptions']
|
||||||
assert end_options.content == '@[params]
|
assert end_options.content == '@[params]
|
||||||
pub struct EndOptions {
|
pub struct EndOptions {
|
||||||
|
pub:
|
||||||
how EndEnum
|
how EndEnum
|
||||||
}'
|
}'
|
||||||
assert end_options.attrs == {
|
assert end_options.attrs == {
|
||||||
|
|
|
@ -35,6 +35,7 @@ pub fn (mut d DotGraph) finish() {
|
||||||
//
|
//
|
||||||
|
|
||||||
pub struct NewNodeConfig {
|
pub struct NewNodeConfig {
|
||||||
|
pub:
|
||||||
node_name string
|
node_name string
|
||||||
should_highlight bool
|
should_highlight bool
|
||||||
tooltip string
|
tooltip string
|
||||||
|
@ -57,6 +58,7 @@ pub fn (mut d DotGraph) new_node(nlabel string, cfg NewNodeConfig) {
|
||||||
//
|
//
|
||||||
|
|
||||||
pub struct NewEdgeConfig {
|
pub struct NewEdgeConfig {
|
||||||
|
pub:
|
||||||
should_highlight bool
|
should_highlight bool
|
||||||
ctx voidptr = unsafe { nil }
|
ctx voidptr = unsafe { nil }
|
||||||
name2node_fn FnLabel2NodeName = node_name
|
name2node_fn FnLabel2NodeName = node_name
|
||||||
|
|
|
@ -51,6 +51,7 @@ pub fn (mut e Eval) run(expression string, args ...Object) ![]Object {
|
||||||
type Symbol = Object | ast.EmptyStmt | ast.FnDecl
|
type Symbol = Object | ast.EmptyStmt | ast.FnDecl
|
||||||
|
|
||||||
pub struct Eval {
|
pub struct Eval {
|
||||||
|
pub:
|
||||||
pref &pref.Preferences = unsafe { nil }
|
pref &pref.Preferences = unsafe { nil }
|
||||||
pub mut:
|
pub mut:
|
||||||
table &ast.Table = unsafe { nil }
|
table &ast.Table = unsafe { nil }
|
||||||
|
|
|
@ -16,6 +16,7 @@ mut:
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
struct AddInfoConfig {
|
struct AddInfoConfig {
|
||||||
|
pub:
|
||||||
use_threshold bool
|
use_threshold bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ pub fn (mut f Fmt) attrs(attrs []ast.Attr) {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct AttrsOptions {
|
pub struct AttrsOptions {
|
||||||
|
pub:
|
||||||
same_line bool
|
same_line bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ const bs = '\\'
|
||||||
|
|
||||||
@[minify]
|
@[minify]
|
||||||
pub struct Fmt {
|
pub struct Fmt {
|
||||||
|
pub:
|
||||||
pref &pref.Preferences = unsafe { nil }
|
pref &pref.Preferences = unsafe { nil }
|
||||||
pub mut:
|
pub mut:
|
||||||
file ast.File
|
file ast.File
|
||||||
|
@ -56,6 +57,7 @@ pub mut:
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct FmtOptions {
|
pub struct FmtOptions {
|
||||||
|
pub:
|
||||||
source_text string
|
source_text string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,6 +169,7 @@ pub fn (mut f Fmt) wrap_long_line(penalty_idx int, add_indent bool) bool {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct RemoveNewLineConfig {
|
pub struct RemoveNewLineConfig {
|
||||||
|
pub:
|
||||||
imports_buffer bool // Work on f.out_imports instead of f.out
|
imports_buffer bool // Work on f.out_imports instead of f.out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ pub fn (mut f Gen) attrs(attrs []ast.Attr) {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct AttrsOptions {
|
pub struct AttrsOptions {
|
||||||
|
pub:
|
||||||
inline bool
|
inline bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,7 @@ pub fn (mut f Gen) wrap_long_line(penalty_idx int, add_indent bool) bool {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct RemoveNewLineConfig {
|
pub struct RemoveNewLineConfig {
|
||||||
|
pub:
|
||||||
imports_buffer bool // Work on f.out_imports instead of f.out
|
imports_buffer bool // Work on f.out_imports instead of f.out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,11 +79,13 @@ enum Amd64SetOp {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
struct AvailableAmd64Register {
|
struct AvailableAmd64Register {
|
||||||
|
pub:
|
||||||
available Amd64Register
|
available Amd64Register
|
||||||
}
|
}
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
struct Amd64RegisterOption {
|
struct Amd64RegisterOption {
|
||||||
|
pub:
|
||||||
reg Amd64Register = Amd64Register.rax
|
reg Amd64Register = Amd64Register.rax
|
||||||
ssereg Amd64SSERegister = Amd64SSERegister.xmm0
|
ssereg Amd64SSERegister = Amd64SSERegister.xmm0
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,6 +231,7 @@ struct GlobalVar {}
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
struct VarConfig {
|
struct VarConfig {
|
||||||
|
pub:
|
||||||
offset i32 // offset from the variable
|
offset i32 // offset from the variable
|
||||||
typ ast.Type // type of the value you want to process e.g. struct fields.
|
typ ast.Type // type of the value you want to process e.g. struct fields.
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,7 @@ pub fn (mut p Pool) type_size(typ ast.Type) (int, int) {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct PoolOpts {
|
pub struct PoolOpts {
|
||||||
|
pub:
|
||||||
null_terminated bool = true
|
null_terminated bool = true
|
||||||
intern_strings bool = true
|
intern_strings bool = true
|
||||||
store_relocs bool = true
|
store_relocs bool = true
|
||||||
|
|
|
@ -21,6 +21,7 @@ fn help_dir() string {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct ExitOptions {
|
pub struct ExitOptions {
|
||||||
|
pub:
|
||||||
exit_code int
|
exit_code int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ const allowed_lock_prefix_ins = ['add', 'adc', 'and', 'btc', 'btr', 'bts', 'cmpx
|
||||||
|
|
||||||
@[minify]
|
@[minify]
|
||||||
pub struct Parser {
|
pub struct Parser {
|
||||||
|
pub:
|
||||||
pref &pref.Preferences = unsafe { nil }
|
pref &pref.Preferences = unsafe { nil }
|
||||||
mut:
|
mut:
|
||||||
file_base string // "hello.v"
|
file_base string // "hello.v"
|
||||||
|
@ -32,7 +33,6 @@ mut:
|
||||||
tok token.Token
|
tok token.Token
|
||||||
prev_tok token.Token
|
prev_tok token.Token
|
||||||
peek_tok token.Token
|
peek_tok token.Token
|
||||||
table &ast.Table = unsafe { nil }
|
|
||||||
language ast.Language
|
language ast.Language
|
||||||
fn_language ast.Language // .c for `fn C.abcd()` declarations
|
fn_language ast.Language // .c for `fn C.abcd()` declarations
|
||||||
expr_level int // prevent too deep recursions for pathological programs
|
expr_level int // prevent too deep recursions for pathological programs
|
||||||
|
@ -70,17 +70,16 @@ mut:
|
||||||
inside_orm bool
|
inside_orm bool
|
||||||
inside_chan_decl bool
|
inside_chan_decl bool
|
||||||
inside_attr_decl bool
|
inside_attr_decl bool
|
||||||
fixed_array_dim int // fixed array dim parsing level
|
fixed_array_dim int // fixed array dim parsing level
|
||||||
or_is_handled bool // ignore `or` in this expression
|
or_is_handled bool // ignore `or` in this expression
|
||||||
builtin_mod bool // are we in the `builtin` module?
|
builtin_mod bool // are we in the `builtin` module?
|
||||||
mod string // current module name
|
mod string // current module name
|
||||||
is_manualfree bool // true when `[manualfree] module abc`, makes *all* fns in the current .v file, opt out of autofree
|
is_manualfree bool // true when `[manualfree] module abc`, makes *all* fns in the current .v file, opt out of autofree
|
||||||
has_globals bool // `[has_globals] module abc` - allow globals declarations, even without -enable-globals, in that single .v file __only__
|
has_globals bool // `[has_globals] module abc` - allow globals declarations, even without -enable-globals, in that single .v file __only__
|
||||||
is_generated bool // `[generated] module abc` - turn off compiler notices for that single .v file __only__.
|
is_generated bool // `[generated] module abc` - turn off compiler notices for that single .v file __only__.
|
||||||
is_translated bool // `[translated] module abc` - mark a file as translated, to relax some compiler checks for translated code.
|
is_translated bool // `[translated] module abc` - mark a file as translated, to relax some compiler checks for translated code.
|
||||||
attrs []ast.Attr // attributes before next decl stmt
|
attrs []ast.Attr // attributes before next decl stmt
|
||||||
expr_mod string // for constructing full type names in parse_type()
|
expr_mod string // for constructing full type names in parse_type()
|
||||||
scope &ast.Scope = unsafe { nil }
|
|
||||||
imports map[string]string // alias => mod_name
|
imports map[string]string // alias => mod_name
|
||||||
ast_imports []ast.Import // mod_names
|
ast_imports []ast.Import // mod_names
|
||||||
used_imports []string // alias
|
used_imports []string // alias
|
||||||
|
@ -107,6 +106,8 @@ mut:
|
||||||
script_mode_start_token token.Token
|
script_mode_start_token token.Token
|
||||||
pub mut:
|
pub mut:
|
||||||
scanner &scanner.Scanner = unsafe { nil }
|
scanner &scanner.Scanner = unsafe { nil }
|
||||||
|
table &ast.Table = unsafe { nil }
|
||||||
|
scope &ast.Scope = unsafe { nil }
|
||||||
errors []errors.Error
|
errors []errors.Error
|
||||||
warnings []errors.Warning
|
warnings []errors.Warning
|
||||||
notices []errors.Notice
|
notices []errors.Notice
|
||||||
|
@ -647,6 +648,7 @@ fn (mut p Parser) check(expected token.Kind) {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
struct ParamsForUnexpected {
|
struct ParamsForUnexpected {
|
||||||
|
pub:
|
||||||
got string
|
got string
|
||||||
expecting string
|
expecting string
|
||||||
prepend_msg string
|
prepend_msg string
|
||||||
|
@ -929,6 +931,7 @@ fn (mut p Parser) comment_stmt() ast.ExprStmt {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
struct EatCommentsConfig {
|
struct EatCommentsConfig {
|
||||||
|
pub:
|
||||||
same_line bool // Only eat comments on the same line as the previous token
|
same_line bool // Only eat comments on the same line as the previous token
|
||||||
follow_up bool // Comments directly below the previous token as long as there is no empty line
|
follow_up bool // Comments directly below the previous token as long as there is no empty line
|
||||||
}
|
}
|
||||||
|
@ -4647,6 +4650,7 @@ fn (mut p Parser) trace[T](fbase string, x &T) {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
struct ParserShowParams {
|
struct ParserShowParams {
|
||||||
|
pub:
|
||||||
msg string
|
msg string
|
||||||
reach int = 3
|
reach int = 3
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module newmodule
|
module newmodule
|
||||||
|
|
||||||
pub struct Params[T] {
|
pub struct Params[T] {
|
||||||
mut:
|
pub mut:
|
||||||
a []T
|
a []T
|
||||||
b int
|
b int
|
||||||
c T
|
c T
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module trace_calls
|
module trace_calls
|
||||||
|
|
||||||
pub struct C.timespec {
|
pub struct C.timespec {
|
||||||
mut:
|
pub mut:
|
||||||
tv_sec i64
|
tv_sec i64
|
||||||
tv_nsec i64
|
tv_nsec i64
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ pub mut:
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct TimerParams {
|
pub struct TimerParams {
|
||||||
|
pub:
|
||||||
should_print bool
|
should_print bool
|
||||||
label string
|
label string
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import os
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct FilterVTestConfig {
|
pub struct FilterVTestConfig {
|
||||||
|
pub:
|
||||||
basepath string
|
basepath string
|
||||||
fix_slashes bool = true
|
fix_slashes bool = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ pub mut:
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SSEMessage {
|
pub struct SSEMessage {
|
||||||
|
pub:
|
||||||
id string
|
id string
|
||||||
event string
|
event string
|
||||||
data string
|
data string
|
||||||
|
|
|
@ -321,6 +321,7 @@ pub fn (mut ctx Context) server_error(ecode int) Result {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct RedirectParams {
|
pub struct RedirectParams {
|
||||||
|
pub:
|
||||||
status_code int = 302
|
status_code int = 302
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,6 +524,7 @@ pub fn run[T](global_app &T, port int) {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct RunParams {
|
pub struct RunParams {
|
||||||
|
pub:
|
||||||
family net.AddrFamily = .ip6 // use `family: .ip, host: 'localhost'` when you want it to bind only to 127.0.0.1
|
family net.AddrFamily = .ip6 // use `family: .ip, host: 'localhost'` when you want it to bind only to 127.0.0.1
|
||||||
host string
|
host string
|
||||||
port int = 8080
|
port int = 8080
|
||||||
|
@ -1215,6 +1217,7 @@ fn (mut w Worker[T]) process_incoming_requests() {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct PoolParams[T] {
|
pub struct PoolParams[T] {
|
||||||
|
pub:
|
||||||
handler fn () T = unsafe { nil } @[required]
|
handler fn () T = unsafe { nil } @[required]
|
||||||
nr_workers int = runtime.nr_jobs()
|
nr_workers int = runtime.nr_jobs()
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import time
|
||||||
// Encoder encodes the an `Any` type into JSON representation.
|
// Encoder encodes the an `Any` type into JSON representation.
|
||||||
// It provides parameters in order to change the end result.
|
// It provides parameters in order to change the end result.
|
||||||
pub struct Encoder {
|
pub struct Encoder {
|
||||||
|
pub:
|
||||||
newline u8
|
newline u8
|
||||||
newline_spaces_count int
|
newline_spaces_count int
|
||||||
escape_unicode bool = true
|
escape_unicode bool = true
|
||||||
|
|
|
@ -16,6 +16,7 @@ pub enum KeyType {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct StructCheckResult {
|
pub struct StructCheckResult {
|
||||||
|
pub:
|
||||||
duplicates []string
|
duplicates []string
|
||||||
superfluous []string
|
superfluous []string
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ pub mut:
|
||||||
// CookieOptions contains the default settings for the cookie created in
|
// CookieOptions contains the default settings for the cookie created in
|
||||||
// the `Sessions` struct.
|
// the `Sessions` struct.
|
||||||
pub struct CookieOptions {
|
pub struct CookieOptions {
|
||||||
|
pub:
|
||||||
cookie_name string = 'sid'
|
cookie_name string = 'sid'
|
||||||
domain string
|
domain string
|
||||||
http_only bool = true
|
http_only bool = true
|
||||||
|
|
|
@ -159,6 +159,7 @@ struct HtmlFileInfo {
|
||||||
// TemplateCacheParams are used to specify cache expiration delay and provide placeholder data for substitution in templates.
|
// TemplateCacheParams are used to specify cache expiration delay and provide placeholder data for substitution in templates.
|
||||||
@[params]
|
@[params]
|
||||||
pub struct TemplateCacheParams {
|
pub struct TemplateCacheParams {
|
||||||
|
pub:
|
||||||
placeholders &map[string]DtmMultiTypeMap = &map[string]DtmMultiTypeMap{}
|
placeholders &map[string]DtmMultiTypeMap = &map[string]DtmMultiTypeMap{}
|
||||||
cache_delay_expiration i64 = dtm.cache_delay_expiration_by_default
|
cache_delay_expiration i64 = dtm.cache_delay_expiration_by_default
|
||||||
}
|
}
|
||||||
|
@ -166,6 +167,7 @@ pub struct TemplateCacheParams {
|
||||||
// DynamicTemplateManagerInitialisationParams is used with 'initialize' function. (See below at initialize section)
|
// DynamicTemplateManagerInitialisationParams is used with 'initialize' function. (See below at initialize section)
|
||||||
@[params]
|
@[params]
|
||||||
pub struct DynamicTemplateManagerInitialisationParams {
|
pub struct DynamicTemplateManagerInitialisationParams {
|
||||||
|
pub:
|
||||||
def_cache_path string
|
def_cache_path string
|
||||||
compress_html bool = true
|
compress_html bool = true
|
||||||
active_cache_server bool = true
|
active_cache_server bool = true
|
||||||
|
|
|
@ -227,6 +227,7 @@ pub fn (mut ctx Context) server_error(msg string) Result {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct RedirectParams {
|
pub struct RedirectParams {
|
||||||
|
pub:
|
||||||
typ RedirectType
|
typ RedirectType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ mut:
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct MiddlewareOptions[T] {
|
pub struct MiddlewareOptions[T] {
|
||||||
|
pub:
|
||||||
handler fn (mut ctx T) bool @[required]
|
handler fn (mut ctx T) bool @[required]
|
||||||
after bool
|
after bool
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,6 +210,7 @@ pub fn run[A, X](mut global_app A, port int) {
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct RunParams {
|
pub struct RunParams {
|
||||||
|
pub:
|
||||||
// use `family: .ip, host: 'localhost'` when you want it to bind only to 127.0.0.1
|
// use `family: .ip, host: 'localhost'` when you want it to bind only to 127.0.0.1
|
||||||
family net.AddrFamily = .ip6
|
family net.AddrFamily = .ip6
|
||||||
host string
|
host string
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue