Skip to content

Commit 845a879

Browse files
motiz88facebook-github-bot
authored andcommitted
Lift console method bodies out of installConsoleHandler
Summary: Changelog: [Internal] The bodies of all `console` methods are currently written as lambdas within `installConsoleHandler` but actually capture nothing meaningful from that scope. This diff rewrites them as free functions instead. To enable the "forwarding console methods" to be written as free functions, we also replace the runtime loop over `kForwardingConsoleMethods` with a compile-time equivalent using macros. (This technique is inspired by the Hermes source code, which uses it heavily for compile-time code generation.) Reviewed By: huntie Differential Revision: D56679956 fbshipit-source-id: babf368ecacb9dc426b2356a4a2091881ca1023e
1 parent 38f8b8e commit 845a879

File tree

3 files changed

+276
-249
lines changed

3 files changed

+276
-249
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
/**
9+
* `console` methods that have no behaviour other than emitting a
10+
* Runtime.consoleAPICalled message.
11+
*/
12+
13+
// console.clear
14+
FORWARDING_CONSOLE_METHOD(clear, ConsoleAPIType::kClear)
15+
// console.debug
16+
FORWARDING_CONSOLE_METHOD(debug, ConsoleAPIType::kDebug)
17+
// console.dir
18+
FORWARDING_CONSOLE_METHOD(dir, ConsoleAPIType::kDir)
19+
// console.dirxml
20+
FORWARDING_CONSOLE_METHOD(dirxml, ConsoleAPIType::kDirXML)
21+
// console.error
22+
FORWARDING_CONSOLE_METHOD(error, ConsoleAPIType::kError)
23+
// console.group
24+
FORWARDING_CONSOLE_METHOD(group, ConsoleAPIType::kStartGroup)
25+
// console.groupCollapsed
26+
FORWARDING_CONSOLE_METHOD(groupCollapsed, ConsoleAPIType::kStartGroupCollapsed)
27+
// console.groupEnd
28+
FORWARDING_CONSOLE_METHOD(groupEnd, ConsoleAPIType::kEndGroup)
29+
// console.info
30+
FORWARDING_CONSOLE_METHOD(info, ConsoleAPIType::kInfo)
31+
// console.log
32+
FORWARDING_CONSOLE_METHOD(log, ConsoleAPIType::kLog)
33+
// console.table
34+
FORWARDING_CONSOLE_METHOD(table, ConsoleAPIType::kTable)
35+
// console.trace
36+
FORWARDING_CONSOLE_METHOD(trace, ConsoleAPIType::kTrace)
37+
// console.warn
38+
FORWARDING_CONSOLE_METHOD(warn, ConsoleAPIType::kWarning)

packages/react-native/ReactCommon/jsinspector-modern/React-jsinspector.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Pod::Spec.new do |s|
3333
s.author = "Meta Platforms, Inc. and its affiliates"
3434
s.platforms = min_supported_versions
3535
s.source = source
36-
s.source_files = "*.{cpp,h}"
36+
s.source_files = "*.{cpp,h,def}"
3737
s.header_dir = 'jsinspector-modern'
3838
s.compiler_flags = folly_compiler_flags
3939
s.pod_target_xcconfig = {

0 commit comments

Comments
 (0)