diff options
author | Araq <rumpf_a@web.de> | 2011-09-28 00:41:40 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-09-28 00:41:40 +0200 |
commit | e9b7d5e68eeeb6d468d407437502fd1c178adc43 (patch) | |
tree | 0ce6957a7dc01b89c86f68e51c49abc857ad9d42 | |
parent | da6046dcba20cb4aaff1e5712ac7a33a3c4e8445 (diff) | |
download | Nim-e9b7d5e68eeeb6d468d407437502fd1c178adc43.tar.gz |
c2nim: bugfix: parsing of typedef'ed function pointers
-rwxr-xr-x | compiler/c2nim/cparse.nim | 18 | ||||
-rwxr-xr-x | compiler/c2nim/tests/systest.c | 1 |
2 files changed, 8 insertions, 11 deletions
diff --git a/compiler/c2nim/cparse.nim b/compiler/c2nim/cparse.nim index 438d3755f..f8f58347d 100755 --- a/compiler/c2nim/cparse.nim +++ b/compiler/c2nim/cparse.nim @@ -270,7 +270,7 @@ proc mangleRules(s: string, p: TParser): string = block mangle: for pattern, frmt in items(p.options.mangleRules): if s.match(pattern): - result = s.replace(pattern, frmt) + result = s.replacef(pattern, frmt) break mangle block prefixes: for prefix in items(p.options.prefixes): @@ -674,21 +674,17 @@ proc addTypeDef(section, name, t: PNode) = addSon(section, def) proc otherTypeDef(p: var TParser, section, typ: PNode) = - var name, t: PNode - case p.tok.xkind - of pxParLe: + var name: PNode + var t = typ + if p.tok.xkind == pxStar: + t = pointer(p, t) + if p.tok.xkind == pxParLe: # function pointer: typedef typ (*name)(); - var x = parseFunctionPointerDecl(p, typ) + var x = parseFunctionPointerDecl(p, t) name = x[0] t = x[2] - of pxStar: - # typedef typ *b; - t = pointer(p, typ) - markTypeIdent(p, t) - name = skipIdentExport(p) else: # typedef typ name; - t = typ markTypeIdent(p, t) name = skipIdentExport(p) t = parseTypeSuffix(p, t) diff --git a/compiler/c2nim/tests/systest.c b/compiler/c2nim/tests/systest.c index 4ba1d9044..d1fbb6784 100755 --- a/compiler/c2nim/tests/systest.c +++ b/compiler/c2nim/tests/systest.c @@ -10,6 +10,7 @@ extern "C" { #endif typedef void (*callback_t) (int rc); +typedef const char* (*callback2)(int rc, long L, const char* buffer); int aw_callback_set (AW_CALLBACK c, callback_t callback ); int aw_instance_callback_set (AW_CALLBACK c, callback_t callback); |