-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add proxy_convenience_aliases.h and add release header testing.
This was causing breakages for missing CDecl when arrays were introduced, but only for the compacted inline release header (vs. using through Bazel). Also, add a build_test so this doesn't happen in the future. :jni_test now conditionally allows the usage of the monolithic header. Lastly, rev the release header. Test:'bazel test --cxxopt='\''-std=c++17'\'' --repo_env=CC=clang' ...' PiperOrigin-RevId: 453236675 Change-Id: I2871a3c03c78f54701300727b679838f495fc44b
- Loading branch information
Showing
8 changed files
with
181 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef JNI_BIND_IMPLEMENTATION_PROXY_CONVENIENCE_ALIASES_H_ | ||
#define JNI_BIND_IMPLEMENTATION_PROXY_CONVENIENCE_ALIASES_H_ | ||
|
||
namespace jni { | ||
|
||
template <typename TUndecayed> | ||
struct ProxyHelper; | ||
|
||
// See jni::Proxy. | ||
template <typename T> | ||
using Proxy_t = typename ProxyHelper<T>::Proxy_t; | ||
|
||
template <typename T> | ||
using Index_t = typename ProxyHelper<T>::Index; | ||
|
||
template <typename T, typename Overload = void> | ||
using CDecl_t = typename ProxyHelper<T>::template CDecl<Overload>; | ||
|
||
template <typename T, typename OverloadSelection> | ||
using Return_t = | ||
typename ProxyHelper<T>::template AsReturn_t<OverloadSelection>; | ||
|
||
template <typename T, typename ParamSelection> | ||
using Arg_t = typename ProxyHelper<T>::template AsArg_t<ParamSelection>; | ||
|
||
template <typename T> | ||
using AsDecl_t = typename ProxyHelper<T>::AsDecl_t; | ||
|
||
} // namespace jni | ||
|
||
#endif // JNI_BIND_IMPLEMENTATION_PROXY_CONVENIENCE_ALIASES_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef JNI_BIND_RELEASE_HEADER_SMOKE_TEST_H_ | ||
#define JNI_BIND_RELEASE_HEADER_SMOKE_TEST_H_ | ||
|
||
#include <gtest/gtest.h> | ||
#include "jni_bind_release_for_testing.h" | ||
#include "jni_test.h" | ||
|
||
namespace { | ||
|
||
using ::jni::Class; | ||
using ::jni::Field; | ||
using ::jni::Method; | ||
using ::jni::Params; | ||
using ::jni::test::JniTest; | ||
|
||
TEST_F(JniTest, SmokeTest_SimplyRun) { | ||
static constexpr Class object{ | ||
"ARCore", | ||
Method{"Foo", jni::Return<jint>{}, Params<jint, jfloat>{}}, | ||
Method{"Bar", jni::Return{jint{}}, Params<>{}}, | ||
Method{"Baz", jni::Return<void>{}, Params<jfloat>{}}, | ||
Field{"SomeField", jint{}}, | ||
}; | ||
|
||
jni::GlobalObject<object> obj{}; | ||
obj("Foo", 1, 2.f); | ||
obj("Baz", 1.f); | ||
obj("Baz", 1.f); | ||
obj("Baz", 2.f); | ||
obj("Baz", 3.f); | ||
obj("Bar"); | ||
obj["SomeField"].Get(); | ||
} | ||
|
||
} // namespace | ||
|
||
#endif // JNI_BIND_RELEASE_HEADER_SMOKE_TEST_H_ |