forked from duckdb/duckdb-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.py
28 lines (22 loc) · 874 Bytes
/
generator.py
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
#!/usr/bin/env python3
import header2whatever
from CppHeaderParser.CppHeaderParser import CppMethod
def function_hook(fn: CppMethod, config):
name = fn['name']
params = fn['parameters']
names = ['env'] + [f'param{i}' for i, param in enumerate(params[1:])]
return_type = fn['rtnType'].split(' ', 1)[1]
return_type = return_type.rsplit(' ', 1)[0]
fn.update(
{
'name': name,
'names': ', '.join(names),
'params': ', '.join(f'{param["type"]} {name}' for param, name in zip(params, names)),
'return_type': return_type,
'short_name': (
'_duckdb_jdbc_' + name.replace('Java_org_duckdb_DuckDBNative_duckdb_1jdbc_1', '').replace('1', '')
),
}
)
if __name__ == '__main__':
header2whatever.batch_convert('header2whatever.yaml', 'src/jni', '.')