Refactor module structure
This commit is contained in:
parent
e0e4cc81bf
commit
22b746bcda
16 changed files with 91 additions and 87 deletions
|
|
@ -13,7 +13,7 @@ requires "nim >= 1.0.6", "nimterop#head"
|
||||||
|
|
||||||
when gorgeEx("nimble path nimterop").exitCode == 0:
|
when gorgeEx("nimble path nimterop").exitCode == 0:
|
||||||
import nimterop/docs
|
import nimterop/docs
|
||||||
task docs, "Generate docs": buildDocs(@["src/sdl2_all.nim"], "build/htmldocs")
|
task docs, "Generate docs": buildDocs(@["src/sdl2.nim"], "build/htmldocs")
|
||||||
else:
|
else:
|
||||||
task docs, "Do nothing": discard
|
task docs, "Do nothing": discard
|
||||||
|
|
||||||
17
src/sdl2.nim
17
src/sdl2.nim
|
|
@ -1,2 +1,15 @@
|
||||||
import nim_sdl2 / wrapper
|
import sdl2/sdl2
|
||||||
export wrapper
|
import sdl2/sdl2_gpu
|
||||||
|
import sdl2/sdl2_image
|
||||||
|
import sdl2/sdl2_mixer
|
||||||
|
import sdl2/sdl2_net
|
||||||
|
import sdl2/sdl2_ttf
|
||||||
|
import sdl2/sdl2_gfx
|
||||||
|
|
||||||
|
export sdl2
|
||||||
|
export sdl2_gpu
|
||||||
|
export sdl2_image
|
||||||
|
export sdl2_mixer
|
||||||
|
export sdl2_net
|
||||||
|
export sdl2_ttf
|
||||||
|
export sdl2_gfx
|
||||||
|
|
@ -13,7 +13,7 @@ getHeader(
|
||||||
)
|
)
|
||||||
|
|
||||||
static:
|
static:
|
||||||
cSkipSymbol @["bool"]
|
cSkipSymbol @["bool", "compile_time_assert_SDL_Event"]
|
||||||
# cDebug()
|
# cDebug()
|
||||||
# cDisableCaching()
|
# cDisableCaching()
|
||||||
|
|
||||||
|
|
@ -120,14 +120,15 @@ cPlugin:
|
||||||
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
||||||
# Get rid of leading and trailing underscores
|
# Get rid of leading and trailing underscores
|
||||||
# sym.name = sym.name.strip(chars = {'_'})
|
# sym.name = sym.name.strip(chars = {'_'})
|
||||||
|
if sym.name == "SDL_init_flags":
|
||||||
|
sym.name = "sdlInitFlags"
|
||||||
|
if sym.name == "GPU_init_flags":
|
||||||
|
sym.name = "gpuInitFlags"
|
||||||
|
|
||||||
# Remove prefixes or suffixes from procs
|
|
||||||
if sym.name == "__MACOSX__":
|
|
||||||
sym.name = "MACOSX"
|
|
||||||
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
||||||
if sym.name != "_":
|
if sym.name != "_":
|
||||||
sym.name = sym.name.replace(re"^_+", "")
|
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
|
||||||
sym.name = sym.name.replace(re"_+$", "")
|
|
||||||
sym.name = sym.name.replace(re"^SDL_", "")
|
sym.name = sym.name.replace(re"^SDL_", "")
|
||||||
|
|
||||||
if sym.name.startsWith("SDLK_"):
|
if sym.name.startsWith("SDLK_"):
|
||||||
|
|
@ -136,6 +137,9 @@ cPlugin:
|
||||||
if EVENT_TYPES.contains(sym.name):
|
if EVENT_TYPES.contains(sym.name):
|
||||||
sym.name = "EVENT_" & sym.name
|
sym.name = "EVENT_" & sym.name
|
||||||
|
|
||||||
|
if sym.name == "version":
|
||||||
|
sym.name = "Version"
|
||||||
|
|
||||||
if sym.name == "ThreadID":
|
if sym.name == "ThreadID":
|
||||||
sym.name = "CurrentThreadID"
|
sym.name = "CurrentThreadID"
|
||||||
if sym.name == "GLContextResetNotification":
|
if sym.name == "GLContextResetNotification":
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import os, strutils, strformat
|
import os, strutils, strformat
|
||||||
import ../nim_sdl2/wrapper as sdl2_wrapper
|
import sdl2
|
||||||
import nimterop/[cimport, build]
|
import nimterop/[cimport, build]
|
||||||
|
|
||||||
export sdl2_wrapper
|
export sdl2
|
||||||
|
|
||||||
const
|
const
|
||||||
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
|
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
|
||||||
|
|
@ -17,9 +17,9 @@ getHeader(
|
||||||
altNames = "SDL2_gfx,SDL_gfx"
|
altNames = "SDL2_gfx,SDL_gfx"
|
||||||
)
|
)
|
||||||
|
|
||||||
# static:
|
static:
|
||||||
# cDebug()
|
cDebug()
|
||||||
# cDisableCaching()
|
cDisableCaching()
|
||||||
|
|
||||||
cPlugin:
|
cPlugin:
|
||||||
import strutils, nre
|
import strutils, nre
|
||||||
|
|
@ -82,15 +82,10 @@ cPlugin:
|
||||||
# Symbol renaming examples
|
# Symbol renaming examples
|
||||||
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
||||||
# Get rid of leading and trailing underscores
|
# Get rid of leading and trailing underscores
|
||||||
# sym.name = sym.name.strip(chars = {'_'})
|
|
||||||
|
|
||||||
# Remove prefixes or suffixes from procs
|
|
||||||
if sym.name == "__MACOSX__":
|
|
||||||
sym.name = "MACOSX"
|
|
||||||
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
||||||
if sym.name != "_":
|
if sym.name != "_":
|
||||||
sym.name = sym.name.replace(re"^_+", "")
|
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
|
||||||
sym.name = sym.name.replace(re"_+$", "")
|
|
||||||
sym.name = sym.name.replace(re"^SDL_", "")
|
sym.name = sym.name.replace(re"^SDL_", "")
|
||||||
|
|
||||||
if sym.name.startsWith("SDLK_"):
|
if sym.name.startsWith("SDLK_"):
|
||||||
|
|
@ -99,6 +94,9 @@ cPlugin:
|
||||||
if EVENT_TYPES.contains(sym.name):
|
if EVENT_TYPES.contains(sym.name):
|
||||||
sym.name = "EVENT_" & sym.name
|
sym.name = "EVENT_" & sym.name
|
||||||
|
|
||||||
|
if sym.name == "version":
|
||||||
|
sym.name = "Version"
|
||||||
|
|
||||||
if sym.name == "ThreadID":
|
if sym.name == "ThreadID":
|
||||||
sym.name = "CurrentThreadID"
|
sym.name = "CurrentThreadID"
|
||||||
if sym.name == "GLContextResetNotification":
|
if sym.name == "GLContextResetNotification":
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import os, strformat
|
import os, strformat, strutils
|
||||||
import ../nim_sdl2/wrapper
|
import sdl2
|
||||||
import nimterop/[build, cimport]
|
import nimterop/[build, cimport]
|
||||||
|
|
||||||
|
export sdl2
|
||||||
|
|
||||||
const
|
const
|
||||||
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
|
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
|
||||||
buildDir = baseDir / "build"
|
buildDir = baseDir / "build"
|
||||||
|
|
@ -19,9 +21,16 @@ getHeader(
|
||||||
&"-DSDL2MAIN_LIBRARY={SDLMainLib} -DSDL2_PATH={sdlDir} -DSDL2_INCLUDE_DIR={sdlIncludeDir} -DSDL_gpu_BUILD_DEMOS=OFF"
|
&"-DSDL2MAIN_LIBRARY={SDLMainLib} -DSDL2_PATH={sdlDir} -DSDL2_INCLUDE_DIR={sdlIncludeDir} -DSDL_gpu_BUILD_DEMOS=OFF"
|
||||||
)
|
)
|
||||||
|
|
||||||
# static:
|
static:
|
||||||
# cDebug()
|
cDebug()
|
||||||
# cDisableCaching()
|
cDisableCaching()
|
||||||
|
|
||||||
|
# This shouldn't be needed, but for some reason is
|
||||||
|
let contents = readFile(srcDir/"include/SDL_gpu.h")
|
||||||
|
let newContents = contents.replace("""typedef struct GPU_Renderer GPU_Renderer;
|
||||||
|
typedef struct GPU_Target GPU_Target;""", "")
|
||||||
|
|
||||||
|
writeFile(srcDir/"include/SDL_gpu.h", newContents)
|
||||||
|
|
||||||
cOverride:
|
cOverride:
|
||||||
type
|
type
|
||||||
|
|
@ -91,12 +100,16 @@ cPlugin:
|
||||||
# Symbol renaming examples
|
# Symbol renaming examples
|
||||||
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
||||||
# Remove prefixes or suffixes from procs
|
# Remove prefixes or suffixes from procs
|
||||||
sym.name = sym.name.replace(re"^GPU_", "")
|
if sym.name == "SDL_init_flags":
|
||||||
|
sym.name = "sdlInitFlags"
|
||||||
|
if sym.name == "GPU_init_flags":
|
||||||
|
sym.name = "gpuInitFlags"
|
||||||
|
|
||||||
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
||||||
if sym.name != "_":
|
if sym.name != "_":
|
||||||
sym.name = sym.name.strip(chars = {'_'})
|
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
|
||||||
|
|
||||||
|
sym.name = sym.name.replace(re"^GPU_", "")
|
||||||
sym.name = sym.name.replace(re"^SDL_", "")
|
sym.name = sym.name.replace(re"^SDL_", "")
|
||||||
|
|
||||||
if sym.name.startsWith("SDLK_"):
|
if sym.name.startsWith("SDLK_"):
|
||||||
|
|
@ -105,6 +118,9 @@ cPlugin:
|
||||||
if EVENT_TYPES.contains(sym.name):
|
if EVENT_TYPES.contains(sym.name):
|
||||||
sym.name = "EVENT_" & sym.name
|
sym.name = "EVENT_" & sym.name
|
||||||
|
|
||||||
|
if sym.name == "version":
|
||||||
|
sym.name = "Version"
|
||||||
|
|
||||||
if sym.name == "ThreadID":
|
if sym.name == "ThreadID":
|
||||||
sym.name = "CurrentThreadID"
|
sym.name = "CurrentThreadID"
|
||||||
if sym.name == "GLContextResetNotification":
|
if sym.name == "GLContextResetNotification":
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import os, strutils, strformat
|
import os, strutils, strformat
|
||||||
import ../nim_sdl2/wrapper
|
import sdl2
|
||||||
import nimterop/[cimport, build]
|
import nimterop/[cimport, build]
|
||||||
|
|
||||||
|
export sdl2
|
||||||
|
|
||||||
const
|
const
|
||||||
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
|
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
|
||||||
buildDir = baseDir / "build"
|
buildDir = baseDir / "build"
|
||||||
|
|
@ -81,15 +83,10 @@ cPlugin:
|
||||||
# Symbol renaming examples
|
# Symbol renaming examples
|
||||||
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
||||||
# Get rid of leading and trailing underscores
|
# Get rid of leading and trailing underscores
|
||||||
# sym.name = sym.name.strip(chars = {'_'})
|
|
||||||
|
|
||||||
# Remove prefixes or suffixes from procs
|
|
||||||
if sym.name == "__MACOSX__":
|
|
||||||
sym.name = "MACOSX"
|
|
||||||
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
||||||
if sym.name != "_":
|
if sym.name != "_":
|
||||||
sym.name = sym.name.replace(re"^_+", "")
|
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
|
||||||
sym.name = sym.name.replace(re"_+$", "")
|
|
||||||
sym.name = sym.name.replace(re"^SDL_", "")
|
sym.name = sym.name.replace(re"^SDL_", "")
|
||||||
|
|
||||||
if sym.name.startsWith("SDLK_"):
|
if sym.name.startsWith("SDLK_"):
|
||||||
|
|
@ -98,6 +95,9 @@ cPlugin:
|
||||||
if EVENT_TYPES.contains(sym.name):
|
if EVENT_TYPES.contains(sym.name):
|
||||||
sym.name = "EVENT_" & sym.name
|
sym.name = "EVENT_" & sym.name
|
||||||
|
|
||||||
|
if sym.name == "version":
|
||||||
|
sym.name = "Version"
|
||||||
|
|
||||||
if sym.name == "ThreadID":
|
if sym.name == "ThreadID":
|
||||||
sym.name = "CurrentThreadID"
|
sym.name = "CurrentThreadID"
|
||||||
if sym.name == "GLContextResetNotification":
|
if sym.name == "GLContextResetNotification":
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import os, strutils, strformat
|
import os, strutils, strformat
|
||||||
import ../nim_sdl2/wrapper as sdl2_wrapper
|
import sdl2
|
||||||
import nimterop/[cimport, build]
|
import nimterop/[cimport, build]
|
||||||
|
|
||||||
|
export sdl2
|
||||||
|
|
||||||
const
|
const
|
||||||
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
|
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
|
||||||
buildDir = baseDir / "build"
|
buildDir = baseDir / "build"
|
||||||
|
|
@ -80,15 +82,10 @@ cPlugin:
|
||||||
# Symbol renaming examples
|
# Symbol renaming examples
|
||||||
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
||||||
# Get rid of leading and trailing underscores
|
# Get rid of leading and trailing underscores
|
||||||
# sym.name = sym.name.strip(chars = {'_'})
|
|
||||||
|
|
||||||
# Remove prefixes or suffixes from procs
|
|
||||||
if sym.name == "__MACOSX__":
|
|
||||||
sym.name = "MACOSX"
|
|
||||||
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
||||||
if sym.name != "_":
|
if sym.name != "_":
|
||||||
sym.name = sym.name.replace(re"^_+", "")
|
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
|
||||||
sym.name = sym.name.replace(re"_+$", "")
|
|
||||||
sym.name = sym.name.replace(re"^SDL_", "")
|
sym.name = sym.name.replace(re"^SDL_", "")
|
||||||
|
|
||||||
if sym.name.startsWith("SDLK_"):
|
if sym.name.startsWith("SDLK_"):
|
||||||
|
|
@ -97,6 +94,9 @@ cPlugin:
|
||||||
if EVENT_TYPES.contains(sym.name):
|
if EVENT_TYPES.contains(sym.name):
|
||||||
sym.name = "EVENT_" & sym.name
|
sym.name = "EVENT_" & sym.name
|
||||||
|
|
||||||
|
if sym.name == "version":
|
||||||
|
sym.name = "Version"
|
||||||
|
|
||||||
if sym.name == "ThreadID":
|
if sym.name == "ThreadID":
|
||||||
sym.name = "CurrentThreadID"
|
sym.name = "CurrentThreadID"
|
||||||
if sym.name == "GLContextResetNotification":
|
if sym.name == "GLContextResetNotification":
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import os, strutils, strformat
|
import os, strutils, strformat
|
||||||
import ../nim_sdl2/wrapper as sdl2_wrapper
|
import sdl2
|
||||||
import nimterop/[cimport, build]
|
import nimterop/[cimport, build]
|
||||||
|
|
||||||
|
export sdl2
|
||||||
|
|
||||||
const
|
const
|
||||||
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
|
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
|
||||||
buildDir = baseDir / "build"
|
buildDir = baseDir / "build"
|
||||||
|
|
@ -81,15 +83,10 @@ cPlugin:
|
||||||
# Symbol renaming examples
|
# Symbol renaming examples
|
||||||
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
||||||
# Get rid of leading and trailing underscores
|
# Get rid of leading and trailing underscores
|
||||||
# sym.name = sym.name.strip(chars = {'_'})
|
|
||||||
|
|
||||||
# Remove prefixes or suffixes from procs
|
|
||||||
if sym.name == "__MACOSX__":
|
|
||||||
sym.name = "MACOSX"
|
|
||||||
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
||||||
if sym.name != "_":
|
if sym.name != "_":
|
||||||
sym.name = sym.name.replace(re"^_+", "")
|
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
|
||||||
sym.name = sym.name.replace(re"_+$", "")
|
|
||||||
sym.name = sym.name.replace(re"^SDL_", "")
|
sym.name = sym.name.replace(re"^SDL_", "")
|
||||||
|
|
||||||
if sym.name.startsWith("SDLK_"):
|
if sym.name.startsWith("SDLK_"):
|
||||||
|
|
@ -98,6 +95,9 @@ cPlugin:
|
||||||
if EVENT_TYPES.contains(sym.name):
|
if EVENT_TYPES.contains(sym.name):
|
||||||
sym.name = "EVENT_" & sym.name
|
sym.name = "EVENT_" & sym.name
|
||||||
|
|
||||||
|
if sym.name == "version":
|
||||||
|
sym.name = "Version"
|
||||||
|
|
||||||
if sym.name == "ThreadID":
|
if sym.name == "ThreadID":
|
||||||
sym.name = "CurrentThreadID"
|
sym.name = "CurrentThreadID"
|
||||||
if sym.name == "GLContextResetNotification":
|
if sym.name == "GLContextResetNotification":
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import os, strutils, strformat
|
import os, strutils, strformat
|
||||||
import ../nim_sdl2/wrapper as sdl2_wrapper
|
import sdl2
|
||||||
import nimterop/[cimport, build]
|
import nimterop/[cimport, build]
|
||||||
|
|
||||||
|
export sdl2
|
||||||
|
|
||||||
const
|
const
|
||||||
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
|
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
|
||||||
buildDir = baseDir / "build"
|
buildDir = baseDir / "build"
|
||||||
|
|
@ -84,15 +86,10 @@ cPlugin:
|
||||||
# Symbol renaming examples
|
# Symbol renaming examples
|
||||||
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
|
||||||
# Get rid of leading and trailing underscores
|
# Get rid of leading and trailing underscores
|
||||||
# sym.name = sym.name.strip(chars = {'_'})
|
|
||||||
|
|
||||||
# Remove prefixes or suffixes from procs
|
|
||||||
if sym.name == "__MACOSX__":
|
|
||||||
sym.name = "MACOSX"
|
|
||||||
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
if sym.kind == nskProc or sym.kind == nskType or sym.kind == nskConst:
|
||||||
if sym.name != "_":
|
if sym.name != "_":
|
||||||
sym.name = sym.name.replace(re"^_+", "")
|
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
|
||||||
sym.name = sym.name.replace(re"_+$", "")
|
|
||||||
sym.name = sym.name.replace(re"^SDL_", "")
|
sym.name = sym.name.replace(re"^SDL_", "")
|
||||||
|
|
||||||
if sym.name.startsWith("SDLK_"):
|
if sym.name.startsWith("SDLK_"):
|
||||||
|
|
@ -101,6 +98,9 @@ cPlugin:
|
||||||
if EVENT_TYPES.contains(sym.name):
|
if EVENT_TYPES.contains(sym.name):
|
||||||
sym.name = "EVENT_" & sym.name
|
sym.name = "EVENT_" & sym.name
|
||||||
|
|
||||||
|
if sym.name == "version":
|
||||||
|
sym.name = "Version"
|
||||||
|
|
||||||
if sym.name == "ThreadID":
|
if sym.name == "ThreadID":
|
||||||
sym.name = "CurrentThreadID"
|
sym.name = "CurrentThreadID"
|
||||||
if sym.name == "GLContextResetNotification":
|
if sym.name == "GLContextResetNotification":
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
import sdl2
|
|
||||||
import sdl2_gpu
|
|
||||||
import sdl2_image
|
|
||||||
import sdl2_mixer
|
|
||||||
import sdl2_net
|
|
||||||
import sdl2_ttf
|
|
||||||
import sdl2_gfx
|
|
||||||
|
|
||||||
export sdl2
|
|
||||||
export sdl2_gpu
|
|
||||||
export sdl2_image
|
|
||||||
export sdl2_mixer
|
|
||||||
export sdl2_net
|
|
||||||
export sdl2_ttf
|
|
||||||
export sdl2_gfx
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import nim_sdl2_gfx / wrapper
|
|
||||||
export wrapper
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import nim_sdl2_gpu / wrapper
|
|
||||||
export wrapper
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import nim_sdl2_image / wrapper
|
|
||||||
export wrapper
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import nim_sdl2_mixer / wrapper
|
|
||||||
export wrapper
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import nim_sdl2_net / wrapper
|
|
||||||
export wrapper
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
import nim_sdl2_ttf / wrapper
|
|
||||||
export wrapper
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue