possible_identifier = re.compile(ur"(?![0-9])\w+$", re.U).match
nice_identifier = re.compile('^[a-zA-Z0-0_]+$').match
+ansi_c_keywords = set(
+['auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do',
+ 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if',
+ 'int', 'long', 'register', 'return', 'short', 'signed', 'sizeof',
+ 'static', 'struct', 'switch', 'typedef', 'union', 'unsigned', 'void',
+ 'volatile', 'while'])
+
+def c_safe_identifier(cname):
+ # There are some C limitations on struct entry names.
+ if cname[:2] == '__' or cname in ansi_c_keywords:
+ cname = Naming.pyrex_prefix + cname
+ return cname
+
class BufferAux(object):
writable_needed = False
# Add an entry for an attribute.
if not cname:
cname = name
+ if visibility == 'private':
+ cname = c_safe_identifier(cname)
if type.is_cfunction:
type = PyrexTypes.CPtrType(type)
entry = self.declare(name, cname, type, pos, visibility)
% name)
if not cname:
cname = name
+ if visibility == 'private':
+ cname = c_safe_identifier(cname)
entry = self.declare(name, cname, type, pos, visibility)
entry.is_variable = 1
self.var_entries.append(entry)