Skip to content

Commit dd65d8f

Browse files
Satish Kumarfacebook-github-bot
authored andcommitted
Add the hack_collections compiler option.
Summary: # What? Add the `hack_collections` compiler option. # Why? `hack_collections`, which was the implicit default in the absence of `arrays` and `no_use_hack_collections`, is now explicit. # Fixtures - Add `hack_collections` to `cmd` files. - Generated fixtures must not change. # Context `arraysets`, `no_use_hack_collections`, `stricttypes`, `array_migration`, `shape_arraykeys`, `const_collections` are all compiler options that control the generation of container fields. To make code generator simpler and easier to reason about, identify which of these can be removed/merged. The new options based on the ones that are currently in use: `legacy_arrays` replaces `no_use_hack_collections`. `hack_collections`, which was the implicit default in the absence of `arrays` and `no_use_hack_collections`, is now explicit. `arrays` will eventually become the default and cease to exist as an explicit option. # The steps The item in bold corresponds to the current diff. 1. Use new compiler options based on the ones that already exist. 1. Make arrays the default option. 1. Use the legacy arrays + hack collections logical equivalent of arrays. 1. Introduce hack collections wherever necessary. 1. Replace no use hack collections with legacy arrays. 1. Remove arraysets if arrays present. 1. Rename `no_use_hack_collections` compiler option to `legacy_arrays`. 1. **Add `hack_collections` compiler option.** 1. Remove references to the `arrays` compiler option. 1. Delete the `arrays` compiler option. Reviewed By: rmakheja Differential Revision: D67617729 fbshipit-source-id: 5101fc8c1ad54cf168ab70e5e5589922dc71c74c
1 parent 87b947a commit dd65d8f

File tree

44 files changed

+56
-56
lines changed
  • third-party/thrift/src/thrift/compiler
    • generate
    • test/fixtures
      • adapter
      • basic-annotations
      • basic-structured-annotations
      • basic
      • complex-union
      • constants
      • default_values
      • doctext
      • enums
      • exceptions
      • from_map_construct
      • hack-attributes
      • hack-const-collections
      • hack-enum-typing
      • hack-exceptions-transparent-enum
      • hack-exceptions
      • hack-mangledsvcs
      • hack-map-with-enum-key
      • hack-structs
      • hack_field_wrapper_with_collections
      • hack_module_internal
      • hack_service
      • hack_typedef
      • inject_metadata_fields
      • int_limits
      • interactions
      • namespace_from_package_without_module_name
      • namespace_from_package
      • optionals
      • params
      • php_hack_ns
      • serialization_field_order
      • shape_arraykeys
      • shape_construct
      • shape_nullable_everything
      • shapes_final
      • shapes_php_arrays
      • shapes
      • sink
      • soft-attribute
      • stream
      • terse_write
      • types

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+56
-56
lines changed

