~ubuntu-branches/debian/stretch/adios/stretch

« back to all changes in this revision

Viewing changes to wrappers/numpy/conf/mpiregexes.py

  • Committer: Package Import Robot
  • Author(s): Alastair McKinstry
  • Date: 2014-06-16 23:06:38 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20140616230638-5a0z7ylxx8i0edrg
Tags: 1.7.0-1
* New upstream release.
* Add adios.pc pkgconfig file. adios_config now uses this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import re
 
2
 
 
3
def join(*args):
 
4
    tokens = []
 
5
    for tok in args:
 
6
        if isinstance(tok, (list, tuple)):
 
7
            tok = '(%s)' % r'\s*'.join(tok)
 
8
        tokens.append(tok)
 
9
    return r'\s*'.join(tokens)
 
10
 
 
11
lparen   = r'\('
 
12
rparen   = r'\)'
 
13
colon    = r'\:'
 
14
asterisk = r'\*'
 
15
eol      = r'$'
 
16
 
 
17
enum    = join('enum', colon)
 
18
typedef = 'ctypedef'
 
19
pointer = asterisk
 
20
struct  = join(typedef, 'struct')
 
21
 
 
22
basic_type    = r'(?:void|int|char\s*\*{1,3})'
 
23
struct_type   = r'MPI_(?:Status)'
 
24
integral_type = r'MPI_(?:Aint|Offset)'
 
25
opaque_type   = r'MPI_(?:Datatype|Request|Op|Info|Group|Errhandler|Comm|Win|File)'
 
26
any_mpi_type  = r'(?:%s|%s|%s)' % (struct_type, integral_type, opaque_type)
 
27
 
 
28
upper_name  = r'MPI_[A-Z0-9_]+'
 
29
camel_name  = r'MPI_[A-Z][a-z0-9_]+'
 
30
usrfun_name = camel_name + r'_(?:function|fn)'
 
31
 
 
32
arg_list = r'.*'
 
33
ret_type = r'void|int|double'
 
34
 
 
35
 
 
36
canylong = join(r'long', r'(?:long)?')
 
37
canyptr  = join(r'\w+', pointer+'?')
 
38
 
 
39
annotation = r'\#\:\='
 
40
defval = r'(?:%s)?' % join (annotation, [r'\(?[A-Za-z0-9_\+\-\(\)\*]+\)?'])
 
41
 
 
42
STRUCT_TYPE   = join( struct,  [struct_type] , colon,  eol)
 
43
INTEGRAL_TYPE = join( typedef, canylong, [integral_type], eol)
 
44
OPAQUE_TYPE   = join( typedef, canyptr,  [opaque_type],   eol)
 
45
FUNCTION_TYPE = join( typedef, [ret_type], [camel_name],
 
46
                      lparen, [arg_list], rparen,
 
47
                      defval, eol)
 
48
 
 
49
ENUM_VALUE     = join( enum,          [upper_name], defval, eol)
 
50
HANDLE_VALUE   = join( [opaque_type], [upper_name], defval, eol)
 
51
BASICP_VALUE   = join( [basic_type,  pointer], [upper_name], defval , eol)
 
52
STRUCTP_VALUE  = join( [struct_type, pointer], [upper_name], defval , eol)
 
53
FUNCTP_VALUE   = join( [usrfun_name, pointer], [upper_name], defval , eol)
 
54
FUNCTION_PROTO = join([ret_type], [camel_name],
 
55
                      lparen, [arg_list], rparen,
 
56
                      defval, eol)
 
57
 
 
58
fint_type = r'MPI_Fint'
 
59
c2f_name  = r'MPI_[A-Z][a-z_]+_c2f'
 
60
f2c_name  = r'MPI_[A-Z][a-z_]+_f2c'
 
61
 
 
62
FINT_TYPE    = join( typedef, canylong, [fint_type], eol)
 
63
FINTP_VALUE  = join( [fint_type, pointer], [upper_name], defval , eol)
 
64
FUNCTION_C2F = join([fint_type], [c2f_name],
 
65
                    lparen, [opaque_type], rparen,
 
66
                    defval, eol)
 
67
FUNCTION_F2C = join([opaque_type], [f2c_name],
 
68
                    lparen, [fint_type], rparen,
 
69
                    defval, eol)
 
70
 
 
71
 
 
72
# compile the RE's
 
73
glb = globals()
 
74
all = [key for key in dict(glb) if key.isupper()]
 
75
for key in all: glb[key] = re.compile(glb[key])