| 1 |
class SystemFunction(object): |
| 2 |
name = None |
| 3 |
|
| 4 |
@classmethod |
| 5 |
def getFunctionName(cls): |
| 6 |
return cls.name |
| 7 |
|
| 8 |
@classmethod |
| 9 |
def getMakeName(cls): |
| 10 |
return cls.name.upper() |
| 11 |
|
| 12 |
@classmethod |
| 13 |
def iterHeaders(cls, targetPlatform): |
| 14 |
raise NotImplementedError |
| 15 |
|
| 16 |
class FTruncateFunction(SystemFunction): |
| 17 |
name = 'ftruncate' |
| 18 |
|
| 19 |
@classmethod |
| 20 |
def iterHeaders(cls, targetPlatform): |
| 21 |
yield '<unistd.h>' |
| 22 |
|
| 23 |
class MMapFunction(SystemFunction): |
| 24 |
name = 'mmap' |
| 25 |
|
| 26 |
@classmethod |
| 27 |
def iterHeaders(cls, targetPlatform): |
| 28 |
if targetPlatform in ('darwin', 'openbsd'): |
| 29 |
yield '<sys/types.h>' |
| 30 |
yield '<sys/mman.h>' |
| 31 |
|
| 32 |
|
| 33 |
systemFunctions = [ |
| 34 |
obj |
| 35 |
for obj in locals().values() |
| 36 |
if isinstance(obj, type) |
| 37 |
and issubclass(obj, SystemFunction) |
| 38 |
and obj is not SystemFunction |
| 39 |
] |