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