1#!/usr/bin/env python
2#
3# extractor.py: extract function names from declarations in header files
4#
5# ====================================================================
6#    Licensed to the Apache Software Foundation (ASF) under one
7#    or more contributor license agreements.  See the NOTICE file
8#    distributed with this work for additional information
9#    regarding copyright ownership.  The ASF licenses this file
10#    to you under the Apache License, Version 2.0 (the
11#    "License"); you may not use this file except in compliance
12#    with the License.  You may obtain a copy of the License at
13#
14#      http://www.apache.org/licenses/LICENSE-2.0
15#
16#    Unless required by applicable law or agreed to in writing,
17#    software distributed under the License is distributed on an
18#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19#    KIND, either express or implied.  See the License for the
20#    specific language governing permissions and limitations
21#    under the License.
22# ====================================================================
23#
24
25import os
26import re
27
28#
29# This parses the following two types of declarations:
30#
31#    void
32#    svn_foo_bar (args)
33# or
34#    void svn_foo_bar (args)
35#
36_funcs = re.compile(r'^(?:(?:(?:\w+|\*) )+\*?)?((?:svn|apr)_[a-z_0-9]+)\s*\(', re.M)
37
38def extract_funcs(fname):
39  funcs = [ ]
40  for name in _funcs.findall(open(fname).read()):
41    if name not in _filter_names:
42      funcs.append(name)
43  return funcs
44
45_filter_names = [
46  'svn_boolean_t',  # svn_config_enumerator_t looks like (to our regex) a
47                    # function declaration for svn_boolean_t
48
49  # Not available on Windows
50  'svn_auth_get_keychain_simple_provider',
51  'svn_auth_get_keychain_ssl_client_cert_pw_provider',
52  'svn_auth_get_gnome_keyring_simple_provider',
53  'svn_auth_get_gnome_keyring_ssl_client_cert_pw_provider',
54  'svn_auth_get_kwallet_simple_provider',
55  'svn_auth_get_kwallet_ssl_client_cert_pw_provider',
56  'svn_auth_gnome_keyring_version',
57  'svn_auth_kwallet_version',
58  'svn_auth_get_gpg_agent_simple_provider',
59  'svn_auth_gpg_agent_version',
60  ]
61
62if __name__ == '__main__':
63  # run the extractor over each file mentioned
64  import sys
65  print("EXPORTS")
66  for fname in sys.argv[1:]:
67    for func in extract_funcs(fname):
68      print(func)
69    if os.path.basename(fname) == 'svn_ctype.h':
70      print('svn_ctype_table = svn_ctype_table_internal CONSTANT')
71    elif os.path.basename(fname) == 'svn_wc_private.h':
72      # svn_wc__internal_walk_children() is now internal to libsvn_wc
73      # but entries-dump.c still calls it
74      print('svn_wc__internal_walk_children')
75