Fixes and test lzma/zlib with ast2
This commit is contained in:
parent
568cfc5da6
commit
748998b0bd
6 changed files with 85 additions and 74 deletions
|
|
@ -283,7 +283,9 @@ proc newXIdent(gState: State, node: TSNode, kind = nskType, fname = "", pragmas:
|
||||||
if name.Bl:
|
if name.Bl:
|
||||||
# Name skipped or overridden since blank
|
# Name skipped or overridden since blank
|
||||||
result = gState.getOverrideOrSkip(node, origname, kind)
|
result = gState.getOverrideOrSkip(node, origname, kind)
|
||||||
elif origname notin gTypeMap and gState.addNewIdentifer(name):
|
elif name notin gTypeMapValues and gState.addNewIdentifer(name):
|
||||||
|
# Add only if not an existing Nim type
|
||||||
|
|
||||||
if kind == nskType:
|
if kind == nskType:
|
||||||
# type name* =
|
# type name* =
|
||||||
#
|
#
|
||||||
|
|
@ -1399,7 +1401,7 @@ proc addEnum(gState: State, node: TSNode) =
|
||||||
continue
|
continue
|
||||||
let
|
let
|
||||||
fname = gState.getIdentifier(gState.getNodeVal(en.getAtom()), nskEnumField)
|
fname = gState.getIdentifier(gState.getNodeVal(en.getAtom()), nskEnumField)
|
||||||
if fname.nBl:
|
if fname.nBl and gState.addNewIdentifer(fname):
|
||||||
var
|
var
|
||||||
fval = ""
|
fval = ""
|
||||||
if prev.Bl:
|
if prev.Bl:
|
||||||
|
|
|
||||||
|
|
@ -30,82 +30,86 @@ yield""".split(Whitespace).toHashSet()
|
||||||
|
|
||||||
# Types related
|
# Types related
|
||||||
|
|
||||||
const gTypeMap* = {
|
const
|
||||||
# char
|
gTypeMap* = {
|
||||||
"char": "cchar",
|
# char
|
||||||
"signed char": "cschar",
|
"char": "cchar",
|
||||||
"unsigned char": "cuchar",
|
"signed char": "cschar",
|
||||||
|
"unsigned char": "cuchar",
|
||||||
|
|
||||||
# short
|
# short
|
||||||
"short": "cshort",
|
"short": "cshort",
|
||||||
"short int": "cshort",
|
"short int": "cshort",
|
||||||
"signed short": "cshort",
|
"signed short": "cshort",
|
||||||
"signed short int": "cshort",
|
"signed short int": "cshort",
|
||||||
"unsigned short": "cushort",
|
"unsigned short": "cushort",
|
||||||
"unsigned short int": "cushort",
|
"unsigned short int": "cushort",
|
||||||
"uShort": "cushort",
|
"uShort": "cushort",
|
||||||
"u_short": "cushort",
|
"u_short": "cushort",
|
||||||
|
|
||||||
# int
|
# int
|
||||||
"int": "cint",
|
"int": "cint",
|
||||||
"signed": "cint",
|
"signed": "cint",
|
||||||
"signed int": "cint",
|
"signed int": "cint",
|
||||||
"ssize_t": "int",
|
"ssize_t": "int",
|
||||||
"unsigned": "cuint",
|
"unsigned": "cuint",
|
||||||
"unsigned int": "cuint",
|
"unsigned int": "cuint",
|
||||||
"uInt": "cuint",
|
"uInt": "cuint",
|
||||||
"u_int": "cuint",
|
"u_int": "cuint",
|
||||||
"size_t": "uint",
|
"size_t": "uint",
|
||||||
|
|
||||||
"int8_t": "int8",
|
"int8_t": "int8",
|
||||||
"int16_t": "int16",
|
"int16_t": "int16",
|
||||||
"int32_t": "int32",
|
"int32_t": "int32",
|
||||||
"int64_t": "int64",
|
"int64_t": "int64",
|
||||||
|
|
||||||
"intptr_t": "ptr int",
|
"intptr_t": "ptr int",
|
||||||
|
|
||||||
"Int8": "int8",
|
"Int8": "int8",
|
||||||
"Int16": "int16",
|
"Int16": "int16",
|
||||||
"Int32": "int32",
|
"Int32": "int32",
|
||||||
"Int64": "int64",
|
"Int64": "int64",
|
||||||
|
|
||||||
"uint8_t": "uint8",
|
"uint8_t": "uint8",
|
||||||
"uint16_t": "uint16",
|
"uint16_t": "uint16",
|
||||||
"uint32_t": "uint32",
|
"uint32_t": "uint32",
|
||||||
"uint64_t": "uint64",
|
"uint64_t": "uint64",
|
||||||
|
|
||||||
"uintptr_t": "ptr uint",
|
"uintptr_t": "ptr uint",
|
||||||
|
|
||||||
"Uint8": "uint8",
|
"Uint8": "uint8",
|
||||||
"Uint16": "uint16",
|
"Uint16": "uint16",
|
||||||
"Uint32": "uint32",
|
"Uint32": "uint32",
|
||||||
"Uint64": "uint64",
|
"Uint64": "uint64",
|
||||||
|
|
||||||
# long
|
# long
|
||||||
"long": "clong",
|
"long": "clong",
|
||||||
"long int": "clong",
|
"long int": "clong",
|
||||||
"signed long": "clong",
|
"signed long": "clong",
|
||||||
"signed long int": "clong",
|
"signed long int": "clong",
|
||||||
"off_t": "clong",
|
"off_t": "clong",
|
||||||
"unsigned long": "culong",
|
"unsigned long": "culong",
|
||||||
"unsigned long int": "culong",
|
"unsigned long int": "culong",
|
||||||
"uLong": "culong",
|
"uLong": "culong",
|
||||||
"u_long": "culong",
|
"u_long": "culong",
|
||||||
|
|
||||||
# long long
|
# long long
|
||||||
"long long": "clonglong",
|
"long long": "clonglong",
|
||||||
"long long int": "clonglong",
|
"long long int": "clonglong",
|
||||||
"signed long long": "clonglong",
|
"signed long long": "clonglong",
|
||||||
"signed long long int": "clonglong",
|
"signed long long int": "clonglong",
|
||||||
"off64_t": "clonglong",
|
"off64_t": "clonglong",
|
||||||
"unsigned long long": "culonglong",
|
"unsigned long long": "culonglong",
|
||||||
"unsigned long long int": "culonglong",
|
"unsigned long long int": "culonglong",
|
||||||
|
|
||||||
# floating point
|
# floating point
|
||||||
"float": "cfloat",
|
"float": "cfloat",
|
||||||
"double": "cdouble",
|
"double": "cdouble",
|
||||||
"long double": "clongdouble"
|
"long double": "clongdouble"
|
||||||
}.toTable()
|
}.toTable()
|
||||||
|
|
||||||
|
# Nim type names that shouldn't need to be wrapped again
|
||||||
|
gTypeMapValues* = toSeq(gTypeMap.values).toHashSet()
|
||||||
|
|
||||||
proc getType*(str: string): string =
|
proc getType*(str: string): string =
|
||||||
if str == "void":
|
if str == "void":
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ proc testCall(cmd, output: string, exitCode: int, delete = true) =
|
||||||
doAssert outp.contains(output), outp
|
doAssert outp.contains(output), outp
|
||||||
|
|
||||||
var
|
var
|
||||||
cmd = "nim c -f --hints:off"
|
cmd = "nim c -f --hints:off -d:FLAGS=\"-f:ast2\""
|
||||||
lrcmd = " -r lzma.nim"
|
lrcmd = " -r lzma.nim"
|
||||||
zrcmd = " -r zlib.nim"
|
zrcmd = " -r zlib.nim"
|
||||||
lexp = "liblzma version = "
|
lexp = "liblzma version = "
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,10 @@ import os, strutils
|
||||||
import nimterop/[build, cimport]
|
import nimterop/[build, cimport]
|
||||||
|
|
||||||
const
|
const
|
||||||
|
FLAGS {.strdefine.} = ""
|
||||||
|
|
||||||
baseDir = getProjectCacheDir("nimterop" / "tests" / "liblzma")
|
baseDir = getProjectCacheDir("nimterop" / "tests" / "liblzma")
|
||||||
flags = "--prefix=___,__,_ --suffix=__,_"
|
tflags = "--prefix=___,__,_ --suffix=__,_ " & FLAGS
|
||||||
|
|
||||||
static:
|
static:
|
||||||
cSkipSymbol(@[
|
cSkipSymbol(@[
|
||||||
|
|
@ -38,8 +40,8 @@ cOverride:
|
||||||
lzma_index_iter = object
|
lzma_index_iter = object
|
||||||
|
|
||||||
when not lzmaStatic:
|
when not lzmaStatic:
|
||||||
cImport(lzmaPath, recurse = true, dynlib = "lzmaLPath", flags = flags)
|
cImport(lzmaPath, recurse = true, dynlib = "lzmaLPath", flags = tflags)
|
||||||
else:
|
else:
|
||||||
cImport(lzmaPath, recurse = true, flags = flags)
|
cImport(lzmaPath, recurse = true, flags = tflags)
|
||||||
|
|
||||||
echo "liblzma version = " & $lzma_version_string()
|
echo "liblzma version = " & $lzma_version_string()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import os, nimterop/[cimport, build]
|
import os, nimterop/[cimport, build]
|
||||||
|
|
||||||
const
|
const
|
||||||
|
FLAGS {.strdefine.} = ""
|
||||||
|
|
||||||
baseDir = getProjectCacheDir("nimterop" / "tests" / "soloud")
|
baseDir = getProjectCacheDir("nimterop" / "tests" / "soloud")
|
||||||
incl = baseDir/"include"
|
incl = baseDir/"include"
|
||||||
src = baseDir/"src"
|
src = baseDir/"src"
|
||||||
|
|
@ -42,7 +44,6 @@ cCompile(src/"audiosource", "cpp", exclude="ay/")
|
||||||
cCompile(src/"audiosource", "c")
|
cCompile(src/"audiosource", "c")
|
||||||
cCompile(src/"filter/*.cpp")
|
cCompile(src/"filter/*.cpp")
|
||||||
|
|
||||||
const FLAGS {.strdefine.} = ""
|
|
||||||
cImport(incl/"soloud_c.h", flags = FLAGS)
|
cImport(incl/"soloud_c.h", flags = FLAGS)
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ import os, strutils
|
||||||
import nimterop/[build, cimport]
|
import nimterop/[build, cimport]
|
||||||
|
|
||||||
const
|
const
|
||||||
|
FLAGS {.strdefine.} = ""
|
||||||
|
|
||||||
baseDir = getProjectCacheDir("nimterop" / "tests" / "zlib")
|
baseDir = getProjectCacheDir("nimterop" / "tests" / "zlib")
|
||||||
|
|
||||||
proc zlibPreBuild(outdir, path: string) =
|
proc zlibPreBuild(outdir, path: string) =
|
||||||
|
|
@ -64,8 +66,8 @@ when zlibGit or zlibDL:
|
||||||
cIncludeDir(baseDir / "buildcache")
|
cIncludeDir(baseDir / "buildcache")
|
||||||
|
|
||||||
when not zlibStatic:
|
when not zlibStatic:
|
||||||
cImport(zlibPath, recurse = true, dynlib = "zlibLPath")
|
cImport(zlibPath, recurse = true, dynlib = "zlibLPath", flags = FLAGS)
|
||||||
else:
|
else:
|
||||||
cImport(zlibPath, recurse = true)
|
cImport(zlibPath, recurse = true, flags = FLAGS)
|
||||||
|
|
||||||
echo "zlib version = " & $zlibVersion()
|
echo "zlib version = " & $zlibVersion()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue