Skip to content

Commit

Permalink
add unicode constant
Browse files Browse the repository at this point in the history
Summary: Add a couple consts to fixture to highlight behavior for unicode `const` strings, which is currently incorrect for thrift-python.

Reviewed By: yoney

Differential Revision: D68361202

fbshipit-source-id: 1288a2c71d63e3a469d5cab8a64f632de23e0534
  • Loading branch information
ahilger authored and facebook-github-bot committed Jan 18, 2025
1 parent f30d20a commit 13a122b
Show file tree
Hide file tree
Showing 20 changed files with 286 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,13 @@ public class Constants {
escaped_strings.add("zzz¦yyy");
}

public static final List<String> unicode_list = new ArrayList<String>();
static {
unicode_list.add("Bulgaria");
unicode_list.add("Benin");
unicode_list.add("Saint Barthélemy");
}

public static final Boolean false_c = false;

public static final Boolean true_c = true;
Expand Down Expand Up @@ -382,6 +389,13 @@ public class Constants {
static {
}

public static final Map<String,String> unicode_map = new HashMap<String,String>();
static {
unicode_map.put("BG", "Bulgaria");
unicode_map.put("BH", "Bahrain");
unicode_map.put("BÉ", "Saint Barthélemy");
}

public static final Long maxIntDec = 9223372036854775807L;

public static final Long maxIntOct = 9223372036854775807L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ ::std::vector<::std::string> const& escaped_strings() {
return *instance;
}

::std::vector<::std::string> const& unicode_list() {
static folly::Indestructible<::std::vector<::std::string>> const instance{ std::initializer_list<::std::string>{ apache::thrift::StringTraits<std::string>::fromStringLiteral("Bulgaria"),
apache::thrift::StringTraits<std::string>::fromStringLiteral("Benin"),
apache::thrift::StringTraits<std::string>::fromStringLiteral("Saint Barth\303\251lemy") } };
return *instance;
}




Expand Down Expand Up @@ -261,6 +268,13 @@ ::std::map<::std::string, ::std::string> const& empty_string_string_map() {
return *instance;
}

::std::map<::std::string, ::std::string> const& unicode_map() {
static folly::Indestructible<::std::map<::std::string, ::std::string>> const instance{ std::initializer_list<::std::map<::std::string, ::std::string>::value_type>{ { apache::thrift::StringTraits<std::string>::fromStringLiteral("BG"), apache::thrift::StringTraits<std::string>::fromStringLiteral("Bulgaria") },
{ apache::thrift::StringTraits<std::string>::fromStringLiteral("BH"), apache::thrift::StringTraits<std::string>::fromStringLiteral("Bahrain") },
{ apache::thrift::StringTraits<std::string>::fromStringLiteral("B\303\211"), apache::thrift::StringTraits<std::string>::fromStringLiteral("Saint Barth\303\251lemy") } } };
return *instance;
}




Expand Down Expand Up @@ -296,10 +310,10 @@ ::std::map<::std::int32_t, bool> const& I2B_REF() {
}


::std::string_view _fbthrift_schema_600be8feae51e639() {
::std::string_view _fbthrift_schema_15f49ce5899b4ce6() {
return "";
}
::folly::Range<const ::std::string_view*> _fbthrift_schema_600be8feae51e639_includes() {
::folly::Range<const ::std::string_view*> _fbthrift_schema_15f49ce5899b4ce6_includes() {
return {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ namespace module_constants {
/** Glean {"constant": "escaped_strings"} */
::std::vector<::std::string> const& escaped_strings();

/** Glean {"constant": "unicode_list"} */
::std::vector<::std::string> const& unicode_list();

/** Glean {"constant": "false_c"} */
constexpr bool const false_c_ = false;
/** Glean {"constant": "false_c"} */
Expand Down Expand Up @@ -297,6 +300,9 @@ namespace module_constants {
/** Glean {"constant": "empty_string_string_map"} */
::std::map<::std::string, ::std::string> const& empty_string_string_map();

/** Glean {"constant": "unicode_map"} */
::std::map<::std::string, ::std::string> const& unicode_map();

/** Glean {"constant": "maxIntDec"} */
constexpr ::std::int64_t const maxIntDec_ = static_cast<::std::int64_t>(9223372036854775807);
/** Glean {"constant": "maxIntDec"} */
Expand Down Expand Up @@ -450,8 +456,8 @@ namespace module_constants {
/** Glean {"constant": "I2B_REF"} */
::std::map<::std::int32_t, bool> const& I2B_REF();

FOLLY_EXPORT ::std::string_view _fbthrift_schema_600be8feae51e639();
FOLLY_EXPORT ::folly::Range<const ::std::string_view*> _fbthrift_schema_600be8feae51e639_includes();
FOLLY_EXPORT ::std::string_view _fbthrift_schema_15f49ce5899b4ce6();
FOLLY_EXPORT ::folly::Range<const ::std::string_view*> _fbthrift_schema_15f49ce5899b4ce6_includes();

} // namespace module_constants
} // namespace cpp2
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,19 @@ public static function escaped_strings()[write_props]: \ConstVector<string>{
};
}

/**
* Original thrift constant:-
* list<string> unicode_list
*/
<<__Memoize>>
public static function unicode_list()[write_props]: \ConstVector<string>{
return ImmVector {
"Bulgaria",
"Benin",
"Saint Barth\303\251lemy",
};
}

/**
* Original thrift constant:-
* bool false_c
Expand Down Expand Up @@ -739,6 +752,19 @@ public static function empty_string_string_map()[write_props]: \ConstMap<string,
};
}

/**
* Original thrift constant:-
* map<string, string> unicode_map
*/
<<__Memoize>>
public static function unicode_map()[write_props]: \ConstMap<string, string>{
return ImmMap {
"BG" => "Bulgaria",
"BH" => "Bahrain",
"B\303\211" => "Saint Barth\303\251lemy",
};
}

/**
* Original thrift constant:-
* i64 maxIntDec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,16 @@ private static List<String> construct_ESCAPED_STRINGS() {
.build();
}

public static final List<String> UNICODE_LIST = construct_UNICODE_LIST();

private static List<String> construct_UNICODE_LIST() {
return ImmutableList.<String>builder()
.add("Bulgaria")
.add("Benin")
.add("Saint Barthélemy")
.build();
}

public static final boolean FALSE_C = false;

public static final boolean TRUE_C = true;
Expand Down Expand Up @@ -364,6 +374,16 @@ private static Map<String, String> construct_EMPTY_STRING_STRING_MAP() {
.build();
}

public static final Map<String, String> UNICODE_MAP = construct_UNICODE_MAP();

private static Map<String, String> construct_UNICODE_MAP() {
return ImmutableMap.<String, String>builder()
.put("BG", "Bulgaria")
.put("BH", "Bahrain")
.put("BÉ", "Saint Barthélemy")
.build();
}

public static final long MAX_INT_DEC = 9223372036854775807L;

public static final long MAX_INT_OCT = 9223372036854775807L;
Expand Down
Loading

0 comments on commit 13a122b

Please sign in to comment.