diff --git a/nimterop/cimport.nim b/nimterop/cimport.nim index 114ab80..cedd903 100644 --- a/nimterop/cimport.nim +++ b/nimterop/cimport.nim @@ -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 diff --git a/nimterop/toastlib/ast2.nim b/nimterop/toastlib/ast2.nim index fb2b55f..083d4b2 100644 --- a/nimterop/toastlib/ast2.nim +++ b/nimterop/toastlib/ast2.nim @@ -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: diff --git a/nimterop/toastlib/getters.nim b/nimterop/toastlib/getters.nim index df930bb..1e70d59 100644 --- a/nimterop/toastlib/getters.nim +++ b/nimterop/toastlib/getters.nim @@ -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) diff --git a/nimterop/toastlib/tshelp.nim b/nimterop/toastlib/tshelp.nim index bbe029f..81c8d0d 100644 --- a/nimterop/toastlib/tshelp.nim +++ b/nimterop/toastlib/tshelp.nim @@ -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") diff --git a/tests/include/tast2.h b/tests/include/tast2.h index f9e0017..38c5f18 100644 --- a/tests/include/tast2.h +++ b/tests/include/tast2.h @@ -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 diff --git a/tests/tast2.nim b/tests/tast2.nim index ade5dff..17edfb0 100644 --- a/tests/tast2.nim +++ b/tests/tast2.nim @@ -515,4 +515,8 @@ when not defined(NOHEADER): # #236 assert SG_MAX_MIPMAPS is cint -assert SG_MAX_MIPMAPS == 16 \ No newline at end of file +assert SG_MAX_MIPMAPS == 16 + +assert parenpoin is object +var pp: parenpoin +assert pp.gtk_reserved1 is pointer \ No newline at end of file