Fix #185 - forward decl symbol change
This commit is contained in:
parent
b2de34328a
commit
f23d17d0b2
3 changed files with 36 additions and 7 deletions
|
|
@ -811,9 +811,16 @@ proc addTypeObject(nimState: NimState, node: TSNode, typeDef: PNode = nil, fname
|
||||||
if not fdlist.isNil and fdlist.len > 0:
|
if not fdlist.isNil and fdlist.len > 0:
|
||||||
# Current node has fields
|
# Current node has fields
|
||||||
let
|
let
|
||||||
name = nimState.getNodeVal(node.getAtom())
|
origname = nimState.getNodeVal(node.getAtom())
|
||||||
|
|
||||||
if nimState.identifierNodes.hasKey(name):
|
# Fix issue #185
|
||||||
|
name =
|
||||||
|
if origname.nBl:
|
||||||
|
nimState.getIdentifier(origname, nskType)
|
||||||
|
else:
|
||||||
|
""
|
||||||
|
|
||||||
|
if name.nBl and nimState.identifierNodes.hasKey(name):
|
||||||
let
|
let
|
||||||
def = nimState.identifierNodes[name]
|
def = nimState.identifierNodes[name]
|
||||||
# Duplicate nkTypeDef for `name` with empty fields
|
# Duplicate nkTypeDef for `name` with empty fields
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,14 @@ struct GPU_Target
|
||||||
char *x, y, **z;
|
char *x, y, **z;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Issue #185
|
||||||
|
struct SDL_AudioCVT;
|
||||||
|
|
||||||
|
typedef struct SDL_AudioCVT
|
||||||
|
{
|
||||||
|
int needed;
|
||||||
|
} SDL_AudioCVT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// DUPLICATES
|
// DUPLICATES
|
||||||
|
|
@ -318,6 +326,14 @@ struct GPU_Target
|
||||||
char *x, y, **z;
|
char *x, y, **z;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Issue #185
|
||||||
|
struct SDL_AudioCVT;
|
||||||
|
|
||||||
|
typedef struct SDL_AudioCVT
|
||||||
|
{
|
||||||
|
int needed;
|
||||||
|
} SDL_AudioCVT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ cOverride:
|
||||||
type
|
type
|
||||||
A1* = A0
|
A1* = A0
|
||||||
|
|
||||||
cImport(path, flags="-f:ast2 -ENK_" & flags)
|
cImport(path, flags="-f:ast2 -ENK_,SDL_" & flags)
|
||||||
|
|
||||||
proc getPragmas(n: NimNode): HashSet[string] =
|
proc getPragmas(n: NimNode): HashSet[string] =
|
||||||
# Find all pragmas in AST, return as "name" or "name:value" in set
|
# Find all pragmas in AST, return as "name" or "name:value" in set
|
||||||
|
|
@ -57,7 +57,8 @@ proc getRecList(n: NimNode): NimNode =
|
||||||
if not rl.isNil:
|
if not rl.isNil:
|
||||||
return rl
|
return rl
|
||||||
|
|
||||||
macro checkPragmas(t: typed, pragmas: static[seq[string]], istype: static[bool] = true): untyped =
|
macro checkPragmas(t: typed, pragmas: static[seq[string]], istype: static[bool] = true,
|
||||||
|
prefix: static[string] = ""): untyped =
|
||||||
# Verify that type has expected pragmas defined
|
# Verify that type has expected pragmas defined
|
||||||
# `istype` is true when typedef X
|
# `istype` is true when typedef X
|
||||||
var
|
var
|
||||||
|
|
@ -67,9 +68,9 @@ macro checkPragmas(t: typed, pragmas: static[seq[string]], istype: static[bool]
|
||||||
when defined(HEADER):
|
when defined(HEADER):
|
||||||
if not istype:
|
if not istype:
|
||||||
if "union" in exprag:
|
if "union" in exprag:
|
||||||
exprag.incl "importc:union " & $t
|
exprag.incl "importc:union " & $prefix & $t
|
||||||
else:
|
else:
|
||||||
exprag.incl "importc:struct " & $t
|
exprag.incl "importc:struct " & $prefix & $t
|
||||||
doAssert symmetricDifference(prag, exprag).len == 0,
|
doAssert symmetricDifference(prag, exprag).len == 0,
|
||||||
"\nWrong number of pragmas in " & $t & "\n" & $prag & " vs " & $exprag
|
"\nWrong number of pragmas in " & $t & "\n" & $prag & " vs " & $exprag
|
||||||
|
|
||||||
|
|
@ -362,3 +363,8 @@ checkPragmas(BASS_DEVICEINFO, pHeaderImpBy)
|
||||||
assert GPU_Target is object
|
assert GPU_Target is object
|
||||||
testFields(GPU_Target, "w|h|x|y|z!cint|ptr cint|cstring|cchar|ptr cstring")
|
testFields(GPU_Target, "w|h|x|y|z!cint|ptr cint|cstring|cchar|ptr cstring")
|
||||||
checkPragmas(GPU_Target, pHeaderBy, istype = false)
|
checkPragmas(GPU_Target, pHeaderBy, istype = false)
|
||||||
|
|
||||||
|
# Issue #185
|
||||||
|
assert AudioCVT is object
|
||||||
|
testFields(AudioCVT, "needed!cint")
|
||||||
|
checkPragmas(AudioCVT, pHeaderBy, istype = false, "SDL_")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue