Commit 7610a728 authored by sammc@chromium.org's avatar sammc@chromium.org

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
parent 2ed32fa8
...@@ -101,6 +101,18 @@ class SampleFactoryImpl : public InterfaceImpl<sample::Factory> { ...@@ -101,6 +101,18 @@ class SampleFactoryImpl : public InterfaceImpl<sample::Factory> {
BindToRequest(new SampleObjectImpl(), &object_request); 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: private:
ScopedMessagePipeHandle pipe1_; ScopedMessagePipeHandle pipe1_;
}; };
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import "sample_import.mojom"
[JavaPackage="org.chromium.mojo.bindings.test.sample"] [JavaPackage="org.chromium.mojo.bindings.test.sample"]
module sample { module sample {
...@@ -29,6 +31,10 @@ interface Factory { ...@@ -29,6 +31,10 @@ interface Factory {
DoStuff(Request request, handle<message_pipe> pipe); DoStuff(Request request, handle<message_pipe> pipe);
DoStuff2(handle<data_pipe_consumer> pipe); DoStuff2(handle<data_pipe_consumer> pipe);
CreateObject(Object& obj); CreateObject(Object& obj);
RequestImportedInterface(
imported.ImportedInterface& obj) => (imported.ImportedInterface& obj);
TakeImportedInterface(
imported.ImportedInterface obj) => (imported.ImportedInterface obj);
}; };
interface FactoryClient { interface FactoryClient {
......
...@@ -19,4 +19,7 @@ struct Point { ...@@ -19,4 +19,7 @@ struct Point {
int32 y; int32 y;
}; };
interface ImportedInterface {
};
} // module imported } // module imported
...@@ -19,9 +19,9 @@ p{{loop.index}} ...@@ -19,9 +19,9 @@ p{{loop.index}}
{%- elif param.kind|is_object_kind -%} {%- elif param.kind|is_object_kind -%}
p{{loop.index}}.Pass() p{{loop.index}}.Pass()
{%- elif param.kind|is_interface_kind -%} {%- elif param.kind|is_interface_kind -%}
mojo::MakeProxy<{{param.kind.name}}>(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(&params->{{param.name}}))) mojo::MakeProxy<{{param.kind|get_name_for_kind}}>(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(&params->{{param.name}})))
{%- elif param.kind|is_interface_request_kind -%} {%- elif param.kind|is_interface_request_kind -%}
mojo::MakeRequest<{{param.kind.kind.name}}>(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(&params->{{param.name}}))) mojo::MakeRequest<{{param.kind.kind|get_name_for_kind}}>(mojo::MakeScopedHandle(mojo::internal::FetchAndReset(&params->{{param.name}})))
{%- elif param.kind|is_handle_kind -%} {%- elif param.kind|is_handle_kind -%}
mojo::MakeScopedHandle(mojo::internal::FetchAndReset(&params->{{param.name}})) mojo::MakeScopedHandle(mojo::internal::FetchAndReset(&params->{{param.name}}))
{%- elif param.kind|is_enum_kind -%} {%- elif param.kind|is_enum_kind -%}
......
...@@ -103,9 +103,9 @@ def GetCppResultWrapperType(kind): ...@@ -103,9 +103,9 @@ def GetCppResultWrapperType(kind):
if isinstance(kind, mojom.Array): if isinstance(kind, mojom.Array):
return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind) return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind)
if isinstance(kind, mojom.Interface): if isinstance(kind, mojom.Interface):
return "%sPtr" % kind.name return "%sPtr" % GetNameForKind(kind)
if isinstance(kind, mojom.InterfaceRequest): if isinstance(kind, mojom.InterfaceRequest):
return "mojo::InterfaceRequest<%s>" % kind.kind.name return "mojo::InterfaceRequest<%s>" % GetNameForKind(kind.kind)
if kind.spec == 's': if kind.spec == 's':
return "mojo::String" return "mojo::String"
if kind.spec == 'h': if kind.spec == 'h':
...@@ -151,9 +151,9 @@ def GetCppConstWrapperType(kind): ...@@ -151,9 +151,9 @@ def GetCppConstWrapperType(kind):
if isinstance(kind, mojom.Array): if isinstance(kind, mojom.Array):
return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind) return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind)
if isinstance(kind, mojom.Interface): if isinstance(kind, mojom.Interface):
return "%sPtr" % kind.name return "%sPtr" % GetNameForKind(kind)
if isinstance(kind, mojom.InterfaceRequest): if isinstance(kind, mojom.InterfaceRequest):
return "mojo::InterfaceRequest<%s>" % kind.kind.name return "mojo::InterfaceRequest<%s>" % GetNameForKind(kind.kind)
if isinstance(kind, mojom.Enum): if isinstance(kind, mojom.Enum):
return GetNameForKind(kind) return GetNameForKind(kind)
if kind.spec == 's': if kind.spec == 's':
...@@ -237,6 +237,7 @@ class Generator(generator.Generator): ...@@ -237,6 +237,7 @@ class Generator(generator.Generator):
"cpp_wrapper_type": GetCppWrapperType, "cpp_wrapper_type": GetCppWrapperType,
"default_value": DefaultValue, "default_value": DefaultValue,
"expression_to_text": ExpressionToText, "expression_to_text": ExpressionToText,
"get_name_for_kind": GetNameForKind,
"get_pad": pack.GetPad, "get_pad": pack.GetPad,
"has_callbacks": HasCallbacks, "has_callbacks": HasCallbacks,
"should_inline": ShouldInlineStruct, "should_inline": ShouldInlineStruct,
......
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