From 2edc485b67d7e23fa4507a6a83069bc9fdb26d7b Mon Sep 17 00:00:00 2001 From: Antonis Geralis Date: Mon, 29 Jan 2024 15:18:59 +0200 Subject: [PATCH] mangle names on all platforms --- naylib.nimble | 9 ++++----- src/raylib.nim | 13 ++++++------- tools/raylib_gen.nim | 11 ++--------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/naylib.nimble b/naylib.nimble index f40b0f8..47499d0 100644 --- a/naylib.nimble +++ b/naylib.nimble @@ -1,6 +1,6 @@ # Package -version = "5.0.2" +version = "5.1.0" author = "Antonis Geralis" description = "Raylib Nim wrapper" license = "MIT" @@ -21,7 +21,6 @@ const PkgDir = thisDir().quoteShell before install: - when defined(windows): - let patchPath = PkgDir / "mangle_names.patch" - withDir(PkgDir / "src/raylib"): - exec "git apply " & patchPath + let patchPath = PkgDir / "mangle_names.patch" + withDir(PkgDir / "src/raylib"): + exec "git apply " & patchPath diff --git a/src/raylib.nim b/src/raylib.nim index cd19532..fd7c4cc 100644 --- a/src/raylib.nim +++ b/src/raylib.nim @@ -500,8 +500,7 @@ type b*: uint8 ## Color blue value a*: uint8 ## Color alpha value - Rectangle* {.importc: when defined(windows): "rlRectangle" else: "Rectangle", - header: "raylib.h", bycopy.} = object ## Rectangle, 4 components + Rectangle* {.importc: "rlRectangle", header: "raylib.h", bycopy.} = object ## Rectangle, 4 components x*: float32 ## Rectangle top-left corner position x y*: float32 ## Rectangle top-left corner position y width*: float32 ## Rectangle width @@ -774,7 +773,7 @@ const {.push callconv: cdecl, header: "raylib.h".} proc initWindowPriv(width: int32, height: int32, title: cstring) {.importc: "InitWindow".} -proc closeWindow*() {.importc: when defined(windows): "rlCloseWindow" else: "CloseWindow".} +proc closeWindow*() {.importc: "rlCloseWindow".} ## Close window and unload OpenGL context proc windowShouldClose*(): bool {.importc: "WindowShouldClose".} ## Check if application should close (KEY_ESCAPE pressed or windows close icon clicked) @@ -865,7 +864,7 @@ proc enableEventWaiting*() {.importc: "EnableEventWaiting".} ## Enable waiting for events on EndDrawing(), no automatic event polling proc disableEventWaiting*() {.importc: "DisableEventWaiting".} ## Disable waiting for events on EndDrawing(), automatic events polling -proc showCursor*() {.importc: when defined(windows): "rlShowCursor" else: "ShowCursor".} +proc showCursor*() {.importc: "rlShowCursor".} ## Shows cursor proc hideCursor*() {.importc: "HideCursor".} ## Hides cursor @@ -1209,7 +1208,7 @@ proc checkCollisionPointLine*(point: Vector2, p1: Vector2, p2: Vector2, threshol ## Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] proc getCollisionRec*(rec1: Rectangle, rec2: Rectangle): Rectangle {.importc: "GetCollisionRec".} ## Get collision rectangle for two rectangles collision -proc loadImagePriv(fileName: cstring): Image {.importc: when defined(windows): "rlLoadImage" else: "LoadImage".} +proc loadImagePriv(fileName: cstring): Image {.importc: "rlLoadImage".} proc loadImageRawPriv(fileName: cstring, width: int32, height: int32, format: PixelFormat, headerSize: int32): Image {.importc: "LoadImageRaw".} proc loadImageSvgPriv(fileNameOrString: cstring, width: int32, height: int32): Image {.importc: "LoadImageSvg".} proc loadImageAnim*(fileName: cstring, frames: out int32): Image {.importc: "LoadImageAnim".} @@ -1407,9 +1406,9 @@ proc exportFontAsCode*(font: Font, fileName: cstring): bool {.importc: "ExportFo ## Export font as code file, returns true on success proc drawFPS*(posX: int32, posY: int32) {.importc: "DrawFPS".} ## Draw current FPS -proc drawText*(text: cstring, posX: int32, posY: int32, fontSize: int32, color: Color) {.importc: when defined(windows): "rlDrawText" else: "DrawText".} +proc drawText*(text: cstring, posX: int32, posY: int32, fontSize: int32, color: Color) {.importc: "rlDrawText".} ## Draw text (using default font) -proc drawText*(font: Font, text: cstring, position: Vector2, fontSize: float32, spacing: float32, tint: Color) {.importc: when defined(windows): "rlDrawTextEx" else: "DrawTextEx".} +proc drawText*(font: Font, text: cstring, position: Vector2, fontSize: float32, spacing: float32, tint: Color) {.importc: "rlDrawTextEx".} ## Draw text using font and additional parameters proc drawText*(font: Font, text: cstring, position: Vector2, origin: Vector2, rotation: float32, fontSize: float32, spacing: float32, tint: Color) {.importc: "DrawTextPro".} ## Draw text using Font and pro parameters (rotation) diff --git a/tools/raylib_gen.nim b/tools/raylib_gen.nim index 20db020..d2934c9 100644 --- a/tools/raylib_gen.nim +++ b/tools/raylib_gen.nim @@ -557,11 +557,7 @@ proc genBindings(t: TopLevel, fname: string; header, middle: string) = elif obj.name in ["Color", "Vector2", "Vector3", "Vector4"]: lit "* {.importc, header: \"raylib.h\", completeStruct, bycopy.} = object" elif obj.name in ["Rectangle", "rlRectangle"]: - lit "* {.importc: when defined(windows): \"rlRectangle\" else: \"Rectangle\"," - scope: - scope: - spaces - lit "header: \"raylib.h\", bycopy.} = object" + lit "* {.importc: \"rlRectangle\", header: \"raylib.h\", bycopy.} = object" else: lit "* {.importc, header: \"raylib.h\", bycopy.} = object" doc obj scope: @@ -698,13 +694,10 @@ proc genBindings(t: TopLevel, fname: string; header, middle: string) = let kind = convertType(fnc.returnType, "", many, not isPrivate, baseKind) lit kind lit " {.importc: " + lit "\"" if fnc.name in ["ShowCursor", "rlShowCursor", "CloseWindow", "rlCloseWindow", "LoadImage", "rlLoadImage", "DrawText", "rlDrawText", "DrawTextEx", "rlDrawTextEx"]: - lit "when defined(windows): \"" if not startsWith(fnc.name, "rl"): lit "rl" - ident fnc.name - lit "\" else: " - lit "\"" ident fnc.name lit "\"" if hasVarargs: