waf

FORK: waf with some random patches
git clone https://git.neptards.moe/neptards/waf.git
Log | Files | Refs | README

funi.py.stpl (792B)


      1 #! /usr/bin/env python
      2 from cffi import FFI
      3 import os.path
      4 import re
      5 
      6 _ffi = FFI()
      7 
      8 pat = '%s.dll'
      9 if os.sep == '/':
     10 	pat = 'lib%s.so'
     11 
     12 _apifile = os.path.join(os.path.dirname(__file__),'funi.h')
     13 _dllname = os.path.join(os.path.split(__file__)[0], pat % 'funi')
     14 def _api():
     15     with open(_apifile) as f:
     16         api = f.readlines()
     17     rng = [i for i in range(len(api)) if re.search('extern', api[i])]
     18     apicffi = []
     19     for i in range(rng[0]+2,rng[1]-1):
     20         a = api[i]
     21         if not re.search('^#',a):
     22             a = a.replace('DLL_PUBLIC','')
     23             apicffi += [a]
     24     return apicffi
     25 
     26 _ffi.cdef('\n'.join(_api()),override=True)
     27 
     28 _dll = _ffi.dlopen(_dllname)
     29 
     30 class Func:
     31 %for i in range(maxfuni):
     32     @staticmethod
     33     def func{{i}}(a):
     34         return _dll.func{{i}}(a);
     35 %end