1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os.v: clean up init_os_args()

This commit is contained in:
Alexander Medvednikov 2019-06-25 23:43:04 +02:00
parent 8417fec5dc
commit 2a3cf0bec9
3 changed files with 11 additions and 11 deletions

View File

@ -345,10 +345,10 @@ fn (p mut Parser) fn_decl() {
p.genln('init_consts();')
if p.table.imports.contains('os') {
if f.name == 'main' {
p.genln('os__init_os_args(argc, argv);')
p.genln('os__args = os__init_os_args(argc, argv);')
}
else if f.name == 'WinMain' {
p.genln('os__parse_windows_cmd_line(pCmdLine);')
p.genln('os__args = os__parse_windows_cmd_line(pCmdLine);')
}
}
// We are in live code reload mode, call the .so loader in bg

View File

@ -453,6 +453,9 @@ fn (p mut Parser) _check_types(got, expected string, throw bool) bool {
if got.eq('int') && expected.eq('byte') {
return true
}
if got.eq('byteptr') && expected.eq('byte*') {
return true
}
if got.eq('int') && expected.eq('byte*') {
return true
}

15
os/os.v
View File

@ -21,24 +21,21 @@ import const (
SEEK_END
)
fn init_os_args(argc int, c voidptr) []string {
fn init_os_args(argc int, _argv *byteptr) []string {
mut args := []string
# char** argv = (char**) c;
# char** argv = (char**) _argv;
for i := 0; i < argc; i++ {
// # printf("ARG %d = '%s'\n", i, argv[i]);
arg := ''
# arg = tos(argv[i], strlen(argv[i]));
//arg := tos(argv[i], strlen(argv[i]))
# arg = tos((char**)(argv[i]), strlen((char**)(argv[i])));
args << arg
}
# os__args = args;
return args
}
fn parse_windows_cmd_line(cmd byteptr) {
fn parse_windows_cmd_line(cmd byteptr) []string {
s := tos2(cmd)
vals := s.split(' ')
println(vals)
# os__args = vals;
return s.split(' ')
}
fn C.ftell(fp voidptr) int