Refactor module structure

This commit is contained in:
Joey Yakimowich-Payne 2020-04-12 08:45:01 -06:00
commit 22b746bcda
16 changed files with 91 additions and 87 deletions

View file

@ -13,7 +13,7 @@ requires "nim >= 1.0.6", "nimterop#head"
when gorgeEx("nimble path nimterop").exitCode == 0:
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:
task docs, "Do nothing": discard

View file

@ -1,2 +1,15 @@
import nim_sdl2 / wrapper
export wrapper
import sdl2/sdl2
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

View file

@ -13,7 +13,7 @@ getHeader(
)
static:
cSkipSymbol @["bool"]
cSkipSymbol @["bool", "compile_time_assert_SDL_Event"]
# cDebug()
# cDisableCaching()
@ -120,14 +120,15 @@ cPlugin:
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
# Get rid of leading and trailing underscores
# 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.name != "_":
sym.name = sym.name.replace(re"^_+", "")
sym.name = sym.name.replace(re"_+$", "")
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
sym.name = sym.name.replace(re"^SDL_", "")
if sym.name.startsWith("SDLK_"):
@ -136,6 +137,9 @@ cPlugin:
if EVENT_TYPES.contains(sym.name):
sym.name = "EVENT_" & sym.name
if sym.name == "version":
sym.name = "Version"
if sym.name == "ThreadID":
sym.name = "CurrentThreadID"
if sym.name == "GLContextResetNotification":

View file

@ -1,8 +1,8 @@
import os, strutils, strformat
import ../nim_sdl2/wrapper as sdl2_wrapper
import sdl2
import nimterop/[cimport, build]
export sdl2_wrapper
export sdl2
const
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
@ -17,9 +17,9 @@ getHeader(
altNames = "SDL2_gfx,SDL_gfx"
)
# static:
# cDebug()
# cDisableCaching()
static:
cDebug()
cDisableCaching()
cPlugin:
import strutils, nre
@ -82,15 +82,10 @@ cPlugin:
# Symbol renaming examples
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
# 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.name != "_":
sym.name = sym.name.replace(re"^_+", "")
sym.name = sym.name.replace(re"_+$", "")
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
sym.name = sym.name.replace(re"^SDL_", "")
if sym.name.startsWith("SDLK_"):
@ -99,6 +94,9 @@ cPlugin:
if EVENT_TYPES.contains(sym.name):
sym.name = "EVENT_" & sym.name
if sym.name == "version":
sym.name = "Version"
if sym.name == "ThreadID":
sym.name = "CurrentThreadID"
if sym.name == "GLContextResetNotification":

View file

@ -1,7 +1,9 @@
import os, strformat
import ../nim_sdl2/wrapper
import os, strformat, strutils
import sdl2
import nimterop/[build, cimport]
export sdl2
const
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
buildDir = baseDir / "build"
@ -19,9 +21,16 @@ getHeader(
&"-DSDL2MAIN_LIBRARY={SDLMainLib} -DSDL2_PATH={sdlDir} -DSDL2_INCLUDE_DIR={sdlIncludeDir} -DSDL_gpu_BUILD_DEMOS=OFF"
)
# static:
# cDebug()
# cDisableCaching()
static:
cDebug()
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:
type
@ -91,12 +100,16 @@ cPlugin:
# Symbol renaming examples
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
# 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.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_", "")
if sym.name.startsWith("SDLK_"):
@ -105,6 +118,9 @@ cPlugin:
if EVENT_TYPES.contains(sym.name):
sym.name = "EVENT_" & sym.name
if sym.name == "version":
sym.name = "Version"
if sym.name == "ThreadID":
sym.name = "CurrentThreadID"
if sym.name == "GLContextResetNotification":

View file

