File: update-keysyms-header

package info (click to toggle)
libwpe 1.16.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 748 kB
  • sloc: ansic: 5,890; sh: 102; cpp: 57; python: 51; makefile: 5
file content (55 lines) | stat: -rwxr-xr-x 1,703 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python

# Based on libxkbcommon script makeheader and GDK script update-keysyms-header.

import os
import re


output_file = os.path.join(os.path.dirname(__file__), '..', 'include', 'wpe', 'keysyms.h')
output = open(output_file, 'wb')

output.write('''#if !defined(__WPE_H_INSIDE__) && !defined(WPE_COMPILATION)
#error "Only <wpe/wpe.h> can be included directly."
#endif

#ifndef wpe_keysyms_h
#define wpe_keysyms_h

/* This file is autogenerated; use https://github.com/WebPlatformForEmbedded/libwpe/blob/master/scripts/update-keysyms-header to update it. */
''')

with open('/usr/include/X11/keysymdef.h') as header:
    for line in header:
        if '#ifdef' in line or '#ifndef' in line or '#endif' in line:
            continue

        output.write(re.sub(r'#define\s*XK_', '#define WPE_KEY_', line))

with open('/usr/include/X11/XF86keysym.h') as header:
    for line in header:
        if '#ifdef' in line or '#ifndef' in line or '#endif' in line:
            continue

        # Ignore XF86XK_Q
        if 'XF86XK_Q' in line:
            continue

        # XF86XK_Calculater is misspelled, and a dupe
        if 'XF86XK_Calculater' in line:
            continue

        # XF86XK_Clear and XF86XK_Select could end up a dupe of XK_Clear and XK_Select.
        if 'XF86XK_Clear' in line:
            line = re.sub(r'#define\s*XF86XK_', '#define WPE_KEY_Window', line)
        elif 'XF86XK_Select' in line:
            line = re.sub(r'#define\s*XF86XK_Select', '#define WPE_KEY_SelectButton', line)
        else:
            line = re.sub(r'#define\s*XF86XK_', '#define WPE_KEY_', line)

        output.write(line)

output.write('''#endif /* wpe_keysyms_h */
''')

output.close()