Skip to content

Commit

Permalink
all: fix `warning: unknown type C.XYZ (all virtual C types must be de…
Browse files Browse the repository at this point in the history
…fined, ...)` (vlang#606)
  • Loading branch information
larpon authored Oct 17, 2023
1 parent 20fde67 commit cc8776b
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 37 deletions.
5 changes: 5 additions & 0 deletions a_types.c.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module sdl

// va_list
[typedef]
pub struct C.va_list {}
8 changes: 4 additions & 4 deletions audio.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ pub fn open_audio_device(const_device &char, iscapture int, const_desired &Audio
allowed_changes))
}

fn C.SDL_OpenAudioDevice(const_device &char, iscapture int, const_desired &C.SDL_AudioSpec, obtained &C.SDL_AudioSpec, allowed_changes int) C.SDL_AudioDeviceID
fn C.SDL_OpenAudioDevice(const_device &char, iscapture int, const_desired &C.SDL_AudioSpec, obtained &C.SDL_AudioSpec, allowed_changes int) AudioDeviceID

// AudioStatus
//
Expand All @@ -394,13 +394,13 @@ pub fn get_audio_status() AudioStatus {
return AudioStatus(C.SDL_GetAudioStatus())
}

fn C.SDL_GetAudioStatus() C.SDL_AudioStatus
fn C.SDL_GetAudioStatus() AudioStatus

pub fn get_audio_device_status(dev AudioDeviceID) AudioStatus {
return AudioStatus(C.SDL_GetAudioDeviceStatus(C.SDL_AudioDeviceID(dev)))
return AudioStatus(C.SDL_GetAudioDeviceStatus(dev))
}

fn C.SDL_GetAudioDeviceStatus(dev C.SDL_AudioDeviceID) C.SDL_AudioStatus
fn C.SDL_GetAudioDeviceStatus(dev AudioDeviceID) AudioStatus

// Pause audio functions
//
Expand Down
2 changes: 1 addition & 1 deletion blendmode.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub enum BlendFactor {
one_minus_dst_alpha = C.SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA // 0xA, 1-dstA, 1-dstA, 1-dstA, 1-dstA
}

fn C.SDL_ComposeCustomBlendMode(src_color_factor C.SDL_BlendFactor, dst_color_factor C.SDL_BlendFactor, color_operation C.SDL_BlendOperation, src_alpha_factor C.SDL_BlendFactor, dst_alpha_factor C.SDL_BlendFactor, alpha_operation C.SDL_BlendOperation) C.SDL_BlendMode
fn C.SDL_ComposeCustomBlendMode(src_color_factor C.SDL_BlendFactor, dst_color_factor C.SDL_BlendFactor, color_operation C.SDL_BlendOperation, src_alpha_factor C.SDL_BlendFactor, dst_alpha_factor C.SDL_BlendFactor, alpha_operation C.SDL_BlendOperation) BlendMode

// compose_custom_blend_mode creates a custom blend mode, which may
// or may not be supported by a given renderer
Expand Down
4 changes: 2 additions & 2 deletions gamecontroller.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pub enum GameControllerAxis {
max = C.SDL_CONTROLLER_AXIS_MAX
}

fn C.SDL_GameControllerGetAxisFromString(pch_string &char) C.SDL_GameControllerAxis
fn C.SDL_GameControllerGetAxisFromString(pch_string &char) GameControllerAxis

