From 049b090e8d8e1b3346a87672c6bc4245e5807163 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 12 Nov 2018 17:38:01 +0100 Subject: [PATCH] detect cases where TORRENT_EXPORT is placed where gen_reference_doc.py ignores it, and fix the code --- docs/gen_reference_doc.py | 23 +++++++++++++++++++++++ include/libtorrent/bdecode.hpp | 2 +- include/libtorrent/magnet_uri.hpp | 4 ++-- include/libtorrent/upnp.hpp | 2 +- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/docs/gen_reference_doc.py b/docs/gen_reference_doc.py index bf4e49779..ee8ea3421 100644 --- a/docs/gen_reference_doc.py +++ b/docs/gen_reference_doc.py @@ -32,6 +32,8 @@ overviews = {} # maps names -> URL symbols = {} +global orphaned_export + # some files that need pre-processing to turn symbols into # links into the reference documentation preprocess_rst = \ @@ -243,6 +245,9 @@ def parse_function(lno, lines, filename): end_paren = 0 signature = '' + global orphaned_export + orphaned_export = False + while lno < len(lines): l = lines[lno].strip() lno += 1 @@ -309,6 +314,8 @@ def parse_class(lno, lines, filename): decl = decl.replace('TORRENT_FINAL', 'final') name = decl.split(':')[0].replace('class ', '').replace('struct ', '').replace('final', '').strip() + global orphaned_export + orphaned_export = False while lno < len(lines): l = lines[lno].strip() @@ -609,7 +616,14 @@ for filename in files: blanks = 0 lno = 0 + global orphaned_export + orphaned_export = False + while lno < len(lines): + if orphaned_export: + print('ERROR: TORRENT_EXPORT without function or class!\n%s:%d\n%s' % (filename, lno, l)) + sys.exit(1) + l = lines[lno].strip() lno += 1 @@ -618,6 +632,15 @@ for filename in files: context = '' continue + if 'TORRENT_EXPORT' in l.split() \ + and not 'ifndef TORRENT_EXPORT' in l \ + and not 'define TORRENT_DEPRECATED_EXPORT TORRENT_EXPORT' in l \ + and not 'define TORRENT_EXPORT' in l \ + and not 'for TORRENT_EXPORT' in l \ + and not 'TORRENT_EXPORT TORRENT_CFG' in l: + orphaned_export = True; + if verbose: print 'maybe orphaned: %s\n' % l + if l.startswith('//') and l[2:].strip() == 'OVERVIEW': # this is a section overview current_overview = '' diff --git a/include/libtorrent/bdecode.hpp b/include/libtorrent/bdecode.hpp index cde025663..5eeaf10b5 100644 --- a/include/libtorrent/bdecode.hpp +++ b/include/libtorrent/bdecode.hpp @@ -101,7 +101,7 @@ namespace libtorrent { TORRENT_EXPORT boost::system::error_category& bdecode_category(); #ifndef TORRENT_NO_DEPRECATED -TORRENT_DEPRECATED TORRENT_EXPORT +TORRENT_DEPRECATED_EXPORT boost::system::error_category& get_bdecode_category(); #endif diff --git a/include/libtorrent/magnet_uri.hpp b/include/libtorrent/magnet_uri.hpp index 019d8dee8..33e7668ae 100644 --- a/include/libtorrent/magnet_uri.hpp +++ b/include/libtorrent/magnet_uri.hpp @@ -77,8 +77,8 @@ namespace libtorrent // This function parses out information from the magnet link and populates the // add_torrent_params object. - TORRENT_EXPORT - void parse_magnet_uri(std::string const& uri, add_torrent_params& p, error_code& ec); + TORRENT_EXPORT void parse_magnet_uri(std::string const& uri + , add_torrent_params& p, error_code& ec); // internal, delete when merge in master TORRENT_EXTRA_EXPORT diff --git a/include/libtorrent/upnp.hpp b/include/libtorrent/upnp.hpp index b4eae7f0c..b5c908dc7 100644 --- a/include/libtorrent/upnp.hpp +++ b/include/libtorrent/upnp.hpp @@ -97,7 +97,7 @@ namespace libtorrent TORRENT_EXPORT boost::system::error_category& upnp_category(); #ifndef TORRENT_NO_DEPRECATED - TORRENT_DEPRECATED TORRENT_EXPORT + TORRENT_DEPRECATED_EXPORT boost::system::error_category& get_upnp_category(); #endif