@ -1,7 +1,9 @@
import os, strutils, strformat
import ../nim_sdl2/wrapper
import sdl2
import nimterop/[cimport, build]
export sdl2
const
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
buildDir = baseDir / "build"
@ -81,15 +83,10 @@ cPlugin:
# Symbol renaming examples
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
# 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.name != "_":
sym.name = sym.name.replace(re"^_+", "")
sym.name = sym.name.replace(re"_+$", "")
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
sym.name = sym.name.replace(re"^SDL_", "")
if sym.name.startsWith("SDLK_"):
@ -98,6 +95,9 @@ cPlugin:
if EVENT_TYPES.contains(sym.name):
sym.name = "EVENT_" & sym.name
if sym.name == "version":
sym.name = "Version"
if sym.name == "ThreadID":
sym.name = "CurrentThreadID"
if sym.name == "GLContextResetNotification":

View file

@ -1,7 +1,9 @@
import os, strutils, strformat
import ../nim_sdl2/wrapper as sdl2_wrapper
import sdl2
import nimterop/[cimport, build]
export sdl2
const
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
buildDir = baseDir / "build"
@ -80,15 +82,10 @@ cPlugin:
# Symbol renaming examples
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
# 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.name != "_":
sym.name = sym.name.replace(re"^_+", "")
sym.name = sym.name.replace(re"_+$", "")
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
sym.name = sym.name.replace(re"^SDL_", "")
if sym.name.startsWith("SDLK_"):
@ -97,6 +94,9 @@ cPlugin:
if EVENT_TYPES.contains(sym.name):
sym.name = "EVENT_" & sym.name
if sym.name == "version":
sym.name = "Version"
if sym.name == "ThreadID":
sym.name = "CurrentThreadID"
if sym.name == "GLContextResetNotification":

View file

@ -1,7 +1,9 @@
import os, strutils, strformat
import ../nim_sdl2/wrapper as sdl2_wrapper
import sdl2
import nimterop/[cimport, build]
export sdl2
const
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
buildDir = baseDir / "build"
@ -81,15 +83,10 @@ cPlugin:
# Symbol renaming examples
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
# 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.name != "_":
sym.name = sym.name.replace(re"^_+", "")
sym.name = sym.name.replace(re"_+$", "")
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
sym.name = sym.name.replace(re"^SDL_", "")
if sym.name.startsWith("SDLK_"):
@ -98,6 +95,9 @@ cPlugin:
if EVENT_TYPES.contains(sym.name):
sym.name = "EVENT_" & sym.name
if sym.name == "version":
sym.name = "Version"
if sym.name == "ThreadID":
sym.name = "CurrentThreadID"
if sym.name == "GLContextResetNotification":

View file

@ -1,7 +1,9 @@
import os, strutils, strformat
import ../nim_sdl2/wrapper as sdl2_wrapper
import sdl2
import nimterop/[cimport, build]
export sdl2
const
baseDir = currentSourcePath.parentDir().parentDir().parentDir()
buildDir = baseDir / "build"
@ -84,15 +86,10 @@ cPlugin:
# Symbol renaming examples
proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
# 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.name != "_":
sym.name = sym.name.replace(re"^_+", "")
sym.name = sym.name.replace(re"_+$", "")
sym.name = sym.name.strip(chars={'_'}).replace("___", "_")
sym.name = sym.name.replace(re"^SDL_", "")
if sym.name.startsWith("SDLK_"):
@ -101,6 +98,9 @@ cPlugin:
if EVENT_TYPES.contains(sym.name):
sym.name = "EVENT_" & sym.name
if sym.name == "version":
sym.name = "Version"
if sym.name == "ThreadID":
sym.name = "CurrentThreadID"
if sym.name == "GLContextResetNotification":

View file

@ -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

View file

@ -1,2 +0,0 @@
import nim_sdl2_gfx / wrapper
export wrapper

View file

@ -1,2 +0,0 @@
import nim_sdl2_gpu / wrapper
export wrapper

View file

@ -1,2 +0,0 @@
import nim_sdl2_image / wrapper
export wrapper

View file

@ -1,2 +0,0 @@
import nim_sdl2_mixer / wrapper
export wrapper

View file

@ -1,2 +0,0 @@
import nim_sdl2_net / wrapper
export wrapper

View file

@ -1,2 +0,0 @@
import nim_sdl2_ttf / wrapper
export wrapper