mirror of
https://github.com/vlang/v.git
synced 2025-09-08 14:51:53 -04:00
vlib: fix C warnings/errors for v -show-c-output -cstrict -cc clang-18 run examples/gg/additive.v
This commit is contained in:
parent
4b0a35a0c1
commit
f676daceb5
@ -1,7 +1,7 @@
|
||||
module builtin
|
||||
|
||||
// vstrlen returns the V length of the C string `s` (0 terminator is not counted).
|
||||
// The C string is expected to be a &byte pointer.
|
||||
// The C string is expected to be a &u8 pointer.
|
||||
@[inline; unsafe]
|
||||
pub fn vstrlen(s &u8) int {
|
||||
return unsafe { C.strlen(&char(s)) }
|
||||
|
@ -82,17 +82,17 @@ pub fn (s string) runes() []rune {
|
||||
// -autofree and `@[manualfree]`.
|
||||
// It will panic, if the pointer `s` is 0.
|
||||
@[unsafe]
|
||||
pub fn cstring_to_vstring(s &char) string {
|
||||
return unsafe { tos2(&u8(s)) }.clone()
|
||||
pub fn cstring_to_vstring(const_s &char) string {
|
||||
return unsafe { tos2(&u8(const_s)) }.clone()
|
||||
}
|
||||
|
||||
// tos_clone creates a new V string copy of the C style string, pointed by `s`.
|
||||
// See also cstring_to_vstring (it is the same as it, the only difference is,
|
||||
// that tos_clone expects `&byte`, while cstring_to_vstring expects &char).
|
||||
// that tos_clone expects `&u8`, while cstring_to_vstring expects &char).
|
||||
// It will panic, if the pointer `s` is 0.
|
||||
@[unsafe]
|
||||
pub fn tos_clone(s &u8) string {
|
||||
return unsafe { tos2(s) }.clone()
|
||||
pub fn tos_clone(const_s &u8) string {
|
||||
return unsafe { tos2(&u8(const_s)) }.clone()
|
||||
}
|
||||
|
||||
// tos creates a V string, given a C style pointer to a 0 terminated block.
|
||||
@ -114,7 +114,7 @@ pub fn tos(s &u8, len int) string {
|
||||
// Note: the memory block pointed by s is *reused, not copied*!
|
||||
// It will calculate the length first, thus it is more costly than `tos`.
|
||||
// It will panic, when the pointer `s` is 0.
|
||||
// It is the same as `tos3`, but for &byte pointers, avoiding callsite casts.
|
||||
// It is the same as `tos3`, but for &u8 pointers, avoiding callsite casts.
|
||||
// See also `tos_clone`.
|
||||
@[unsafe]
|
||||
pub fn tos2(s &u8) string {
|
||||
@ -148,7 +148,7 @@ pub fn tos3(s &char) string {
|
||||
// Note: the memory block pointed by s is *reused, not copied*!
|
||||
// It will calculate the length first, so it is more costly than tos.
|
||||
// It returns '', when given a 0 pointer `s`, it does NOT panic.
|
||||
// It is the same as `tos5`, but for &byte pointers, avoiding callsite casts.
|
||||
// It is the same as `tos5`, but for &u8 pointers, avoiding callsite casts.
|
||||
// See also `tos_clone`.
|
||||
@[unsafe]
|
||||
pub fn tos4(s &u8) string {
|
||||
|
@ -752,7 +752,7 @@ pub fn window_size() Size {
|
||||
|
||||
// set_window_title sets main window's title
|
||||
pub fn set_window_title(title string) {
|
||||
C.sapp_set_window_title(title.str)
|
||||
C.sapp_set_window_title(&char(title.str))
|
||||
}
|
||||
|
||||
// window_size_real_pixels returns the `Size` of the active window without scale
|
||||
|
@ -92,7 +92,7 @@ pub fn (mut img Image) init_sokol_image() &Image {
|
||||
num_mipmaps: 0
|
||||
// wrap_u: .clamp_to_edge // XTODO SAMPLER
|
||||
// wrap_v: .clamp_to_edge
|
||||
label: img.path.str
|
||||
label: &char(img.path.str)
|
||||
d3d11_texture: 0
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ pub fn (mut ctx Context) new_streaming_image(w int, h int, channels int, sicfg S
|
||||
num_slices: 1
|
||||
num_mipmaps: 1
|
||||
usage: .stream
|
||||
label: img.path.str
|
||||
label: &char(img.path.str)
|
||||
}
|
||||
// Sokol requires that streamed images have NO .ptr/.size initially:
|
||||
img_desc.data.subimage[0][0] = gfx.Range{
|
||||
|
@ -211,7 +211,7 @@ pub fn frame_duration() f64 {
|
||||
// write string into clipboard
|
||||
@[inline]
|
||||
pub fn set_clipboard_string(str &u8) {
|
||||
C.sapp_set_clipboard_string(str)
|
||||
C.sapp_set_clipboard_string(&char(str))
|
||||
}
|
||||
|
||||
// read string from clipboard (usually during SAPP_EVENTTYPE_CLIPBOARD_PASTED)
|
||||
@ -252,17 +252,17 @@ pub fn metal_get_device() voidptr {
|
||||
|
||||
// Metal: get ARC-bridged pointer to current drawable
|
||||
pub fn metal_get_current_drawable() voidptr {
|
||||
return C.sapp_metal_get_current_drawable()
|
||||
return voidptr(C.sapp_metal_get_current_drawable())
|
||||
}
|
||||
|
||||
// Metal: get bridged pointer to MTKView's depth-stencil texture of type MTLTexture
|
||||
pub fn metal_get_depth_stencil_texture() voidptr {
|
||||
return C.sapp_metal_get_depth_stencil_texture()
|
||||
return voidptr(C.sapp_metal_get_depth_stencil_texture())
|
||||
}
|
||||
|
||||
// Metal: get bridged pointer to MTKView's msaa-color-texture of type MTLTexture (may be null)
|
||||
pub fn metal_get_msaa_color_texture() voidptr {
|
||||
return C.sapp_metal_get_msaa_color_texture()
|
||||
return voidptr(C.sapp_metal_get_msaa_color_texture())
|
||||
}
|
||||
|
||||
// macOS: get ARC-bridged pointer to macOS NSWindow
|
||||
@ -298,7 +298,7 @@ pub fn d3d11_get_render_view() voidptr {
|
||||
// D3D11: get pointer ID3D11RenderTargetView object for msaa-resolve (may return null)
|
||||
@[inline]
|
||||
pub fn d3d11_get_resolve_view() voidptr {
|
||||
return C.sapp_d3d11_get_resolve_view()
|
||||
return voidptr(C.sapp_d3d11_get_resolve_view())
|
||||
}
|
||||
|
||||
// D3D11: get pointer to ID3D11DepthStencilView
|
||||
@ -315,22 +315,22 @@ pub fn win32_get_hwnd() voidptr {
|
||||
|
||||
// WebGPU: get WGPUDevice handle
|
||||
pub fn wgpu_get_device() voidptr {
|
||||
return C.sapp_wgpu_get_device()
|
||||
return voidptr(C.sapp_wgpu_get_device())
|
||||
}
|
||||
|
||||
// WebGPU: get swapchain's WGPUTextureView handle for rendering
|
||||
pub fn wgpu_get_render_view() voidptr {
|
||||
return C.sapp_wgpu_get_render_view()
|
||||
return voidptr(C.sapp_wgpu_get_render_view())
|
||||
}
|
||||
|
||||
// WebGPU: get swapchain's MSAA-resolve WGPUTextureView (may return null)
|
||||
pub fn wgpu_get_resolve_view() voidptr {
|
||||
return C.sapp_wgpu_get_resolve_view()
|
||||
return voidptr(C.sapp_wgpu_get_resolve_view())
|
||||
}
|
||||
|
||||
// WebGPU: get swapchain's WGPUTextureView for the depth-stencil surface
|
||||
pub fn wgpu_get_depth_stencil_view() voidptr {
|
||||
return C.sapp_wgpu_get_depth_stencil_view()
|
||||
return voidptr(C.sapp_wgpu_get_depth_stencil_view())
|
||||
}
|
||||
|
||||
// GL: get framebuffer object
|
||||
|
@ -78,10 +78,10 @@ fn C.sapp_frame_count() u64
|
||||
fn C.sapp_frame_duration() f64
|
||||
|
||||
// write string into clipboard
|
||||
fn C.sapp_set_clipboard_string(str &u8)
|
||||
fn C.sapp_set_clipboard_string(const_str &char)
|
||||
|
||||
// read string from clipboard (usually during SAPP_EVENTTYPE_CLIPBOARD_PASTED)
|
||||
fn C.sapp_get_clipboard_string() &u8
|
||||
fn C.sapp_get_clipboard_string() &char
|
||||
|
||||
// set the window title (only on desktop platforms)
|
||||
fn C.sapp_set_window_title(&char)
|
||||
@ -93,7 +93,7 @@ fn C.sapp_set_window_title(&char)
|
||||
fn C.sapp_get_num_dropped_files() int
|
||||
|
||||
// Get the file path of the dropped file
|
||||
fn C.sapp_get_dropped_file_path(int) &u8
|
||||
fn C.sapp_get_dropped_file_path(int) &char
|
||||
|
||||
// special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub)
|
||||
fn C.sapp_run(desc &Desc) int
|
||||
|
Loading…
x
Reference in New Issue
Block a user