Author: Alex Stapleton <[email protected]>
Branch: cmacros
Changeset: r2233:a9930603a424
Date: 2015-07-25 14:50 +0100
http://bitbucket.org/cffi/cffi/changeset/a9930603a424/
Log: #if defined() now works for unprotected functions too
diff --git a/cffi/recompiler.py b/cffi/recompiler.py
--- a/cffi/recompiler.py
+++ b/cffi/recompiler.py
@@ -17,11 +17,14 @@
self._child = child
def as_c_expr(self):
- return """\
- #if {0}
- {1}
- #endif
- """.format(self._ifdef, self._child.as_c_expr())
+ if self._ifdef:
+ return """\
+ #if {0}
+ {1}
+ #endif
+ """.format(self._ifdef, self._child.as_c_expr())
+ else:
+ return self._child.as_c_expr()
class GlobalExpr:
def __init__(self, name, address, type_op, size=0, check_value=0):
@@ -615,7 +618,8 @@
else:
argname = 'args'
- prnt('#if {0}'.format(ifdef))
+ if ifdef:
+ prnt('#if {0}'.format(ifdef))
#
# ------------------------------
@@ -745,7 +749,10 @@
prnt('# define _cffi_f_%s _cffi_d_%s' % (name, name))
#
prnt('#endif') # ------------------------------
- prnt('#endif')
+
+ if ifdef:
+ prnt('#endif')
+
prnt()
def _generate_cpy_function_ctx(self, tp, name, ifdef):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit