Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions scripts/cxx-api/parser/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ def main():
type=str,
help="Directory containing committed snapshots for comparison (used with --check)",
)
parser.add_argument(
"--view",
type=str,
help="Name of the API view to generate",
)
parser.add_argument(
"--test",
action="store_true",
Expand Down Expand Up @@ -250,6 +255,9 @@ def main():
def build_snapshots(output_dir: str, verbose: bool) -> None:
if not args.test:
for config in snapshot_configs:
if args.view and config.snapshot_name != args.view:
continue

build_snapshot_for_view(
api_view=config.snapshot_name,
react_native_dir=react_native_package_dir,
Expand Down
25 changes: 22 additions & 3 deletions scripts/cxx-api/parser/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
normalize_pointer_spacing,
parse_qualified_path,
resolve_linked_text_name,
split_specialization,
)
from .utils.argument_parsing import _find_matching_angle, _split_arguments

Expand Down Expand Up @@ -124,8 +125,7 @@ def _fix_inherited_constructor_name(
return

class_unqualified_name = parse_qualified_path(compound_name)[-1]
# Strip template args for comparison
class_base_name = class_unqualified_name.split("<")[0]
class_base_name, _ = split_specialization(class_unqualified_name)

if func_member.name != class_base_name:
func_member.name = class_unqualified_name
Expand Down Expand Up @@ -249,7 +249,7 @@ def get_variable_member(
if initializer_type == InitializerType.BRACE:
is_brace_initializer = True

return VariableMember(
member = VariableMember(
variable_name,
variable_type,
visibility,
Expand All @@ -263,6 +263,10 @@ def get_variable_member(
is_brace_initializer,
)

member.add_template(get_template_params(member_def))

return member


def get_doxygen_params(
function_def: compound.MemberdefType,
Expand Down Expand Up @@ -313,6 +317,21 @@ def get_doxygen_params(
else:
param_type += param_array

# Handle pointer-to-member-function types where the name must be
# embedded inside the declarator group. Doxygen gives:
# type = "void(ns::*)() const", name = "asFoo"
# We need to produce:
# "void(ns::*asFoo)() const"
if param_name:
m = re.search(r"\([^)]*::\*\)", param_type)
if m:
# Insert name before the closing ')' of the ptr-to-member group
insert_pos = m.end() - 1
param_type = (
param_type[:insert_pos] + param_name + param_type[insert_pos:]
)
param_name = None

qualifiers, core_type = extract_qualifiers(param_type)
arguments.append((qualifiers, core_type, param_name, param_default))

Expand Down
12 changes: 11 additions & 1 deletion scripts/cxx-api/parser/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
get_variable_member,
)
from .snapshot import Snapshot
from .utils import parse_qualified_path
from .utils import has_scope_resolution_outside_angles, parse_qualified_path


def build_snapshot(xml_dir: str) -> Snapshot:
Expand Down Expand Up @@ -84,12 +84,22 @@ def build_snapshot(xml_dir: str) -> Snapshot:
for section_def in compound_object.sectiondef:
if section_def.kind == "var":
for variable_def in section_def.memberdef:
# Skip out-of-class definitions (e.g. "Strct<T>::VALUE")
if has_scope_resolution_outside_angles(
variable_def.get_name()
):
continue
is_static = variable_def.static == "yes"
namespace_scope.add_member(
get_variable_member(variable_def, "public", is_static)
)
elif section_def.kind == "func":
for function_def in section_def.memberdef:
# Skip out-of-class definitions (e.g. "Strct<T>::convert")
if has_scope_resolution_outside_angles(
function_def.get_name()
):
continue
function_static = function_def.static == "yes"

if not function_static:
Expand Down
Loading
Loading