mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
all: unwrap const() blocks
This commit is contained in:
parent
399af6768d
commit
f09826e928
436 changed files with 10448 additions and 11207 deletions
|
@ -9,12 +9,10 @@ struct Vector {
|
|||
z f64
|
||||
}
|
||||
|
||||
const (
|
||||
boids_count = 10000
|
||||
max_coordinate = 10000.0
|
||||
cohesion_distance = 10.0
|
||||
separation_distance = 5.0
|
||||
)
|
||||
const boids_count = 10000
|
||||
const max_coordinate = 10000.0
|
||||
const cohesion_distance = 10.0
|
||||
const separation_distance = 5.0
|
||||
|
||||
@[direct_array_access]
|
||||
fn main() {
|
||||
|
|
|
@ -10,10 +10,9 @@ import v.ast
|
|||
import rand
|
||||
import term
|
||||
|
||||
const (
|
||||
base_os = 'linux'
|
||||
os_names = ['linux', 'macos', 'windows', 'freebsd', 'openbsd', 'solaris', 'termux']
|
||||
skip_modules = [
|
||||
const base_os = 'linux'
|
||||
const os_names = ['linux', 'macos', 'windows', 'freebsd', 'openbsd', 'solaris', 'termux']
|
||||
const skip_modules = [
|
||||
'builtin.bare',
|
||||
'builtin.linux_bare.old',
|
||||
'builtin.js',
|
||||
|
@ -26,8 +25,7 @@ const (
|
|||
'os2',
|
||||
'szip',
|
||||
'v.eval',
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
struct App {
|
||||
diff_cmd string
|
||||
|
|
|
@ -22,60 +22,50 @@ import net.urllib
|
|||
// --force force update even if already up to date
|
||||
|
||||
// git credentials
|
||||
const (
|
||||
git_username = os.getenv('GITUSER')
|
||||
git_password = os.getenv('GITPASS')
|
||||
)
|
||||
const git_username = os.getenv('GITUSER')
|
||||
const git_password = os.getenv('GITPASS')
|
||||
|
||||
// repository
|
||||
const (
|
||||
// git repo
|
||||
git_repo_v = 'github.com/vlang/v'
|
||||
git_repo_vc = 'github.com/vlang/vc'
|
||||
// local repo directories
|
||||
git_repo_dir_v = 'v'
|
||||
git_repo_dir_vc = 'vc'
|
||||
)
|
||||
// git repo
|
||||
const git_repo_v = 'github.com/vlang/v'
|
||||
const git_repo_vc = 'github.com/vlang/vc'
|
||||
// local repo directories
|
||||
const git_repo_dir_v = 'v'
|
||||
const git_repo_dir_vc = 'vc'
|
||||
|
||||
// gen_vc
|
||||
const (
|
||||
// name
|
||||
app_name = 'gen_vc'
|
||||
// version
|
||||
app_version = '0.1.3'
|
||||
// description
|
||||
app_description = "This tool regenerates V's bootstrap .c files every time the V master branch is updated."
|
||||
// assume something went wrong if file size less than this
|
||||
too_short_file_limit = 5000
|
||||
// create a .c file for these os's
|
||||
vc_build_oses = [
|
||||
// name
|
||||
const app_name = 'gen_vc'
|
||||
// version
|
||||
const app_version = '0.1.3'
|
||||
// description
|
||||
const app_description = "This tool regenerates V's bootstrap .c files every time the V master branch is updated."
|
||||
// assume something went wrong if file size less than this
|
||||
const too_short_file_limit = 5000
|
||||
// create a .c file for these os's
|
||||
const vc_build_oses = [
|
||||
'nix',
|
||||
// all nix based os
|
||||
'windows',
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
// default options (overridden by flags)
|
||||
const (
|
||||
// gen_vc working directory
|
||||
work_dir = '/tmp/gen_vc'
|
||||
// dont push anything to remote repo
|
||||
dry_run = false
|
||||
// server port
|
||||
server_port = 7171
|
||||
// log file
|
||||
log_file = '${work_dir}/log.txt'
|
||||
// log_to is either 'file' or 'terminal'
|
||||
log_to = 'terminal'
|
||||
)
|
||||
// gen_vc working directory
|
||||
const work_dir = '/tmp/gen_vc'
|
||||
// dont push anything to remote repo
|
||||
const dry_run = false
|
||||
// server port
|
||||
const server_port = 7171
|
||||
// log file
|
||||
const log_file = '${work_dir}/log.txt'
|
||||
// log_to is either 'file' or 'terminal'
|
||||
const log_to = 'terminal'
|
||||
|
||||
// errors
|
||||
const (
|
||||
err_msg_build = 'error building'
|
||||
err_msg_make = 'make failed'
|
||||
err_msg_gen_c = 'failed to generate .c file'
|
||||
err_msg_cmd_x = 'error running cmd'
|
||||
)
|
||||
const err_msg_build = 'error building'
|
||||
const err_msg_make = 'make failed'
|
||||
const err_msg_gen_c = 'failed to generate .c file'
|
||||
const err_msg_cmd_x = 'error running cmd'
|
||||
|
||||
struct GenVC {
|
||||
// logger
|
||||
|
|
|
@ -4,9 +4,7 @@ import os
|
|||
import term
|
||||
import time
|
||||
|
||||
const (
|
||||
term_colors = term.can_show_color_on_stdout()
|
||||
)
|
||||
const term_colors = term.can_show_color_on_stdout()
|
||||
|
||||
pub fn set_verbose(on bool) {
|
||||
// setting a global here would be the obvious solution,
|
||||
|
|
|
@ -3,9 +3,8 @@ import flag
|
|||
import scripting
|
||||
import vgit
|
||||
|
||||
const (
|
||||
tool_version = '0.0.4'
|
||||
tool_description = ' Checkout an old V and compile it as it was on specific commit.
|
||||
const tool_version = '0.0.4'
|
||||
const tool_description = ' Checkout an old V and compile it as it was on specific commit.
|
||||
| This tool is useful, when you want to discover when something broke.
|
||||
| It is also useful, when you just want to experiment with an older historic V.
|
||||
|
|
||||
|
@ -25,7 +24,6 @@ const (
|
|||
| ## until you find the commit, where the problem first occurred.
|
||||
| ## When you finish, do not forget to do:
|
||||
| git bisect reset'.strip_margin()
|
||||
)
|
||||
|
||||
struct Context {
|
||||
mut:
|
||||
|
|
|
@ -3,13 +3,11 @@ import flag
|
|||
import scripting
|
||||
import vgit
|
||||
|
||||
const (
|
||||
tool_version = '0.0.6'
|
||||
tool_description = " Compares V executable size and performance,
|
||||
const tool_version = '0.0.6'
|
||||
const tool_description = " Compares V executable size and performance,
|
||||
| between 2 commits from V's local git history.
|
||||
| When only one commit is given, it is compared to master.
|
||||
| ".strip_margin()
|
||||
)
|
||||
|
||||
struct Context {
|
||||
cwd string // current working folder
|
||||
|
|
|
@ -135,11 +135,10 @@ fn (a Aints) str() string {
|
|||
'ms ± σ: ${a.stddev:4.1f}ms, min: ${a.imin:4}ms, max: ${a.imax:4}ms, runs:${a.values.len:3}, nmins:${a.nmins:2}, nmaxs:${a.nmaxs:2}'
|
||||
}
|
||||
|
||||
const (
|
||||
max_fail_percent = 100 * 1000
|
||||
max_time = 60 * 1000 // ms
|
||||
performance_regression_label = 'Performance regression detected, failing since '
|
||||
)
|
||||
const max_fail_percent = 100 * 1000
|
||||
const max_time = 60 * 1000 // ms
|
||||
|
||||
const performance_regression_label = 'Performance regression detected, failing since '
|
||||
|
||||
fn main() {
|
||||
mut context := Context{}
|
||||
|
|
|
@ -5,11 +5,9 @@ module main
|
|||
import os
|
||||
import rand
|
||||
|
||||
const (
|
||||
vexe = os.quoted_path(get_vexe_path())
|
||||
vroot = os.dir(vexe)
|
||||
tdir = new_tdir()
|
||||
)
|
||||
const vexe = os.quoted_path(get_vexe_path())
|
||||
const vroot = os.dir(vexe)
|
||||
const tdir = new_tdir()
|
||||
|
||||
fn get_vexe_path() string {
|
||||
env_vexe := os.getenv('VEXE')
|
||||
|
|
|
@ -10,11 +10,9 @@ import math
|
|||
import time { Time, now }
|
||||
|
||||
// const decl
|
||||
const (
|
||||
a = 1
|
||||
b = 3
|
||||
c = 'c'
|
||||
)
|
||||
const a = 1
|
||||
const b = 3
|
||||
const c = 'c'
|
||||
|
||||
// struct decl
|
||||
struct Point {
|
||||
|
|
|
@ -4,10 +4,8 @@ import os
|
|||
import flag
|
||||
import strings
|
||||
|
||||
const (
|
||||
tool_version = '0.0.4'
|
||||
tool_description = 'Converts a list of arbitrary files into a single v module file.'
|
||||
)
|
||||
const tool_version = '0.0.4'
|
||||
const tool_description = 'Converts a list of arbitrary files into a single v module file.'
|
||||
|
||||
struct Context {
|
||||
mut:
|
||||
|
|
|
@ -7,10 +7,9 @@ import os
|
|||
import regex
|
||||
import semver
|
||||
|
||||
const (
|
||||
tool_name = os.file_name(os.executable())
|
||||
tool_version = '0.1.0'
|
||||
tool_description = '\n Bump the semantic version of the v.mod and/or specified files.
|
||||
const tool_name = os.file_name(os.executable())
|
||||
const tool_version = '0.1.0'
|
||||
const tool_description = '\n Bump the semantic version of the v.mod and/or specified files.
|
||||
|
||||
The first instance of a version number is replaced with the new version.
|
||||
Additionally, the line affected must contain the word "version" in any
|
||||
|
@ -34,8 +33,8 @@ Examples:
|
|||
Upgrade the minor version in sample.v only
|
||||
v bump --minor sample.v
|
||||
'
|
||||
semver_query = r'((0)|([1-9]\d*)\.){2}(0)|([1-9]\d*)(\-[\w\d\.\-_]+)?(\+[\w\d\.\-_]+)?'
|
||||
)
|
||||
|
||||
const semver_query = r'((0)|([1-9]\d*)\.){2}(0)|([1-9]\d*)(\-[\w\d\.\-_]+)?(\+[\w\d\.\-_]+)?'
|
||||
|
||||
struct Options {
|
||||
show_help bool
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import os
|
||||
|
||||
const (
|
||||
vexe = @VEXE
|
||||
tfolder = os.join_path(os.vtmp_dir(), 'vbump')
|
||||
)
|
||||
const vexe = @VEXE
|
||||
const tfolder = os.join_path(os.vtmp_dir(), 'vbump')
|
||||
|
||||
fn testsuite_begin() {
|
||||
os.mkdir_all(tfolder) or {}
|
||||
|
@ -59,10 +57,9 @@ version = '1.5.1'
|
|||
import os
|
||||
import flag
|
||||
|
||||
const (
|
||||
tool_name = os.file_name(os.executable())
|
||||
tool_version = '0.1.33'
|
||||
)
|
||||
const tool_name = os.file_name(os.executable())
|
||||
const tool_version = '0.1.33'
|
||||
|
||||
fn main() {
|
||||
// stuff
|
||||
}
|
||||
|
|
|
@ -10,21 +10,19 @@ import term
|
|||
import v.help
|
||||
import regex
|
||||
|
||||
const (
|
||||
too_long_line_length_example = 120
|
||||
too_long_line_length_codeblock = 120
|
||||
too_long_line_length_table = 120
|
||||
too_long_line_length_link = 150
|
||||
too_long_line_length_other = 100
|
||||
term_colors = term.can_show_color_on_stderr()
|
||||
hide_warnings = '-hide-warnings' in os.args || '-w' in os.args
|
||||
show_progress = os.getenv('GITHUB_JOB') == '' && '-silent' !in os.args
|
||||
non_option_args = cmdline.only_non_options(os.args[2..])
|
||||
is_verbose = os.getenv('VERBOSE') != ''
|
||||
vcheckfolder = os.join_path(os.vtmp_dir(), 'vcheck_${os.getuid()}')
|
||||
should_autofix = os.getenv('VAUTOFIX') != ''
|
||||
vexe = @VEXE
|
||||
)
|
||||
const too_long_line_length_example = 120
|
||||
const too_long_line_length_codeblock = 120
|
||||
const too_long_line_length_table = 120
|
||||
const too_long_line_length_link = 150
|
||||
const too_long_line_length_other = 100
|
||||
const term_colors = term.can_show_color_on_stderr()
|
||||
const hide_warnings = '-hide-warnings' in os.args || '-w' in os.args
|
||||
const show_progress = os.getenv('GITHUB_JOB') == '' && '-silent' !in os.args
|
||||
const non_option_args = cmdline.only_non_options(os.args[2..])
|
||||
const is_verbose = os.getenv('VERBOSE') != ''
|
||||
const vcheckfolder = os.join_path(os.vtmp_dir(), 'vcheck_${os.getuid()}')
|
||||
const should_autofix = os.getenv('VAUTOFIX') != ''
|
||||
const vexe = @VEXE
|
||||
|
||||
struct CheckResult {
|
||||
pub mut:
|
||||
|
|
|
@ -41,10 +41,10 @@ module main
|
|||
|
||||
import os
|
||||
|
||||
const (
|
||||
auto_complete_shells = ['bash', 'fish', 'zsh', 'powershell'] // list of supported shells
|
||||
vexe = os.getenv('VEXE')
|
||||
help_text = "Usage:
|
||||
const auto_complete_shells = ['bash', 'fish', 'zsh', 'powershell'] // list of supported shells
|
||||
|
||||
const vexe = os.getenv('VEXE')
|
||||
const help_text = "Usage:
|
||||
v complete [options] [SUBCMD] QUERY...
|
||||
|
||||
Description:
|
||||
|
@ -72,11 +72,9 @@ SUBCMD:
|
|||
fish : [QUERY] - returns Fish compatible completion code with completions computed from QUERY
|
||||
zsh : [QUERY] - returns ZSH compatible completion code with completions computed from QUERY
|
||||
powershell: [QUERY] - returns PowerShell compatible completion code with completions computed from QUERY"
|
||||
)
|
||||
|
||||
// Snooped from cmd/v/v.v, vlib/v/pref/pref.c.v
|
||||
const (
|
||||
auto_complete_commands = [
|
||||
const auto_complete_commands = [
|
||||
// simple_cmd
|
||||
'ast',
|
||||
'doc',
|
||||
|
@ -131,12 +129,12 @@ const (
|
|||
'build',
|
||||
'build-module',
|
||||
'missdoc',
|
||||
]
|
||||
// Entries in the flag arrays below should be entered as is:
|
||||
// * Short flags, e.g.: "-v", should be entered: '-v'
|
||||
// * Long flags, e.g.: "--version", should be entered: '--version'
|
||||
// * Single-dash flags, e.g.: "-version", should be entered: '-version'
|
||||
auto_complete_flags = [
|
||||
]
|
||||
// Entries in the flag arrays below should be entered as is:
|
||||
// * Short flags, e.g.: "-v", should be entered: '-v'
|
||||
// * Long flags, e.g.: "--version", should be entered: '--version'
|
||||
// * Single-dash flags, e.g.: "-version", should be entered: '-version'
|
||||
const auto_complete_flags = [
|
||||
'-apk',
|
||||
'-show-timings',
|
||||
'-check-syntax',
|
||||
|
@ -196,8 +194,8 @@ const (
|
|||
'-V',
|
||||
'-version',
|
||||
'--version',
|
||||
]
|
||||
auto_complete_flags_doc = [
|
||||
]
|
||||
const auto_complete_flags_doc = [
|
||||
'-all',
|
||||
'-f',
|
||||
'-h',
|
||||
|
@ -215,16 +213,16 @@ const (
|
|||
'-p',
|
||||
'-s',
|
||||
'-l',
|
||||
]
|
||||
auto_complete_flags_fmt = [
|
||||
]
|
||||
const auto_complete_flags_fmt = [
|
||||
'-c',
|
||||
'-diff',
|
||||
'-l',
|
||||
'-w',
|
||||
'-debug',
|
||||
'-verify',
|
||||
]
|
||||
auto_complete_flags_bin2v = [
|
||||
]
|
||||
const auto_complete_flags_bin2v = [
|
||||
'-h',
|
||||
'--help',
|
||||
'-m',
|
||||
|
@ -233,8 +231,8 @@ const (
|
|||
'--prefix',
|
||||
'-w',
|
||||
'--write',
|
||||
]
|
||||
auto_complete_flags_shader = [
|
||||
]
|
||||
const auto_complete_flags_shader = [
|
||||
'--help',
|
||||
'-h',
|
||||
'--force-update',
|
||||
|
@ -245,8 +243,8 @@ const (
|
|||
'-l',
|
||||
'--output',
|
||||
'-o',
|
||||
]
|
||||
auto_complete_flags_missdoc = [
|
||||
]
|
||||
const auto_complete_flags_missdoc = [
|
||||
'--help',
|
||||
'-h',
|
||||
'--tags',
|
||||
|
@ -264,16 +262,16 @@ const (
|
|||
'--js',
|
||||
'--verify',
|
||||
'--diff',
|
||||
]
|
||||
auto_complete_flags_bump = [
|
||||
]
|
||||
const auto_complete_flags_bump = [
|
||||
'--patch',
|
||||
'--minor',
|
||||
'--major',
|
||||
]
|
||||
auto_complete_flags_self = [
|
||||
]
|
||||
const auto_complete_flags_self = [
|
||||
'-prod',
|
||||
]
|
||||
auto_complete_compilers = [
|
||||
]
|
||||
const auto_complete_compilers = [
|
||||
'cc',
|
||||
'gcc',
|
||||
'tcc',
|
||||
|
@ -281,8 +279,7 @@ const (
|
|||
'clang',
|
||||
'mingw',
|
||||
'msvc',
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
// auto_complete prints auto completion results back to the calling shell's completion system.
|
||||
// auto_complete acts as communication bridge between the calling shell and V's completions.
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import os
|
||||
|
||||
const (
|
||||
vexe = @VEXE
|
||||
tfolder = os.join_path(os.vtmp_dir(), 'vcomplete_test')
|
||||
)
|
||||
const vexe = @VEXE
|
||||
const tfolder = os.join_path(os.vtmp_dir(), 'vcomplete_test')
|
||||
|
||||
enum Shell {
|
||||
bash
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
import os
|
||||
import v.vmod
|
||||
|
||||
const (
|
||||
vroot = os.quoted_path(@VEXEROOT)
|
||||
vexe = os.quoted_path(@VEXE)
|
||||
// Expect has to be installed for the test.
|
||||
expect_exe = os.quoted_path(os.find_abs_path_of_executable('expect') or {
|
||||
const vroot = os.quoted_path(@VEXEROOT)
|
||||
const vexe = os.quoted_path(@VEXE)
|
||||
// Expect has to be installed for the test.
|
||||
const expect_exe = os.quoted_path(os.find_abs_path_of_executable('expect') or {
|
||||
eprintln('skipping test, since expect is missing')
|
||||
exit(0)
|
||||
})
|
||||
// Directory that contains the Expect scripts used in the test.
|
||||
expect_tests_path = os.join_path(@VEXEROOT, 'cmd', 'tools', 'vcreate', 'tests')
|
||||
test_project_dir_name = 'test_project'
|
||||
// Running tests appends a tsession path to VTMP, which is automatically cleaned up after the test.
|
||||
// The following will result in e.g. `$VTMP/tsession_7fe8e93bd740_1612958707536/test_project/`.
|
||||
test_path = os.join_path(os.vtmp_dir(), test_project_dir_name)
|
||||
)
|
||||
})
|
||||
// Directory that contains the Expect scripts used in the test.
|
||||
const expect_tests_path = os.join_path(@VEXEROOT, 'cmd', 'tools', 'vcreate', 'tests')
|
||||
const test_project_dir_name = 'test_project'
|
||||
// Running tests appends a tsession path to VTMP, which is automatically cleaned up after the test.
|
||||
// The following will result in e.g. `$VTMP/tsession_7fe8e93bd740_1612958707536/test_project/`.
|
||||
const test_path = os.join_path(os.vtmp_dir(), test_project_dir_name)
|
||||
|
||||
fn testsuite_end() {
|
||||
os.rmdir_all(test_path) or {}
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
import os
|
||||
import v.vmod
|
||||
|
||||
const (
|
||||
vroot = @VEXEROOT
|
||||
// Expect has to be installed for the test.
|
||||
expect_exe = os.quoted_path(os.find_abs_path_of_executable('expect') or {
|
||||
const vroot = @VEXEROOT
|
||||
// Expect has to be installed for the test.
|
||||
const expect_exe = os.quoted_path(os.find_abs_path_of_executable('expect') or {
|
||||
eprintln('skipping test, since expect is missing')
|
||||
exit(0)
|
||||
})
|
||||
// Directory that contains the Expect scripts used in the test.
|
||||
expect_tests_path = os.join_path(@VEXEROOT, 'cmd', 'tools', 'vcreate', 'tests')
|
||||
// Running tests appends a tsession path to VTMP, which is automatically cleaned up after the test.
|
||||
// The following will result in e.g. `$VTMP/tsession_7fe8e93bd740_1612958707536/test_vcreate_input/`.
|
||||
test_module_path = os.join_path(os.vtmp_dir(), 'test_vcreate_input')
|
||||
)
|
||||
})
|
||||
// Directory that contains the Expect scripts used in the test.
|
||||
const expect_tests_path = os.join_path(@VEXEROOT, 'cmd', 'tools', 'vcreate', 'tests')
|
||||
// Running tests appends a tsession path to VTMP, which is automatically cleaned up after the test.
|
||||
// The following will result in e.g. `$VTMP/tsession_7fe8e93bd740_1612958707536/test_vcreate_input/`.
|
||||
const test_module_path = os.join_path(os.vtmp_dir(), 'test_vcreate_input')
|
||||
|
||||
fn testsuite_begin() {
|
||||
dump(expect_exe)
|
||||
|
|
|
@ -12,19 +12,17 @@ import v.doc
|
|||
import v.pref
|
||||
import v.util { tabs }
|
||||
|
||||
const (
|
||||
css_js_assets = ['doc.css', 'normalize.css', 'doc.js', 'dark-mode.js']
|
||||
default_theme = os.resource_abs_path('theme')
|
||||
link_svg = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>'
|
||||
const css_js_assets = ['doc.css', 'normalize.css', 'doc.js', 'dark-mode.js']
|
||||
const default_theme = os.resource_abs_path('theme')
|
||||
const link_svg = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>'
|
||||
|
||||
single_quote = "'"
|
||||
double_quote = '"'
|
||||
no_quotes_replacement = [single_quote, '', double_quote, '']
|
||||
const single_quote = "'"
|
||||
const double_quote = '"'
|
||||
const no_quotes_replacement = [single_quote, '', double_quote, '']
|
||||
|
||||
html_tag_escape_re = regex.regex_opt(r'`.+[(<)(>)].+`') or { panic(err) }
|
||||
html_tag_escape_seq = ['<', '<', '>', '>']
|
||||
md_script_escape_seq = ['<script>', '`', '</script>', '`']
|
||||
)
|
||||
const html_tag_escape_re = regex.regex_opt(r'`.+[(<)(>)].+`') or { panic(err) }
|
||||
const html_tag_escape_seq = ['<', '<', '>', '>']
|
||||
const md_script_escape_seq = ['<script>', '`', '</script>', '`']
|
||||
|
||||
enum HighlightTokenTyp {
|
||||
unone
|
||||
|
|
14
cmd/tools/vdoc/tests/testdata/basic/main.v
vendored
14
cmd/tools/vdoc/tests/testdata/basic/main.v
vendored
|
@ -1,13 +1,11 @@
|
|||
pub const (
|
||||
source_root = 'temp' // some const
|
||||
another = int(5) //
|
||||
)
|
||||
pub const source_root = 'temp' // some const
|
||||
|
||||
pub const another = int(5)
|
||||
|
||||
// Used to indicate that you don't care what the window position is.
|
||||
pub const (
|
||||
windowpos_undefined_mask = C.SDL_WINDOWPOS_UNDEFINED_MASK // 0x1FFF0000u
|
||||
windowpos_undefined = C.SDL_WINDOWPOS_UNDEFINED //
|
||||
)
|
||||
pub const windowpos_undefined_mask = C.SDL_WINDOWPOS_UNDEFINED_MASK // 0x1FFF0000u
|
||||
|
||||
pub const windowpos_undefined = C.SDL_WINDOWPOS_UNDEFINED
|
||||
|
||||
// funky - comment for function below
|
||||
pub fn funky() {
|
||||
|
|
|
@ -31,11 +31,9 @@ mut:
|
|||
diff_cmd string // filled in when -diff or -verify is passed
|
||||
}
|
||||
|
||||
const (
|
||||
formatted_file_token = '\@\@\@' + 'FORMATTED_FILE: '
|
||||
vtmp_folder = os.vtmp_dir()
|
||||
term_colors = term.can_show_color_on_stderr()
|
||||
)
|
||||
const formatted_file_token = '\@\@\@' + 'FORMATTED_FILE: '
|
||||
const vtmp_folder = os.vtmp_dir()
|
||||
const term_colors = term.can_show_color_on_stderr()
|
||||
|
||||
fn main() {
|
||||
// if os.getenv('VFMT_ENABLE') == '' {
|
||||
|
|
|
@ -44,10 +44,9 @@ import flag
|
|||
import time
|
||||
import toml
|
||||
|
||||
const (
|
||||
tool_name = 'vgret'
|
||||
tool_version = '0.0.2'
|
||||
tool_description = '\n Dump and/or compare rendered frames of graphical apps
|
||||
const tool_name = 'vgret'
|
||||
const tool_version = '0.0.2'
|
||||
const tool_description = '\n Dump and/or compare rendered frames of graphical apps
|
||||
both external and `gg` based apps is supported.
|
||||
|
||||
Examples:
|
||||
|
@ -58,25 +57,21 @@ Examples:
|
|||
Compare screenshots in `/tmp/src` to existing screenshots in `/tmp/dst`
|
||||
v gret --compare-only /tmp/src /tmp/dst
|
||||
'
|
||||
tmp_dir = os.join_path(os.vtmp_dir(), tool_name)
|
||||
runtime_os = os.user_os()
|
||||
v_root = os.real_path(@VMODROOT)
|
||||
)
|
||||
|
||||
const (
|
||||
supported_hosts = ['linux']
|
||||
supported_capture_methods = ['gg_record', 'generic_screenshot']
|
||||
// External tool executables
|
||||
v_exe = os.getenv('VEXE')
|
||||
idiff_exe = os.find_abs_path_of_executable('idiff') or { '' }
|
||||
)
|
||||
const tmp_dir = os.join_path(os.vtmp_dir(), tool_name)
|
||||
const runtime_os = os.user_os()
|
||||
const v_root = os.real_path(@VMODROOT)
|
||||
|
||||
const (
|
||||
embedded_toml = $embed_file('vgret.defaults.toml', .zlib)
|
||||
default_toml = embedded_toml.to_string()
|
||||
empty_toml_array = []toml.Any{}
|
||||
empty_toml_map = map[string]toml.Any{}
|
||||
)
|
||||
const supported_hosts = ['linux']
|
||||
const supported_capture_methods = ['gg_record', 'generic_screenshot']
|
||||
// External tool executables
|
||||
const v_exe = os.getenv('VEXE')
|
||||
const idiff_exe = os.find_abs_path_of_executable('idiff') or { '' }
|
||||
|
||||
const embedded_toml = $embed_file('vgret.defaults.toml', .zlib)
|
||||
const default_toml = embedded_toml.to_string()
|
||||
const empty_toml_array = []toml.Any{}
|
||||
const empty_toml_map = map[string]toml.Any{}
|
||||
|
||||
struct Config {
|
||||
path string
|
||||
|
|
|
@ -4,12 +4,10 @@
|
|||
import os
|
||||
import flag
|
||||
|
||||
const (
|
||||
tool_name = 'v missdoc'
|
||||
tool_version = '0.1.0'
|
||||
tool_description = 'Prints all V functions in .v files under PATH/, that do not yet have documentation comments.'
|
||||
work_dir_prefix = normalise_path(os.real_path(os.wd_at_startup) + os.path_separator)
|
||||
)
|
||||
const tool_name = 'v missdoc'
|
||||
const tool_version = '0.1.0'
|
||||
const tool_description = 'Prints all V functions in .v files under PATH/, that do not yet have documentation comments.'
|
||||
const work_dir_prefix = normalise_path(os.real_path(os.wd_at_startup) + os.path_separator)
|
||||
|
||||
struct UndocumentedFN {
|
||||
file string
|
||||
|
|
|
@ -30,10 +30,8 @@ struct ErrorOptions {
|
|||
verbose bool // is used to only output the error message if the verbose setting is enabled.
|
||||
}
|
||||
|
||||
const (
|
||||
vexe = os.quoted_path(os.getenv('VEXE'))
|
||||
home_dir = os.home_dir()
|
||||
)
|
||||
const vexe = os.quoted_path(os.getenv('VEXE'))
|
||||
const home_dir = os.home_dir()
|
||||
|
||||
fn get_mod_date_info(mut pp pool.PoolProcessor, idx int, wid int) &ModuleDateInfo {
|
||||
mut result := &ModuleDateInfo{
|
||||
|
|
|
@ -3,10 +3,8 @@
|
|||
import os
|
||||
import v.vmod
|
||||
|
||||
const (
|
||||
v = os.quoted_path(@VEXE)
|
||||
test_path = os.join_path(os.vtmp_dir(), 'vpm_dependency_test')
|
||||
)
|
||||
const v = os.quoted_path(@VEXE)
|
||||
const test_path = os.join_path(os.vtmp_dir(), 'vpm_dependency_test')
|
||||
|
||||
fn testsuite_begin() {
|
||||
os.setenv('VMODULES', test_path, true)
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
// vtest retry: 3
|
||||
import os
|
||||
|
||||
const (
|
||||
v = os.quoted_path(@VEXE)
|
||||
test_path = os.join_path(os.vtmp_dir(), 'vpm_update_test')
|
||||
)
|
||||
const v = os.quoted_path(@VEXE)
|
||||
const test_path = os.join_path(os.vtmp_dir(), 'vpm_update_test')
|
||||
|
||||
fn testsuite_begin() {
|
||||
os.setenv('VMODULES', test_path, true)
|
||||
|
|
|
@ -21,14 +21,13 @@ struct VCS {
|
|||
}
|
||||
}
|
||||
|
||||
const (
|
||||
settings = init_settings()
|
||||
default_vpm_server_urls = ['https://vpm.vlang.io', 'https://vpm.url4e.com']
|
||||
vpm_server_urls = rand.shuffle_clone(default_vpm_server_urls) or { [] } // ensure that all queries are distributed fairly
|
||||
valid_vpm_commands = ['help', 'search', 'install', 'update', 'upgrade', 'outdated', 'list',
|
||||
const settings = init_settings()
|
||||
const default_vpm_server_urls = ['https://vpm.vlang.io', 'https://vpm.url4e.com']
|
||||
const vpm_server_urls = rand.shuffle_clone(default_vpm_server_urls) or { [] } // ensure that all queries are distributed fairly
|
||||
const valid_vpm_commands = ['help', 'search', 'install', 'update', 'upgrade', 'outdated', 'list',
|
||||
'remove', 'show']
|
||||
excluded_dirs = ['cache', 'vlib']
|
||||
supported_vcs = {
|
||||
const excluded_dirs = ['cache', 'vlib']
|
||||
const supported_vcs = {
|
||||
'git': VCS{
|
||||
dir: '.git'
|
||||
cmd: 'git'
|
||||
|
@ -51,8 +50,7 @@ const (
|
|||
outdated: ['incoming']
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// This tool is intended to be launched by the v frontend,
|
||||
|
|
|
@ -31,12 +31,10 @@ mut:
|
|||
eval_func_lines []string // same line of the `VSTARTUP` file, but used to test fn type
|
||||
}
|
||||
|
||||
const (
|
||||
is_stdin_a_pipe = os.is_atty(0) == 0
|
||||
vexe = os.getenv('VEXE')
|
||||
vstartup = os.getenv('VSTARTUP')
|
||||
repl_folder = os.join_path(os.vtmp_dir(), 'repl')
|
||||
)
|
||||
const is_stdin_a_pipe = os.is_atty(0) == 0
|
||||
const vexe = os.getenv('VEXE')
|
||||
const vstartup = os.getenv('VSTARTUP')
|
||||
const repl_folder = os.join_path(os.vtmp_dir(), 'repl')
|
||||
|
||||
const possible_statement_patterns = [
|
||||
'++',
|
||||
|
|
|
@ -18,18 +18,15 @@ import io.util
|
|||
import flag
|
||||
import net.http
|
||||
|
||||
const (
|
||||
shdc_full_hash = '6b84ea387a323db9e8e17f5abed2b254a6e409fe'
|
||||
tool_version = '0.0.3'
|
||||
tool_description = "Compile shaders in sokol's annotated GLSL format to C headers for use with sokol based apps"
|
||||
tool_name = os.file_name(os.executable())
|
||||
cache_dir = os.join_path(os.cache_dir(), 'v', tool_name)
|
||||
runtime_os = os.user_os()
|
||||
)
|
||||
const shdc_full_hash = '6b84ea387a323db9e8e17f5abed2b254a6e409fe'
|
||||
const tool_version = '0.0.3'
|
||||
const tool_description = "Compile shaders in sokol's annotated GLSL format to C headers for use with sokol based apps"
|
||||
const tool_name = os.file_name(os.executable())
|
||||
const cache_dir = os.join_path(os.cache_dir(), 'v', tool_name)
|
||||
const runtime_os = os.user_os()
|
||||
|
||||
const (
|
||||
supported_hosts = ['linux', 'macos', 'windows']
|
||||
supported_slangs = [
|
||||
const supported_hosts = ['linux', 'macos', 'windows']
|
||||
const supported_slangs = [
|
||||
'glsl330', // desktop OpenGL backend (SOKOL_GLCORE33)
|
||||
'glsl100', // OpenGLES2 and WebGL (SOKOL_GLES3)
|
||||
'glsl300es', // OpenGLES3 and WebGL2 (SOKOL_GLES3)
|
||||
|
@ -39,8 +36,8 @@ const (
|
|||
'metal_ios', // Metal on iOS devices (SOKOL_METAL)
|
||||
'metal_sim', // Metal on iOS simulator (SOKOL_METAL)
|
||||
'wgsl', // WebGPU (SOKOL_WGPU)
|
||||
]
|
||||
default_slangs = [
|
||||
]
|
||||
const default_slangs = [
|
||||
'glsl330',
|
||||
'glsl100',
|
||||
'glsl300es',
|
||||
|
@ -50,19 +47,18 @@ const (
|
|||
'metal_ios',
|
||||
'metal_sim',
|
||||
'wgsl',
|
||||
]
|
||||
]
|
||||
|
||||
shdc_version = shdc_full_hash[0..8]
|
||||
shdc_urls = {
|
||||
const shdc_version = shdc_full_hash[0..8]
|
||||
const shdc_urls = {
|
||||
'windows': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/win32/sokol-shdc.exe'
|
||||
'macos': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/osx/sokol-shdc'
|
||||
'linux': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/linux/sokol-shdc'
|
||||
'osx_a64': 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash}/bin/osx_arm64/sokol-shdc'
|
||||
}
|
||||
shdc_version_file = os.join_path(cache_dir, 'sokol-shdc.version')
|
||||
shdc = shdc_exe()
|
||||
shdc_exe_name = 'sokol-shdc.exe'
|
||||
)
|
||||
}
|
||||
const shdc_version_file = os.join_path(cache_dir, 'sokol-shdc.version')
|
||||
const shdc = shdc_exe()
|
||||
const shdc_exe_name = 'sokol-shdc.exe'
|
||||
|
||||
struct Options {
|
||||
show_help bool
|
||||
|
|
|
@ -4,11 +4,9 @@ import os
|
|||
import testing
|
||||
import v.util
|
||||
|
||||
const (
|
||||
known_failing_exceptions = [
|
||||
const known_failing_exceptions = [
|
||||
'vlib/crypto/aes/const.v', // const array wrapped in too many lines
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
fn main() {
|
||||
args_string := os.args[1..].join(' ')
|
||||
|
|
|
@ -6,18 +6,16 @@ import v.parser
|
|||
import v.ast
|
||||
import v.pref
|
||||
|
||||
const (
|
||||
vexe = os.real_path(os.getenv_opt('VEXE') or { @VEXE })
|
||||
vroot = os.dir(vexe)
|
||||
support_color = term.can_show_color_on_stderr() && term.can_show_color_on_stdout()
|
||||
ecode_timeout = 101
|
||||
ecode_memout = 102
|
||||
ecode_details = {
|
||||
const vexe = os.real_path(os.getenv_opt('VEXE') or { @VEXE })
|
||||
const vroot = os.dir(vexe)
|
||||
const support_color = term.can_show_color_on_stderr() && term.can_show_color_on_stdout()
|
||||
const ecode_timeout = 101
|
||||
const ecode_memout = 102
|
||||
const ecode_details = {
|
||||
-1: 'worker executable not found'
|
||||
101: 'too slow'
|
||||
102: 'too memory hungry'
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
struct Context {
|
||||
mut:
|
||||
|
|
|
@ -7,8 +7,7 @@ const github_job = os.getenv('GITHUB_JOB')
|
|||
|
||||
const just_essential = os.getenv('VTEST_JUST_ESSENTIAL') != ''
|
||||
|
||||
const (
|
||||
essential_list = [
|
||||
const essential_list = [
|
||||
'cmd/tools/vvet/vet_test.v',
|
||||
'vlib/arrays/arrays_test.v',
|
||||
'vlib/bitfield/bitfield_test.v',
|
||||
|
@ -82,8 +81,8 @@ const (
|
|||
'vlib/v/pkgconfig/pkgconfig_test.v',
|
||||
'vlib/v/slow_tests/inout/compiler_test.v',
|
||||
'vlib/x/json2/json2_test.v',
|
||||
]
|
||||
skip_test_files = [
|
||||
]
|
||||
const skip_test_files = [
|
||||
'do_not_remove',
|
||||
'cmd/tools/vdoc/html_tag_escape_test.v', // can't locate local module: markdown
|
||||
'cmd/tools/vdoc/tests/vdoc_file_test.v', // fails on Windows; order of output is not as expected
|
||||
|
@ -92,10 +91,10 @@ const (
|
|||
'vlib/db/mysql/mysql_orm_test.v', // mysql not installed
|
||||
'vlib/db/mysql/mysql_test.v', // mysql not installed
|
||||
'vlib/db/pg/pg_orm_test.v', // pg not installed
|
||||
]
|
||||
// These tests are too slow to be run in the CI on each PR/commit
|
||||
// in the sanitized modes:
|
||||
skip_fsanitize_too_slow = [
|
||||
]
|
||||
// These tests are too slow to be run in the CI on each PR/commit
|
||||
// in the sanitized modes:
|
||||
const skip_fsanitize_too_slow = [
|
||||
'do_not_remove',
|
||||
'vlib/v/compiler_errors_test.v',
|
||||
'vlib/v/doc/doc_test.v',
|
||||
|
@ -110,8 +109,8 @@ const (
|
|||
'vlib/v/slow_tests/profile/profile_test.v',
|
||||
'vlib/v/slow_tests/repl/repl_test.v',
|
||||
'vlib/v/slow_tests/valgrind/valgrind_test.v',
|
||||
]
|
||||
skip_with_fsanitize_memory = [
|
||||
]
|
||||
const skip_with_fsanitize_memory = [
|
||||
'do_not_remove',
|
||||
'vlib/net/tcp_simple_client_server_test.v',
|
||||
'vlib/net/http/cookie_test.v',
|
||||
|
@ -158,8 +157,8 @@ const (
|
|||
'vlib/net/smtp/smtp_test.v',
|
||||
'vlib/v/tests/websocket_logger_interface_should_compile_test.v',
|
||||
'vlib/v/tests/fn_literal_type_test.v',
|
||||
]
|
||||
skip_with_fsanitize_address = [
|
||||
]
|
||||
const skip_with_fsanitize_address = [
|
||||
'do_not_remove',
|
||||
'vlib/net/websocket/websocket_test.v',
|
||||
'vlib/orm/orm_create_and_drop_test.v',
|
||||
|
@ -170,8 +169,8 @@ const (
|
|||
'vlib/v/tests/orm_enum_test.v',
|
||||
'vlib/v/tests/orm_sub_array_struct_test.v',
|
||||
'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
|
||||
]
|
||||
skip_with_fsanitize_undefined = [
|
||||
]
|
||||
const skip_with_fsanitize_undefined = [
|
||||
'do_not_remove',
|
||||
'vlib/orm/orm_create_and_drop_test.v',
|
||||
'vlib/orm/orm_insert_test.v',
|
||||
|
@ -181,25 +180,25 @@ const (
|
|||
'vlib/v/tests/orm_sub_array_struct_test.v',
|
||||
'vlib/v/tests/orm_handle_error_for_select_from_not_created_table_test.v',
|
||||
'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.c.v', // fails compilation with: undefined reference to vtable for __cxxabiv1::__function_type_info'
|
||||
]
|
||||
skip_with_werror = [
|
||||
]
|
||||
const skip_with_werror = [
|
||||
'do_not_remove',
|
||||
'vlib/v/embed_file/tests/embed_file_test.v',
|
||||
]
|
||||
skip_with_asan_compiler = [
|
||||
]
|
||||
const skip_with_asan_compiler = [
|
||||
'do_not_remove',
|
||||
]
|
||||
skip_with_msan_compiler = [
|
||||
]
|
||||
const skip_with_msan_compiler = [
|
||||
'do_not_remove',
|
||||
]
|
||||
skip_on_musl = [
|
||||
]
|
||||
const skip_on_musl = [
|
||||
'do_not_remove',
|
||||
'vlib/v/slow_tests/profile/profile_test.v',
|
||||
'vlib/gg/draw_fns_api_test.v',
|
||||
'vlib/v/tests/skip_unused/gg_code.vv',
|
||||
'vlib/v/tests/c_struct_with_reserved_field_name_test.v',
|
||||
]
|
||||
skip_on_ubuntu_musl = [
|
||||
]
|
||||
const skip_on_ubuntu_musl = [
|
||||
'do_not_remove',
|
||||
//'vlib/v/gen/js/jsgen_test.v',
|
||||
'vlib/net/http/cookie_test.v',
|
||||
|
@ -246,22 +245,22 @@ const (
|
|||
'vlib/net/smtp/smtp_test.v',
|
||||
'vlib/v/tests/websocket_logger_interface_should_compile_test.v',
|
||||
'vlib/v/tests/fn_literal_type_test.v',
|
||||
]
|
||||
skip_on_linux = [
|
||||
]
|
||||
const skip_on_linux = [
|
||||
'do_not_remove',
|
||||
]
|
||||
skip_on_non_linux = [
|
||||
]
|
||||
const skip_on_non_linux = [
|
||||
'do_not_remove',
|
||||
]
|
||||
skip_on_windows_msvc = [
|
||||
]
|
||||
const skip_on_windows_msvc = [
|
||||
'do_not_remove',
|
||||
'vlib/v/tests/const_fixed_array_containing_references_to_itself_test.v', // error C2099: initializer is not a constant
|
||||
'vlib/v/tests/const_and_global_with_same_name_test.v', // error C2099: initializer is not a constant
|
||||
'vlib/v/tests/sumtype_as_cast_1_test.v', // error: cannot support compound statement expression ({expr; expr; expr;})
|
||||
'vlib/v/tests/sumtype_as_cast_2_test.v', // error: cannot support compound statement expression ({expr; expr; expr;})
|
||||
'vlib/v/tests/project_with_cpp_code/compiling_cpp_files_with_a_cplusplus_compiler_test.c.v', // TODO
|
||||
]
|
||||
skip_on_windows = [
|
||||
]
|
||||
const skip_on_windows = [
|
||||
'do_not_remove',
|
||||
'vlib/orm/orm_test.v',
|
||||
'vlib/v/tests/orm_sub_struct_test.v',
|
||||
|
@ -281,23 +280,23 @@ const (
|
|||
'vlib/sync/once_test.v',
|
||||
'vlib/v/tests/websocket_logger_interface_should_compile_test.v',
|
||||
'vlib/v/tests/fn_literal_type_test.v',
|
||||
]
|
||||
skip_on_non_windows = [
|
||||
]
|
||||
const skip_on_non_windows = [
|
||||
'do_not_remove',
|
||||
]
|
||||
skip_on_macos = [
|
||||
]
|
||||
const skip_on_macos = [
|
||||
'do_not_remove',
|
||||
]
|
||||
skip_on_non_macos = [
|
||||
]
|
||||
const skip_on_non_macos = [
|
||||
'do_not_remove',
|
||||
]
|
||||
skip_on_amd64 = [
|
||||
]
|
||||
const skip_on_amd64 = [
|
||||
'do_not_remove',
|
||||
]
|
||||
skip_on_arm64 = [
|
||||
]
|
||||
const skip_on_arm64 = [
|
||||
'do_not_remove',
|
||||
]
|
||||
skip_on_non_amd64_or_arm64 = [
|
||||
]
|
||||
const skip_on_non_amd64_or_arm64 = [
|
||||
'do_not_remove',
|
||||
// closures aren't implemented yet:
|
||||
'vlib/v/tests/closure_test.v',
|
||||
|
@ -309,8 +308,7 @@ const (
|
|||
'vlib/sync/once_test.v',
|
||||
'vlib/sync/many_times_test.v',
|
||||
'do_not_remove',
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
// Note: musl misses openssl, thus the http tests can not be done there
|
||||
// Note: http_httpbin_test.v: fails with 'cgen error: json: map_string_string is not struct'
|
||||
|
|
|
@ -29,10 +29,8 @@ struct Options {
|
|||
doc_private_fns_too bool
|
||||
}
|
||||
|
||||
const (
|
||||
term_colors = term.can_show_color_on_stderr()
|
||||
clean_seq = ['[', '', ']', '', ' ', '']
|
||||
)
|
||||
const term_colors = term.can_show_color_on_stderr()
|
||||
const clean_seq = ['[', '', ']', '', ' ', '']
|
||||
|
||||
fn main() {
|
||||
vet_options := cmdline.options_after(os.args, ['vet'])
|
||||
|
|
|
@ -30,12 +30,11 @@ enum Mutability {
|
|||
not
|
||||
}
|
||||
|
||||
const (
|
||||
_args = os.args
|
||||
verbose = '-v' in cmdline.only_options(_args)
|
||||
header = '-h' in cmdline.only_options(_args)
|
||||
format = '-f' in cmdline.only_options(_args)
|
||||
symbols = {
|
||||
const _args = os.args
|
||||
const verbose = '-v' in cmdline.only_options(_args)
|
||||
const header = '-h' in cmdline.only_options(_args)
|
||||
const format = '-f' in cmdline.only_options(_args)
|
||||
const symbols = {
|
||||
'fn': Symbol.@fn
|
||||
'method': .method
|
||||
'struct': .@struct
|
||||
|
@ -44,24 +43,23 @@ const (
|
|||
'const': .@const
|
||||
'var': .var
|
||||
'regexp': .regexp
|
||||
}
|
||||
visibilities = {
|
||||
}
|
||||
const visibilities = {
|
||||
'all': Visibility.all
|
||||
'pub': .@pub
|
||||
'pri': .pri
|
||||
}
|
||||
mutabilities = {
|
||||
}
|
||||
const mutabilities = {
|
||||
'any': Mutability.any
|
||||
'yes': .yes
|
||||
'not': .not
|
||||
}
|
||||
vexe = os.real_path(os.getenv_opt('VEXE') or { @VEXE })
|
||||
vlib_dir = os.join_path(os.dir(vexe), 'vlib')
|
||||
vmod_dir = os.vmodules_dir()
|
||||
vmod_paths = os.vmodules_paths()[1..]
|
||||
current_dir = os.abs_path('.')
|
||||
color_out = term.can_show_color_on_stdout()
|
||||
)
|
||||
}
|
||||
const vexe = os.real_path(os.getenv_opt('VEXE') or { @VEXE })
|
||||
const vlib_dir = os.join_path(os.dir(vexe), 'vlib')
|
||||
const vmod_dir = os.vmodules_dir()
|
||||
const vmod_paths = os.vmodules_paths()[1..]
|
||||
const current_dir = os.abs_path('.')
|
||||
const color_out = term.can_show_color_on_stdout()
|
||||
|
||||
fn (mut cfg Symbol) set_from_str(str_in string) {
|
||||
if str_in !in symbols {
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
module test
|
||||
|
||||
const (
|
||||
x = 10
|
||||
y = 100
|
||||
z = 1000
|
||||
)
|
||||
const x = 10
|
||||
const y = 100
|
||||
const z = 1000
|
||||
|
||||
pub enum Public {
|
||||
importable
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
module nested_mod
|
||||
|
||||
pub const (
|
||||
a = 30
|
||||
b = 60
|
||||
c = 120
|
||||
)
|
||||
pub const a = 30
|
||||
pub const b = 60
|
||||
pub const c = 120
|
||||
|
|
|
@ -123,8 +123,8 @@ fn test_find_pri_const() {
|
|||
assert fdr.matches == [
|
||||
Match{
|
||||
path: os.join_path(test_dir, 'file_two.v')
|
||||
line: 5
|
||||
text: 'y = 100'
|
||||
line: 4
|
||||
text: 'const y = 100'
|
||||
},
|
||||
]
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ fn test_find_pub_enum() {
|
|||
assert fdr.matches == [
|
||||
Match{
|
||||
path: os.join_path(test_dir, 'file_two.v')
|
||||
line: 9
|
||||
line: 7
|
||||
text: 'pub enum Public'
|
||||
},
|
||||
]
|
||||
|
@ -151,7 +151,7 @@ fn test_find_pri_enum() {
|
|||
assert fdr.matches == [
|
||||
Match{
|
||||
path: os.join_path(test_dir, 'file_two.v')
|
||||
line: 14
|
||||
line: 12
|
||||
text: 'enum Private'
|
||||
},
|
||||
]
|
||||
|
@ -165,7 +165,7 @@ fn test_find_fn() {
|
|||
assert fdr.matches == [
|
||||
Match{
|
||||
path: os.join_path(test_dir, 'file_two.v')
|
||||
line: 27
|
||||
line: 25
|
||||
text: 'fn some_function_name(foo string, bar int) string'
|
||||
},
|
||||
]
|
||||
|
@ -179,8 +179,8 @@ fn test_find_pub_const_with_mod() {
|
|||
assert fdr.matches == [
|
||||
Match{
|
||||
path: os.join_path(test_dir, 'nested_mod', 'nested_file.v')
|
||||
line: 5
|
||||
text: 'b = 60'
|
||||
line: 4
|
||||
text: 'pub const b = 60'
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
|
@ -12,8 +12,7 @@ import v.util.version
|
|||
import v.builder
|
||||
import v.builder.cbuilder
|
||||
|
||||
const (
|
||||
external_tools = [
|
||||
const external_tools = [
|
||||
'ast',
|
||||
'bin2v',
|
||||
'bug',
|
||||
|
@ -50,9 +49,8 @@ const (
|
|||
'wipe-cache',
|
||||
'watch',
|
||||
'where',
|
||||
]
|
||||
list_of_flags_that_allow_duplicates = ['cc', 'd', 'define', 'cf', 'cflags']
|
||||
)
|
||||
]
|
||||
const list_of_flags_that_allow_duplicates = ['cc', 'd', 'define', 'cf', 'cflags']
|
||||
|
||||
fn main() {
|
||||
mut timers_should_print := false
|
||||
|
|
|
@ -5843,21 +5843,21 @@ main_default.c.v:
|
|||
|
||||
```v ignore
|
||||
module main
|
||||
const ( message = 'Hello world' )
|
||||
const message = 'Hello world'
|
||||
```
|
||||
|
||||
main_linux.c.v:
|
||||
|
||||
```v ignore
|
||||
module main
|
||||
const ( message = 'Hello linux' )
|
||||
const message = 'Hello linux'
|
||||
```
|
||||
|
||||
main_windows.c.v:
|
||||
|
||||
```v ignore
|
||||
module main
|
||||
const ( message = 'Hello windows' )
|
||||
const message = 'Hello windows'
|
||||
```
|
||||
|
||||
With the example above:
|
||||
|
|
|
@ -45,8 +45,7 @@ struct Theme {
|
|||
tile_colors []gx.Color
|
||||
}
|
||||
|
||||
const (
|
||||
themes = [
|
||||
const themes = [
|
||||
&Theme{
|
||||
bg_color: gx.rgb(250, 248, 239)
|
||||
padding_color: gx.rgb(143, 130, 119)
|
||||
|
@ -110,16 +109,16 @@ const (
|
|||
gx.rgb(106, 87, 35),
|
||||
]
|
||||
},
|
||||
]
|
||||
window_title = 'V 2048'
|
||||
default_window_width = 544
|
||||
default_window_height = 560
|
||||
animation_length = 10 // frames
|
||||
frames_per_ai_move = 8
|
||||
possible_moves = [Direction.up, .right, .down, .left]
|
||||
predictions_per_move = 200
|
||||
prediction_depth = 8
|
||||
)
|
||||
]
|
||||
const window_title = 'V 2048'
|
||||
const default_window_width = 544
|
||||
const default_window_height = 560
|
||||
const animation_length = 10 // frames
|
||||
|
||||
const frames_per_ai_move = 8
|
||||
const possible_moves = [Direction.up, .right, .down, .left]
|
||||
const predictions_per_move = 200
|
||||
const prediction_depth = 8
|
||||
|
||||
// Used for performance monitoring when `-d showfps` is passed, unused / optimized out otherwise
|
||||
struct Perf {
|
||||
|
|
|
@ -8,27 +8,25 @@ import gx
|
|||
import math
|
||||
import time
|
||||
|
||||
const (
|
||||
// All coordinates are designed for a clock size of this many pixel.
|
||||
// You cannot change the size of the clock by adjusting this value.
|
||||
design_size = 700
|
||||
center = 350
|
||||
// All coordinates are designed for a clock size of this many pixel.
|
||||
// You cannot change the size of the clock by adjusting this value.
|
||||
const design_size = 700
|
||||
const center = 350
|
||||
|
||||
// Half the width of a tic-mark.
|
||||
tw = 9
|
||||
// Height of a minute tic-mark. (hour is twice, 3-hour is thrice)
|
||||
th = 25
|
||||
// Padding of tic-mark to window border
|
||||
tp = 10
|
||||
// Half the width of a tic-mark.
|
||||
const tw = 9
|
||||
// Height of a minute tic-mark. (hour is twice, 3-hour is thrice)
|
||||
const th = 25
|
||||
// Padding of tic-mark to window border
|
||||
const tp = 10
|
||||
|
||||
tic_color = gx.Color{
|
||||
const tic_color = gx.Color{
|
||||
r: 50
|
||||
g: 50
|
||||
b: 50
|
||||
}
|
||||
hand_color = gx.black
|
||||
second_hand_color = gx.red
|
||||
)
|
||||
}
|
||||
const hand_color = gx.black
|
||||
const second_hand_color = gx.red
|
||||
|
||||
struct App {
|
||||
minutes_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw,
|
||||
|
|
|
@ -20,20 +20,16 @@ import db.pg
|
|||
// * Child
|
||||
// in the passed databases, so it is better to use empty DBs for it.
|
||||
|
||||
const (
|
||||
mysql_host = os.getenv_opt('MHOST') or { 'localhost' }
|
||||
mysql_port = os.getenv_opt('MPORT') or { '3306' }.u32()
|
||||
mysql_user = os.getenv_opt('MUSER') or { 'myuser' }
|
||||
mysql_pass = os.getenv_opt('MPASS') or { 'abc' }
|
||||
mysql_db = os.getenv_opt('MDATABASE') or { 'test' }
|
||||
)
|
||||
const mysql_host = os.getenv_opt('MHOST') or { 'localhost' }
|
||||
const mysql_port = os.getenv_opt('MPORT') or { '3306' }.u32()
|
||||
const mysql_user = os.getenv_opt('MUSER') or { 'myuser' }
|
||||
const mysql_pass = os.getenv_opt('MPASS') or { 'abc' }
|
||||
const mysql_db = os.getenv_opt('MDATABASE') or { 'test' }
|
||||
|
||||
const (
|
||||
pg_host = os.getenv_opt('PGHOST') or { 'localhost' }
|
||||
pg_user = os.getenv_opt('PGUSER') or { 'test' }
|
||||
pg_pass = os.getenv_opt('PGPASS') or { 'abc' }
|
||||
pg_db = os.getenv_opt('PGDATABASE') or { 'test' }
|
||||
)
|
||||
const pg_host = os.getenv_opt('PGHOST') or { 'localhost' }
|
||||
const pg_user = os.getenv_opt('PGUSER') or { 'test' }
|
||||
const pg_pass = os.getenv_opt('PGPASS') or { 'abc' }
|
||||
const pg_db = os.getenv_opt('PGDATABASE') or { 'test' }
|
||||
|
||||
@[table: 'modules']
|
||||
struct Module {
|
||||
|
|
|
@ -9,15 +9,13 @@ import dl.loader
|
|||
|
||||
type FNAdder = fn (int, int) int
|
||||
|
||||
const (
|
||||
cfolder = os.dir(@FILE)
|
||||
default_paths = [
|
||||
const cfolder = os.dir(@FILE)
|
||||
const default_paths = [
|
||||
os.join_path(cfolder, 'library${dl.dl_ext}'),
|
||||
os.join_path(cfolder, 'location1/library${dl.dl_ext}'),
|
||||
os.join_path(cfolder, 'location2/library${dl.dl_ext}'),
|
||||
os.join_path(cfolder, 'modules/library/library${dl.dl_ext}'),
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
fn main() {
|
||||
mut dl_loader := loader.get_or_create_dynamic_lib_loader(
|
||||
|
|
|
@ -5,10 +5,8 @@ module main
|
|||
import os
|
||||
import dl
|
||||
|
||||
const (
|
||||
vexe = os.real_path(os.getenv('VEXE'))
|
||||
so_ext = dl.dl_ext
|
||||
)
|
||||
const vexe = os.real_path(os.getenv('VEXE'))
|
||||
const so_ext = dl.dl_ext
|
||||
|
||||
fn test_vexe() {
|
||||
// dump(vexe)
|
||||
|
|
|
@ -5,12 +5,10 @@ module main
|
|||
import os
|
||||
import dl
|
||||
|
||||
const (
|
||||
vexe = os.real_path(os.getenv('VEXE'))
|
||||
cfolder = os.dir(@FILE)
|
||||
so_ext = dl.dl_ext
|
||||
library_file_name = os.join_path(cfolder, dl.get_libname('library'))
|
||||
)
|
||||
const vexe = os.real_path(os.getenv('VEXE'))
|
||||
const cfolder = os.dir(@FILE)
|
||||
const so_ext = dl.dl_ext
|
||||
const library_file_name = os.join_path(cfolder, dl.get_libname('library'))
|
||||
|
||||
fn test_vexe() {
|
||||
// dump(vexe)
|
||||
|
|
|
@ -2,9 +2,7 @@ module some_module
|
|||
|
||||
import eventbus
|
||||
|
||||
const (
|
||||
eb = eventbus.new[string]()
|
||||
)
|
||||
const eb = eventbus.new[string]()
|
||||
|
||||
pub struct Duration {
|
||||
pub:
|
||||
|
|
|
@ -8,10 +8,8 @@ import math
|
|||
import rand
|
||||
import neuroevolution
|
||||
|
||||
const (
|
||||
win_width = 500
|
||||
win_height = 512
|
||||
)
|
||||
const win_width = 500
|
||||
const win_height = 512
|
||||
|
||||
struct Bird {
|
||||
mut:
|
||||
|
|
|
@ -2,15 +2,13 @@ import term
|
|||
import rand
|
||||
import time
|
||||
|
||||
const (
|
||||
cell = '█'
|
||||
nothing = ' '
|
||||
switches = {
|
||||
const cell = '█'
|
||||
const nothing = ' '
|
||||
const switches = {
|
||||
cell: nothing
|
||||
nothing: cell
|
||||
}
|
||||
transformers = [nothing, cell]
|
||||
)
|
||||
}
|
||||
const transformers = [nothing, cell]
|
||||
|
||||
struct Game {
|
||||
mut:
|
||||
|
|
|
@ -4,11 +4,9 @@ import gg
|
|||
import gx
|
||||
import automaton
|
||||
|
||||
const (
|
||||
screen_width = 800
|
||||
screen_height = 600
|
||||
filled_color = gx.blue
|
||||
)
|
||||
const screen_width = 800
|
||||
const screen_height = 600
|
||||
const filled_color = gx.blue
|
||||
|
||||
@[live]
|
||||
fn print_automaton(app &App) {
|
||||
|
|
|
@ -4,12 +4,10 @@ import gg
|
|||
import gx
|
||||
import math
|
||||
|
||||
const (
|
||||
win_width = 700
|
||||
win_height = 800
|
||||
bg_color = gx.white
|
||||
colour = gx.black
|
||||
)
|
||||
const win_width = 700
|
||||
const win_height = 800
|
||||
const bg_color = gx.white
|
||||
const colour = gx.black
|
||||
|
||||
enum Selection {
|
||||
segs = 0
|
||||
|
|
|
@ -3,9 +3,7 @@ module main
|
|||
import gg
|
||||
import gx
|
||||
|
||||
const (
|
||||
points = [f32(200.0), 200.0, 200.0, 100.0, 400.0, 100.0, 400.0, 300.0]
|
||||
)
|
||||
const points = [f32(200.0), 200.0, 200.0, 100.0, 400.0, 100.0, 400.0, 300.0]
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -5,11 +5,9 @@ import gg
|
|||
import gx
|
||||
import sokol.sapp
|
||||
|
||||
const (
|
||||
max_files = 12
|
||||
text = 'Drag&Drop here max ${max_files} files.'
|
||||
text_size = 16
|
||||
)
|
||||
const max_files = 12
|
||||
const text = 'Drag&Drop here max ${max_files} files.'
|
||||
const text_size = 16
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -5,14 +5,11 @@ import gx
|
|||
import os
|
||||
import math
|
||||
|
||||
const (
|
||||
win_width = 600
|
||||
win_height = 700
|
||||
bg_color = gx.white
|
||||
)
|
||||
const win_width = 600
|
||||
const win_height = 700
|
||||
const bg_color = gx.white
|
||||
|
||||
const (
|
||||
text = '
|
||||
const text = '
|
||||
Once upon a midnight dreary, while I pondered, weak and weary,
|
||||
Over many a quaint and curious volume of forgotten lore—
|
||||
While I nodded, nearly napping, suddenly there came a tapping,
|
||||
|
@ -55,8 +52,8 @@ Soon again I heard a tapping somewhat louder than before.
|
|||
Let my heart be still a moment and this mystery explore;—
|
||||
’Tis the wind and nothing more!”
|
||||
'
|
||||
lines = text.split('\n')
|
||||
)
|
||||
|
||||
const lines = text.split('\n')
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -4,10 +4,8 @@ import gg
|
|||
import gx
|
||||
import os
|
||||
|
||||
const (
|
||||
win_width = 600
|
||||
win_height = 300
|
||||
)
|
||||
const win_width = 600
|
||||
const win_height = 300
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -6,12 +6,10 @@ import gx
|
|||
import rand
|
||||
import sokol.sgl
|
||||
|
||||
const (
|
||||
win_width = 800
|
||||
win_height = 600
|
||||
max_stars = 5000
|
||||
max_v_letters = 5
|
||||
)
|
||||
const win_width = 800
|
||||
const win_height = 600
|
||||
const max_stars = 5000
|
||||
const max_v_letters = 5
|
||||
|
||||
struct Star {
|
||||
mut:
|
||||
|
|
|
@ -9,12 +9,10 @@ import gx
|
|||
import math
|
||||
import time
|
||||
|
||||
const (
|
||||
win_width = 600
|
||||
win_height = 700
|
||||
bg_color = gx.white
|
||||
count_color = gx.black
|
||||
)
|
||||
const win_width = 600
|
||||
const win_height = 700
|
||||
const bg_color = gx.white
|
||||
const count_color = gx.black
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// hanoi tower
|
||||
const (
|
||||
num = 7
|
||||
)
|
||||
const num = 7
|
||||
|
||||
fn main() {
|
||||
hanoi(num, 'A', 'B', 'C')
|
||||
|
|
|
@ -18,11 +18,9 @@ mut:
|
|||
draw_fn voidptr
|
||||
}
|
||||
|
||||
const (
|
||||
window_width = 400
|
||||
window_height = 300
|
||||
width = 50
|
||||
)
|
||||
const window_width = 400
|
||||
const window_height = 300
|
||||
const width = 50
|
||||
|
||||
fn main() {
|
||||
mut game := &Game{
|
||||
|
|
|
@ -5,10 +5,8 @@ import gg
|
|||
import time
|
||||
import math
|
||||
|
||||
const (
|
||||
size = 700
|
||||
scale = 50.0
|
||||
)
|
||||
const size = 700
|
||||
const scale = 50.0
|
||||
|
||||
struct Context {
|
||||
mut:
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
import js.dom
|
||||
import math
|
||||
|
||||
const (
|
||||
vert_code = 'attribute vec3 position;uniform mat4 Pmatrix;uniform mat4 Vmatrix;uniform mat4 Mmatrix;attribute vec3 color;varying vec3 vColor;void main(void) {gl_Position = Pmatrix * Vmatrix * Mmatrix * vec4(position,1.);vColor = color;}
|
||||
const vert_code = 'attribute vec3 position;uniform mat4 Pmatrix;uniform mat4 Vmatrix;uniform mat4 Mmatrix;attribute vec3 color;varying vec3 vColor;void main(void) {gl_Position = Pmatrix * Vmatrix * Mmatrix * vec4(position,1.);vColor = color;}
|
||||
'
|
||||
|
||||
frag_code = 'precision mediump float;varying vec3 vColor;void main(void) {gl_FragColor = vec4(vColor, 1.);}
|
||||
const frag_code = 'precision mediump float;varying vec3 vColor;void main(void) {gl_FragColor = vec4(vColor, 1.);}
|
||||
'
|
||||
|
||||
vertices = [
|
||||
const vertices = [
|
||||
f32(-1),
|
||||
-1,
|
||||
-1,
|
||||
|
@ -81,8 +80,8 @@ const (
|
|||
1,
|
||||
1,
|
||||
-1,
|
||||
]
|
||||
colors = [
|
||||
]
|
||||
const colors = [
|
||||
f32(5),
|
||||
3,
|
||||
7,
|
||||
|
@ -155,8 +154,8 @@ const (
|
|||
0,
|
||||
1,
|
||||
0,
|
||||
]
|
||||
indices = [
|
||||
]
|
||||
const indices = [
|
||||
u16(0),
|
||||
1,
|
||||
2,
|
||||
|
@ -193,9 +192,8 @@ const (
|
|||
20,
|
||||
22,
|
||||
23,
|
||||
]
|
||||
amortization = 0.95
|
||||
)
|
||||
]
|
||||
const amortization = 0.95
|
||||
|
||||
fn get_webgl() (JS.HTMLCanvasElement, JS.WebGLRenderingContext) {
|
||||
JS.console.log(dom.document)
|
||||
|
|
|
@ -38,10 +38,8 @@ fn (framework_platform FrameworkPlatform) to_map() map[string][]int {
|
|||
return mapa
|
||||
}
|
||||
|
||||
const (
|
||||
http_port = 3001
|
||||
benchmark_loop_length = 20
|
||||
)
|
||||
const http_port = 3001
|
||||
const benchmark_loop_length = 20
|
||||
|
||||
struct App {
|
||||
vweb.Context
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
// -0.169059907
|
||||
import math
|
||||
|
||||
const (
|
||||
solar_mass = 39.47841760435743197 // 4.0 * math.Pi * math.Pi
|
||||
days_per_year = 365.24
|
||||
c_n = 5
|
||||
)
|
||||
const solar_mass = 39.47841760435743197 // 4.0 * math.Pi * math.Pi
|
||||
|
||||
const days_per_year = 365.24
|
||||
const c_n = 5
|
||||
|
||||
struct Position {
|
||||
pub mut:
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
import os
|
||||
|
||||
const (
|
||||
// Expect has to be installed for the test.
|
||||
expect_exe = os.find_abs_path_of_executable('expect') or {
|
||||
// Expect has to be installed for the test.
|
||||
const expect_exe = os.find_abs_path_of_executable('expect') or {
|
||||
eprintln('skipping test, since expect is missing')
|
||||
exit(0)
|
||||
}
|
||||
// Directory that contains the Expect scripts used in the test.
|
||||
expect_tests_path = os.join_path(@VMODROOT, 'examples', 'password', 'tests')
|
||||
)
|
||||
}
|
||||
// Directory that contains the Expect scripts used in the test.
|
||||
const expect_tests_path = os.join_path(@VMODROOT, 'examples', 'password', 'tests')
|
||||
|
||||
fn test_password_input() {
|
||||
correct := os.execute(os.join_path(expect_tests_path, 'correct.expect'))
|
||||
|
|
|
@ -30,11 +30,9 @@ import rand
|
|||
import time
|
||||
import term
|
||||
|
||||
const (
|
||||
inf = 1e+10
|
||||
eps = 1e-4
|
||||
f_0 = 0.0
|
||||
)
|
||||
const inf = 1e+10
|
||||
const eps = 1e-4
|
||||
const f_0 = 0.0
|
||||
|
||||
//**************************** 3D Vector utility struct *********************
|
||||
struct Vec {
|
||||
|
@ -163,9 +161,9 @@ fn (sp Sphere) intersect(r Ray) f64 {
|
|||
* 2) Psychedelic
|
||||
* The sphere fields are: Sphere{radius, position, emission, color, material}
|
||||
******************************************************************************/
|
||||
const (
|
||||
cen = Vec{50, 40.8, -860} // used by scene 1
|
||||
spheres = [
|
||||
const cen = Vec{50, 40.8, -860} // used by scene 1
|
||||
|
||||
const spheres = [
|
||||
[// scene 0 cornnel box
|
||||
Sphere{
|
||||
rad: 1e+5
|
||||
|
@ -319,8 +317,7 @@ const (
|
|||
refl: .spec
|
||||
},
|
||||
],
|
||||
] // end of scene array
|
||||
)
|
||||
]
|
||||
|
||||
//********************************** Utilities ******************************
|
||||
@[inline]
|
||||
|
@ -360,10 +357,9 @@ fn rand_f64() f64 {
|
|||
return f64(x) / f64(0x3FFF_FFFF)
|
||||
}
|
||||
|
||||
const (
|
||||
cache_len = 65536 // the 2*pi angle will be split in 2^16 parts
|
||||
cache_mask = cache_len - 1 // mask to speed-up the module process
|
||||
)
|
||||
const cache_len = 65536 // the 2*pi angle will be split in 2^16 parts
|
||||
|
||||
const cache_mask = cache_len - 1
|
||||
|
||||
struct Cache {
|
||||
mut:
|
||||
|
@ -383,9 +379,7 @@ fn new_tabs() Cache {
|
|||
}
|
||||
|
||||
//************ Cache for sin/cos speed-up table and scene selector **********
|
||||
const (
|
||||
tabs = new_tabs()
|
||||
)
|
||||
const tabs = new_tabs()
|
||||
|
||||
//****************** main function for the radiance calculation *************
|
||||
fn radiance(r Ray, depthi int, scene_id int) Vec {
|
||||
|
|
|
@ -2,14 +2,12 @@ module sim
|
|||
|
||||
import math
|
||||
|
||||
pub const (
|
||||
default_rope_length = 0.25
|
||||
default_bearing_mass = 0.03
|
||||
default_magnet_spacing = 0.05
|
||||
default_magnet_height = 0.03
|
||||
default_magnet_strength = 10.0
|
||||
default_gravity = 4.9
|
||||
)
|
||||
pub const default_rope_length = 0.25
|
||||
pub const default_bearing_mass = 0.03
|
||||
pub const default_magnet_spacing = 0.05
|
||||
pub const default_magnet_height = 0.03
|
||||
pub const default_magnet_strength = 10.0
|
||||
pub const default_gravity = 4.9
|
||||
|
||||
@[params]
|
||||
pub struct SimParams {
|
||||
|
|
|
@ -2,16 +2,15 @@ module sim
|
|||
|
||||
import math
|
||||
|
||||
const (
|
||||
params_test_mock_params = SimParams{
|
||||
const params_test_mock_params = SimParams{
|
||||
rope_length: 0.25
|
||||
bearing_mass: 0.03
|
||||
magnet_spacing: 0.05
|
||||
magnet_height: 0.03
|
||||
magnet_strength: 10
|
||||
gravity: 4.9
|
||||
}
|
||||
params_test_mock_state = SimState{
|
||||
}
|
||||
const params_test_mock_state = SimState{
|
||||
position: vector(
|
||||
x: -0.016957230930171364
|
||||
y: -0.02937078552673521
|
||||
|
@ -27,9 +26,8 @@ const (
|
|||
y: -2.842170943040401e-10
|
||||
z: 1.2126596023639044e-10
|
||||
)
|
||||
}
|
||||
params_test_mock_tetha = 2.0 * math.pi / 3.0
|
||||
)
|
||||
}
|
||||
const params_test_mock_tetha = 2.0 * math.pi / 3.0
|
||||
|
||||
pub fn test_get_rope_vector() {
|
||||
result := sim.params_test_mock_params.get_rope_vector(sim.params_test_mock_state)
|
||||
|
|
|
@ -9,10 +9,8 @@ pub type SimStartHandler = fn () !
|
|||
|
||||
pub type SimFinishHandler = fn () !
|
||||
|
||||
pub const (
|
||||
default_width = 600
|
||||
default_height = 600
|
||||
)
|
||||
pub const default_width = 600
|
||||
pub const default_height = 600
|
||||
|
||||
@[params]
|
||||
pub struct GridSettings {
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
module sim
|
||||
|
||||
const (
|
||||
sim_test_mock_params = SimParams{
|
||||
const sim_test_mock_params = SimParams{
|
||||
rope_length: 0.25
|
||||
bearing_mass: 0.03
|
||||
magnet_spacing: 0.05
|
||||
magnet_height: 0.03
|
||||
magnet_strength: 10
|
||||
gravity: 4.9
|
||||
}
|
||||
sim_test_mock_state = SimState{
|
||||
}
|
||||
const sim_test_mock_state = SimState{
|
||||
position: vector(
|
||||
x: -0.016957230930171364
|
||||
y: -0.02937078552673521
|
||||
|
@ -25,8 +24,7 @@ const (
|
|||
y: -2.842170943040401e-10
|
||||
z: 1.2126596023639044e-10
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
pub fn test_satisfy_rope_constraint() {
|
||||
mut state := SimState{
|
||||
|
|
|
@ -3,10 +3,8 @@ module sim
|
|||
import math
|
||||
import benchmark
|
||||
|
||||
const (
|
||||
max_iterations = 1000
|
||||
simulation_delta_t = 0.0005
|
||||
)
|
||||
const max_iterations = 1000
|
||||
const simulation_delta_t = 0.0005
|
||||
|
||||
pub struct SimRequest {
|
||||
params SimParams
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
module sim
|
||||
|
||||
const (
|
||||
worker_test_mock_params = SimParams{
|
||||
const worker_test_mock_params = SimParams{
|
||||
rope_length: 0.25
|
||||
bearing_mass: 0.03
|
||||
magnet_spacing: 0.05
|
||||
magnet_height: 0.03
|
||||
magnet_strength: 10
|
||||
gravity: 4.9
|
||||
}
|
||||
worker_test_mock_state = SimState{
|
||||
}
|
||||
const worker_test_mock_state = SimState{
|
||||
position: vector(
|
||||
x: -0.016957230930171364
|
||||
y: -0.02937078552673521
|
||||
|
@ -25,8 +24,7 @@ const (
|
|||
y: -2.842170943040401e-10
|
||||
z: 1.2126596023639044e-10
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn test_compute_result() {
|
||||
request := SimRequest{
|
||||
|
|
|
@ -2,9 +2,7 @@ import json
|
|||
import picoev
|
||||
import picohttpparser
|
||||
|
||||
const (
|
||||
port = 8089
|
||||
)
|
||||
const port = 8089
|
||||
|
||||
struct Message {
|
||||
message string
|
||||
|
|
|
@ -3,10 +3,8 @@ module main
|
|||
import net
|
||||
import picoev
|
||||
|
||||
const (
|
||||
port = 8080
|
||||
http_response = 'HTTP/1.1 200 OK\r\nContent-type: text/html\r\nContent-length: 18\r\n\r\nHello from Picoev!'
|
||||
)
|
||||
const port = 8080
|
||||
const http_response = 'HTTP/1.1 200 OK\r\nContent-type: text/html\r\nContent-length: 18\r\n\r\nHello from Picoev!'
|
||||
|
||||
fn main() {
|
||||
println('Starting webserver on http://localhost:${port}/ ...')
|
||||
|
|
|
@ -8,19 +8,18 @@ import time
|
|||
import math
|
||||
import rand
|
||||
|
||||
const (
|
||||
win_width = 1340
|
||||
win_height = 640
|
||||
timer_period = 40 * time.millisecond // defaulted at 25 fps
|
||||
font_small = gx.TextCfg{
|
||||
const win_width = 1340
|
||||
const win_height = 640
|
||||
const timer_period = 40 * time.millisecond // defaulted at 25 fps
|
||||
|
||||
const font_small = gx.TextCfg{
|
||||
color: gx.black
|
||||
size: 20
|
||||
}
|
||||
font_large = gx.TextCfg{
|
||||
}
|
||||
const font_large = gx.TextCfg{
|
||||
color: gx.black
|
||||
size: 40
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import rand
|
||||
|
||||
const (
|
||||
gen_len = 1000 // how many random numbers to generate
|
||||
gen_max = 10000 // max of the generated numbers
|
||||
)
|
||||
const gen_len = 1000 // how many random numbers to generate
|
||||
|
||||
const gen_max = 10000
|
||||
|
||||
fn main() {
|
||||
mut arr := []int{}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
import os
|
||||
|
||||
const (
|
||||
// Expect has to be installed for the test.
|
||||
expect_exe = os.find_abs_path_of_executable('expect') or {
|
||||
// Expect has to be installed for the test.
|
||||
const expect_exe = os.find_abs_path_of_executable('expect') or {
|
||||
eprintln('skipping test, since expect is missing')
|
||||
exit(0)
|
||||
}
|
||||
// Directory that contains the Expect scripts used in the test.
|
||||
expect_tests_path = os.join_path(@VMODROOT, 'examples', 'readline', 'tests')
|
||||
)
|
||||
}
|
||||
// Directory that contains the Expect scripts used in the test.
|
||||
const expect_tests_path = os.join_path(@VMODROOT, 'examples', 'readline', 'tests')
|
||||
|
||||
fn test_password_input() {
|
||||
correct := os.execute(os.join_path(expect_tests_path, 'readline.expect'))
|
||||
|
|
|
@ -5,13 +5,11 @@ import time
|
|||
import rand
|
||||
|
||||
// constants
|
||||
const (
|
||||
top_height = 100
|
||||
canvas_size = 700
|
||||
game_size = 17
|
||||
tile_size = canvas_size / game_size
|
||||
tick_rate_ms = 100
|
||||
)
|
||||
const top_height = 100
|
||||
const canvas_size = 700
|
||||
const game_size = 17
|
||||
const tile_size = canvas_size / game_size
|
||||
const tick_rate_ms = 100
|
||||
|
||||
// types
|
||||
struct Pos {
|
||||
|
|
|
@ -6,13 +6,11 @@ import time
|
|||
import rand
|
||||
|
||||
// constants
|
||||
const (
|
||||
top_height = 100
|
||||
canvas_size = 700
|
||||
game_size = 17
|
||||
tile_size = canvas_size / game_size
|
||||
tick_rate_ms = 100
|
||||
)
|
||||
const top_height = 100
|
||||
const canvas_size = 700
|
||||
const game_size = 17
|
||||
const tile_size = canvas_size / game_size
|
||||
const tick_rate_ms = 100
|
||||
|
||||
const high_score_file_path = os.join_path(os.cache_dir(), 'v', 'examples', 'snek')
|
||||
|
||||
|
|
|
@ -17,11 +17,9 @@ import sokol.sapp
|
|||
import sokol.gfx
|
||||
import sokol.sgl
|
||||
|
||||
const (
|
||||
win_width = 800
|
||||
win_height = 800
|
||||
bg_color = gx.white
|
||||
)
|
||||
const win_width = 800
|
||||
const win_height = 800
|
||||
const bg_color = gx.white
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -28,11 +28,9 @@ import gg.m4
|
|||
|
||||
fn C.cube_shader_desc(gfx.Backend) &gfx.ShaderDesc
|
||||
|
||||
const (
|
||||
win_width = 800
|
||||
win_height = 800
|
||||
bg_color = gx.white
|
||||
)
|
||||
const win_width = 800
|
||||
const win_height = 800
|
||||
const bg_color = gx.white
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -29,11 +29,9 @@ import time
|
|||
|
||||
fn C.rt_shader_desc(gfx.Backend) &gfx.ShaderDesc
|
||||
|
||||
const (
|
||||
win_width = 800
|
||||
win_height = 800
|
||||
bg_color = gx.white
|
||||
)
|
||||
const win_width = 800
|
||||
const win_height = 800
|
||||
const bg_color = gx.white
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -30,11 +30,9 @@ import time
|
|||
fn C.rt_march_shader_desc(gfx.Backend) &gfx.ShaderDesc
|
||||
fn C.rt_puppy_shader_desc(gfx.Backend) &gfx.ShaderDesc
|
||||
|
||||
const (
|
||||
win_width = 800
|
||||
win_height = 800
|
||||
bg_color = gx.white
|
||||
)
|
||||
const win_width = 800
|
||||
const win_height = 800
|
||||
const bg_color = gx.white
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -21,12 +21,10 @@ import sokol.gfx
|
|||
// import sokol.sgl
|
||||
import time
|
||||
|
||||
const (
|
||||
win_width = 800
|
||||
win_height = 800
|
||||
bg_color = gx.white
|
||||
num_inst = 16384
|
||||
)
|
||||
const win_width = 800
|
||||
const win_height = 800
|
||||
const bg_color = gx.white
|
||||
const num_inst = 16384
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -37,11 +37,9 @@ import obj
|
|||
|
||||
fn C.gouraud_shader_desc(gfx.Backend) &gfx.ShaderDesc
|
||||
|
||||
const (
|
||||
win_width = 600
|
||||
win_height = 600
|
||||
bg_color = gx.white
|
||||
)
|
||||
const win_width = 600
|
||||
const win_height = 600
|
||||
const bg_color = gx.white
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -7,9 +7,7 @@ struct AppState {
|
|||
pass_action gfx.PassAction
|
||||
}
|
||||
|
||||
const (
|
||||
used_import = sokol.used_import
|
||||
)
|
||||
const used_import = sokol.used_import
|
||||
|
||||
fn main() {
|
||||
state := &AppState{
|
||||
|
|
|
@ -6,8 +6,7 @@ import fontstash
|
|||
import sokol.sfons
|
||||
import os
|
||||
|
||||
const (
|
||||
text = '
|
||||
const text = '
|
||||
Once upon a midnight dreary, while I pondered, weak and weary,
|
||||
Over many a quaint and curious volume of forgotten lore—
|
||||
While I nodded, nearly napping, suddenly there came a tapping,
|
||||
|
@ -50,8 +49,8 @@ Soon again I heard a tapping somewhat louder than before.
|
|||
Let my heart be still a moment and this mystery explore;—
|
||||
’Tis the wind and nothing more!”
|
||||
'
|
||||
lines = text.split('\n')
|
||||
)
|
||||
|
||||
const lines = text.split('\n')
|
||||
|
||||
struct AppState {
|
||||
mut:
|
||||
|
@ -114,9 +113,7 @@ fn frame(mut state AppState) {
|
|||
gfx.commit()
|
||||
}
|
||||
|
||||
const (
|
||||
black = sfons.rgba(0, 0, 0, 255)
|
||||
)
|
||||
const black = sfons.rgba(0, 0, 0, 255)
|
||||
|
||||
fn (mut state AppState) render_font() {
|
||||
lh := 30
|
||||
|
|
|
@ -5,10 +5,8 @@ module particle
|
|||
import math.vec
|
||||
import sokol.sgl
|
||||
|
||||
const (
|
||||
default_life_time = 1000
|
||||
default_v_color = Color{93, 136, 193, 255}
|
||||
)
|
||||
const default_life_time = 1000
|
||||
const default_v_color = Color{93, 136, 193, 255}
|
||||
|
||||
// * Module public
|
||||
pub fn new(location vec.Vec2[f64]) &Particle {
|
||||
|
|
|
@ -9,9 +9,7 @@ import sokol.gfx
|
|||
import sokol.sgl
|
||||
import particle
|
||||
|
||||
const (
|
||||
used_import = sokol.used_import
|
||||
)
|
||||
const used_import = sokol.used_import
|
||||
|
||||
fn main() {
|
||||
mut app := &App{
|
||||
|
|
|
@ -2,10 +2,8 @@ import time
|
|||
import math
|
||||
import sokol.audio
|
||||
|
||||
const (
|
||||
sw = time.new_stopwatch()
|
||||
sw_start_ms = sw.elapsed().milliseconds()
|
||||
)
|
||||
const sw = time.new_stopwatch()
|
||||
const sw_start_ms = sw.elapsed().milliseconds()
|
||||
|
||||
@[inline]
|
||||
fn sintone(periods int, frame int, num_frames int) f32 {
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
import term.ui as tui
|
||||
|
||||
const (
|
||||
colors = [
|
||||
const colors = [
|
||||
tui.Color{33, 150, 243},
|
||||
tui.Color{0, 150, 136},
|
||||
tui.Color{205, 220, 57},
|
||||
tui.Color{255, 152, 0},
|
||||
tui.Color{244, 67, 54},
|
||||
tui.Color{156, 39, 176},
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
struct Point {
|
||||
x int
|
||||
|
|
|
@ -9,12 +9,12 @@ enum Mode {
|
|||
game
|
||||
}
|
||||
|
||||
const (
|
||||
player_one = 1 // Human control this racket
|
||||
player_two = 0 // Take over this AI controller
|
||||
white = ui.Color{255, 255, 255}
|
||||
orange = ui.Color{255, 140, 0}
|
||||
)
|
||||
const player_one = 1 // Human control this racket
|
||||
|
||||
const player_two = 0 // Take over this AI controller
|
||||
|
||||
const white = ui.Color{255, 255, 255}
|
||||
const orange = ui.Color{255, 140, 0}
|
||||
|
||||
@[heap]
|
||||
struct App {
|
||||
|
|
|
@ -6,8 +6,7 @@ module main
|
|||
import term.ui
|
||||
|
||||
// The color palette, taken from Google's Material design
|
||||
const (
|
||||
colors = [
|
||||
const colors = [
|
||||
[
|
||||
ui.Color{239, 154, 154},
|
||||
ui.Color{244, 143, 177},
|
||||
|
@ -71,22 +70,20 @@ const (
|
|||
ui.Color{33, 33, 33},
|
||||
ui.Color{55, 71, 79},
|
||||
],
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
const (
|
||||
frame_rate = 30 // fps
|
||||
msg_display_time = 5 * frame_rate
|
||||
w = 200
|
||||
h = 100
|
||||
space = ' '
|
||||
spaces = ' '
|
||||
select_color = 'Select color: '
|
||||
select_size = 'Size: + -'
|
||||
help_1 = '╭────────╮'
|
||||
help_2 = '│ HELP │'
|
||||
help_3 = '╰────────╯'
|
||||
)
|
||||
const frame_rate = 30 // fps
|
||||
|
||||
const msg_display_time = 5 * frame_rate
|
||||
const w = 200
|
||||
const h = 100
|
||||
const space = ' '
|
||||
const spaces = ' '
|
||||
const select_color = 'Select color: '
|
||||
const select_size = 'Size: + -'
|
||||
const help_1 = '╭────────╮'
|
||||
const help_2 = '│ HELP │'
|
||||
const help_3 = '╰────────╯'
|
||||
|
||||
struct App {
|
||||
mut:
|
||||
|
|
|
@ -9,10 +9,9 @@ import term.ui as tui
|
|||
import encoding.utf8
|
||||
import encoding.utf8.east_asian
|
||||
|
||||
const (
|
||||
rune_digits = [`0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`]
|
||||
const rune_digits = [`0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`]
|
||||
|
||||
zero_width_unicode = [
|
||||
const zero_width_unicode = [
|
||||
`\u034f`, // U+034F COMBINING GRAPHEME JOINER
|
||||
`\u061c`, // U+061C ARABIC LETTER MARK
|
||||
`\u17b4`, // U+17B4 KHMER VOWEL INHERENT AQ
|
||||
|
@ -35,8 +34,7 @@ const (
|
|||
`\u206e`, // U+206E NATIONAL DIGIT SHAPES
|
||||
`\u206f`, // U+206F NOMINAL DIGIT SHAPES
|
||||
`\ufeff`, // U+FEFF ZERO WIDTH NO-BREAK SPACE
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
enum Movement {
|
||||
up
|
||||
|
|
|
@ -3,16 +3,14 @@ import term.ui as termui
|
|||
import rand
|
||||
|
||||
// define some global constants
|
||||
const (
|
||||
block_size = 1
|
||||
buffer = 10
|
||||
green = termui.Color{0, 255, 0}
|
||||
grey = termui.Color{150, 150, 150}
|
||||
white = termui.Color{255, 255, 255}
|
||||
blue = termui.Color{0, 0, 255}
|
||||
red = termui.Color{255, 0, 0}
|
||||
black = termui.Color{0, 0, 0}
|
||||
)
|
||||
const block_size = 1
|
||||
const buffer = 10
|
||||
const green = termui.Color{0, 255, 0}
|
||||
const grey = termui.Color{150, 150, 150}
|
||||
const white = termui.Color{255, 255, 255}
|
||||
const blue = termui.Color{0, 0, 255}
|
||||
const red = termui.Color{255, 0, 0}
|
||||
const black = termui.Color{0, 0, 0}
|
||||
|
||||
// what edge of the screen are you facing
|
||||
enum Orientation {
|
||||
|
|
|
@ -9,39 +9,37 @@ import gx
|
|||
import gg
|
||||
// import sokol.sapp
|
||||
|
||||
const (
|
||||
block_size = 20 // virtual pixels
|
||||
field_height = 20 // # of blocks
|
||||
field_width = 10
|
||||
tetro_size = 4
|
||||
win_width = block_size * field_width
|
||||
win_height = block_size * field_height
|
||||
timer_period = 250 // ms
|
||||
text_size = 24
|
||||
limit_thickness = 3
|
||||
)
|
||||
const block_size = 20 // virtual pixels
|
||||
|
||||
const (
|
||||
text_cfg = gx.TextCfg{
|
||||
const field_height = 20 // # of blocks
|
||||
|
||||
const field_width = 10
|
||||
const tetro_size = 4
|
||||
const win_width = block_size * field_width
|
||||
const win_height = block_size * field_height
|
||||
const timer_period = 250 // ms
|
||||
|
||||
const text_size = 24
|
||||
const limit_thickness = 3
|
||||
|
||||
const text_cfg = gx.TextCfg{
|
||||
align: .left
|
||||
size: text_size
|
||||
color: gx.rgb(0, 0, 0)
|
||||
}
|
||||
over_cfg = gx.TextCfg{
|
||||
}
|
||||
const over_cfg = gx.TextCfg{
|
||||
align: .left
|
||||
size: text_size
|
||||
color: gx.white
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const (
|
||||
// Tetros' 4 possible states are encoded in binaries
|
||||
// 0000 0 0000 0 0000 0 0000 0 0000 0 0000 0
|
||||
// 0000 0 0000 0 0000 0 0000 0 0011 3 0011 3
|
||||
// 0110 6 0010 2 0011 3 0110 6 0001 1 0010 2
|
||||
// 0110 6 0111 7 0110 6 0011 3 0001 1 0010 2
|
||||
// There is a special case 1111, since 15 can't be used.
|
||||
b_tetros = [
|
||||
// Tetros' 4 possible states are encoded in binaries
|
||||
// 0000 0 0000 0 0000 0 0000 0 0000 0 0000 0
|
||||
// 0000 0 0000 0 0000 0 0000 0 0011 3 0011 3
|
||||
// 0110 6 0010 2 0011 3 0110 6 0001 1 0010 2
|
||||
// 0110 6 0111 7 0110 6 0011 3 0001 1 0010 2
|
||||
// There is a special case 1111, since 15 can't be used.
|
||||
const b_tetros = [
|
||||
[66, 66, 66, 66],
|
||||
[27, 131, 72, 232],
|
||||
[36, 231, 36, 231],
|
||||
|
@ -49,9 +47,9 @@ const (
|
|||
[311, 17, 223, 74],
|
||||
[322, 71, 113, 47],
|
||||
[1111, 9, 1111, 9],
|
||||
]
|
||||
// Each tetro has its unique color
|
||||
colors = [
|
||||
]
|
||||
// Each tetro has its unique color
|
||||
const colors = [
|
||||
gx.rgb(0, 0, 0), // unused ?
|
||||
gx.rgb(255, 242, 0), // yellow quad
|
||||
gx.rgb(174, 0, 255), // purple triple
|
||||
|
@ -61,10 +59,9 @@ const (
|
|||
gx.rgb(33, 66, 255), // blue long topright
|
||||
gx.rgb(74, 198, 255), // lightblue longest
|
||||
gx.rgb(0, 170, 170),
|
||||
]
|
||||
background_color = gx.white
|
||||
ui_color = gx.rgba(255, 0, 0, 210)
|
||||
)
|
||||
]
|
||||
const background_color = gx.white
|
||||
const ui_color = gx.rgba(255, 0, 0, 210)
|
||||
|
||||
// TODO: type Tetro [tetro_size]struct{ x, y int }
|
||||
struct Block {
|
||||
|
|
|
@ -10,39 +10,37 @@ import gx
|
|||
import gg
|
||||
// import sokol.sapp
|
||||
|
||||
const (
|
||||
block_size = 20 // virtual pixels
|
||||
field_height = 20 // # of blocks
|
||||
field_width = 10
|
||||
tetro_size = 4
|
||||
win_width = block_size * field_width
|
||||
win_height = block_size * field_height
|
||||
timer_period = 250 // ms
|
||||
text_size = 24
|
||||
limit_thickness = 3
|
||||
)
|
||||
const block_size = 20 // virtual pixels
|
||||
|
||||
const (
|
||||
text_cfg = gx.TextCfg{
|
||||
const field_height = 20 // # of blocks
|
||||
|
||||
const field_width = 10
|
||||
const tetro_size = 4
|
||||
const win_width = block_size * field_width
|
||||
const win_height = block_size * field_height
|
||||
const timer_period = 250 // ms
|
||||
|
||||
const text_size = 24
|
||||
const limit_thickness = 3
|
||||
|
||||
const text_cfg = gx.TextCfg{
|
||||
align: .left
|
||||
size: text_size
|
||||
color: gx.rgb(0, 0, 0)
|
||||
}
|
||||
over_cfg = gx.TextCfg{
|
||||
}
|
||||
const over_cfg = gx.TextCfg{
|
||||
align: .left
|
||||
size: text_size
|
||||
color: gx.white
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const (
|
||||
// Tetros' 4 possible states are encoded in binaries
|
||||
// 0000 0 0000 0 0000 0 0000 0 0000 0 0000 0
|
||||
// 0000 0 0000 0 0000 0 0000 0 0011 3 0011 3
|
||||
// 0110 6 0010 2 0011 3 0110 6 0001 1 0010 2
|
||||
// 0110 6 0111 7 0110 6 0011 3 0001 1 0010 2
|
||||
// There is a special case 1111, since 15 can't be used.
|
||||
b_tetros = [
|
||||
// Tetros' 4 possible states are encoded in binaries
|
||||
// 0000 0 0000 0 0000 0 0000 0 0000 0 0000 0
|
||||
// 0000 0 0000 0 0000 0 0000 0 0011 3 0011 3
|
||||
// 0110 6 0010 2 0011 3 0110 6 0001 1 0010 2
|
||||
// 0110 6 0111 7 0110 6 0011 3 0001 1 0010 2
|
||||
// There is a special case 1111, since 15 can't be used.
|
||||
const b_tetros = [
|
||||
[66, 66, 66, 66],
|
||||
[27, 131, 72, 232],
|
||||
[36, 231, 36, 231],
|
||||
|
@ -50,9 +48,9 @@ const (
|
|||
[311, 17, 223, 74],
|
||||
[322, 71, 113, 47],
|
||||
[1111, 9, 1111, 9],
|
||||
]
|
||||
// Each tetro has its unique color
|
||||
colors = [
|
||||
]
|
||||
// Each tetro has its unique color
|
||||
const colors = [
|
||||
gx.rgb(0, 0, 0), // unused ?
|
||||
gx.rgb(255, 242, 0), // yellow quad
|
||||
gx.rgb(174, 0, 255), // purple triple
|
||||
|
@ -62,10 +60,9 @@ const (
|
|||
gx.rgb(33, 66, 255), // blue long topright
|
||||
gx.rgb(74, 198, 255), // lightblue longest
|
||||
gx.rgb(0, 170, 170),
|
||||
]
|
||||
background_color = gx.white
|
||||
ui_color = gx.rgba(255, 0, 0, 210)
|
||||
)
|
||||
]
|
||||
const background_color = gx.white
|
||||
const ui_color = gx.rgba(255, 0, 0, 210)
|
||||
|
||||
// TODO: type Tetro [tetro_size]struct{ x, y int }
|
||||
struct Block {
|
||||
|
|
|
@ -7,15 +7,13 @@ import x.ttf
|
|||
import os
|
||||
|
||||
// import math
|
||||
const (
|
||||
win_width = 600
|
||||
win_height = 700
|
||||
bg_color = gx.white
|
||||
font_paths = [
|
||||
const win_width = 600
|
||||
const win_height = 700
|
||||
const bg_color = gx.white
|
||||
const font_paths = [
|
||||
os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'Imprima-Regular.ttf')),
|
||||
os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'Graduate-Regular.ttf')),
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
// UI
|
||||
struct App_data {
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
import rand
|
||||
import os
|
||||
|
||||
const (
|
||||
help_text = ' Usage:\t./VCasino\n
|
||||
const help_text = ' Usage:\t./VCasino\n
|
||||
Description:\n VCasino is a little game only made to learn V.\n'
|
||||
g_desc = " The object of Roulette is to pick the number where the spinning ball will land on the wheel.
|
||||
|
||||
const g_desc = " The object of Roulette is to pick the number where the spinning ball will land on the wheel.
|
||||
If your number is the good one, you'll get your bet x3.
|
||||
If your number is the same color as the ball one, you'll get your bet /2.
|
||||
Otherwise, you will lose your bet.\n"
|
||||
odd = 'red'
|
||||
even = 'black'
|
||||
)
|
||||
|
||||
const odd = 'red'
|
||||
const even = 'black'
|
||||
|
||||
struct Options {
|
||||
long_opt string
|
||||
|
|
|
@ -20,8 +20,7 @@ import szip
|
|||
import strings
|
||||
|
||||
// Help text
|
||||
const (
|
||||
help_text_rows = [
|
||||
const help_text_rows = [
|
||||
'Image Viewer 0.9 help.',
|
||||
'',
|
||||
'ESC/q - Quit',
|
||||
|
@ -36,20 +35,17 @@ const (
|
|||
'mouse wheel - next/previous images',
|
||||
'keep pressed left Mouse button - Pan on the image',
|
||||
'keep pressed right Mouse button - Zoom on the image',
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
const (
|
||||
win_width = 800
|
||||
win_height = 800
|
||||
bg_color = gx.black
|
||||
pi_2 = 3.14159265359 / 2.0
|
||||
uv = [f32(0), 0, 1, 0, 1, 1, 0, 1]! // used for zoom icon during rotations
|
||||
const win_width = 800
|
||||
const win_height = 800
|
||||
const bg_color = gx.black
|
||||
const pi_2 = 3.14159265359 / 2.0
|
||||
const uv = [f32(0), 0, 1, 0, 1, 1, 0, 1]! // used for zoom icon during rotations
|
||||
|
||||
text_drop_files = 'Drop here some images/folder/zip to navigate in the pics'
|
||||
text_scanning = 'Scanning...'
|
||||
text_loading = 'Loading...'
|
||||
)
|
||||
const text_drop_files = 'Drop here some images/folder/zip to navigate in the pics'
|
||||
const text_scanning = 'Scanning...'
|
||||
const text_loading = 'Loading...'
|
||||
|
||||
enum Viewer_state {
|
||||
loading
|
||||
|
|
|
@ -3,9 +3,7 @@ module main
|
|||
import vweb
|
||||
|
||||
// for another example see vlib/vweb/tests/middleware_test_server.v
|
||||
const (
|
||||
http_port = 8080
|
||||
)
|
||||
const http_port = 8080
|
||||
|
||||
struct App {
|
||||
vweb.Context
|
||||
|
|
|
@ -5,9 +5,7 @@ import vweb
|
|||
// import vweb.assets
|
||||
import time
|
||||
|
||||
const (
|
||||
port = 8081
|
||||
)
|
||||
const port = 8081
|
||||
|
||||
struct App {
|
||||
vweb.Context
|
||||
|
|
|
@ -4,9 +4,7 @@ import vweb
|
|||
import databases
|
||||
import os
|
||||
|
||||
const (
|
||||
port = 8082
|
||||
)
|
||||
const port = 8082
|
||||
|
||||
struct App {
|
||||
vweb.Context
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue