Skip to content
Closed
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
30 changes: 14 additions & 16 deletions scripts/cxx-api/parser/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,20 @@ def build_snapshots(
failed_views = ", ".join(name for name, _ in errors)
raise RuntimeError(f"Failed to generate snapshots: {failed_views}")
else:
with tempfile.TemporaryDirectory(prefix="cxx-api-test-") as work_dir:
snapshot = build_snapshot_for_view(
api_view="Test",
react_native_dir=react_native_dir,
include_directories=[],
exclude_patterns=[],
definitions={},
output_dir=output_dir,
codegen_platform=None,
verbose=verbose,
input_filter=input_filter,
work_dir=work_dir,
)

if verbose:
print(snapshot)
snapshot = build_snapshot_for_view(
api_view="Test",
react_native_dir=react_native_dir,
include_directories=[],
exclude_patterns=[],
definitions={},
output_dir=output_dir,
codegen_platform=None,
verbose=verbose,
input_filter=input_filter,
)

if verbose:
print(snapshot)


def get_default_snapshot_dir() -> str:
Expand Down
2 changes: 2 additions & 0 deletions scripts/cxx-api/parser/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ def get_doxygen_params(
+ param_array
)
param_name = None
elif param_name:
param_name += param_array
else:
param_type += param_array

Expand Down
2 changes: 2 additions & 0 deletions scripts/cxx-api/parser/member/variable_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def to_string(
result += f"{qualified_type} (*{name})({formatted_args})"
else:
result += f"{format_parsed_type(self._parsed_type)} {name}"
if self.argstring:
result += self.argstring

if STORE_INITIALIZERS_IN_SNAPSHOT and self.value is not None:
if self.is_brace_initializer:
Expand Down
5 changes: 5 additions & 0 deletions scripts/cxx-api/parser/scope/base_scope_kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ def _format_scope_body(self, scope: Scope, member_suffix: str = "") -> str:
stringified_members = [
member.to_string(2) + member_suffix for member in scope.get_members()
]

stringified_members = natsorted(stringified_members)
# Deduplicate members that produce identical signatures (e.g.
# constructors inherited from multiple bases).
stringified_members = list(dict.fromkeys(stringified_members))

result = "{"
if stringified_members:
result += "\n" + "\n".join(stringified_members)
Expand Down
2 changes: 2 additions & 0 deletions scripts/cxx-api/parser/scope/namespace_scope_kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def to_string(self, scope: Scope) -> str:
result = []
for kind in MemberKind:
sorted_group = natsorted(groups[kind])
# Deduplicate members with identical signatures.
sorted_group = list(dict.fromkeys(sorted_group))
result.extend(sorted_group)

return "\n".join(result)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
void test::arrayParam(const char name[]);
void test::arrayParamSized(int values[10]);
void test::arrayParamUnnamed(const char[]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#pragma once

namespace test {

void arrayParam(const char name[]);
void arrayParamSized(int values[10]);
void arrayParamUnnamed(const char[]);

} // namespace test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const char test::ViewComponentName[];
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#pragma once

namespace test {

const char ViewComponentName[] = "View";

} // namespace test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class test::BaseTextShadowNode : public test::ShadowNode {
public BaseTextShadowNode(const test::ShadowNode& source, const test::ShadowNode::Fragment& fragment);
public BaseTextShadowNode(const test::ShadowNode::Fragment& fragment, const test::ShadowNode::Shared& family, test::ShadowNode::Traits traits);
}

class test::ConcreteViewShadowNode : public test::ShadowNode {
public ConcreteViewShadowNode(const test::ShadowNode& source, const test::ShadowNode::Fragment& fragment);
public ConcreteViewShadowNode(const test::ShadowNode::Fragment& fragment, const test::ShadowNode::Shared& family, test::ShadowNode::Traits traits);
}

class test::ParagraphShadowNode : public test::ConcreteViewShadowNode, public test::BaseTextShadowNode {
public ParagraphShadowNode(const test::ShadowNode& source, const test::ShadowNode::Fragment& fragment);
public ParagraphShadowNode(const test::ShadowNode::Fragment& fragment, const test::ShadowNode::Shared& family, test::ShadowNode::Traits traits);
}

class test::ShadowNode {
}

enum test::ShadowNode::Traits {
None,
}

struct test::ShadowNode::Fragment {
}

struct test::ShadowNode::Shared {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#pragma once

namespace test {

class ShadowNode {
public:
struct Fragment {};
struct Shared {};
enum class Traits { None };
};

class ConcreteViewShadowNode : public ShadowNode {
public:
ConcreteViewShadowNode(const ShadowNode &source, const Fragment &fragment);
ConcreteViewShadowNode(const Fragment &fragment, const Shared &family, Traits traits);
};

class BaseTextShadowNode : public ShadowNode {
public:
BaseTextShadowNode(const ShadowNode &source, const Fragment &fragment);
BaseTextShadowNode(const Fragment &fragment, const Shared &family, Traits traits);
};

class ParagraphShadowNode : public ConcreteViewShadowNode, public BaseTextShadowNode {
public:
using BaseTextShadowNode::BaseTextShadowNode;
using ConcreteViewShadowNode::ConcreteViewShadowNode;
};

} // namespace test
Loading