Commit db959361 authored by yzshen's avatar yzshen Committed by Commit bot

Mojo C++ bindings: remove support for generating code with mojo::Array/String/Map/WTFArray/WTFMap.

BUG=624136

Review-Url: https://codereview.chromium.org/2584763002
Cr-Commit-Position: refs/heads/master@{#438992}
parent 15a7ab4d
...@@ -1542,32 +1542,6 @@ def _CheckIpcOwners(input_api, output_api): ...@@ -1542,32 +1542,6 @@ def _CheckIpcOwners(input_api, output_api):
return results return results
def _CheckMojoUsesNewWrapperTypes(input_api, output_api):
"""Checks to make sure that all newly added mojom targets map array/map/string
to STL (for chromium) or WTF (for blink) types.
TODO(yzshen): remove this check once crbug.com/624136 is completed.
"""
files = []
pattern = input_api.re.compile(r'use_new_wrapper_types.*false',
input_api.re.MULTILINE)
for f in input_api.AffectedFiles():
if not f.LocalPath().endswith(('.gyp', '.gypi', 'gn', 'gni')):
continue
for _, line in f.ChangedContents():
if pattern.search(line):
files.append(f)
break
if len(files):
return [output_api.PresubmitError(
'Do not introduce new mojom targets with use_new_wrapper_types set to '
'false. The mode is deprecated and will be removed soon.',
files)]
return []
def _CheckUselessForwardDeclarations(input_api, output_api): def _CheckUselessForwardDeclarations(input_api, output_api):
"""Checks that added or removed lines in non third party affected """Checks that added or removed lines in non third party affected
header files do not lead to new useless class or struct forward header files do not lead to new useless class or struct forward
...@@ -2084,7 +2058,6 @@ def _CommonChecks(input_api, output_api): ...@@ -2084,7 +2058,6 @@ def _CommonChecks(input_api, output_api):
results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) results.extend(_CheckPydepsNeedsUpdating(input_api, output_api))
results.extend(_CheckJavaStyle(input_api, output_api)) results.extend(_CheckJavaStyle(input_api, output_api))
results.extend(_CheckIpcOwners(input_api, output_api)) results.extend(_CheckIpcOwners(input_api, output_api))
results.extend(_CheckMojoUsesNewWrapperTypes(input_api, output_api))
results.extend(_CheckUselessForwardDeclarations(input_api, output_api)) results.extend(_CheckUselessForwardDeclarations(input_api, output_api))
results.extend(_CheckForRiskyJsFeatures(input_api, output_api)) results.extend(_CheckForRiskyJsFeatures(input_api, output_api))
......
...@@ -55,7 +55,7 @@ class {{export_attribute}} {{interface.name}} ...@@ -55,7 +55,7 @@ class {{export_attribute}} {{interface.name}}
{%- endif %} {%- endif %}
using {{method.name}}Callback = {{interface_macros.declare_callback(method, using {{method.name}}Callback = {{interface_macros.declare_callback(method,
for_blink, use_new_wrapper_types, use_once_callback)}}; for_blink, use_once_callback)}};
{%- endif %} {%- endif %}
virtual void {{method.name}}({{interface_macros.declare_request_params("", method, use_once_callback)}}) = 0; virtual void {{method.name}}({{interface_macros.declare_request_params("", method, use_once_callback)}}) = 0;
{%- endfor %} {%- endfor %}
......
...@@ -269,8 +269,7 @@ class {{class_name}}_{{method.name}}_ProxyToResponder { ...@@ -269,8 +269,7 @@ class {{class_name}}_{{method.name}}_ProxyToResponder {
void Run( void Run(
{{interface_macros.declare_responder_params( {{interface_macros.declare_responder_params(
"in_", method.response_parameters, for_blink, "in_", method.response_parameters, for_blink)}});
use_new_wrapper_types)}});
uint64_t request_id_; uint64_t request_id_;
bool is_sync_; bool is_sync_;
...@@ -283,8 +282,7 @@ class {{class_name}}_{{method.name}}_ProxyToResponder { ...@@ -283,8 +282,7 @@ class {{class_name}}_{{method.name}}_ProxyToResponder {
void {{class_name}}_{{method.name}}_ProxyToResponder::Run( void {{class_name}}_{{method.name}}_ProxyToResponder::Run(
{{interface_macros.declare_responder_params( {{interface_macros.declare_responder_params(
"in_", method.response_parameters, for_blink, "in_", method.response_parameters, for_blink)}}) {
use_new_wrapper_types)}}) {
{{struct_macros.get_serialized_size(response_params_struct, "in_%s", {{struct_macros.get_serialized_size(response_params_struct, "in_%s",
"&serialization_context_")}} "&serialization_context_")}}
mojo::internal::ResponseMessageBuilder builder( mojo::internal::ResponseMessageBuilder builder(
......
...@@ -5,33 +5,21 @@ ...@@ -5,33 +5,21 @@
{%- endfor %} {%- endfor %}
{%- endmacro %} {%- endmacro %}
{%- macro declare_responder_params(prefix, parameters, for_blink, use_new_wrapper_types) %} {%- macro declare_responder_params(prefix, parameters, for_blink) %}
{%- for param in parameters -%} {%- for param in parameters -%}
{%- if (not param.kind|is_string_kind) or for_blink or
use_new_wrapper_types -%}
{{param.kind|cpp_wrapper_param_type}} {{prefix}}{{param.name}} {{param.kind|cpp_wrapper_param_type}} {{prefix}}{{param.name}}
{%- else %}
mojo::String {{prefix}}{{param.name}}
{%- endif %}
{%- if not loop.last %}, {% endif %} {%- if not loop.last %}, {% endif %}
{%- endfor %} {%- endfor %}
{%- endmacro %} {%- endmacro %}
{%- macro declare_callback(method, for_blink, use_new_wrapper_types, use_once_callback) -%} {%- macro declare_callback(method, for_blink, use_once_callback) -%}
{%- if use_once_callback -%} {%- if use_once_callback -%}
base::OnceCallback<void( base::OnceCallback<void(
{%- else -%} {%- else -%}
base::Callback<void( base::Callback<void(
{%- endif -%} {%- endif -%}
{%- for param in method.response_parameters -%} {%- for param in method.response_parameters -%}
{#- TODO(yzshen): For historical reasons, we use mojo::String here (instead of
const mojo::String&) inconsistently. Preserve the behavior temporarily. #}
{%- if (not param.kind|is_string_kind) or for_blink or
use_new_wrapper_types -%}
{{param.kind|cpp_wrapper_param_type}} {{param.kind|cpp_wrapper_param_type}}
{%- else -%}
mojo::String
{%- endif %}
{%- if not loop.last %}, {% endif %} {%- if not loop.last %}, {% endif %}
{%- endfor -%} {%- endfor -%}
)> )>
......
...@@ -36,7 +36,6 @@ _kind_to_cpp_literal_suffix = { ...@@ -36,7 +36,6 @@ _kind_to_cpp_literal_suffix = {
# generator library code so that filters can use the generator as context. # generator library code so that filters can use the generator as context.
_current_typemap = {} _current_typemap = {}
_for_blink = False _for_blink = False
_use_new_wrapper_types = False
# TODO(rockot, yzshen): The variant handling is kind of a hack currently. Make # TODO(rockot, yzshen): The variant handling is kind of a hack currently. Make
# it right. # it right.
_variant = None _variant = None
...@@ -142,11 +141,6 @@ def DefaultValue(field): ...@@ -142,11 +141,6 @@ def DefaultValue(field):
if not IsTypemappedKind(field.kind): if not IsTypemappedKind(field.kind):
return "%s::New()" % GetNameForKind(field.kind) return "%s::New()" % GetNameForKind(field.kind)
return ExpressionToText(field.default, kind=field.kind) return ExpressionToText(field.default, kind=field.kind)
if not _use_new_wrapper_types:
if mojom.IsArrayKind(field.kind) or mojom.IsMapKind(field.kind):
return "nullptr";
if mojom.IsStringKind(field.kind):
return "" if _for_blink else "nullptr"
return "" return ""
def NamespaceToArray(namespace): def NamespaceToArray(namespace):
...@@ -245,24 +239,16 @@ def GetCppWrapperType(kind, add_same_module_namespaces=False): ...@@ -245,24 +239,16 @@ def GetCppWrapperType(kind, add_same_module_namespaces=False):
return "%sPtr" % GetNameForKind( return "%sPtr" % GetNameForKind(
kind, add_same_module_namespaces=add_same_module_namespaces) kind, add_same_module_namespaces=add_same_module_namespaces)
if mojom.IsArrayKind(kind): if mojom.IsArrayKind(kind):
pattern = None
if _use_new_wrapper_types:
pattern = "WTF::Vector<%s>" if _for_blink else "std::vector<%s>" pattern = "WTF::Vector<%s>" if _for_blink else "std::vector<%s>"
if mojom.IsNullableKind(kind): if mojom.IsNullableKind(kind):
pattern = _AddOptional(pattern) pattern = _AddOptional(pattern)
else:
pattern = "mojo::WTFArray<%s>" if _for_blink else "mojo::Array<%s>"
return pattern % GetCppWrapperType( return pattern % GetCppWrapperType(
kind.kind, add_same_module_namespaces=add_same_module_namespaces) kind.kind, add_same_module_namespaces=add_same_module_namespaces)
if mojom.IsMapKind(kind): if mojom.IsMapKind(kind):
pattern = None
if _use_new_wrapper_types:
pattern = ("WTF::HashMap<%s, %s>" if _for_blink else pattern = ("WTF::HashMap<%s, %s>" if _for_blink else
"std::unordered_map<%s, %s>") "std::unordered_map<%s, %s>")
if mojom.IsNullableKind(kind): if mojom.IsNullableKind(kind):
pattern = _AddOptional(pattern) pattern = _AddOptional(pattern)
else:
pattern = "mojo::WTFMap<%s, %s>" if _for_blink else "mojo::Map<%s, %s>"
return pattern % ( return pattern % (
GetCppWrapperType( GetCppWrapperType(
kind.key_kind, kind.key_kind,
...@@ -285,8 +271,6 @@ def GetCppWrapperType(kind, add_same_module_namespaces=False): ...@@ -285,8 +271,6 @@ def GetCppWrapperType(kind, add_same_module_namespaces=False):
if mojom.IsStringKind(kind): if mojom.IsStringKind(kind):
if _for_blink: if _for_blink:
return "WTF::String" return "WTF::String"
if not _use_new_wrapper_types:
return "mojo::String"
type_name = "std::string" type_name = "std::string"
return _AddOptional(type_name) if mojom.IsNullableKind(kind) else type_name return _AddOptional(type_name) if mojom.IsNullableKind(kind) else type_name
if mojom.IsGenericHandleKind(kind): if mojom.IsGenericHandleKind(kind):
...@@ -311,9 +295,9 @@ def IsMoveOnlyKind(kind): ...@@ -311,9 +295,9 @@ def IsMoveOnlyKind(kind):
if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind): if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind):
return True return True
if mojom.IsArrayKind(kind): if mojom.IsArrayKind(kind):
return IsMoveOnlyKind(kind.kind) if _use_new_wrapper_types else True return IsMoveOnlyKind(kind.kind)
if mojom.IsMapKind(kind): if mojom.IsMapKind(kind):
return IsMoveOnlyKind(kind.value_kind) if _use_new_wrapper_types else True return IsMoveOnlyKind(kind.value_kind)
if mojom.IsAnyHandleOrInterfaceKind(kind): if mojom.IsAnyHandleOrInterfaceKind(kind):
return True return True
return False return False
...@@ -621,7 +605,6 @@ class Generator(generator.Generator): ...@@ -621,7 +605,6 @@ class Generator(generator.Generator):
"extra_traits_headers": self.GetExtraTraitsHeaders(), "extra_traits_headers": self.GetExtraTraitsHeaders(),
"extra_public_headers": self.GetExtraPublicHeaders(), "extra_public_headers": self.GetExtraPublicHeaders(),
"for_blink": self.for_blink, "for_blink": self.for_blink,
"use_new_wrapper_types": self.use_new_wrapper_types,
"use_once_callback": self.use_once_callback, "use_once_callback": self.use_once_callback,
"export_attribute": self.export_attribute, "export_attribute": self.export_attribute,
"export_header": self.export_header, "export_header": self.export_header,
...@@ -669,8 +652,6 @@ class Generator(generator.Generator): ...@@ -669,8 +652,6 @@ class Generator(generator.Generator):
_current_typemap = self.typemap _current_typemap = self.typemap
global _for_blink global _for_blink
_for_blink = self.for_blink _for_blink = self.for_blink
global _use_new_wrapper_types
_use_new_wrapper_types = self.use_new_wrapper_types
global _use_once_callback global _use_once_callback
_use_once_callback = self.use_once_callback _use_once_callback = self.use_once_callback
global _variant global _variant
......
...@@ -87,15 +87,6 @@ foreach(configuration, _bindings_configurations) { ...@@ -87,15 +87,6 @@ foreach(configuration, _bindings_configurations) {
# #
# visibility (optional) # visibility (optional)
# #
# use_new_wrapper_types (optional)
# If set to true, mojom array/map/string will be mapped to STL (for
# chromium variant) or WTF (for blink) types. Otherwise, they will be
# mapped to mojo::Array/Map/String/etc.
# Default value is true.
# TODO(yzshen):
# - convert all users to use the new mode;
# - remove support for the old mode.
#
# use_once_callback (optional) # use_once_callback (optional)
# If set to true, generated classes will use base::OnceCallback instead of # If set to true, generated classes will use base::OnceCallback instead of
# base::RepeatingCallback. # base::RepeatingCallback.
...@@ -363,11 +354,6 @@ template("mojom") { ...@@ -363,11 +354,6 @@ template("mojom") {
} }
} }
if (!defined(invoker.use_new_wrapper_types) ||
invoker.use_new_wrapper_types) {
args += [ "--use_new_wrapper_types" ]
}
if (defined(invoker.use_once_callback) && invoker.use_once_callback) { if (defined(invoker.use_once_callback) && invoker.use_once_callback) {
args += [ "--use_once_callback" ] args += [ "--use_once_callback" ]
} }
......
...@@ -166,7 +166,6 @@ class MojomProcessor(object): ...@@ -166,7 +166,6 @@ class MojomProcessor(object):
module, args.output_dir, typemap=self._typemap.get(language, {}), module, args.output_dir, typemap=self._typemap.get(language, {}),
variant=args.variant, bytecode_path=args.bytecode_path, variant=args.variant, bytecode_path=args.bytecode_path,
for_blink=args.for_blink, for_blink=args.for_blink,
use_new_wrapper_types=args.use_new_wrapper_types,
use_once_callback=args.use_once_callback, use_once_callback=args.use_once_callback,
export_attribute=args.export_attribute, export_attribute=args.export_attribute,
export_header=args.export_header, export_header=args.export_header,
...@@ -289,10 +288,6 @@ def main(): ...@@ -289,10 +288,6 @@ def main():
generate_parser.add_argument("--for_blink", action="store_true", generate_parser.add_argument("--for_blink", action="store_true",
help="Use WTF types as generated types for mojo " help="Use WTF types as generated types for mojo "
"string/array/map.") "string/array/map.")
generate_parser.add_argument(
"--use_new_wrapper_types", action="store_true",
help="Map mojom array/map/string to STL (for chromium variant) or WTF "
"(for blink variant) types directly.")
generate_parser.add_argument( generate_parser.add_argument(
"--use_once_callback", action="store_true", "--use_once_callback", action="store_true",
help="Use base::OnceCallback instead of base::RepeatingCallback.") help="Use base::OnceCallback instead of base::RepeatingCallback.")
......
...@@ -37,16 +37,15 @@ class Generator(object): ...@@ -37,16 +37,15 @@ class Generator(object):
# Pass |output_dir| to emit files to disk. Omit |output_dir| to echo all # Pass |output_dir| to emit files to disk. Omit |output_dir| to echo all
# files to stdout. # files to stdout.
def __init__(self, module, output_dir=None, typemap=None, variant=None, def __init__(self, module, output_dir=None, typemap=None, variant=None,
bytecode_path=None, for_blink=False, use_new_wrapper_types=False, bytecode_path=None, for_blink=False, use_once_callback=False,
use_once_callback=False, export_attribute=None, export_attribute=None, export_header=None,
export_header=None, generate_non_variant_code=False): generate_non_variant_code=False):
self.module = module self.module = module
self.output_dir = output_dir self.output_dir = output_dir
self.typemap = typemap or {} self.typemap = typemap or {}
self.variant = variant self.variant = variant
self.bytecode_path = bytecode_path self.bytecode_path = bytecode_path
self.for_blink = for_blink self.for_blink = for_blink
self.use_new_wrapper_types = use_new_wrapper_types
self.use_once_callback = use_once_callback self.use_once_callback = use_once_callback
self.export_attribute = export_attribute self.export_attribute = export_attribute
self.export_header = export_header self.export_header = export_header
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment