From 95509cf8fbd30e723da6d6aae9872475cdfef026 Mon Sep 17 00:00:00 2001 From: Larpon Date: Wed, 25 Oct 2023 14:01:50 +0200 Subject: [PATCH] all: make all `struct C.XYZ` -> `pub struct C.XYZ` (#19651) --- doc/docs.md | 8 +-- examples/c_interop_wkhtmltopdf.v | 6 +-- vlib/builtin/builtin_d_use_libbacktrace.c.v | 2 +- vlib/builtin/cfns.c.v | 2 +- vlib/builtin/option.c.v | 2 +- vlib/builtin/wchar/wchar.c.v | 2 +- vlib/clipboard/x11/clipboard.c.v | 10 ++-- vlib/db/mysql/_cdefs.c.v | 6 +-- vlib/db/mysql/stmt.c.v | 4 +- vlib/db/pg/pg.v | 4 +- vlib/db/sqlite/sqlite.v | 4 +- vlib/log/default.c.v | 2 +- vlib/net/http/backend_windows.c.v | 2 +- vlib/net/mbedtls/c.v | 16 +++--- vlib/net/net_windows.c.v | 2 +- vlib/os/notify/backend_darwin.c.v | 2 +- vlib/os/notify/backend_linux.c.v | 2 +- vlib/os/os_android_outside_termux.c.v | 6 +-- vlib/os/os_structs_dirent_default.c.v | 2 +- vlib/os/os_structs_sigaction_default.c.v | 2 +- vlib/os/os_structs_stat_default.c.v | 2 +- vlib/os/os_structs_stat_linux.c.v | 2 +- vlib/os/os_structs_utsname_default.c.v | 4 +- vlib/os/os_windows.c.v | 2 +- vlib/runtime/free_memory_impl_darwin.c.v | 6 +-- vlib/runtime/runtime_windows.c.v | 4 +- vlib/sokol/gfx/gfx_structs.c.v | 50 +++++++++---------- vlib/sokol/sgl/sgl_structs.c.v | 4 +- vlib/sync/channels.c.v | 2 +- vlib/sync/sync_darwin.c.v | 12 ++--- vlib/sync/sync_default.c.v | 8 +-- vlib/sync/sync_windows.c.v | 4 +- vlib/szip/szip.v | 2 +- vlib/term/termios/termios_android.c.v | 2 +- vlib/term/termios/termios_darwin.c.v | 2 +- vlib/term/termios/termios_dragonfly.c.v | 2 +- vlib/term/termios/termios_freebsd.c.v | 2 +- vlib/term/termios/termios_linux.c.v | 2 +- vlib/term/termios/termios_openbsd.c.v | 2 +- vlib/term/termios/termios_qnx.c.v | 2 +- vlib/term/termios/termios_solaris.c.v | 2 +- vlib/time/time_darwin.c.v | 2 +- vlib/time/time_nix.c.v | 2 +- vlib/time/time_windows.c.v | 4 +- .../redeclare_time_structs.v | 2 +- .../private_redeclaration_of_C_struct.out | 28 ----------- .../private_redeclaration_of_C_struct.vv | 9 ---- .../tests/struct_type_is_private_err.out | 11 ---- .../tests/struct_type_is_private_err.vv | 5 -- vlib/v/fmt/tests/struct_keep.vv | 2 +- vlib/v/fmt/tests/structs_expected.vv | 2 +- vlib/v/fmt/tests/structs_input.vv | 2 +- .../c/testdata/alias_c_parent_type_decl.vv | 2 +- vlib/v/gen/c/testdata/compare_structs.vv | 2 +- vlib/v/parser/tests/c_struct_no_embed.out | 4 +- vlib/v/parser/tests/c_struct_no_embed.vv | 2 +- vlib/v/parser/tests/const_index.vv | 2 +- vlib/v/preludes/test_runner.v | 2 +- ...operator_overload_of_c_struct_alias_test.v | 4 +- .../c_struct_free_property_test.v | 2 +- .../tests/dump_c_structs/dump_c_struct_test.v | 2 +- vlib/v/tests/modules/sub/foo.v | 2 +- .../string_interpolation_test.v | 2 +- .../tests/project_with_c_code/mod1/wrapper.v | 2 +- .../project_with_c_code_2/modc/wrapper.v | 2 +- vlib/v/tests/struct_test.v | 4 +- 66 files changed, 127 insertions(+), 180 deletions(-) delete mode 100644 vlib/v/checker/tests/private_redeclaration_of_C_struct.out delete mode 100644 vlib/v/checker/tests/private_redeclaration_of_C_struct.vv delete mode 100644 vlib/v/checker/tests/struct_type_is_private_err.out delete mode 100644 vlib/v/checker/tests/struct_type_is_private_err.vv diff --git a/doc/docs.md b/doc/docs.md index b51c715ce..29458182d 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -5489,7 +5489,7 @@ fn custom_allocations() { // For C interop only, tells V that the following struct is defined with `typedef struct` in C [typedef] -struct C.Foo { +pub struct C.Foo { } // Used to add a custom calling convention to a function, available calling convention: stdcall, fastcall and cdecl. @@ -6508,10 +6508,10 @@ For all supported options check the latest help: #flag -lsqlite3 #include "sqlite3.h" // See also the example from https://www.sqlite.org/quickstart.html -struct C.sqlite3 { +pub struct C.sqlite3 { } -struct C.sqlite3_stmt { +pub struct C.sqlite3_stmt { } type FnSqlite3Callback = fn (voidptr, int, &&char, &&char) int @@ -6744,7 +6744,7 @@ struct SomeCStruct { members of sub-data-structures may be directly declared in the containing struct as below: ```v -struct C.SomeCStruct { +pub struct C.SomeCStruct { implTraits u8 memPoolData u16 // These members are part of sub data structures that can't currently be represented in V. diff --git a/examples/c_interop_wkhtmltopdf.v b/examples/c_interop_wkhtmltopdf.v index 5f7240887..b650076cb 100644 --- a/examples/c_interop_wkhtmltopdf.v +++ b/examples/c_interop_wkhtmltopdf.v @@ -13,11 +13,11 @@ import os #flag -lwkhtmltox #include "wkhtmltox/pdf.h" # You can install the C package for your system from the wkhtmltopdf.org/downloads.html page -struct C.wkhtmltopdf_global_settings {} +pub struct C.wkhtmltopdf_global_settings {} -struct C.wkhtmltopdf_object_settings {} +pub struct C.wkhtmltopdf_object_settings {} -struct C.wkhtmltopdf_converter {} +pub struct C.wkhtmltopdf_converter {} fn C.wkhtmltopdf_init(use_graphics bool) int diff --git a/vlib/builtin/builtin_d_use_libbacktrace.c.v b/vlib/builtin/builtin_d_use_libbacktrace.c.v index c9df8deae..bd0879a95 100644 --- a/vlib/builtin/builtin_d_use_libbacktrace.c.v +++ b/vlib/builtin/builtin_d_use_libbacktrace.c.v @@ -6,7 +6,7 @@ module builtin #include // NOTE: Don't mark this as a [typedef] or it may cause compiler errors! -struct C.backtrace_state { +pub struct C.backtrace_state { // filename &char } diff --git a/vlib/builtin/cfns.c.v b/vlib/builtin/cfns.c.v index 007fd2079..0cc87dfaf 100644 --- a/vlib/builtin/cfns.c.v +++ b/vlib/builtin/cfns.c.v @@ -153,7 +153,7 @@ fn C.sleep(seconds u32) u32 fn C.usleep(usec u32) int [typedef] -struct C.DIR { +pub struct C.DIR { } fn C.opendir(&char) &C.DIR diff --git a/vlib/builtin/option.c.v b/vlib/builtin/option.c.v index 1e04b2648..6b308fb3c 100644 --- a/vlib/builtin/option.c.v +++ b/vlib/builtin/option.c.v @@ -1,7 +1,7 @@ module builtin [typedef] -struct C.IError { +pub struct C.IError { _object voidptr } diff --git a/vlib/builtin/wchar/wchar.c.v b/vlib/builtin/wchar/wchar.c.v index a04c320b3..bd9279a8b 100644 --- a/vlib/builtin/wchar/wchar.c.v +++ b/vlib/builtin/wchar/wchar.c.v @@ -5,7 +5,7 @@ import strings #include [typedef] -struct C.wchar_t {} +pub struct C.wchar_t {} // Character is a type, that eases working with the platform dependent C.wchar_t type. // Note: the size of C.wchar_t varies between platforms, it is 2 bytes on windows, diff --git a/vlib/clipboard/x11/clipboard.c.v b/vlib/clipboard/x11/clipboard.c.v index a203bc2bc..183a6727a 100644 --- a/vlib/clipboard/x11/clipboard.c.v +++ b/vlib/clipboard/x11/clipboard.c.v @@ -18,7 +18,7 @@ $if freebsd { #include # Please install a package with the X11 development headers, for example: `apt-get install libx11-dev` // X11 [typedef] -struct C.Display { +pub struct C.Display { } type Window = u64 @@ -69,7 +69,7 @@ fn C.XFree(data voidptr) fn todo_del() {} [typedef] -struct C.XSelectionRequestEvent { +pub struct C.XSelectionRequestEvent { mut: display &C.Display = unsafe { nil } // Display the event was read from owner Window @@ -81,7 +81,7 @@ mut: } [typedef] -struct C.XSelectionEvent { +pub struct C.XSelectionEvent { mut: @type int display &C.Display = unsafe { nil } // Display the event was read from @@ -93,14 +93,14 @@ mut: } [typedef] -struct C.XSelectionClearEvent { +pub struct C.XSelectionClearEvent { mut: window Window selection Atom } [typedef] -struct C.XDestroyWindowEvent { +pub struct C.XDestroyWindowEvent { mut: window Window } diff --git a/vlib/db/mysql/_cdefs.c.v b/vlib/db/mysql/_cdefs.c.v index cd7193472..303a8e677 100644 --- a/vlib/db/mysql/_cdefs.c.v +++ b/vlib/db/mysql/_cdefs.c.v @@ -1,15 +1,15 @@ module mysql [typedef] -struct C.MYSQL { +pub struct C.MYSQL { } [typedef] -struct C.MYSQL_RES { +pub struct C.MYSQL_RES { } [typedef] -struct C.MYSQL_FIELD { +pub struct C.MYSQL_FIELD { name &u8 // Name of column org_name &u8 // Original column name, if an alias table &u8 // Table of column if column was a field diff --git a/vlib/db/mysql/stmt.c.v b/vlib/db/mysql/stmt.c.v index 13a495c3f..b434d9cd8 100644 --- a/vlib/db/mysql/stmt.c.v +++ b/vlib/db/mysql/stmt.c.v @@ -1,13 +1,13 @@ module mysql [typedef] -struct C.MYSQL_STMT { +pub struct C.MYSQL_STMT { mysql &C.MYSQL stmt_id u32 } [typedef] -struct C.MYSQL_BIND { +pub struct C.MYSQL_BIND { mut: buffer_type int buffer voidptr diff --git a/vlib/db/pg/pg.v b/vlib/db/pg/pg.v index 1c6b2851d..201df403d 100644 --- a/vlib/db/pg/pg.v +++ b/vlib/db/pg/pg.v @@ -57,9 +57,9 @@ pub: // -struct C.pg_result {} +pub struct C.pg_result {} -struct C.pg_conn {} +pub struct C.pg_conn {} [typedef] pub struct C.PGresult {} diff --git a/vlib/db/sqlite/sqlite.v b/vlib/db/sqlite/sqlite.v index 0dd6525b1..f915a2fdd 100644 --- a/vlib/db/sqlite/sqlite.v +++ b/vlib/db/sqlite/sqlite.v @@ -52,10 +52,10 @@ pub enum JournalMode { memory } -struct C.sqlite3 { +pub struct C.sqlite3 { } -struct C.sqlite3_stmt { +pub struct C.sqlite3_stmt { } [heap] diff --git a/vlib/log/default.c.v b/vlib/log/default.c.v index d265bdd93..219bbf229 100644 --- a/vlib/log/default.c.v +++ b/vlib/log/default.c.v @@ -8,7 +8,7 @@ __global default_logger &Logger // TODO: remove this hack, when the language has a way to access the raw pointer to an interface value directly: [typedef] -struct C.log__Logger { +pub struct C.log__Logger { mut: _object voidptr } diff --git a/vlib/net/http/backend_windows.c.v b/vlib/net/http/backend_windows.c.v index 5a758bb0c..6ecd26dec 100644 --- a/vlib/net/http/backend_windows.c.v +++ b/vlib/net/http/backend_windows.c.v @@ -11,7 +11,7 @@ $if gcboehm ? { #flag -l ws2_32 -l crypt32 -l secur32 -l user32 #include "vschannel.c" -struct C.TlsContext {} +pub struct C.TlsContext {} fn C.new_tls_context() C.TlsContext diff --git a/vlib/net/mbedtls/c.v b/vlib/net/mbedtls/c.v index 8361be305..2434f7a85 100644 --- a/vlib/net/mbedtls/c.v +++ b/vlib/net/mbedtls/c.v @@ -118,31 +118,31 @@ $if prod && opt_size ? { #include [typedef] -struct C.mbedtls_net_context { +pub struct C.mbedtls_net_context { mut: fd int } [typedef] -struct C.mbedtls_x509_crt {} +pub struct C.mbedtls_x509_crt {} [typedef] -struct C.mbedtls_x509_crl {} +pub struct C.mbedtls_x509_crl {} [typedef] -struct C.mbedtls_pk_context {} +pub struct C.mbedtls_pk_context {} [typedef] -struct C.mbedtls_entropy_context {} +pub struct C.mbedtls_entropy_context {} [typedef] -struct C.mbedtls_ctr_drbg_context {} +pub struct C.mbedtls_ctr_drbg_context {} [typedef] -struct C.mbedtls_ssl_context {} +pub struct C.mbedtls_ssl_context {} [typedef] -struct C.mbedtls_ssl_config {} +pub struct C.mbedtls_ssl_config {} fn C.mbedtls_net_init(&C.mbedtls_net_context) fn C.mbedtls_ssl_init(&C.mbedtls_ssl_context) diff --git a/vlib/net/net_windows.c.v b/vlib/net/net_windows.c.v index ec04c5795..0e595c5ef 100644 --- a/vlib/net/net_windows.c.v +++ b/vlib/net/net_windows.c.v @@ -761,7 +761,7 @@ fn error_code() int { return C.WSAGetLastError() } -struct C.WSAData { +pub struct C.WSAData { mut: wVersion u16 wHighVersion u16 diff --git a/vlib/os/notify/backend_darwin.c.v b/vlib/os/notify/backend_darwin.c.v index 6d5a29b40..733ccb1de 100644 --- a/vlib/os/notify/backend_darwin.c.v +++ b/vlib/os/notify/backend_darwin.c.v @@ -5,7 +5,7 @@ import os #insert "@VEXEROOT/vlib/os/notify/kqueue.h" -struct C.kevent { +pub struct C.kevent { mut: ident u32 filter i16 diff --git a/vlib/os/notify/backend_linux.c.v b/vlib/os/notify/backend_linux.c.v index 05109e070..bcf6f41c0 100644 --- a/vlib/os/notify/backend_linux.c.v +++ b/vlib/os/notify/backend_linux.c.v @@ -5,7 +5,7 @@ import os #insert "@VEXEROOT/vlib/os/notify/epoll.h" -struct C.epoll_event { +pub struct C.epoll_event { events u32 data C.epoll_data_t } diff --git a/vlib/os/os_android_outside_termux.c.v b/vlib/os/os_android_outside_termux.c.v index c9caa53ac..84acd4f23 100644 --- a/vlib/os/os_android_outside_termux.c.v +++ b/vlib/os/os_android_outside_termux.c.v @@ -12,7 +12,7 @@ pub enum AssetMode { } // See https://developer.android.com/ndk/reference/struct/a-native-activity for more info. -struct C.ANativeActivity { +pub struct C.ANativeActivity { pub: assetManager &AssetManager = unsafe { nil } // Pointer to the Asset Manager instance for the application. clazz voidptr // (jobject) The NativeActivity object handle. @@ -28,7 +28,7 @@ pub: // NativeActivity defines the native side of an android.app.NativeActivity. pub type NativeActivity = C.ANativeActivity -struct C.AAssetManager { +pub struct C.AAssetManager { } // AssetManager provides access to an application's raw assets by creating Asset objects. @@ -45,7 +45,7 @@ pub fn (am &AssetManager) open(filename string, mode AssetMode) !&Asset { return asset } -struct C.AAsset { +pub struct C.AAsset { } pub type Asset = C.AAsset diff --git a/vlib/os/os_structs_dirent_default.c.v b/vlib/os/os_structs_dirent_default.c.v index 6fd387552..269fc44b3 100644 --- a/vlib/os/os_structs_dirent_default.c.v +++ b/vlib/os/os_structs_dirent_default.c.v @@ -1,5 +1,5 @@ module os -struct C.dirent { +pub struct C.dirent { d_name [256]char } diff --git a/vlib/os/os_structs_sigaction_default.c.v b/vlib/os/os_structs_sigaction_default.c.v index ba5a773c2..4346779f2 100644 --- a/vlib/os/os_structs_sigaction_default.c.v +++ b/vlib/os/os_structs_sigaction_default.c.v @@ -2,7 +2,7 @@ module os pub type FN_SA_Handler = fn (sig int) -struct C.sigaction { +pub struct C.sigaction { mut: sa_mask int sa_sigaction int diff --git a/vlib/os/os_structs_stat_default.c.v b/vlib/os/os_structs_stat_default.c.v index d022d3360..de5073463 100644 --- a/vlib/os/os_structs_stat_default.c.v +++ b/vlib/os/os_structs_stat_default.c.v @@ -6,7 +6,7 @@ pub struct C.stat { st_mtime int } -struct C.__stat64 { +pub struct C.__stat64 { st_size u64 st_mode u32 st_mtime int diff --git a/vlib/os/os_structs_stat_linux.c.v b/vlib/os/os_structs_stat_linux.c.v index e69680877..06f16bd6e 100644 --- a/vlib/os/os_structs_stat_linux.c.v +++ b/vlib/os/os_structs_stat_linux.c.v @@ -16,7 +16,7 @@ pub struct C.stat { st_ctime i64 // 8 } -struct C.__stat64 { +pub struct C.__stat64 { st_mode u32 st_size u64 st_mtime u64 diff --git a/vlib/os/os_structs_utsname_default.c.v b/vlib/os/os_structs_utsname_default.c.v index 5441d4d5b..5782afffd 100644 --- a/vlib/os/os_structs_utsname_default.c.v +++ b/vlib/os/os_structs_utsname_default.c.v @@ -1,6 +1,6 @@ module os -struct C.utsname { +pub struct C.utsname { mut: sysname &char nodename &char @@ -9,7 +9,7 @@ mut: machine &char } -struct C.utimbuf { +pub struct C.utimbuf { actime int modtime int } diff --git a/vlib/os/os_windows.c.v b/vlib/os/os_windows.c.v index 37cff46bb..75357f1db 100644 --- a/vlib/os/os_windows.c.v +++ b/vlib/os/os_windows.c.v @@ -89,7 +89,7 @@ mut: b_inherit_handle bool } -struct C._utimbuf { +pub struct C._utimbuf { actime int modtime int } diff --git a/vlib/runtime/free_memory_impl_darwin.c.v b/vlib/runtime/free_memory_impl_darwin.c.v index 16080da21..35943521c 100644 --- a/vlib/runtime/free_memory_impl_darwin.c.v +++ b/vlib/runtime/free_memory_impl_darwin.c.v @@ -3,11 +3,11 @@ module runtime #include [typedef] -struct C.vm_size_t { +pub struct C.vm_size_t { } [typedef] -struct C.vm_statistics64_data_t { +pub struct C.vm_statistics64_data_t { free_count u32 purgeable_count u32 speculative_count u32 @@ -15,7 +15,7 @@ struct C.vm_statistics64_data_t { } [typedef] -struct C.host_t {} +pub struct C.host_t {} fn C.mach_host_self() C.host_t fn C.host_page_size(host C.host_t, out_page_size &C.vm_size_t) int diff --git a/vlib/runtime/runtime_windows.c.v b/vlib/runtime/runtime_windows.c.v index 76dfcacc6..12ecf9e61 100644 --- a/vlib/runtime/runtime_windows.c.v +++ b/vlib/runtime/runtime_windows.c.v @@ -3,12 +3,12 @@ module runtime import os [typedef] -struct C.SYSTEM_INFO { +pub struct C.SYSTEM_INFO { dwNumberOfProcessors u32 } [typedef] -struct C.MEMORYSTATUS { +pub struct C.MEMORYSTATUS { dwTotalPhys usize dwAvailPhys usize } diff --git a/vlib/sokol/gfx/gfx_structs.c.v b/vlib/sokol/gfx/gfx_structs.c.v index bc783bfae..24b27f571 100644 --- a/vlib/sokol/gfx/gfx_structs.c.v +++ b/vlib/sokol/gfx/gfx_structs.c.v @@ -24,7 +24,7 @@ pub mut: pub type Desc = C.sg_desc -struct C.sg_context_desc { +pub struct C.sg_context_desc { pub mut: color_format PixelFormat depth_format PixelFormat @@ -37,13 +37,13 @@ pub mut: pub type ContextDesc = C.sg_context_desc -struct C.sg_gl_context_desc { +pub struct C.sg_gl_context_desc { force_gles2 bool } pub type GLContextDesc = C.sg_gl_context_desc -struct C.sg_metal_context_desc { +pub struct C.sg_metal_context_desc { device voidptr renderpass_descriptor_cb fn () voidptr = unsafe { nil } drawable_cb fn () voidptr = unsafe { nil } @@ -51,7 +51,7 @@ struct C.sg_metal_context_desc { pub type MetalContextDesc = C.sg_metal_context_desc -struct C.sg_d3d11_context_desc { +pub struct C.sg_d3d11_context_desc { device voidptr device_context voidptr render_target_view_cb fn () voidptr = unsafe { nil } @@ -60,7 +60,7 @@ struct C.sg_d3d11_context_desc { pub type D3D11ContextDesc = C.sg_d3d11_context_desc -struct C.sg_color_target_state { +pub struct C.sg_color_target_state { pub mut: pixel_format PixelFormat write_mask ColorMask @@ -107,7 +107,7 @@ pub fn (mut p C.sg_pipeline) free() { C.sg_destroy_pipeline(*p) } -struct C.sg_bindings { +pub struct C.sg_bindings { pub mut: _start_canary u32 vertex_buffers [8]Buffer @@ -172,7 +172,7 @@ pub mut: pub type StageBindings = C.sg_stage_bindings [heap] -struct C.sg_shader_desc { +pub struct C.sg_shader_desc { pub mut: attrs [16]ShaderAttrDesc vs ShaderStageDesc @@ -230,7 +230,7 @@ pub fn (desc &ShaderDesc) make_shader() Shader { return C.sg_make_shader(desc) } -struct C.sg_shader_attr_desc { +pub struct C.sg_shader_attr_desc { pub mut: name &char // GLSL vertex attribute name (only required for GLES2) sem_name &char // HLSL semantic name @@ -239,7 +239,7 @@ pub mut: pub type ShaderAttrDesc = C.sg_shader_attr_desc -struct C.sg_shader_stage_desc { +pub struct C.sg_shader_stage_desc { pub mut: source &char bytecode Range @@ -259,7 +259,7 @@ pub fn (mut desc ShaderStageDesc) set_image(index int, name string) ShaderStageD return *desc } -struct C.sg_shader_uniform_block_desc { +pub struct C.sg_shader_uniform_block_desc { pub mut: size usize layout UniformLayout @@ -268,7 +268,7 @@ pub mut: pub type ShaderUniformBlockDesc = C.sg_shader_uniform_block_desc -struct C.sg_shader_uniform_desc { +pub struct C.sg_shader_uniform_desc { pub mut: name &char @type UniformType @@ -277,7 +277,7 @@ pub mut: pub type ShaderUniformDesc = C.sg_shader_uniform_desc -struct C.sg_shader_image_desc { +pub struct C.sg_shader_image_desc { pub mut: used bool multisampled bool @@ -328,7 +328,7 @@ pub mut: pub type Range = C.sg_range -struct C.sg_color { +pub struct C.sg_color { pub mut: r f32 g f32 @@ -349,7 +349,7 @@ pub fn (mut s Shader) free() { C.sg_destroy_shader(*s) } -struct C.sg_pass_desc { +pub struct C.sg_pass_desc { pub mut: color_attachments [4]PassAttachmentDesc depth_stencil_attachment PassAttachmentDesc @@ -358,7 +358,7 @@ pub mut: pub type PassDesc = C.sg_pass_desc -struct C.sg_pass_info { +pub struct C.sg_pass_info { info SlotInfo } @@ -373,7 +373,7 @@ pub mut: pub type PassAction = C.sg_pass_action -struct C.sg_pass { +pub struct C.sg_pass { id u32 } @@ -383,7 +383,7 @@ pub fn (mut p Pass) free() { C.sg_destroy_pass(*p) } -struct C.sg_buffer_desc { +pub struct C.sg_buffer_desc { pub mut: size usize @type BufferType @@ -399,7 +399,7 @@ pub mut: pub type BufferDesc = C.sg_buffer_desc -struct C.sg_slot_info { +pub struct C.sg_slot_info { state ResourceState res_id u32 ctx_id u32 @@ -524,7 +524,7 @@ pub mut: pub type ImageData = C.sg_image_data -struct C.sg_features { +pub struct C.sg_features { pub: origin_top_left bool // framebuffer and texture origin is in top left corner image_clamp_to_border bool // border color and clamp-to-border UV-wrap mode is supported @@ -579,7 +579,7 @@ pub mut: pub type VertexAttrDesc = C.sg_vertex_attr_state -struct C.sg_stencil_state { +pub struct C.sg_stencil_state { enabled bool front StencilFaceState back StencilFaceState @@ -590,7 +590,7 @@ struct C.sg_stencil_state { pub type StencilState = C.sg_stencil_state -struct C.sg_depth_state { +pub struct C.sg_depth_state { pixel_format PixelFormat compare CompareFunc write_enabled bool @@ -601,7 +601,7 @@ struct C.sg_depth_state { pub type DepthState = C.sg_depth_state -struct C.sg_stencil_face_state { +pub struct C.sg_stencil_face_state { compare CompareFunc fail_op StencilOp depth_fail_op StencilOp @@ -610,7 +610,7 @@ struct C.sg_stencil_face_state { pub type StencilFaceState = C.sg_stencil_face_state -struct C.sg_blend_state { +pub struct C.sg_blend_state { pub mut: enabled bool src_factor_rgb BlendFactor @@ -623,7 +623,7 @@ pub mut: pub type BlendState = C.sg_blend_state -struct C.sg_color_attachment_action { +pub struct C.sg_color_attachment_action { pub mut: load_action LoadAction store_action StoreAction @@ -670,7 +670,7 @@ pub: pub type PixelFormatInfo = C.sg_pixelformat_info -struct C.sg_pass_attachment_desc { +pub struct C.sg_pass_attachment_desc { pub mut: image Image mip_level int diff --git a/vlib/sokol/sgl/sgl_structs.c.v b/vlib/sokol/sgl/sgl_structs.c.v index 0951a3c03..7b630c304 100644 --- a/vlib/sokol/sgl/sgl_structs.c.v +++ b/vlib/sokol/sgl/sgl_structs.c.v @@ -3,14 +3,14 @@ module sgl import sokol.gfx [typedef] -struct C.sgl_pipeline { +pub struct C.sgl_pipeline { id u32 } pub type Pipeline = C.sgl_pipeline [typedef] -struct C.sgl_context { +pub struct C.sgl_context { id u32 } diff --git a/vlib/sync/channels.c.v b/vlib/sync/channels.c.v index a444ee339..e2ff06b79 100644 --- a/vlib/sync/channels.c.v +++ b/vlib/sync/channels.c.v @@ -32,7 +32,7 @@ pub enum Direction { } [typedef] -struct C.atomic_uintptr_t {} +pub struct C.atomic_uintptr_t {} pub struct Channel { ringbuf &u8 = unsafe { nil } // queue for buffered channels diff --git a/vlib/sync/sync_darwin.c.v b/vlib/sync/sync_darwin.c.v index 35a43a4c8..639abb1b8 100644 --- a/vlib/sync/sync_darwin.c.v +++ b/vlib/sync/sync_darwin.c.v @@ -32,19 +32,19 @@ fn C.pthread_cond_timedwait(voidptr, voidptr, voidptr) int fn C.pthread_cond_destroy(voidptr) int [typedef] -struct C.pthread_mutex_t {} +pub struct C.pthread_mutex_t {} [typedef] -struct C.pthread_cond_t {} +pub struct C.pthread_cond_t {} [typedef] -struct C.pthread_rwlock_t {} +pub struct C.pthread_rwlock_t {} [typedef] -struct C.pthread_rwlockattr_t {} +pub struct C.pthread_rwlockattr_t {} [typedef] -struct C.sem_t {} +pub struct C.sem_t {} // [init_with=new_mutex] // TODO: implement support for this struct attribute, and disallow Mutex{} from outside the sync.new_mutex() function. [heap] @@ -62,7 +62,7 @@ struct RwMutexAttr { } [typedef] -struct C.pthread_condattr_t {} +pub struct C.pthread_condattr_t {} struct CondAttr { attr C.pthread_condattr_t diff --git a/vlib/sync/sync_default.c.v b/vlib/sync/sync_default.c.v index 43dde304d..ae7fcbf76 100644 --- a/vlib/sync/sync_default.c.v +++ b/vlib/sync/sync_default.c.v @@ -35,16 +35,16 @@ fn C.sem_timedwait(voidptr, voidptr) int fn C.sem_destroy(voidptr) int [typedef] -struct C.pthread_mutex_t {} +pub struct C.pthread_mutex_t {} [typedef] -struct C.pthread_rwlock_t {} +pub struct C.pthread_rwlock_t {} [typedef] -struct C.pthread_rwlockattr_t {} +pub struct C.pthread_rwlockattr_t {} [typedef] -struct C.sem_t {} +pub struct C.sem_t {} // [init_with=new_mutex] // TODO: implement support for this struct attribute, and disallow Mutex{} from outside the sync.new_mutex() function. [heap] diff --git a/vlib/sync/sync_windows.c.v b/vlib/sync/sync_windows.c.v index cec021db6..cce2c1703 100644 --- a/vlib/sync/sync_windows.c.v +++ b/vlib/sync/sync_windows.c.v @@ -23,10 +23,10 @@ type MHANDLE = voidptr type SHANDLE = voidptr [typedef] -struct C.SRWLOCK {} +pub struct C.SRWLOCK {} [typedef] -struct C.CONDITION_VARIABLE {} +pub struct C.CONDITION_VARIABLE {} //[init_with=new_mutex] // TODO: implement support for this struct attribute, and disallow Mutex{} from outside the sync.new_mutex() function. diff --git a/vlib/szip/szip.v b/vlib/szip/szip.v index 2eaedae49..505d9c900 100644 --- a/vlib/szip/szip.v +++ b/vlib/szip/szip.v @@ -10,7 +10,7 @@ pub struct ZipFolderOptions { omit_empty_folders bool } -struct C.zip_t { +pub struct C.zip_t { } type Zip = C.zip_t diff --git a/vlib/term/termios/termios_android.c.v b/vlib/term/termios/termios_android.c.v index dc37096ff..20c870e8f 100644 --- a/vlib/term/termios/termios_android.c.v +++ b/vlib/term/termios/termios_android.c.v @@ -19,7 +19,7 @@ type Speed = int type Cc = u8 // Termios stores the terminal options on Linux. -struct C.termios { +pub struct C.termios { mut: c_iflag TcFlag c_oflag TcFlag diff --git a/vlib/term/termios/termios_darwin.c.v b/vlib/term/termios/termios_darwin.c.v index 5509a1060..69d592a67 100644 --- a/vlib/term/termios/termios_darwin.c.v +++ b/vlib/term/termios/termios_darwin.c.v @@ -19,7 +19,7 @@ type Speed = usize type Cc = u8 // Termios stores the terminal options -struct C.termios { +pub struct C.termios { mut: c_iflag TcFlag c_oflag TcFlag diff --git a/vlib/term/termios/termios_dragonfly.c.v b/vlib/term/termios/termios_dragonfly.c.v index c2df2a5b6..14416d341 100644 --- a/vlib/term/termios/termios_dragonfly.c.v +++ b/vlib/term/termios/termios_dragonfly.c.v @@ -19,7 +19,7 @@ type Speed = int type Cc = u8 // Termios stores the terminal options -struct C.termios { +pub struct C.termios { mut: c_iflag TcFlag c_oflag TcFlag diff --git a/vlib/term/termios/termios_freebsd.c.v b/vlib/term/termios/termios_freebsd.c.v index 1503dbf05..47f84acbd 100644 --- a/vlib/term/termios/termios_freebsd.c.v +++ b/vlib/term/termios/termios_freebsd.c.v @@ -19,7 +19,7 @@ type Speed = int type Cc = u8 // Termios stores the terminal options -struct C.termios { +pub struct C.termios { mut: c_iflag TcFlag c_oflag TcFlag diff --git a/vlib/term/termios/termios_linux.c.v b/vlib/term/termios/termios_linux.c.v index dc37096ff..20c870e8f 100644 --- a/vlib/term/termios/termios_linux.c.v +++ b/vlib/term/termios/termios_linux.c.v @@ -19,7 +19,7 @@ type Speed = int type Cc = u8 // Termios stores the terminal options on Linux. -struct C.termios { +pub struct C.termios { mut: c_iflag TcFlag c_oflag TcFlag diff --git a/vlib/term/termios/termios_openbsd.c.v b/vlib/term/termios/termios_openbsd.c.v index a2c93b914..ede5855d0 100644 --- a/vlib/term/termios/termios_openbsd.c.v +++ b/vlib/term/termios/termios_openbsd.c.v @@ -19,7 +19,7 @@ type Speed = int type Cc = u8 // Termios stores the terminal options -struct C.termios { +pub struct C.termios { mut: c_iflag TcFlag c_oflag TcFlag diff --git a/vlib/term/termios/termios_qnx.c.v b/vlib/term/termios/termios_qnx.c.v index f2adbe5ea..508842964 100644 --- a/vlib/term/termios/termios_qnx.c.v +++ b/vlib/term/termios/termios_qnx.c.v @@ -19,7 +19,7 @@ type Speed = int type Cc = u8 // Termios stores the terminal options -struct C.termios { +pub struct C.termios { mut: c_iflag TcFlag c_oflag TcFlag diff --git a/vlib/term/termios/termios_solaris.c.v b/vlib/term/termios/termios_solaris.c.v index faffdc354..f459deabd 100644 --- a/vlib/term/termios/termios_solaris.c.v +++ b/vlib/term/termios/termios_solaris.c.v @@ -19,7 +19,7 @@ type Speed = int type Cc = u8 // Termios stores the terminal options -struct C.termios { +pub struct C.termios { mut: c_iflag TcFlag c_oflag TcFlag diff --git a/vlib/time/time_darwin.c.v b/vlib/time/time_darwin.c.v index c4b9bf50a..1206b57a7 100644 --- a/vlib/time/time_darwin.c.v +++ b/vlib/time/time_darwin.c.v @@ -8,7 +8,7 @@ const start_time = C.mach_absolute_time() const time_base = init_time_base() [typedef] -struct C.mach_timebase_info_data_t { +pub struct C.mach_timebase_info_data_t { numer u32 denom u32 } diff --git a/vlib/time/time_nix.c.v b/vlib/time/time_nix.c.v index f46de43b8..9bdfbfeea 100644 --- a/vlib/time/time_nix.c.v +++ b/vlib/time/time_nix.c.v @@ -7,7 +7,7 @@ module time #include #include -struct C.tm { +pub struct C.tm { tm_sec int tm_min int tm_hour int diff --git a/vlib/time/time_windows.c.v b/vlib/time/time_windows.c.v index 694e313cb..56c222c3c 100644 --- a/vlib/time/time_windows.c.v +++ b/vlib/time/time_windows.c.v @@ -6,7 +6,7 @@ module time #include // #include -struct C.tm { +pub struct C.tm { tm_year int tm_mon int tm_mday int @@ -49,7 +49,7 @@ const ( ) // in most systems, these are __quad_t, which is an i64 -struct C.timespec { +pub struct C.timespec { tv_sec i64 tv_nsec i64 } diff --git a/vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.v b/vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.v index 2ca4ad49d..ed5bdcfde 100644 --- a/vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.v +++ b/vlib/v/checker/tests/modules/module_with_redeclaration/redeclare_time_structs.v @@ -19,7 +19,7 @@ pub mut: user_data voidptr } -struct C.saudio_desc { +pub struct C.saudio_desc { pub mut: user_data voidptr allocator C.saudio_allocator diff --git a/vlib/v/checker/tests/private_redeclaration_of_C_struct.out b/vlib/v/checker/tests/private_redeclaration_of_C_struct.out deleted file mode 100644 index 5eaad2452..000000000 --- a/vlib/v/checker/tests/private_redeclaration_of_C_struct.out +++ /dev/null @@ -1,28 +0,0 @@ -vlib/sokol/audio/audio.v:107:26: error: struct `C.saudio_desc` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `sokol.audio` - 105 | fn C.saudio_userdata() voidptr - 106 | - 107 | fn C.saudio_query_desc() C.saudio_desc - | ~~~~~~~~~~~~~ - 108 | - 109 | fn C.saudio_sample_rate() int -vlib/sokol/audio/audio.v:122:19: error: struct `C.saudio_desc` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `sokol.audio` - 120 | - 121 | // setup - setup sokol-audio - 122 | pub fn setup(desc &C.saudio_desc) { - | ~~~~~~~~~~~~~~ - 123 | if desc.allocator.alloc_fn == unsafe { nil } && desc.allocator.free_fn == unsafe { nil } { - 124 | unsafe { -vlib/sokol/audio/audio.v:154:16: error: struct `C.saudio_desc` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `sokol.audio` - 152 | - 153 | // query - return a copy of the original saudio_desc struct - 154 | pub fn query() C.saudio_desc { - | ~~~~~~~~~~~~~ - 155 | return C.saudio_query_desc() - 156 | } -vlib/v/checker/tests/private_redeclaration_of_C_struct.vv:7:10: error: struct `C.saudio_desc` was declared as private to module `module_with_redeclaration`, so it can not be used inside module `main` - 5 | - 6 | fn main() { - 7 | sd := C.saudio_desc{} - | ~~~~~~~~~~~~~ - 8 | audio.setup(sd) - 9 | } diff --git a/vlib/v/checker/tests/private_redeclaration_of_C_struct.vv b/vlib/v/checker/tests/private_redeclaration_of_C_struct.vv deleted file mode 100644 index 0318ee2b1..000000000 --- a/vlib/v/checker/tests/private_redeclaration_of_C_struct.vv +++ /dev/null @@ -1,9 +0,0 @@ -import module_with_redeclaration as mr -import sokol.audio - -const used = mr.used - -fn main() { - sd := C.saudio_desc{} - audio.setup(sd) -} diff --git a/vlib/v/checker/tests/struct_type_is_private_err.out b/vlib/v/checker/tests/struct_type_is_private_err.out deleted file mode 100644 index 57266567e..000000000 --- a/vlib/v/checker/tests/struct_type_is_private_err.out +++ /dev/null @@ -1,11 +0,0 @@ -vlib/v/checker/tests/struct_type_is_private_err.vv:1:8: warning: module 'sqlite (db.sqlite)' is imported but never used - 1 | import db.sqlite - | ~~~~~~~~~ - 2 | - 3 | fn main() { -vlib/v/checker/tests/struct_type_is_private_err.vv:4:10: error: struct `C.sqlite3` was declared as private to module `db.sqlite`, so it can not be used inside module `main` - 2 | - 3 | fn main() { - 4 | _ := &C.sqlite3{} - | ~~~~~~~~~ - 5 | } diff --git a/vlib/v/checker/tests/struct_type_is_private_err.vv b/vlib/v/checker/tests/struct_type_is_private_err.vv deleted file mode 100644 index 9ed43b798..000000000 --- a/vlib/v/checker/tests/struct_type_is_private_err.vv +++ /dev/null @@ -1,5 +0,0 @@ -import db.sqlite - -fn main() { - _ := &C.sqlite3{} -} diff --git a/vlib/v/fmt/tests/struct_keep.vv b/vlib/v/fmt/tests/struct_keep.vv index 023afbb4c..c82222740 100644 --- a/vlib/v/fmt/tests/struct_keep.vv +++ b/vlib/v/fmt/tests/struct_keep.vv @@ -46,7 +46,7 @@ struct KeepMultiLineDefaultExprsIndent { } [typedef] -struct C.some_t { +pub struct C.some_t { @type int data struct {} diff --git a/vlib/v/fmt/tests/structs_expected.vv b/vlib/v/fmt/tests/structs_expected.vv index fb0490bb6..e4c2a7022 100644 --- a/vlib/v/fmt/tests/structs_expected.vv +++ b/vlib/v/fmt/tests/structs_expected.vv @@ -56,4 +56,4 @@ pub: */ } -struct C.Foo {} +pub struct C.Foo {} diff --git a/vlib/v/fmt/tests/structs_input.vv b/vlib/v/fmt/tests/structs_input.vv index e6778aa26..30c5b50c5 100644 --- a/vlib/v/fmt/tests/structs_input.vv +++ b/vlib/v/fmt/tests/structs_input.vv @@ -63,4 +63,4 @@ somefield4 int */ } -struct C.Foo +pub struct C.Foo diff --git a/vlib/v/gen/c/testdata/alias_c_parent_type_decl.vv b/vlib/v/gen/c/testdata/alias_c_parent_type_decl.vv index 0623498bd..9d7446d96 100644 --- a/vlib/v/gen/c/testdata/alias_c_parent_type_decl.vv +++ b/vlib/v/gen/c/testdata/alias_c_parent_type_decl.vv @@ -1,2 +1,2 @@ -struct C.atype{} +pub struct C.atype{} type BType = &C.atype diff --git a/vlib/v/gen/c/testdata/compare_structs.vv b/vlib/v/gen/c/testdata/compare_structs.vv index aaf97ef6f..8581a9a9e 100644 --- a/vlib/v/gen/c/testdata/compare_structs.vv +++ b/vlib/v/gen/c/testdata/compare_structs.vv @@ -1,5 +1,5 @@ -struct C.Something { +pub struct C.Something { fint int ff32 f32 fchar char diff --git a/vlib/v/parser/tests/c_struct_no_embed.out b/vlib/v/parser/tests/c_struct_no_embed.out index 89972cdcd..81d53af6a 100644 --- a/vlib/v/parser/tests/c_struct_no_embed.out +++ b/vlib/v/parser/tests/c_struct_no_embed.out @@ -1,5 +1,5 @@ vlib/v/parser/tests/c_struct_no_embed.vv:7:1: error: expecting type declaration - 5 | struct C.Unknown { + 5 | pub struct C.Unknown { 6 | Foo 7 | } - | ^ \ No newline at end of file + | ^ diff --git a/vlib/v/parser/tests/c_struct_no_embed.vv b/vlib/v/parser/tests/c_struct_no_embed.vv index 020dce752..2b7d67b20 100644 --- a/vlib/v/parser/tests/c_struct_no_embed.vv +++ b/vlib/v/parser/tests/c_struct_no_embed.vv @@ -2,6 +2,6 @@ struct Foo { x int } -struct C.Unknown { +pub struct C.Unknown { Foo } \ No newline at end of file diff --git a/vlib/v/parser/tests/const_index.vv b/vlib/v/parser/tests/const_index.vv index 26b021582..23efb9fdf 100644 --- a/vlib/v/parser/tests/const_index.vv +++ b/vlib/v/parser/tests/const_index.vv @@ -12,7 +12,7 @@ fn h() {} const z = 6 [typedef] -struct C.Foo{} +pub struct C.Foo{} a := [3] _ := a[0] diff --git a/vlib/v/preludes/test_runner.v b/vlib/v/preludes/test_runner.v index 33ec919a1..84f83d765 100644 --- a/vlib/v/preludes/test_runner.v +++ b/vlib/v/preludes/test_runner.v @@ -88,7 +88,7 @@ fn (i &VTestFnMetaInfo) free() { // [typedef] -struct C.main__TestRunner { +pub struct C.main__TestRunner { mut: _object voidptr } diff --git a/vlib/v/tests/aliasing_c_structs/eq_operator_overload_of_c_struct_alias_test.v b/vlib/v/tests/aliasing_c_structs/eq_operator_overload_of_c_struct_alias_test.v index 49f561c07..0dd0d3ded 100644 --- a/vlib/v/tests/aliasing_c_structs/eq_operator_overload_of_c_struct_alias_test.v +++ b/vlib/v/tests/aliasing_c_structs/eq_operator_overload_of_c_struct_alias_test.v @@ -1,11 +1,11 @@ #include "@VMODROOT/cstructs.h" -struct C.__mpz_struct1 { +pub struct C.__mpz_struct1 { x int } [typedef] -struct C.__mpz_struct_typedef { +pub struct C.__mpz_struct_typedef { x int } diff --git a/vlib/v/tests/c_struct_free/c_struct_free_property_test.v b/vlib/v/tests/c_struct_free/c_struct_free_property_test.v index c3981a15c..9a1f4b72a 100644 --- a/vlib/v/tests/c_struct_free/c_struct_free_property_test.v +++ b/vlib/v/tests/c_struct_free/c_struct_free_property_test.v @@ -1,7 +1,7 @@ #flag -I @VEXEROOT/vlib/v/tests/c_struct_free #include "free_struct.c" -struct C.foo { +pub struct C.foo { mut: free int } diff --git a/vlib/v/tests/dump_c_structs/dump_c_struct_test.v b/vlib/v/tests/dump_c_structs/dump_c_struct_test.v index 1ec8d59a8..fbbb36b14 100644 --- a/vlib/v/tests/dump_c_structs/dump_c_struct_test.v +++ b/vlib/v/tests/dump_c_structs/dump_c_struct_test.v @@ -20,7 +20,7 @@ struct Epoll { ev C.epoll_event } -struct C.hostent { +pub struct C.hostent { h_name &char h_aliases &&char h_addrtype int diff --git a/vlib/v/tests/modules/sub/foo.v b/vlib/v/tests/modules/sub/foo.v index 761e48aea..4c80ebe1c 100644 --- a/vlib/v/tests/modules/sub/foo.v +++ b/vlib/v/tests/modules/sub/foo.v @@ -3,7 +3,7 @@ module sub import sub.foo.c [typedef] -struct C.sub_foo { +pub struct C.sub_foo { a int } diff --git a/vlib/v/tests/printing_c_structs/string_interpolation_test.v b/vlib/v/tests/printing_c_structs/string_interpolation_test.v index 69d0712fb..d0c47b8f8 100644 --- a/vlib/v/tests/printing_c_structs/string_interpolation_test.v +++ b/vlib/v/tests/printing_c_structs/string_interpolation_test.v @@ -2,7 +2,7 @@ const the_string = 'the string' -struct C.Abc { +pub struct C.Abc { char_pointer_field &char } diff --git a/vlib/v/tests/project_with_c_code/mod1/wrapper.v b/vlib/v/tests/project_with_c_code/mod1/wrapper.v index e244a55a8..db787d39d 100644 --- a/vlib/v/tests/project_with_c_code/mod1/wrapper.v +++ b/vlib/v/tests/project_with_c_code/mod1/wrapper.v @@ -5,7 +5,7 @@ module mod1 #include "header.h" -struct C.MyStruct { +pub struct C.MyStruct { UppercaseField int } diff --git a/vlib/v/tests/project_with_c_code_2/modc/wrapper.v b/vlib/v/tests/project_with_c_code_2/modc/wrapper.v index 1c8f6b59b..0c2f49ffe 100644 --- a/vlib/v/tests/project_with_c_code_2/modc/wrapper.v +++ b/vlib/v/tests/project_with_c_code_2/modc/wrapper.v @@ -4,7 +4,7 @@ module modc #flag @VMODROOT/modc/impl.o #include "header.h" -struct C.Atype { +pub struct C.Atype { } // Note: [trusted] below, means that the C function, can be safely called outside unsafe{} blocks. diff --git a/vlib/v/tests/struct_test.v b/vlib/v/tests/struct_test.v index 120aba01d..6e0c99368 100644 --- a/vlib/v/tests/struct_test.v +++ b/vlib/v/tests/struct_test.v @@ -224,12 +224,12 @@ fn fooo() { /* [typedef] -struct C.fixed { +pub struct C.fixed { points [10]C.point } [typedef] -struct C.point { +pub struct C.point { x int y int } -- 2.39.5