Improve code by implicit integer coercion for literals and const vals
This commit is contained in:
committed by
SvyatoslavScherbina
parent
2c12dcd612
commit
2b8612632e
@@ -58,10 +58,10 @@ fun test(s: S, x1: Long, x2: B2, x3: UShort, x4: UInt, x5: Int, x6: Long) {
|
||||
|
||||
// Also check with some insignificant bits modified:
|
||||
|
||||
assign(s, x1 + 2, x2, (x3 + 8u).toUShort(), x4 - 16u, x5 + 32, x6 + Long.MIN_VALUE)
|
||||
assign(s, x1 + 2, x2, (x3 + 8).toUShort(), x4 - 16, x5 + 32, x6 + Long.MIN_VALUE)
|
||||
check(s, x1, x2, x3, x4, x5, x6)
|
||||
|
||||
assignReversed(s, x1 + 2, x2, (x3 + 8u).toUShort(), x4 - 16u, x5 + 32, x6 + Long.MIN_VALUE)
|
||||
assignReversed(s, x1 + 2, x2, (x3 + 8).toUShort(), x4 - 16, x5 + 32, x6 + Long.MIN_VALUE)
|
||||
check(s, x1, x2, x3, x4, x5, x6)
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ fun main(args: Array<String>) {
|
||||
for (x1 in -1L..0L)
|
||||
for (x2 in B2.values())
|
||||
for (x3 in 0..7)
|
||||
for (x4 in uintArrayOf(0u, 6u, 15u))
|
||||
for (x4 in uintArrayOf(0, 6, 15))
|
||||
for (x5 in intArrayOf(-16, -2, -1, 0, 5, 15))
|
||||
for (x6 in longArrayOf(Long.MIN_VALUE/2, -1L shl 36, -325L, 0, 1L shl 48, Long.MAX_VALUE/2))
|
||||
test(s, x1, x2, x3.toUShort(), x4, x5, x6)
|
||||
|
||||
@@ -26,7 +26,7 @@ fun main(args: Array<String>) {
|
||||
with(serverAddr) {
|
||||
memset(this.ptr, 0, sockaddr_in.size.convert())
|
||||
sin_family = AF_INET.convert()
|
||||
sin_addr.s_addr = htons(0u).convert()
|
||||
sin_addr.s_addr = htons(0).convert()
|
||||
sin_port = htons(port)
|
||||
}
|
||||
|
||||
|
||||
@@ -45,13 +45,13 @@ fun display() {
|
||||
|
||||
fun initialize() {
|
||||
// select projection matrix
|
||||
glMatrixMode(GL_PROJECTION.convert())
|
||||
glMatrixMode(GL_PROJECTION)
|
||||
|
||||
// set the viewport
|
||||
glViewport(0, 0, windowWidth, windowHeight)
|
||||
|
||||
// set matrix mode
|
||||
glMatrixMode(GL_PROJECTION.convert())
|
||||
glMatrixMode(GL_PROJECTION)
|
||||
|
||||
// reset projection matrix
|
||||
glLoadIdentity()
|
||||
@@ -61,29 +61,29 @@ fun initialize() {
|
||||
gluPerspective(45.0, aspect, 1.0, 500.0)
|
||||
|
||||
// specify which matrix is the current matrix
|
||||
glMatrixMode(GL_MODELVIEW.convert())
|
||||
glShadeModel(GL_SMOOTH.convert())
|
||||
glMatrixMode(GL_MODELVIEW)
|
||||
glShadeModel(GL_SMOOTH)
|
||||
|
||||
// specify the clear value for the depth buffer
|
||||
glClearDepth(1.0)
|
||||
glEnable(GL_DEPTH_TEST.convert())
|
||||
glDepthFunc(GL_LEQUAL.convert())
|
||||
glEnable(GL_DEPTH_TEST)
|
||||
glDepthFunc(GL_LEQUAL)
|
||||
|
||||
// specify implementation-specific hints
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT.convert(), GL_NICEST.convert())
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
|
||||
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT.convert(), cValuesOf(0.1f, 0.1f, 0.1f, 1.0f))
|
||||
glLightfv(GL_LIGHT0.convert(), GL_DIFFUSE.convert(), cValuesOf(0.6f, 0.6f, 0.6f, 1.0f))
|
||||
glLightfv(GL_LIGHT0.convert(), GL_SPECULAR.convert(), cValuesOf(0.7f, 0.7f, 0.3f, 1.0f))
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, cValuesOf(0.1f, 0.1f, 0.1f, 1.0f))
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, cValuesOf(0.6f, 0.6f, 0.6f, 1.0f))
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, cValuesOf(0.7f, 0.7f, 0.3f, 1.0f))
|
||||
|
||||
glEnable(GL_LIGHT0.convert())
|
||||
glEnable(GL_COLOR_MATERIAL.convert())
|
||||
glShadeModel(GL_SMOOTH.convert())
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE.convert(), GL_FALSE)
|
||||
glDepthFunc(GL_LEQUAL.convert())
|
||||
glEnable(GL_DEPTH_TEST.convert())
|
||||
glEnable(GL_LIGHTING.convert())
|
||||
glEnable(GL_LIGHT0.convert())
|
||||
glEnable(GL_LIGHT0)
|
||||
glEnable(GL_COLOR_MATERIAL)
|
||||
glShadeModel(GL_SMOOTH)
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE)
|
||||
glDepthFunc(GL_LEQUAL)
|
||||
glEnable(GL_DEPTH_TEST)
|
||||
glEnable(GL_LIGHTING)
|
||||
glEnable(GL_LIGHT0)
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f)
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ private class Controller : NSObject() {
|
||||
fun onClick() {
|
||||
// Execute some async action on button click.
|
||||
dispatch_async_f(asyncQueue, DetachedObjectGraph {
|
||||
Data(clock_gettime_nsec_np(CLOCK_REALTIME.convert()))
|
||||
Data(clock_gettime_nsec_np(CLOCK_REALTIME))
|
||||
}.asCPointer(), staticCFunction {
|
||||
it ->
|
||||
initRuntimeIfNeeded()
|
||||
|
||||
@@ -56,13 +56,13 @@ fun display() {
|
||||
|
||||
fun initialize() {
|
||||
// select projection matrix
|
||||
glMatrixMode(GL_PROJECTION.convert())
|
||||
glMatrixMode(GL_PROJECTION)
|
||||
|
||||
// set the viewport
|
||||
glViewport(0, 0, windowWidth, windowHeight)
|
||||
|
||||
// set matrix mode
|
||||
glMatrixMode(GL_PROJECTION.convert())
|
||||
glMatrixMode(GL_PROJECTION)
|
||||
|
||||
// reset projection matrix
|
||||
glLoadIdentity()
|
||||
@@ -72,29 +72,29 @@ fun initialize() {
|
||||
gluPerspective(45.0, aspect, 1.0, 500.0)
|
||||
|
||||
// specify which matrix is the current matrix
|
||||
glMatrixMode(GL_MODELVIEW.convert())
|
||||
glShadeModel(GL_SMOOTH.convert())
|
||||
glMatrixMode(GL_MODELVIEW)
|
||||
glShadeModel(GL_SMOOTH)
|
||||
|
||||
// specify the clear value for the depth buffer
|
||||
glClearDepth(1.0)
|
||||
glEnable(GL_DEPTH_TEST.convert())
|
||||
glDepthFunc(GL_LEQUAL.convert())
|
||||
glEnable(GL_DEPTH_TEST)
|
||||
glDepthFunc(GL_LEQUAL)
|
||||
|
||||
// specify implementation-specific hints
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT.convert(), GL_NICEST.convert())
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
|
||||
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT.convert(), cValuesOf(0.1f, 0.1f, 0.1f, 1.0f))
|
||||
glLightfv(GL_LIGHT0.convert(), GL_DIFFUSE.convert(), cValuesOf(0.6f, 0.6f, 0.6f, 1.0f))
|
||||
glLightfv(GL_LIGHT0.convert(), GL_SPECULAR.convert(), cValuesOf(0.7f, 0.7f, 0.3f, 1.0f))
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, cValuesOf(0.1f, 0.1f, 0.1f, 1.0f))
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, cValuesOf(0.6f, 0.6f, 0.6f, 1.0f))
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, cValuesOf(0.7f, 0.7f, 0.3f, 1.0f))
|
||||
|
||||
glEnable(GL_LIGHT0.convert())
|
||||
glEnable(GL_COLOR_MATERIAL.convert())
|
||||
glShadeModel(GL_SMOOTH.convert())
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE.convert(), GL_FALSE)
|
||||
glDepthFunc(GL_LEQUAL.convert())
|
||||
glEnable(GL_DEPTH_TEST.convert())
|
||||
glEnable(GL_LIGHTING.convert())
|
||||
glEnable(GL_LIGHT0.convert())
|
||||
glEnable(GL_LIGHT0)
|
||||
glEnable(GL_COLOR_MATERIAL)
|
||||
glShadeModel(GL_SMOOTH)
|
||||
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE)
|
||||
glDepthFunc(GL_LEQUAL)
|
||||
glEnable(GL_DEPTH_TEST)
|
||||
glEnable(GL_LIGHTING)
|
||||
glEnable(GL_LIGHT0)
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f)
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ private class VideoDecoder(
|
||||
dispose = ::sws_freeContext
|
||||
)
|
||||
private val scaledFrameSize = avpicture_get_size(avPixelFormat, windowSize.w, windowSize.h)
|
||||
private val buffer: UByteArray = UByteArray(scaledFrameSize) { 0u }
|
||||
private val buffer: UByteArray = UByteArray(scaledFrameSize)
|
||||
|
||||
private val videoQueue = Queue<VideoFrame>(100)
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class SDLRendererWindow(windowPos: Dimensions, videoSize: Dimensions) : Disposab
|
||||
SDL_CreateTexture(renderer, SDL_GetWindowPixelFormat(window), 0, videoSize.w, videoSize.h),
|
||||
::SDL_DestroyTexture)
|
||||
private val rect = sdlDisposable("calloc(SDL_Rect)",
|
||||
SDL_calloc(1u, SDL_Rect.size.convert()), ::SDL_free)
|
||||
SDL_calloc(1, SDL_Rect.size.convert()), ::SDL_free)
|
||||
.reinterpret<SDL_Rect>()
|
||||
|
||||
init {
|
||||
|
||||
@@ -71,7 +71,7 @@ class VideoPlayer(val requestedSize: Dimensions?) : DisposableContainer() {
|
||||
}
|
||||
|
||||
private fun getTime(): Double {
|
||||
clock_gettime(platform.posix.CLOCK_MONOTONIC.convert(), now)
|
||||
clock_gettime(platform.posix.CLOCK_MONOTONIC, now)
|
||||
return now.pointed.tv_sec + now.pointed.tv_nsec / 1e9
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ class VideoPlayer(val requestedSize: Dimensions?) : DisposableContainer() {
|
||||
while (state == State.PAUSED) {
|
||||
audio.pause()
|
||||
input.check()
|
||||
usleep(1u * 1000u)
|
||||
usleep(1 * 1000)
|
||||
}
|
||||
audio.resume()
|
||||
}
|
||||
@@ -152,14 +152,14 @@ class VideoPlayer(val requestedSize: Dimensions?) : DisposableContainer() {
|
||||
if (!decoder.audioVideoSynced()) {
|
||||
println("Resynchronizing video with audio")
|
||||
while (!decoder.audioVideoSynced() && state == State.PLAYING) {
|
||||
usleep(500u)
|
||||
usleep(500)
|
||||
input.check()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// For pure sound, playback is driven by demand.
|
||||
usleep(10u * 1000u)
|
||||
usleep(10 * 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user