Handle (*field), ident starting w/ digit error, fix detection of plugin and toast errors

This commit is contained in:
Ganesh Viswanathan 2020-07-03 16:17:34 -05:00
commit 4d344e5807
6 changed files with 24 additions and 9 deletions

View file

@ -157,7 +157,7 @@ proc getToast(fullpaths: seq[string], recurse: bool = false, dynlib: string = ""
var
(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 =
## When the wrapper code generated by nimterop is missing certain symbols or not

View file

@ -523,7 +523,8 @@ proc newIdentDef(gState: State, name: string, node: TSNode, tname: string, tinfo
result.add pident
let
count = node[offset].getPtrCount()
# Could be parenthesized
count = node[offset].getAtom().tsNodeParent().getPtrCount(reverse = true)
if count > 0:
result.add gState.newPtrTree(count, tident)
else:

View file

@ -167,13 +167,15 @@ proc checkIdentifier(name, kind, parent, origName: string) =
if name.nBl:
let
origStr = if name != origName: &", originally '{origName}' before 'cPlugin:onSymbol()', still" else: ""
errmsg = &"Identifier '{parentStr}{name}' ({kind}){origStr} contains $1 " &
origStr = if name != origName: &", originally '{origName}' before 'cPlugin:onSymbol()'," else: ""
errmsg = &"Identifier '{parentStr}{name}' ({kind}){origStr} $1 " &
"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
#
@ -381,7 +383,8 @@ proc loadPlugin*(gState: State, sourcePath: string) =
# Compile plugin as library with `markAndSweep` GC
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
let lib = loadLib(pdll)

View file

@ -116,7 +116,7 @@ proc getXCount*(node: TSNode, ntype: string, reverse = false): int =
break
proc getPtrCount*(node: TSNode, reverse = false): int =
node.getXCount("pointer_declarator")
node.getXCount("pointer_declarator", reverse)
proc getArrayCount*(node: TSNode, reverse = false): int =
node.getXCount("array_declarator")

View file

@ -292,6 +292,9 @@ enum {
SG_MAX_TEXTUREARRAY_LAYERS = 128
};
struct parenpoin {
void (*gtk_reserved1);
};
// DUPLICATES
@ -588,6 +591,10 @@ enum {
SG_MAX_TEXTUREARRAY_LAYERS = 128
};
struct parenpoin {
void (*__gtk_reserved1);
};
#endif
#ifdef __cplusplus

View file

@ -515,4 +515,8 @@ when not defined(NOHEADER):
# #236
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