// game_controller_get_axis_from_string turns the string into an axis mapping
pub fn game_controller_get_axis_from_string(pch_string &char) GameControllerAxis {
Expand Down Expand Up @@ -324,7 +324,7 @@ pub enum GameControllerButton {
max = C.SDL_CONTROLLER_BUTTON_MAX
}

fn C.SDL_GameControllerGetButtonFromString(pch_string &char) C.SDL_GameControllerButton
fn C.SDL_GameControllerGetButtonFromString(pch_string &char) GameControllerButton

// game_controller_get_button_from_string turns the string into a button mapping
pub fn game_controller_get_button_from_string(pch_string &char) GameControllerButton {
Expand Down
16 changes: 8 additions & 8 deletions joystick.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ pub enum JoystickType {
throttle
}

// C.SDL_JoystickID // Sint32 / int
pub type JoystickID = int
// C.SDL_JoystickID // Sint32
pub type JoystickID = i32

// JoystickPowerLevel is C.SDL_JoystickPowerLevel
pub enum JoystickPowerLevel {
Expand Down Expand Up @@ -138,15 +138,15 @@ pub fn joystick_get_device_product_version(device_index int) u16 {
return C.SDL_JoystickGetDeviceProductVersion(device_index)
}

fn C.SDL_JoystickGetDeviceType(device_index int) C.SDL_JoystickType
fn C.SDL_JoystickGetDeviceType(device_index int) JoystickType

// joystick_get_device_type gets the type of a joystick, if available.
// This can be called before any joysticks are opened.
pub fn joystick_get_device_type(device_index int) JoystickType {
return unsafe { JoystickType(int(C.SDL_JoystickGetDeviceType(device_index))) }
}

fn C.SDL_JoystickGetDeviceInstanceID(device_index int) C.SDL_JoystickID
fn C.SDL_JoystickGetDeviceInstanceID(device_index int) JoystickID

// joystick_get_device_instance_id gets the instance ID of a joystick.
// This can be called before any joysticks are opened.
Expand Down Expand Up @@ -214,7 +214,7 @@ pub fn joystick_get_product_version(joystick &Joystick) u16 {
return C.SDL_JoystickGetProductVersion(joystick)
}

fn C.SDL_JoystickGetType(joystick &C.SDL_Joystick) C.SDL_JoystickType
fn C.SDL_JoystickGetType(joystick &C.SDL_Joystick) JoystickType

// joystick_get_type gets the type of an opened joystick.
pub fn joystick_get_type(joystick &Joystick) JoystickType {
Expand Down Expand Up @@ -243,10 +243,10 @@ pub fn joystick_get_attached(joystick &Joystick) bool {
return C.SDL_JoystickGetAttached(joystick)
}

fn C.SDL_JoystickInstanceID(joystick &C.SDL_Joystick) C.SDL_JoystickID
fn C.SDL_JoystickInstanceID(joystick &C.SDL_Joystick) JoystickID

// joystick_instance_id gets the instance ID of an opened joystick or -1 if the joystick is invalid.
pub fn joystick_instance_id(joystick &Joystick) C.SDL_JoystickID {
pub fn joystick_instance_id(joystick &Joystick) JoystickID {
return C.SDL_JoystickInstanceID(joystick)
}

Expand Down Expand Up @@ -375,7 +375,7 @@ pub fn joystick_close(joystick &Joystick) {
C.SDL_JoystickClose(joystick)
}

fn C.SDL_JoystickCurrentPowerLevel(joystick &C.SDL_Joystick) C.SDL_JoystickPowerLevel
fn C.SDL_JoystickCurrentPowerLevel(joystick &C.SDL_Joystick) JoystickPowerLevel

// joystick_current_power_level returns the battery level of this joystick
pub fn joystick_current_power_level(joystick &Joystick) JoystickPowerLevel {
Expand Down
10 changes: 5 additions & 5 deletions keyboard.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn get_keyboard_state(numkeys &int) &u8 {
return C.SDL_GetKeyboardState(numkeys)
}

fn C.SDL_GetModState() C.SDL_Keymod
fn C.SDL_GetModState() Keymod

// get_mod_state gets the current key modifier state for the keyboard.
pub fn get_mod_state() Keymod {
Expand All @@ -66,7 +66,7 @@ pub fn set_mod_state(modstate Keymod) {
C.SDL_SetModState(C.SDL_Keymod(modstate))
}

fn C.SDL_GetKeyFromScancode(scancode C.SDL_Scancode) C.SDL_Keycode
fn C.SDL_GetKeyFromScancode(scancode C.SDL_Scancode) Keycode

// get_key_from_scancode gets the key code corresponding to the given scancode according
// to the current keyboard layout.
Expand All @@ -78,7 +78,7 @@ pub fn get_key_from_scancode(scancode Scancode) Keycode {
return Keycode(int(C.SDL_GetKeyFromScancode(C.SDL_Scancode(scancode))))
}

fn C.SDL_GetScancodeFromKey(key C.SDL_Keycode) C.SDL_Scancode
fn C.SDL_GetScancodeFromKey(key C.SDL_Keycode) Scancode

// get_scancode_from_key gets the scancode corresponding to the given key code according to the
// current keyboard layout.
Expand All @@ -103,7 +103,7 @@ pub fn get_scancode_name(scancode Scancode) &char {
return C.SDL_GetScancodeName(C.SDL_Scancode(scancode))
}

fn C.SDL_GetScancodeFromName(name &char) C.SDL_Scancode
fn C.SDL_GetScancodeFromName(name &char) Scancode

// get_scancode_from_name gets a scancode from a human-readable name
//
Expand All @@ -128,7 +128,7 @@ pub fn get_key_name(key Keycode) &char {
return C.SDL_GetKeyName(C.SDL_Keycode(key))
}

fn C.SDL_GetKeyFromName(name &char) C.SDL_Keycode
fn C.SDL_GetKeyFromName(name &char) Keycode

// get_key_from_name gets a key code from a human-readable name
//
Expand Down
2 changes: 1 addition & 1 deletion log.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn log_set_priority(category int, priority LogPriority) {
C.SDL_LogSetPriority(category, C.SDL_LogPriority(int(priority)))
}

fn C.SDL_LogGetPriority(category int) C.SDL_LogPriority
fn C.SDL_LogGetPriority(category int) LogPriority

// log_get_priority gets the priority of a particular log category
pub fn log_get_priority(category int) LogPriority {
Expand Down
6 changes: 3 additions & 3 deletions mixer/mixer.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pub fn has_music_decoder(name &char) bool {
}
*/

fn C.Mix_GetMusicType(music &C.Mix_Music) C.Mix_MusicType
fn C.Mix_GetMusicType(music &C.Mix_Music) MusicType

// get_music_type finds out the music format of a mixer music, or the currently playing
// music, if 'music' is NULL.
Expand Down Expand Up @@ -747,14 +747,14 @@ pub fn fade_out_music(ms int) int {
return C.Mix_FadeOutMusic(ms)
}

fn C.Mix_FadingMusic() C.Mix_Fading
fn C.Mix_FadingMusic() Fading

// fading_music queries the fading status of a channel
pub fn fading_music() Fading {
return Fading(C.Mix_FadingMusic())
}

fn C.Mix_FadingChannel(which int) C.Mix_Fading
fn C.Mix_FadingChannel(which int) Fading
pub fn fading_channel(which int) Fading {
return Fading(C.Mix_FadingChannel(which))
}
Expand Down
2 changes: 1 addition & 1 deletion power.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub enum PowerState {
charged = C.SDL_POWERSTATE_CHARGED // Plugged in, battery charged
}

fn C.SDL_GetPowerInfo(secs &int, pct &int) C.SDL_PowerState
fn C.SDL_GetPowerInfo(secs &int, pct &int) PowerState

// get_power_info gets the current power supply details.
//
Expand Down
8 changes: 4 additions & 4 deletions stdinc.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ pub fn ultoa(value u32, str &char, radix int) &char {
return C.SDL_ultoa(value, str, radix)
}

fn C.SDL_lltoa(value C.Sint64, str &char, radix int) &char
pub fn lltoa(value C.Sint64, str &char, radix int) &char {
fn C.SDL_lltoa(value i64, str &char, radix int) &char
pub fn lltoa(value i64, str &char, radix int) &char {
return C.SDL_lltoa(value, str, radix)
}

Expand Down Expand Up @@ -340,8 +340,8 @@ pub fn strtoul(str &char, endp &&char, base int) u32 {
return C.SDL_strtoul(str, endp, base)
}

fn C.SDL_strtoll(str &char, endp &&char, base int) C.Sint64
pub fn strtoll(str &char, endp &&char, base int) C.Sint64 {
fn C.SDL_strtoll(str &char, endp &&char, base int) i64
pub fn strtoll(str &char, endp &&char, base int) i64 {
return C.SDL_strtoll(str, endp, base)
}

Expand Down
4 changes: 2 additions & 2 deletions surface.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,14 @@ pub fn set_yuv_conversion_mode(mode YUVConversionMode) {
C.SDL_SetYUVConversionMode(C.SDL_YUV_CONVERSION_MODE(int(mode)))
}

fn C.SDL_GetYUVConversionMode() C.SDL_YUV_CONVERSION_MODE
fn C.SDL_GetYUVConversionMode() YUVConversionMode

// get_yuv_conversion_mode gets the YUV conversion mode
pub fn get_yuv_conversion_mode() YUVConversionMode {
return unsafe { YUVConversionMode(int(C.SDL_GetYUVConversionMode())) }
}

fn C.SDL_GetYUVConversionModeForResolution(width int, height int) C.SDL_YUV_CONVERSION_MODE
fn C.SDL_GetYUVConversionModeForResolution(width int, height int) YUVConversionMode

// get_yuv_conversion_mode_for_resolution gets the YUV conversion mode, returning the correct mode for the resolution when
// the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC
Expand Down
6 changes: 3 additions & 3 deletions thread.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ pub fn get_thread_name(pthread &Thread) &char {
return C.SDL_GetThreadName(pthread)
}

fn C.SDL_ThreadID() C.SDL_threadID
fn C.SDL_ThreadID() ThreadID

// thread_id gets the thread identifier for the current thread.
pub fn thread_id() ThreadID {
return ThreadID(u32(C.SDL_ThreadID()))
}

fn C.SDL_GetThreadID(thrd &C.SDL_Thread) C.SDL_threadID
fn C.SDL_GetThreadID(thrd &C.SDL_Thread) ThreadID

// get_thread_id gets the thread identifier for the specified thread.
//
Expand Down Expand Up @@ -164,7 +164,7 @@ pub fn detach_thread(thrd &Thread) {
C.SDL_DetachThread(thrd)
}

fn C.SDL_TLSCreate() C.SDL_TLSID
fn C.SDL_TLSCreate() TLSID

// tls_create create an identifier that is globally visible to all threads but refers to data that is thread-specific.
//
Expand Down
2 changes: 1 addition & 1 deletion timer.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn delay(ms u32) {
C.SDL_Delay(ms)
}

fn C.SDL_AddTimer(interval u32, callback C.SDL_TimerCallback, param voidptr) C.SDL_TimerID
fn C.SDL_AddTimer(interval u32, callback C.SDL_TimerCallback, param voidptr) TimerID

// add_timer adds a new timer to the pool of timers already running.
//
Expand Down
4 changes: 2 additions & 2 deletions video.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ pub fn gl_get_attribute(attr GLattr, value &int) int {
return C.SDL_GL_GetAttribute(C.SDL_GLattr(int(attr)), value)
}

fn C.SDL_GL_CreateContext(window &C.SDL_Window) C.SDL_GLContext
fn C.SDL_GL_CreateContext(window &C.SDL_Window) GLContext

// gl_create_context creates an OpenGL context for use with an OpenGL window, and make it
// current.
Expand All @@ -1259,7 +1259,7 @@ pub fn gl_get_current_window() &Window {
return C.SDL_GL_GetCurrentWindow()
}

fn C.SDL_GL_GetCurrentContext() C.SDL_GLContext
fn C.SDL_GL_GetCurrentContext() GLContext

// gl_get_current_context gets the currently active OpenGL context.
pub fn gl_get_current_context() GLContext {
Expand Down

0 comments on commit cc8776b

Please sign in to comment.