Review fixes

This commit is contained in:
Igor Chevdar
2017-03-20 19:00:37 +03:00
parent 02878f14c0
commit 1be913de63
5 changed files with 41 additions and 32 deletions
@@ -91,7 +91,7 @@ internal class NativeIndexImpl(val language: Language) : NativeIndex() {
}
}
if (underlying !is ConstArrayType) return underlying
assert (underlying is ConstArrayType)
// So the result must feel like array:
return ConstArrayType(RecordType(structDeclaration), 1)
}
@@ -102,7 +102,7 @@ internal class NativeIndexImpl(val language: Language) : NativeIndex() {
val underlying = convertType(clang_getTypedefDeclUnderlyingType(declCursor))
if (name == "__builtin_va_list") {
if (name == "__builtin_va_list" && underlying is ConstArrayType) {
// On some platforms (e.g. macOS) libclang reports `__builtin_va_list` to be defined as array using
// typedef struct __va_list_tag __builtin_va_list[1]
// while `struct __va_list_tag` is incomplete.
-5
View File
@@ -38,8 +38,3 @@ extern "C" int Konan_main(int argc, char** argv) {
return exitStatus;
}
// Allow override of entry point for cases like SDL.
int __attribute__((weak)) main(int argc, char** argv) {
return Konan_main(argc, argv);
}
+11
View File
@@ -0,0 +1,11 @@
Start with building compiler by using `dist` and `cross_dist` for cross-targets.
To build Tetris application for your host platform use
./build
note that SDL2 must be installed on the host.
For cross-compilation to iOS use
TARGET=iphone ./build
During build process compilation script creates interoperability bindings to SDL2, using SDL C headers,
and then compiles an application with the produced bindings.
To deploy executable to iPhone device take Info.plist, then use XCode and your own private signing identity.
+5 -4
View File
@@ -1,12 +1,13 @@
headers = SDL.h stdio.h string.h unistd.h stdlib.h time.h
excludedFunctions = _IO_flockfile _IO_funlockfile _IO_ftrylockfile \
_IO_cleanup_region_start _IO_cleanup_region_end \
mkstemp_dprotected_np add_profil profil unwhiteout zopen \
SDL_PointInRect SDL_RectEmpty SDL_RectEquals \
__darwin_fd_isset __sputc matherr _mm_stream_si32 _mm_stream_si64
_mm_stream_si32 _mm_stream_si64 \
SDL_PointInRect SDL_RectEmpty SDL_RectEquals
entryPoint = SDL_main
compilerOpts.osx = -D_POSIX_SOURCE -mxsave -mavx -mf16c
compilerOpts = -D_POSIX_SOURCE
compilerOpts.osx =
compilerOpts.linux = -D_REENTRANT
compilerOpts.ios =
linkerOpts.linux = -lm
+23 -21
View File
@@ -513,6 +513,10 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
private fun stretch(value: Int) = (value.toFloat() * ratio + 0.5).toInt()
inner class GamePadButtons(width: Int, height: Int, gamePadHeight: Int) {
val MOVE_BUTTON_SIZE = 50
val ROTATE_BUTTON_SIZE = 80
val BUTTONS_MARGIN = 25
val arena = Arena()
val leftRect: SDL_Rect
val rightRect: SDL_Rect
@@ -521,40 +525,38 @@ class SDL_Visualizer(val width: Int, val height: Int): GameFieldVisualizer, User
val rotateRect: SDL_Rect
init {
val s1 = 50
val s2 = 80
val m = 25
val x = (width - 3 * s1 - 2 * m - m - s2) / 2 - s1
val y2 = (gamePadHeight - 2 * s1 - m) / 2
val moveButtonsWidth = 3 * MOVE_BUTTON_SIZE + 2 * BUTTONS_MARGIN + BUTTONS_MARGIN
val x = (width - moveButtonsWidth - ROTATE_BUTTON_SIZE) / 2 - MOVE_BUTTON_SIZE
val y2 = (gamePadHeight - 2 * MOVE_BUTTON_SIZE - BUTTONS_MARGIN) / 2
leftRect = arena.alloc<SDL_Rect>()
leftRect.w.value = s1
leftRect.h.value = s1
leftRect.w.value = MOVE_BUTTON_SIZE
leftRect.h.value = MOVE_BUTTON_SIZE
leftRect.x.value = x
leftRect.y.value = height - gamePadHeight + y2 + s1 + m
leftRect.y.value = height - gamePadHeight + y2 + MOVE_BUTTON_SIZE + BUTTONS_MARGIN
downRect = arena.alloc<SDL_Rect>()
downRect.w.value = s1
downRect.h.value = s1
downRect.x.value = x + s1 + m
downRect.w.value = MOVE_BUTTON_SIZE
downRect.h.value = MOVE_BUTTON_SIZE
downRect.x.value = x + MOVE_BUTTON_SIZE + BUTTONS_MARGIN
downRect.y.value = leftRect.y.value
dropRect = arena.alloc<SDL_Rect>()
dropRect.w.value = s1
dropRect.h.value = s1
dropRect.w.value = MOVE_BUTTON_SIZE
dropRect.h.value = MOVE_BUTTON_SIZE
dropRect.x.value = downRect.x.value
dropRect.y.value = height - gamePadHeight + y2
rightRect = arena.alloc<SDL_Rect>()
rightRect.w.value = s1
rightRect.h.value = s1
rightRect.x.value = x + 2 * s1 + 2 * m
rightRect.y.value = height - gamePadHeight + y2 + s1 + m
rightRect.w.value = MOVE_BUTTON_SIZE
rightRect.h.value = MOVE_BUTTON_SIZE
rightRect.x.value = x + 2 * MOVE_BUTTON_SIZE + 2 * BUTTONS_MARGIN
rightRect.y.value = height - gamePadHeight + y2 + MOVE_BUTTON_SIZE + BUTTONS_MARGIN
rotateRect = arena.alloc<SDL_Rect>()
rotateRect.w.value = s2
rotateRect.h.value = s2
rotateRect.x.value = x + 3 * s1 + 2 * m + m
rotateRect.y.value = height - gamePadHeight + y2 - m
rotateRect.w.value = ROTATE_BUTTON_SIZE
rotateRect.h.value = ROTATE_BUTTON_SIZE
rotateRect.x.value = x + moveButtonsWidth
rotateRect.y.value = height - gamePadHeight + y2 - BUTTONS_MARGIN
}
fun getCommandAt(x: Int, y: Int): UserCommand? {