diff --git a/vlib/compiler/enum.v b/vlib/compiler/enum.v index 8765ea2284..0dea86b498 100644 --- a/vlib/compiler/enum.v +++ b/vlib/compiler/enum.v @@ -6,6 +6,12 @@ module compiler fn (p mut Parser) enum_decl(_enum_name string) { mut enum_name := _enum_name + is_pub := p.tok == .key_pub + if is_pub { + p.next() + p.check(.key_enum) + enum_name = p.check_name() + } // Specify full type name if !p.builtin_mod && p.mod != 'main' { enum_name = p.prepend_mod(enum_name) @@ -49,6 +55,7 @@ fn (p mut Parser) enum_decl(_enum_name string) { parent: 'int' cat: TypeCategory.enum_ enum_vals: fields.clone() + is_public: is_pub }) p.check(.rcbr) p.fgenln('\n') diff --git a/vlib/compiler/parser.v b/vlib/compiler/parser.v index 39b1f96a9f..b1850feb80 100644 --- a/vlib/compiler/parser.v +++ b/vlib/compiler/parser.v @@ -320,10 +320,12 @@ fn (p mut Parser) parse(pass Pass) { p.fgen(' ') p.enum_decl(name) } - // enum without a name, only allowed in code, translated from C - // it's a very bad practice in C as well, but is used unfortunately (for example, by DOOM) - // such fields are basically int consts else if p.pref.translated { + // enum without a name, only allowed in code, + // translated from C. it's a very bad practice + // in C as well, but is used unfortunately + // (for example, by DOOM). such fields are + // basically int consts p.enum_decl('int') } else { @@ -335,6 +337,7 @@ fn (p mut Parser) parse(pass Pass) { .key_fn { p.fn_decl() } .key_const { p.const_decl() } .key_struct { p.struct_decl() } + .key_enum { p.enum_decl('') } else { p.error('wrong pub keyword usage') } @@ -1101,7 +1104,7 @@ fn (p mut Parser) get_type() string { } } else if !t.is_public && t.mod != p.mod && t.name != '' { - p.warn('type `$t.name` is private') + p.error('type `$t.name` is private') } } if typ == 'void' { diff --git a/vlib/crypto/crypto.v b/vlib/crypto/crypto.v index a86f86b3d9..4e58d40174 100644 --- a/vlib/crypto/crypto.v +++ b/vlib/crypto/crypto.v @@ -1,6 +1,6 @@ module crypto -enum Hash { +pub enum Hash { MD4 MD5 SHA1 diff --git a/vlib/gl/1shader.v b/vlib/gl/1shader.v index 1ccf739163..eaec134394 100644 --- a/vlib/gl/1shader.v +++ b/vlib/gl/1shader.v @@ -10,7 +10,7 @@ import glm // import darwin -struct Shader { +pub struct Shader { program_id int } diff --git a/vlib/gl/gl.v b/vlib/gl/gl.v index e2324ead15..b995c52d96 100644 --- a/vlib/gl/gl.v +++ b/vlib/gl/gl.v @@ -9,7 +9,7 @@ module gl #flag @VROOT/thirdparty/glad/glad.o // joe-c: fix & remove -enum TmpGlImportHack{} +pub enum TmpGlImportHack{} pub fn init_glad() { ok := C.gladLoadGL() diff --git a/vlib/gx/gx.v b/vlib/gx/gx.v index de3992bf54..c97a7b3fed 100644 --- a/vlib/gx/gx.v +++ b/vlib/gx/gx.v @@ -4,14 +4,14 @@ module gx -struct Color { +pub struct Color { pub: r int g int b int } -const ( +pub const ( // Primary colors Blue = Color { r: 0, g: 0, b: 255 } Red = Color { r: 255, g: 0, b: 0 } diff --git a/vlib/net/urllib/urllib.v b/vlib/net/urllib/urllib.v index f1e4b78b59..0e62de337f 100644 --- a/vlib/net/urllib/urllib.v +++ b/vlib/net/urllib/urllib.v @@ -305,7 +305,7 @@ fn escape(s string, mode EncodingMode) string { // // URL's String method uses the escaped_path method to obtain the path. See the // escaped_path method for more details. -struct URL { +pub struct URL { pub: mut: scheme string opaque string // encoded opaque data diff --git a/vlib/sync/sync_nix.v b/vlib/sync/sync_nix.v index 13a6a5be74..46707bd8b0 100644 --- a/vlib/sync/sync_nix.v +++ b/vlib/sync/sync_nix.v @@ -5,7 +5,7 @@ module sync #include -struct Mutex { +pub struct Mutex { mutex C.pthread_mutex_t } diff --git a/vlib/sync/sync_win.v b/vlib/sync/sync_win.v index 447d541ee9..be540803eb 100644 --- a/vlib/sync/sync_win.v +++ b/vlib/sync/sync_win.v @@ -7,7 +7,7 @@ module sync // Mutex HANDLE type MHANDLE voidptr -struct Mutex { +pub struct Mutex { mut: mx MHANDLE // mutex handle state MutexState // mutex state diff --git a/vlib/sync/waitgroup.v b/vlib/sync/waitgroup.v index 5eca30507c..669401e4e7 100644 --- a/vlib/sync/waitgroup.v +++ b/vlib/sync/waitgroup.v @@ -4,7 +4,7 @@ module sync -struct WaitGroup { +pub struct WaitGroup { mut: mu Mutex active int