Author: Armin Rigo <[email protected]>
Branch:
Changeset: r554:731c6223b465
Date: 2012-06-28 12:46 +0200
http://bitbucket.org/cffi/cffi/changeset/731c6223b465/
Log: Fix: RawFunctionType must not be a superclass of FunctionTypePtr, it
creates endless confusion in "isinstance(x, RawFunctionType)".
diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -144,8 +144,7 @@
self._declarations[name] = obj
def _get_type_pointer(self, type, const=False):
- if (isinstance(type, model.RawFunctionType) and
- not isinstance(type, model.FunctionPtrType)):
+ if isinstance(type, model.RawFunctionType):
return model.FunctionPtrType(type.args, type.result, type.ellipsis)
if const:
return model.ConstPointerType(type)
diff --git a/cffi/model.py b/cffi/model.py
--- a/cffi/model.py
+++ b/cffi/model.py
@@ -75,10 +75,7 @@
return ffi._backend.new_primitive_type(self.name)
-class RawFunctionType(BaseType):
- # Corresponds to a C type like 'int(int)', which is the C type of
- # a function, but not a pointer-to-function. The backend has no
- # notion of such a type; it's used temporarily by parsing.
+class BaseFunctionType(BaseType):
_attrs_ = ('args', 'result', 'ellipsis')
def __init__(self, args, result, ellipsis):
@@ -94,16 +91,22 @@
replace_with = '(%s)(%s)' % (replace_with, ', '.join(reprargs))
return self.result._get_c_name(replace_with)
+
+class RawFunctionType(BaseFunctionType):
+ # Corresponds to a C type like 'int(int)', which is the C type of
+ # a function, but not a pointer-to-function. The backend has no
+ # notion of such a type; it's used temporarily by parsing.
+
def prepare_backend_type(self, ffi):
from . import api
raise api.CDefError("cannot render the type %r: it is a function "
"type, not a pointer-to-function type" % (self,))
-class FunctionPtrType(RawFunctionType):
+class FunctionPtrType(BaseFunctionType):
def _get_c_name(self, replace_with):
- return RawFunctionType._get_c_name(self, '*'+replace_with)
+ return BaseFunctionType._get_c_name(self, '*'+replace_with)
def prepare_backend_type(self, ffi):
args = [ffi._get_cached_btype(self.result)]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit