Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: run vfmt to apply new const format #647

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 42 additions & 39 deletions audio.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ module sdl
pub type AudioFormat = u16

// Audio flags
pub const (
audio_mask_bitsize = C.SDL_AUDIO_MASK_BITSIZE
audio_mask_datatype = C.SDL_AUDIO_MASK_DATATYPE
audio_mask_endian = C.SDL_AUDIO_MASK_ENDIAN
audio_mask_signed = C.SDL_AUDIO_MASK_SIGNED
)
pub const audio_mask_bitsize = C.SDL_AUDIO_MASK_BITSIZE
pub const audio_mask_datatype = C.SDL_AUDIO_MASK_DATATYPE
pub const audio_mask_endian = C.SDL_AUDIO_MASK_ENDIAN
pub const audio_mask_signed = C.SDL_AUDIO_MASK_SIGNED

fn C.SDL_AUDIO_BITSIZE(x int) int
pub fn audio_bitsize(x int) int {
Expand Down Expand Up @@ -74,49 +72,54 @@ pub fn audio_isunsigned(x int) bool {
// Audio format flags
//
// Defaults to LSB byte order.
pub const (
audio_u8 = C.AUDIO_U8 // 0x0008, Unsigned 8-bit samples
audio_s8 = C.AUDIO_S8 // 0x8008, Signed 8-bit samples
audio_u16lsb = C.AUDIO_U16LSB // 0x0010, Unsigned 16-bit samples
audio_s16lsb = C.AUDIO_S16LSB // 0x8010, Signed 16-bit samples
audio_u16msb = C.AUDIO_U16MSB // 0x1010, As above, but big-endian byte order
audio_s16msb = C.AUDIO_S16MSB // 0x9010, As above, but big-endian byte order
audio_u16 = C.AUDIO_U16 // AUDIO_U16LSB
audio_s16 = C.AUDIO_S16 // AUDIO_S16LSB
)
pub const audio_u8 = C.AUDIO_U8 // 0x0008, Unsigned 8-bit samples

pub const audio_s8 = C.AUDIO_S8 // 0x8008, Signed 8-bit samples

pub const audio_u16lsb = C.AUDIO_U16LSB // 0x0010, Unsigned 16-bit samples

pub const audio_s16lsb = C.AUDIO_S16LSB // 0x8010, Signed 16-bit samples

pub const audio_u16msb = C.AUDIO_U16MSB // 0x1010, As above, but big-endian byte order

pub const audio_s16msb = C.AUDIO_S16MSB // 0x9010, As above, but big-endian byte order

pub const audio_u16 = C.AUDIO_U16 // AUDIO_U16LSB

pub const audio_s16 = C.AUDIO_S16 // AUDIO_S16LSB

// int32 support
pub const (
audio_s32lsb = C.AUDIO_S32LSB // 0x8020, 32-bit integer samples
audio_s32msb = C.AUDIO_S32MSB // 0x9020, As above, but big-endian byte order
audio_s32 = C.AUDIO_S32 // AUDIO_S32LSB
)
pub const audio_s32lsb = C.AUDIO_S32LSB // 0x8020, 32-bit integer samples

pub const audio_s32msb = C.AUDIO_S32MSB // 0x9020, As above, but big-endian byte order

pub const audio_s32 = C.AUDIO_S32 // AUDIO_S32LSB

// float32 support
pub const (
audio_f32lsb = C.AUDIO_F32LSB // 0x8120, 32-bit floating point samples
audio_f32msb = C.AUDIO_F32MSB // 0x9120, As above, but big-endian byte order
audio_f32 = C.AUDIO_F32
)
pub const audio_f32lsb = C.AUDIO_F32LSB // 0x8120, 32-bit floating point samples

pub const audio_f32msb = C.AUDIO_F32MSB // 0x9120, As above, but big-endian byte order

pub const audio_f32 = C.AUDIO_F32

// Native audio byte ordering
pub const (
audio_u16sys = C.AUDIO_U16SYS
audio_s16sys = C.AUDIO_S16SYS
audio_s32sys = C.AUDIO_S32SYS
audio_f32sys = C.AUDIO_F32SYS
)
pub const audio_u16sys = C.AUDIO_U16SYS
pub const audio_s16sys = C.AUDIO_S16SYS
pub const audio_s32sys = C.AUDIO_S32SYS
pub const audio_f32sys = C.AUDIO_F32SYS

// Allow change flags
//
// Which audio format changes are allowed when opening a device.
pub const (
audio_allow_frequency_change = C.SDL_AUDIO_ALLOW_FREQUENCY_CHANGE // 0x00000001
audio_allow_format_change = C.SDL_AUDIO_ALLOW_FORMAT_CHANGE // 0x00000002
audio_allow_channels_change = C.SDL_AUDIO_ALLOW_CHANNELS_CHANGE // 0x00000004
sdl_audio_allow_samples_change = C.SDL_AUDIO_ALLOW_SAMPLES_CHANGE // 0x00000008
audio_allow_any_change = C.SDL_AUDIO_ALLOW_ANY_CHANGE
)
pub const audio_allow_frequency_change = C.SDL_AUDIO_ALLOW_FREQUENCY_CHANGE // 0x00000001

pub const audio_allow_format_change = C.SDL_AUDIO_ALLOW_FORMAT_CHANGE // 0x00000002

pub const audio_allow_channels_change = C.SDL_AUDIO_ALLOW_CHANNELS_CHANGE // 0x00000004

pub const sdl_audio_allow_samples_change = C.SDL_AUDIO_ALLOW_SAMPLES_CHANGE // 0x00000008

pub const audio_allow_any_change = C.SDL_AUDIO_ALLOW_ANY_CHANGE

// This function is called when the audio device needs more data.
//
Expand Down
8 changes: 3 additions & 5 deletions endian.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ module sdl
// SDL_endian.h
//

pub const (
lil_endian = C.SDL_LIL_ENDIAN
big_endian = C.SDL_BIG_ENDIAN
byteorder = C.SDL_BYTEORDER
)
pub const lil_endian = C.SDL_LIL_ENDIAN
pub const big_endian = C.SDL_BIG_ENDIAN
pub const byteorder = C.SDL_BYTEORDER

// TODO SDL_endian.h fails on `tcc` with:
// 2.0.18/include/SDL2/SDL_endian.h:125: error: unknown constraint 'Q'
Expand Down
31 changes: 15 additions & 16 deletions events.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@ module sdl
// SDL_events.h
//

pub const (
released = C.SDL_RELEASED // 0
pressed = C.SDL_PRESSED // 1
)

pub const (
textinputevent_text_size = C.SDL_TEXTINPUTEVENT_TEXT_SIZE // (32)
texteditingevent_text_size = C.SDL_TEXTEDITINGEVENT_TEXT_SIZE // (32)
)

pub const (
query = C.SDL_QUERY // -1
ignore = C.SDL_IGNORE // 0
disable = C.SDL_DISABLE // 0
enable = C.SDL_ENABLE // 1
)
pub const released = C.SDL_RELEASED // 0

pub const pressed = C.SDL_PRESSED // 1

pub const textinputevent_text_size = C.SDL_TEXTINPUTEVENT_TEXT_SIZE // (32)

pub const texteditingevent_text_size = C.SDL_TEXTEDITINGEVENT_TEXT_SIZE // (32)

pub const query = C.SDL_QUERY // -1

pub const ignore = C.SDL_IGNORE // 0

pub const disable = C.SDL_DISABLE // 0

pub const enable = C.SDL_ENABLE // 1

// EventFilter is a function pointer used for callbacks that watch the event queue.
//
Expand Down
4 changes: 1 addition & 3 deletions examples/basic_image/basic_image.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import os
import sdl
import sdl.image

const (
images = ['v-logo.svg', 'v-logo.png', 'v-logo.jpg', 'v-logo.lossless.webp', 'v-logo.webp']
)
const images = ['v-logo.svg', 'v-logo.png', 'v-logo.jpg', 'v-logo.lossless.webp', 'v-logo.webp']

fn get_asset_path(path string) string {
$if android {
Expand Down
8 changes: 3 additions & 5 deletions examples/basic_mixer/basic_mixer.v
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ import os
import sdl
import sdl.mixer

const (
wav_sound = 'sounds/sound_01.wav'
sounds = ['sounds/sound_02.mp3', 'sounds/sound_03.flac', 'sounds/sound_04.ogg',
'sounds/TwintrisThosenine.mod', 'sounds/IcyGarden.mid']
)
const wav_sound = 'sounds/sound_01.wav'
const sounds = ['sounds/sound_02.mp3', 'sounds/sound_03.flac', 'sounds/sound_04.ogg',
'sounds/TwintrisThosenine.mod', 'sounds/IcyGarden.mid']

struct PlayCycle {
pub mut:
Expand Down
Loading