Handle (*field), ident starting w/ digit error, fix detection of plugin and toast errors
This commit is contained in:
parent
1ad32e4574
commit
4d344e5807
6 changed files with 24 additions and 9 deletions
|
|
@ -157,7 +157,7 @@ proc getToast(fullpaths: seq[string], recurse: bool = false, dynlib: string = ""
|
||||||
|
|
||||||
var
|
var
|
||||||
(output, ret) = execAction(cmd, die = false)
|
(output, ret) = execAction(cmd, die = false)
|
||||||
doAssert ret == 0, result.readFile() & output
|
doAssert ret == 0, "\n\n" & (if result.fileExists(): result.readFile() else: "") & output
|
||||||
|
|
||||||
macro cOverride*(body): untyped =
|
macro cOverride*(body): untyped =
|
||||||
## When the wrapper code generated by nimterop is missing certain symbols or not
|
## When the wrapper code generated by nimterop is missing certain symbols or not
|
||||||
|
|
|
||||||
|
|
@ -523,7 +523,8 @@ proc newIdentDef(gState: State, name: string, node: TSNode, tname: string, tinfo
|
||||||
result.add pident
|
result.add pident
|
||||||
|
|
||||||
let
|
let
|
||||||
count = node[offset].getPtrCount()
|
# Could be parenthesized
|
||||||
|
count = node[offset].getAtom().tsNodeParent().getPtrCount(reverse = true)
|
||||||
if count > 0:
|
if count > 0:
|
||||||
result.add gState.newPtrTree(count, tident)
|
result.add gState.newPtrTree(count, tident)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -167,13 +167,15 @@ proc checkIdentifier(name, kind, parent, origName: string) =
|
||||||
|
|
||||||
if name.nBl:
|
if name.nBl:
|
||||||
let
|
let
|
||||||
origStr = if name != origName: &", originally '{origName}' before 'cPlugin:onSymbol()', still" else: ""
|
origStr = if name != origName: &", originally '{origName}' before 'cPlugin:onSymbol()'," else: ""
|
||||||
errmsg = &"Identifier '{parentStr}{name}' ({kind}){origStr} contains $1 " &
|
errmsg = &"Identifier '{parentStr}{name}' ({kind}){origStr} $1 " &
|
||||||
"which Nim does not allow. Use toast flag '$2' or 'cPlugin()' to modify."
|
"which Nim does not allow. Use toast flag '$2' or 'cPlugin()' to modify."
|
||||||
|
|
||||||
doAssert name[0] != '_' and name[^1] != '_', errmsg % ["leading/trailing underscores '_'", "--prefix or --suffix"]
|
doAssert name[0] != '_' and name[^1] != '_', errmsg % ["has leading/trailing underscores '_'", "--prefix or --suffix"]
|
||||||
|
|
||||||
doAssert (not name.contains("__")): errmsg % ["consecutive underscores '_'", "--replace"]
|
doAssert (not name.contains("__")): errmsg % ["has consecutive underscores '_'", "--replace"]
|
||||||
|
|
||||||
|
doAssert not name[0].isDigit(), errmsg % [&"starts with a digit '{name[0]}'", "--prefix"]
|
||||||
|
|
||||||
# Cannot blank out symbols which are fields or params
|
# Cannot blank out symbols which are fields or params
|
||||||
#
|
#
|
||||||
|
|
@ -381,7 +383,8 @@ proc loadPlugin*(gState: State, sourcePath: string) =
|
||||||
# Compile plugin as library with `markAndSweep` GC
|
# Compile plugin as library with `markAndSweep` GC
|
||||||
cmd = &"{gState.nim} c --app:lib --gc:markAndSweep {flags} {outflags} {sourcePath.sanitizePath}"
|
cmd = &"{gState.nim} c --app:lib --gc:markAndSweep {flags} {outflags} {sourcePath.sanitizePath}"
|
||||||
|
|
||||||
discard execAction(cmd)
|
(output, ret) = execAction(cmd, die = false)
|
||||||
|
doAssert ret == 0, output & "\nFailed to compile cPlugin()\n\ncmd: " & cmd
|
||||||
doAssert fileExists(pdll), "No plugin binary generated for " & sourcePath
|
doAssert fileExists(pdll), "No plugin binary generated for " & sourcePath
|
||||||
|
|
||||||
let lib = loadLib(pdll)
|
let lib = loadLib(pdll)
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ proc getXCount*(node: TSNode, ntype: string, reverse = false): int =
|
||||||
break
|
break
|
||||||
|
|
||||||
proc getPtrCount*(node: TSNode, reverse = false): int =
|
proc getPtrCount*(node: TSNode, reverse = false): int =
|
||||||
node.getXCount("pointer_declarator")
|
node.getXCount("pointer_declarator", reverse)
|
||||||
|
|
||||||
proc getArrayCount*(node: TSNode, reverse = false): int =
|
proc getArrayCount*(node: TSNode, reverse = false): int =
|
||||||
node.getXCount("array_declarator")
|
node.getXCount("array_declarator")
|
||||||
|
|
|
||||||
|
|
@ -292,6 +292,9 @@ enum {
|
||||||
SG_MAX_TEXTUREARRAY_LAYERS = 128
|
SG_MAX_TEXTUREARRAY_LAYERS = 128
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct parenpoin {
|
||||||
|
void (*gtk_reserved1);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// DUPLICATES
|
// DUPLICATES
|
||||||
|
|
@ -588,6 +591,10 @@ enum {
|
||||||
SG_MAX_TEXTUREARRAY_LAYERS = 128
|
SG_MAX_TEXTUREARRAY_LAYERS = 128
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct parenpoin {
|
||||||
|
void (*__gtk_reserved1);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -516,3 +516,7 @@ when not defined(NOHEADER):
|
||||||
# #236
|
# #236
|
||||||
assert SG_MAX_MIPMAPS is cint
|
assert SG_MAX_MIPMAPS is cint
|
||||||
assert SG_MAX_MIPMAPS == 16
|
assert SG_MAX_MIPMAPS == 16
|
||||||
|
|
||||||
|
assert parenpoin is object
|
||||||
|
var pp: parenpoin
|
||||||
|
assert pp.gtk_reserved1 is pointer
|
||||||
Loading…
Add table
Add a link
Reference in a new issue