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