Fix cuclonglong issue #32
This commit is contained in:
parent
51ae21f8d5
commit
ac7231a882
1 changed files with 22 additions and 13 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import macros, os, strformat, strutils
|
import macros, os, strformat, strutils, tables
|
||||||
|
|
||||||
import regex
|
import regex
|
||||||
|
|
||||||
|
|
@ -28,6 +28,25 @@ when while
|
||||||
xor
|
xor
|
||||||
yield""".split(Whitespace)
|
yield""".split(Whitespace)
|
||||||
|
|
||||||
|
const gTypeMap = {
|
||||||
|
"long": "clong",
|
||||||
|
"unsigned long": "culong",
|
||||||
|
"char": "cchar",
|
||||||
|
"signed char": "cschar",
|
||||||
|
"short": "cshort",
|
||||||
|
"int": "cint",
|
||||||
|
"size_t": "uint",
|
||||||
|
"ssize_t": "int",
|
||||||
|
"long long": "clonglong",
|
||||||
|
"float": "cfloat",
|
||||||
|
"double": "cdouble",
|
||||||
|
"long double": "clongdouble",
|
||||||
|
"unsigned char": "cuchar",
|
||||||
|
"unsigned short": "cushort",
|
||||||
|
"unsigned int": "cuint",
|
||||||
|
"unsigned long long": "culonglong"
|
||||||
|
}.toTable()
|
||||||
|
|
||||||
proc sanitizePath*(path: string): string =
|
proc sanitizePath*(path: string): string =
|
||||||
path.multiReplace([("\\\\", $DirSep), ("\\", $DirSep), ("//", $DirSep)])
|
path.multiReplace([("\\\\", $DirSep), ("\\", $DirSep), ("//", $DirSep)])
|
||||||
|
|
||||||
|
|
@ -52,21 +71,11 @@ proc getType*(str: string): string =
|
||||||
return "object"
|
return "object"
|
||||||
|
|
||||||
result = str.strip(chars={'_'}).
|
result = str.strip(chars={'_'}).
|
||||||
multiReplace([
|
|
||||||
("unsigned ", "cu"),
|
|
||||||
("double ", "cdouble"),
|
|
||||||
("long ", "clong"),
|
|
||||||
("ssize_t", "int"),
|
|
||||||
("size_t", "uint")
|
|
||||||
]).
|
|
||||||
replace(re"([u]?int[\d]+)_t", "$1").
|
replace(re"([u]?int[\d]+)_t", "$1").
|
||||||
replace(re"([u]?int)ptr_t", "ptr $1")
|
replace(re"([u]?int)ptr_t", "ptr $1")
|
||||||
|
|
||||||
case result:
|
if gTypeMap.hasKey(result):
|
||||||
of "long":
|
result = gTypeMap[result]
|
||||||
result = "clong"
|
|
||||||
of "double":
|
|
||||||
result = "cdouble"
|
|
||||||
|
|
||||||
proc getLit*(str: string): string =
|
proc getLit*(str: string): string =
|
||||||
if str.contains(re"^[\-]?[\d]+$") or
|
if str.contains(re"^[\-]?[\d]+$") or
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue