Skip to content

Commit b4e8190

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
Fix handling of member function pointers in the API snapshot (#56069)
Summary: Changelog: [Internal] Fixes handling of member function pointers in the C++ Api snapshot. Differential Revision: D96279461
1 parent 3f0fae7 commit b4e8190

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

scripts/cxx-api/parser/builders.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,21 @@ def get_doxygen_params(
317317
else:
318318
param_type += param_array
319319

320+
# Handle pointer-to-member-function types where the name must be
321+
# embedded inside the declarator group. Doxygen gives:
322+
# type = "void(ns::*)() const", name = "asFoo"
323+
# We need to produce:
324+
# "void(ns::*asFoo)() const"
325+
if param_name:
326+
m = re.search(r"\([^)]*::\*\)", param_type)
327+
if m:
328+
# Insert name before the closing ')' of the ptr-to-member group
329+
insert_pos = m.end() - 1
330+
param_type = (
331+
param_type[:insert_pos] + param_name + param_type[insert_pos:]
332+
)
333+
param_name = None
334+
320335
qualifiers, core_type = extract_qualifiers(param_type)
321336
arguments.append((qualifiers, core_type, param_name, param_default))
322337

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
struct folly::dynamic {
2+
}
3+
4+
5+
template <typename R, typename... T>
6+
R test::jsArg(const folly::dynamic& arg, R(folly::dynamic::*asFoo)() const, const T &... desc);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
namespace folly {
11+
12+
struct dynamic {};
13+
14+
} // namespace folly
15+
16+
namespace test {
17+
18+
template <typename R, typename... T>
19+
R jsArg(const folly::dynamic &arg, R (folly::dynamic::*asFoo)() const, const T &...desc);
20+
21+
} // namespace test

0 commit comments

Comments
 (0)