third-party/thrift/src/thrift/compiler/generate/t_hack_generator.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ class t_hack_generator : public t_concat_generator {
126126
array_migration_ = option_is_specified(options, "array_migration");
127127
arrays_ = option_is_specified(options, "arrays");
128128
legacy_arrays_ = option_is_specified(options, "legacy_arrays");
129-
// Set the future state of compiler options based on the current state.
130-
// A subsequent change will remove the current compiler options.
131-
hack_collections_ = !arrays_ && !legacy_arrays_;
129+
hack_collections_ = option_is_specified(options, "hack_collections");
132130

133131
nullable_everything_ = option_is_specified(options, "nullable_everything");
134132
const_collections_ = option_is_specified(options, "const_collections");
@@ -7622,6 +7620,7 @@ THRIFT_REGISTER_GENERATOR(
76227620
" stricttypes Use Collection classes everywhere rather than "
76237621
"KeyedContainer.\n"
76247622
" arraysets Use legacy arrays for sets rather than objects.\n"
7623+
" Either legacy_arrays or hack_collections must be present.\n"
76257624
" nonullables Instantiate struct fields within structs, rather "
76267625
"than nullable\n"
76277626
" structtrait Add 'use [StructName]Trait;' to generated classes\n"
@@ -7635,6 +7634,7 @@ THRIFT_REGISTER_GENERATOR(
76357634
" frommap_construct Generate fromMap_DEPRECATED method.\n"
76367635
" arrays Use Hack arrays for maps/lists/sets instead of "
76377636
"objects.\n"
7637+
" hack_collections Generate hack collections instead of hack arrays.\n"
76387638
" const_collections Use ConstCollection objects rather than their "
76397639
"mutable counterparts.\n"
76407640
" typedef Generate type aliases for all the types defined\n"

third-party/thrift/src/thrift/compiler/test/fixtures/adapter/cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
android: android src/module.thrift
2-
hack: hack:json,typedef,shapes=1,shapes_use_pipe_structure=1 src/module.thrift
2+
hack: hack:json,typedef,shapes=1,shapes_use_pipe_structure=1,hack_collections=1 src/module.thrift
33
java_deprecated: java_deprecated src/module.thrift
44
json: json src/module.thrift
55
cpp2: mstch_cpp2:includes=\"adapter_dependency.h\" src/module.thrift

third-party/thrift/src/thrift/compiler/test/fixtures/basic-annotations/cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
android: android src/module.thrift
22
java_deprecated: java_deprecated src/module.thrift
3-
hack: hack:json,server=1,shapes=1,shapes_allow_unknown_fields=1,shapes_use_pipe_structure=1 src/module.thrift
3+
hack: hack:json,server=1,shapes=1,shapes_allow_unknown_fields=1,shapes_use_pipe_structure=1,hack_collections=1 src/module.thrift
44
cpp2: mstch_cpp2 src/module.thrift
55
go: mstch_go src/module.thrift
66
rust: mstch_rust src/module.thrift
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
hack: hack src/module.thrift
1+
hack: hack:hack_collections=1 src/module.thrift
22
json: json:annotate src/module.thrift
33
cpp2: mstch_cpp2 src/module.thrift

third-party/thrift/src/thrift/compiler/test/fixtures/basic/cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
android: android src/module.thrift
2-
hack: hack:json,server=1,shapes=1,shapes_allow_unknown_fields=1,shapes_use_pipe_structure=1 src/module.thrift
2+
hack: hack:json,server=1,shapes=1,shapes_allow_unknown_fields=1,shapes_use_pipe_structure=1,hack_collections=1 src/module.thrift
33
java_deprecated: java_deprecated src/module.thrift
44
json: json src/module.thrift
55
json_experimental: json_experimental src/module.thrift

third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
android: android src/module.thrift
22
java_deprecated: java_deprecated src/module.thrift
3-
hack: hack:json=1,protected_unions=1 src/module.thrift
3+
hack: hack:json=1,protected_unions=1,hack_collections=1 src/module.thrift
44
cpp2: mstch_cpp2 src/module.thrift
55
go: mstch_go src/module.thrift
66
rust: mstch_rust src/module.thrift

third-party/thrift/src/thrift/compiler/test/fixtures/constants/cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
android: android src/module.thrift
22
py: py src/module.thrift
3-
hack: hack:typedef,lazy_constants=1 src/module.thrift
3+
hack: hack:typedef,lazy_constants=1,hack_collections=1 src/module.thrift
44
cpp2: mstch_cpp2 src/module.thrift
55
go: mstch_go src/module.thrift
66
rust: mstch_rust src/module.thrift
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cpp2: mstch_cpp2 src/module.thrift
22
go: mstch_go src/module.thrift
3-
hack: hack src/module.thrift
3+
hack: hack:hack_collections=1 src/module.thrift
44
py3: mstch_py3 src/module.thrift
55
python: mstch_python src/module.thrift
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
cpp2: mstch_cpp2 src/module.thrift
22
go: mstch_go src/module.thrift
33
rust: mstch_rust src/module.thrift
4-
hack: hack src/module.thrift
4+
hack: hack:hack_collections=1 src/module.thrift

third-party/thrift/src/thrift/compiler/test/fixtures/enums/cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
android: android src/module.thrift
2-
hack: hack:json,server=1,shapes=1,shapes_allow_unknown_fields=1 src/module.thrift
2+
hack: hack:json,server=1,shapes=1,shapes_allow_unknown_fields=1,hack_collections=1 src/module.thrift
33
json: json src/module.thrift
44
java_deprecated: java_deprecated src/module.thrift
55
json_experimental: json_experimental src/module.thrift

0 commit comments

Comments
 (0)