diff options
author | sammc@chromium.org <sammc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-12 09:21:06 +0000 |
---|---|---|
committer | sammc@chromium.org <sammc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-12 09:21:06 +0000 |
commit | 7610a728d860829d50c1d2d18151fc7817e16ad9 (patch) | |
tree | 0110865e14a6477fae4bc886b97655efe246c22f /mojo | |
parent | 2ed32fa8474375a37109ee6afe9e7624a5f8e3f1 (diff) | |
download | chromium_src-7610a728d860829d50c1d2d18151fc7817e16ad9.zip chromium_src-7610a728d860829d50c1d2d18151fc7817e16ad9.tar.gz chromium_src-7610a728d860829d50c1d2d18151fc7817e16ad9.tar.bz2 |
Mojo: Fix the C++ bindings generator for methods taking imported interfaces.
Previously, the namespace was omitted for interface and interface
request arguments imported from another module.
Review URL: https://codereview.chromium.org/332653002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276598 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
5 files changed, 28 insertions, 6 deletions
diff --git a/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc b/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc index f996852..e590548 100644 --- a/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc +++ b/mojo/public/cpp/bindings/tests/handle_passing_unittest.cc @@ -101,6 +101,18 @@ class SampleFactoryImpl : public InterfaceImpl<sample::Factory> { BindToRequest(new SampleObjectImpl(), &object_request); } + // These aren't called or implemented, but exist here to test that the + // methods are generated with the correct argument types for imported + // interfaces. + virtual void RequestImportedInterface( + InterfaceRequest<imported::ImportedInterface> imported, + const mojo::Callback<void(InterfaceRequest<imported::ImportedInterface>)>& + callback) MOJO_OVERRIDE {} + virtual void TakeImportedInterface( + imported::ImportedInterfacePtr imported, + const mojo::Callback<void(imported::ImportedInterfacePtr)>& callback) + MOJO_OVERRIDE {} + private: ScopedMessagePipeHandle pipe1_; }; diff --git a/mojo/public/interfaces/bindings/tests/sample_factory.mojom b/mojo/public/interfaces/bindings/tests/sample_factory.mojom index daaed1e..f33864f 100644 --- a/mojo/public/interfaces/bindings/tests/sample_factory.mojom +++ b/mojo/public/interfaces/bindings/tests/sample_factory.mojom @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import "sample_import.mojom" + [JavaPackage="org.chromium.mojo.bindings.test.sample"] module sample { @@ -29,6 +31,10 @@ interface Factory { DoStuff(Request request, handle<message_pipe> pipe); DoStuff2(handle<data_pipe_consumer> pipe); CreateObject(Object& obj); + RequestImportedInterface( + imported.ImportedInterface& obj) => (imported.ImportedInterface& obj); + TakeImportedInterface( + imported.ImportedInterface obj) => (imported.ImportedInterface obj); }; interface FactoryClient { diff --git a/mojo/public/interfaces/bindings/tests/sample_import.mojom b/mojo/public/interfaces/bindings/tests/sample_import.mojom index feeb69d..ff99c09 100644 --- a/mojo/public/interfaces/bindings/tests/sample_import.mojom +++ b/mojo/public/interfaces/bindings/tests/sample_import.mojom @@ -19,4 +19,7 @@ struct Point { int32 y; }; +interface ImportedInterface { +}; + } // module imported diff --git a/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl index 4bf9200..9b6a324 100644 --- a/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl +++ b/mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl @@ -19,9 +19,9 @@ p{{loop.index}} {%- elif param.kind|is_object_kind -%} p{{loop.index}}.Pass() {%- elif param.kind|is_interface_kind -%} -mojo::MakeProxy<{{param.kind.name}}>(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(¶ms->{{param.name}}))) +mojo::MakeProxy<{{param.kind|get_name_for_kind}}>(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(¶ms->{{param.name}}))) {%- elif param.kind|is_interface_request_kind -%} -mojo::MakeRequest<{{param.kind.kind.name}}>(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(¶ms->{{param.name}}))) +mojo::MakeRequest<{{param.kind.kind|get_name_for_kind}}>(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(¶ms->{{param.name}}))) {%- elif param.kind|is_handle_kind -%} mojo::MakeScopedHandle(mojo::internal::FetchAndReset(¶ms->{{param.name}})) {%- elif param.kind|is_enum_kind -%} diff --git a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py index 1b3e4aa..812dd47 100644 --- a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py +++ b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py @@ -103,9 +103,9 @@ def GetCppResultWrapperType(kind): if isinstance(kind, mojom.Array): return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind) if isinstance(kind, mojom.Interface): - return "%sPtr" % kind.name + return "%sPtr" % GetNameForKind(kind) if isinstance(kind, mojom.InterfaceRequest): - return "mojo::InterfaceRequest<%s>" % kind.kind.name + return "mojo::InterfaceRequest<%s>" % GetNameForKind(kind.kind) if kind.spec == 's': return "mojo::String" if kind.spec == 'h': @@ -151,9 +151,9 @@ def GetCppConstWrapperType(kind): if isinstance(kind, mojom.Array): return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind) if isinstance(kind, mojom.Interface): - return "%sPtr" % kind.name + return "%sPtr" % GetNameForKind(kind) if isinstance(kind, mojom.InterfaceRequest): - return "mojo::InterfaceRequest<%s>" % kind.kind.name + return "mojo::InterfaceRequest<%s>" % GetNameForKind(kind.kind) if isinstance(kind, mojom.Enum): return GetNameForKind(kind) if kind.spec == 's': @@ -237,6 +237,7 @@ class Generator(generator.Generator): "cpp_wrapper_type": GetCppWrapperType, "default_value": DefaultValue, "expression_to_text": ExpressionToText, + "get_name_for_kind": GetNameForKind, "get_pad": pack.GetPad, "has_callbacks": HasCallbacks, "should_inline": ShouldInlineStruct, |