mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
make all necessary structs public
This commit is contained in:
parent
dce3275df4
commit
4a88a28a3b
@ -26,7 +26,7 @@ println( bmark.total_message('remarks about the benchmark') )
|
||||
```
|
||||
*/
|
||||
|
||||
struct Benchmark{
|
||||
pub struct Benchmark{
|
||||
pub mut:
|
||||
bench_start_time i64
|
||||
bench_end_time i64
|
||||
|
@ -6,7 +6,7 @@ module builtin
|
||||
|
||||
import strings
|
||||
|
||||
struct map {
|
||||
pub struct map {
|
||||
element_size int
|
||||
root &mapnode
|
||||
pub:
|
||||
|
@ -43,7 +43,7 @@ NB: A V string should be/is immutable from the point of view of
|
||||
|
||||
import strconv
|
||||
|
||||
struct string {
|
||||
pub struct string {
|
||||
//mut:
|
||||
//hash_cache int
|
||||
pub:
|
||||
@ -51,7 +51,7 @@ pub:
|
||||
len int // the length of the .str field, excluding the ending 0 byte. It is always equal to strlen(.str).
|
||||
}
|
||||
|
||||
struct ustring {
|
||||
pub struct ustring {
|
||||
pub:
|
||||
s string
|
||||
runes []int
|
||||
|
@ -1100,6 +1100,9 @@ fn (p mut Parser) get_type() string {
|
||||
p.error('unknown type `$typ`')
|
||||
}
|
||||
}
|
||||
else if !t.is_public && t.mod != p.mod && t.name != '' {
|
||||
p.warn('type `$t.name` is private')
|
||||
}
|
||||
}
|
||||
if typ == 'void' {
|
||||
p.error('unknown type `$typ`')
|
||||
@ -3179,6 +3182,9 @@ fn (p mut Parser) array_init() string {
|
||||
fn (p mut Parser) struct_init(typ string) string {
|
||||
p.is_struct_init = true
|
||||
t := p.table.find_type(typ)
|
||||
if !t.is_public && t.mod != p.mod {
|
||||
p.warn('type `$t.name` is private')
|
||||
}
|
||||
if p.gen_struct_init(typ, t) { return typ }
|
||||
p.scanner.fmt_out.cut(typ.len)
|
||||
ptr := typ.contains('*')
|
||||
@ -4120,7 +4126,7 @@ fn (p mut Parser) js_decode() string {
|
||||
p.gen('json__jsdecode_$typ($cjson_tmp, &$tmp); cJSON_Delete($cjson_tmp);')
|
||||
opt_type := 'Option_$typ'
|
||||
p.cgen.typedefs << 'typedef Option $opt_type;'
|
||||
p.table.register_type(opt_type)
|
||||
p.table.register_builtin(opt_type)
|
||||
return opt_type
|
||||
}
|
||||
else if op == 'encode' {
|
||||
|
@ -180,7 +180,7 @@ for (int i = 0; i < ${qprefix}rows.len; i++) {
|
||||
} else if query_one {
|
||||
opt_type := 'Option_$table_name'
|
||||
p.cgen.typedefs << 'typedef Option $opt_type;'
|
||||
p.table.register_type( opt_type )
|
||||
p.table.register_builtin( opt_type )
|
||||
return opt_type
|
||||
} else {
|
||||
p.register_array('array_$table_name')
|
||||
|
@ -234,8 +234,8 @@ fn new_table(obfuscate bool) &Table {
|
||||
mut t := &Table {
|
||||
obfuscate: obfuscate
|
||||
}
|
||||
t.register_type('int')
|
||||
t.register_type('size_t')
|
||||
t.register_builtin('int')
|
||||
t.register_builtin('size_t')
|
||||
t.register_type_with_parent('i8', 'int')
|
||||
t.register_type_with_parent('byte', 'int')
|
||||
t.register_type_with_parent('char', 'int') // for C functions only, to avoid warnings
|
||||
@ -244,17 +244,17 @@ fn new_table(obfuscate bool) &Table {
|
||||
t.register_type_with_parent('u32', 'int')
|
||||
t.register_type_with_parent('i64', 'int')
|
||||
t.register_type_with_parent('u64', 'u32')
|
||||
t.register_type('byteptr')
|
||||
t.register_type('intptr')
|
||||
t.register_type('f32')
|
||||
t.register_type('f64')
|
||||
t.register_type('rune')
|
||||
t.register_type('bool')
|
||||
t.register_type('void')
|
||||
t.register_type('voidptr')
|
||||
t.register_type('va_list')
|
||||
t.register_builtin('byteptr')
|
||||
t.register_builtin('intptr')
|
||||
t.register_builtin('f32')
|
||||
t.register_builtin('f64')
|
||||
t.register_builtin('rune')
|
||||
t.register_builtin('bool')
|
||||
t.register_builtin('void')
|
||||
t.register_builtin('voidptr')
|
||||
t.register_builtin('va_list')
|
||||
for c in reserved_type_param_names {
|
||||
t.register_type(c)
|
||||
t.register_builtin(c)
|
||||
}
|
||||
t.register_const('stdin', 'int', 'main', true)
|
||||
t.register_const('stdout', 'int', 'main', true)
|
||||
@ -390,14 +390,14 @@ fn (t &Table) known_const(name string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
fn (t mut Table) register_type(typ string) {
|
||||
fn (t mut Table) register_builtin(typ string) {
|
||||
if typ.len == 0 {
|
||||
return
|
||||
}
|
||||
if typ in t.typesmap {
|
||||
return
|
||||
}
|
||||
t.typesmap[typ] = Type{name:typ}
|
||||
t.typesmap[typ] = Type{name:typ, is_public:true}
|
||||
}
|
||||
|
||||
fn (p mut Parser) register_type_with_parent(strtyp, parent string) {
|
||||
@ -405,6 +405,7 @@ fn (p mut Parser) register_type_with_parent(strtyp, parent string) {
|
||||
name: strtyp
|
||||
parent: parent
|
||||
mod: p.mod
|
||||
is_public: true
|
||||
}
|
||||
p.table.register_type2(typ)
|
||||
}
|
||||
@ -416,6 +417,7 @@ fn (t mut Table) register_type_with_parent(typ, parent string) {
|
||||
t.typesmap[typ] = Type {
|
||||
name: typ
|
||||
parent: parent
|
||||
is_public: true
|
||||
//mod: mod
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ struct C.FILE {
|
||||
|
||||
}
|
||||
|
||||
struct File {
|
||||
pub struct File {
|
||||
cfile &FILE
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
module strings
|
||||
|
||||
struct Builder {
|
||||
pub struct Builder {
|
||||
mut:
|
||||
buf []byte
|
||||
pub:
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
module strings
|
||||
|
||||
struct Builder {
|
||||
pub struct Builder {
|
||||
mut:
|
||||
buf []byte
|
||||
pub:
|
||||
|
Loading…
Reference in New Issue
Block a user