c2nim: bugfix: parsing of typedef'ed function pointers

This commit is contained in:
Araq 2011-09-28 00:41:40 +02:00
commit e9b7d5e68e
2 changed files with 8 additions and 11 deletions

View file

@ -270,7 +270,7 @@ proc mangleRules(s: string, p: TParser): string =
block mangle: block mangle:
for pattern, frmt in items(p.options.mangleRules): for pattern, frmt in items(p.options.mangleRules):
if s.match(pattern): if s.match(pattern):
result = s.replace(pattern, frmt) result = s.replacef(pattern, frmt)
break mangle break mangle
block prefixes: block prefixes:
for prefix in items(p.options.prefixes): for prefix in items(p.options.prefixes):
@ -674,21 +674,17 @@ proc addTypeDef(section, name, t: PNode) =
addSon(section, def) addSon(section, def)
proc otherTypeDef(p: var TParser, section, typ: PNode) = proc otherTypeDef(p: var TParser, section, typ: PNode) =
var name, t: PNode var name: PNode
case p.tok.xkind var t = typ
of pxParLe: if p.tok.xkind == pxStar:
t = pointer(p, t)
if p.tok.xkind == pxParLe:
# function pointer: typedef typ (*name)(); # function pointer: typedef typ (*name)();
var x = parseFunctionPointerDecl(p, typ) var x = parseFunctionPointerDecl(p, t)
name = x[0] name = x[0]
t = x[2] t = x[2]
of pxStar:
# typedef typ *b;
t = pointer(p, typ)
markTypeIdent(p, t)
name = skipIdentExport(p)
else: else:
# typedef typ name; # typedef typ name;
t = typ
markTypeIdent(p, t) markTypeIdent(p, t)
name = skipIdentExport(p) name = skipIdentExport(p)
t = parseTypeSuffix(p, t) t = parseTypeSuffix(p, t)

View file

@ -10,6 +10,7 @@ extern "C" {
#endif #endif
typedef void (*callback_t) (int rc); 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_callback_set (AW_CALLBACK c, callback_t callback );
int aw_instance_callback_set (AW_CALLBACK c, callback_t callback); int aw_instance_callback_set (AW_CALLBACK c, callback_t callback);