1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- class SystemFunction(object):
- name = None
- @classmethod
- def getFunctionName(cls):
- return cls.name
- @classmethod
- def getMakeName(cls):
- return cls.name.upper()
- @classmethod
- def iterHeaders(cls, targetPlatform):
- raise NotImplementedError
- class FTruncateFunction(SystemFunction):
- name = 'ftruncate'
- @classmethod
- def iterHeaders(cls, targetPlatform):
- yield '<unistd.h>'
- class MMapFunction(SystemFunction):
- name = 'mmap'
- @classmethod
- def iterHeaders(cls, targetPlatform):
- if targetPlatform in ('darwin', 'openbsd'):
- yield '<sys/types.h>'
- yield '<sys/mman.h>'
- class PosixMemAlignFunction(SystemFunction):
- name = 'posix_memalign'
- @classmethod
- def iterHeaders(cls, targetPlatform):
- yield '<stdlib.h>'
- class NftwFunction(SystemFunction):
- name = 'nftw'
- @classmethod
- def iterHeaders(cls, targetPlatform):
- yield '<ftw.h>'
- # Build a list of system functions using introspection.
- def _discoverSystemFunctions(localObjects):
- for obj in localObjects:
- if isinstance(obj, type) and issubclass(obj, SystemFunction):
- if obj is not SystemFunction:
- yield obj
- systemFunctions = list(_discoverSystemFunctions(locals().itervalues()))
|