initial commit
Change-Id: I5faa546164b7c8e9f4cac46998282458ece1c963
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 4f2cf5e..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,236 +0,0 @@
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-hidl_cflags := -Wall -Wextra -Werror
-hidl_static_libraries := libbase libcutils
-
-hidl_module_host_os := darwin linux windows
-ifdef BRILLO
- hidl_module_host_os := darwin linux
-endif
-
-# This tool is prebuilt if we're doing an app-only build.
-ifeq ($(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK)),)
-
-# Logic shared between hidl and its unittests
-include $(CLEAR_VARS)
-LOCAL_MODULE := libhidl-common
-LOCAL_MODULE_HOST_OS := $(hidl_module_host_os)
-
-LOCAL_C_INCLUDES := external/gtest/include
-LOCAL_CLANG_CFLAGS := $(hidl_cflags)
-# Tragically, the code is riddled with unused parameters.
-LOCAL_CLANG_CFLAGS += -Wno-unused-parameter
-# yacc dumps a lot of code *just in case*.
-LOCAL_CLANG_CFLAGS += -Wno-unused-function
-LOCAL_CLANG_CFLAGS += -Wno-unneeded-internal-declaration
-# yacc is a tool from a more civilized age.
-LOCAL_CLANG_CFLAGS += -Wno-deprecated-register
-# yacc also has a habit of using char* over const char*.
-LOCAL_CLANG_CFLAGS += -Wno-writable-strings
-LOCAL_STATIC_LIBRARIES := $(hidl_static_libraries)
-
-LOCAL_SRC_FILES := \
- code_writer.cpp \
- generate.cpp \
- parser.cpp \
- ast.cpp \
- hidl_language_l.ll \
- hidl_language_y.yy \
- io_delegate.cpp \
- line_reader.cpp \
- options.cpp \
- generator_utility.cpp \
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-
-# hidl-gen executable
-include $(CLEAR_VARS)
-LOCAL_MODULE := hidl-gen
-LOCAL_MODULE_CLASS := EXECUTABLES
-LOCAL_IS_HOST_MODULE := true
-
-intermediates:= $(local-generated-sources-dir)
-private_input_files := \
- $(LOCAL_PATH)/templates/BnTemplate.h \
- $(LOCAL_PATH)/templates/BpTemplate.h \
- $(LOCAL_PATH)/templates/ITemplate.h \
- $(LOCAL_PATH)/templates/Template.vts \
- $(LOCAL_PATH)/templates/Template.json \
- $(LOCAL_PATH)/templates/TemplateAll.cpp \
- $(LOCAL_PATH)/templates/TemplateBinder.h \
- $(LOCAL_PATH)/templates/TemplateProxy.cpp \
- $(LOCAL_PATH)/templates/TemplateStubs.cpp \
-
-the_py_script := $(LOCAL_PATH)/make_snippets.py
-GEN := $(intermediates)/snippets.cpp
-$(GEN): PRIVATE_INPUT_FILES := $(private_input_files)
-$(GEN): PRIVATE_PY_SCRIPT := $(the_py_script)
-$(GEN): PRIVATE_CUSTOM_TOOL = python $(PRIVATE_PY_SCRIPT) $@ $(PRIVATE_INPUT_FILES)
-$(GEN): $(private_input_files) $(the_py_script)
- $(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-
-LOCAL_MODULE_HOST_OS := $(hidl_module_host_os)
-LOCAL_CFLAGS := $(hidl_cflags)
-LOCAL_C_INCLUDES := external/gtest/include
-LOCAL_SRC_FILES := main_hidl.cpp
-
-LOCAL_STATIC_LIBRARIES := libhidl-common $(hidl_static_libraries)
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := hidl_test
-LOCAL_MODULE_CLASS := FAKE
-LOCAL_IS_HOST_MODULE := true
-
-include $(BUILD_SYSTEM)/base_rules.mk
-
-the_py_script := $(LOCAL_PATH)/tests/testAll.py
-$(LOCAL_BUILT_MODULE): PRIVATE_PY_SCRIPT := $(the_py_script)
-$(LOCAL_BUILT_MODULE): PRIVATE_OUT_DIR := $(intermediates)/test_out
-$(LOCAL_BUILT_MODULE): PRIVATE_TEST_DIR := $(LOCAL_PATH)/tests
-$(LOCAL_BUILT_MODULE): PRIVATE_HIDL_EXEC := $(HOST_OUT_EXECUTABLES)/hidl-gen
-$(LOCAL_BUILT_MODULE): $(the_py_script) $(HOST_OUT_EXECUTABLES)/hidl-gen
- @echo "host Test: $(PRIVATE_MODULE)"
- @mkdir -p $(dir $@)
- @mkdir -p $(PRIVATE_OUT_DIR)
- $(hide) python $(PRIVATE_PY_SCRIPT) $(PRIVATE_HIDL_EXEC) $(PRIVATE_TEST_DIR) $(PRIVATE_OUT_DIR)
- $(hide) touch $@
-
-
-# Unit tests
-include $(CLEAR_VARS)
-LOCAL_MODULE := hidl_unittests
-LOCAL_MODULE_HOST_OS := darwin linux
-
-LOCAL_CFLAGS := $(hidl_cflags) -g -DUNIT_TEST
-# Tragically, the code is riddled with unused parameters.
-LOCAL_CLANG_CFLAGS := -Wno-unused-parameter
-LOCAL_SRC_FILES := \
- hidl_unittest.cpp \
- ast_cpp_unittest.cpp \
- ast_java_unittest.cpp \
- generate_cpp_unittest.cpp \
- options_unittest.cpp \
- tests/end_to_end_tests.cpp \
- tests/fake_io_delegate.cpp \
- tests/main.cpp \
- tests/test_data_example_interface.cpp \
- tests/test_data_ping_responder.cpp \
- tests/test_util.cpp \
- type_cpp_unittest.cpp \
- type_java_unittest.cpp \
-
-LOCAL_STATIC_LIBRARIES := \
- libhidl-common \
- libhidl-parse \
- $(hidl_static_libraries) \
- libgmock_host \
- libgtest_host \
-
-LOCAL_LDLIBS_linux := -lrt
-#include $(BUILD_HOST_NATIVE_TEST)
-
-endif # No TARGET_BUILD_APPS or TARGET_BUILD_PDK
-
-#
-# Everything below here is used for integration testing of generated HIDL code.
-#
-hidl_integration_test_cflags := $(hidl_cflags) -Wunused-parameter
-hidl_integration_test_shared_libs := \
- libbase \
- libbinder \
- liblog \
- libutils
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libhidl-integration-test
-LOCAL_MODULE_CLASS := SHARED_LIBRARIES
-LOCAL_CFLAGS := $(hidl_integration_test_cflags)
-LOCAL_SHARED_LIBRARIES := $(hidl_integration_test_shared_libs)
-LOCAL_HIDL_INCLUDES := \
- system/tools/hidl/tests/ \
- frameworks/native/hidl/binder
-LOCAL_SRC_FILES := \
- tests/android/hidl/tests/ITestService.hal \
- tests/android/hidl/tests/INamedCallback.hal \
- tests/simple_parcelable.cpp
-#include $(BUILD_SHARED_LIBRARY)
-# TODO re-enable tests
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := hidl_test_service
-LOCAL_CFLAGS := $(hidl_integration_test_cflags)
-LOCAL_SHARED_LIBRARIES := \
- libhidl-integration-test \
- $(hidl_integration_test_shared_libs)
-LOCAL_SRC_FILES := \
- tests/hidl_test_service.cpp
-#include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := hidl_test_client
-LOCAL_CFLAGS := $(hidl_integration_test_cflags)
-LOCAL_SHARED_LIBRARIES := \
- libhidl-integration-test \
- $(hidl_integration_test_shared_libs)
-LOCAL_SRC_FILES := \
- tests/hidl_test_client.cpp \
- tests/hidl_test_client_file_descriptors.cpp \
- tests/hidl_test_client_parcelables.cpp \
- tests/hidl_test_client_nullables.cpp \
- tests/hidl_test_client_primitives.cpp \
- tests/hidl_test_client_utf8_strings.cpp \
- tests/hidl_test_client_service_exceptions.cpp
-#include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := hidl_test_sentinel_searcher
-LOCAL_SRC_FILES := tests/hidl_test_sentinel_searcher.cpp
-LOCAL_CFLAGS := $(hidl_integration_test_cflags)
-#include $(BUILD_EXECUTABLE)
-
-
-# hidl on its own doesn't need the framework, but testing native/java
-# compatibility introduces java dependencies.
-ifndef BRILLO
-
-include $(CLEAR_VARS)
-LOCAL_PACKAGE_NAME := hidl_test_services
-# Turn off Java optimization tools to speed up our test iterations.
-LOCAL_PROGUARD_ENABLED := disabled
-LOCAL_DEX_PREOPT := false
-LOCAL_CERTIFICATE := platform
-LOCAL_MANIFEST_FILE := tests/java_app/AndroidManifest.xml
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/tests/java_app/resources
-LOCAL_SRC_FILES := \
- tests/android/hidl/tests/ITestService.hal \
- tests/android/hidl/tests/INamedCallback.hal \
- tests/java_app/src/android/hidl/tests/SimpleParcelable.java \
- tests/java_app/src/android/hidl/tests/TestServiceClient.java
-LOCAL_HIDL_INCLUDES := \
- system/tools/hidl/tests/ \
- frameworks/native/hidl/binder
-#include $(BUILD_PACKAGE)
-
-endif # not defined BRILLO
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/CleanSpec.mk b/CleanSpec.mk
deleted file mode 100644
index 0c0a268..0000000
--- a/CleanSpec.mk
+++ /dev/null
@@ -1 +0,0 @@
-$(call add-clean-step, find $(PRODUCT_OUT) -name "hidl-generated" | xargs rm)
diff --git a/FooProxy.cpp b/FooProxy.cpp
deleted file mode 100644
index 900acc7..0000000
--- a/FooProxy.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-// SECTION proxy_cpp
-// START file
-#include <android/hardware/tests/Ipackage_name.h>
-#include <android/hardware/tests/Bppackage_name.h>
-
-namespace android {
-
-namespace hardware {
-
-namespace tests {
-
-IMPLEMENT_META_INTERFACE(package_name, "android.hardware.tests.Ipackage_name");
-
-} // namespace tests
-
-} // namespace hardware
-
-} // namespace android
-#include <android/hardware/tests/Bppackage_name.h>
-#include <binder/Parcel.h>
-
-namespace android {
-
-namespace hardware {
-
-namespace tests {
-
-Bppackage_name::Bppackage_name(const ::android::sp<::android::IBinder>& _aidl_impl)
- : BpInterface<Ipackage_name>(_aidl_impl){
-}
-// START code_snips
-// START code_for_function
-::android::binder::Status Bppackage_name::function_name(function_params_proxy) {
-::android::Parcel _aidl_data;
-::android::Parcel _aidl_reply;
-::android::status_t _aidl_ret_status = ::android::OK;
-::android::binder::Status _aidl_status;
-_aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
-if (((_aidl_ret_status) != (::android::OK))) {
-goto _aidl_error;
-}
-// START param_write_snips
-// START param_write_scalar
-_aidl_ret_status = _aidl_data.aidl_writer_fun(param_name);
-if (((_aidl_ret_status) != (::android::OK))) {
-goto _aidl_error;
-}
-// END param_write_scalar
-// END param_write_snips
-_aidl_ret_status = remote()->transact(Ipackage_name::ECHOINTEGER, _aidl_data, &_aidl_reply);
-if (((_aidl_ret_status) != (::android::OK))) {
-goto _aidl_error;
-}
-_aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
-if (((_aidl_ret_status) != (::android::OK))) {
-goto _aidl_error;
-}
-if (!_aidl_status.isOk()) {
-return _aidl_status;
-}
-// START param_read_ret_snips
-// START param_read_scalar
-_aidl_ret_status = _aidl_reply.aidl_reader_fun(param_name);
-if (((_aidl_ret_status) != (::android::OK))) {
-goto _aidl_error;
-}
-// END param_read_scalar
-// END param_read_ret_snips
-_aidl_error:
-_aidl_status.setFromStatusT(_aidl_ret_status);
-return _aidl_status;
-}
-// END code_for_function
-// END code_snips
-} // namespace tests
-
-} // namespace hardware
-
-} // namespace android
-// END file
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/NOTICE b/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- 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.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/ast.cpp b/ast.cpp
deleted file mode 100644
index e94ae8e..0000000
--- a/ast.cpp
+++ /dev/null
@@ -1,617 +0,0 @@
-#include "ast.h"
-
-#include <android-base/strings.h>
-#include <cstdarg>
-#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <string>
-
-#include "hidl_language_y.h"
-#include "logging.h"
-#include "parser.h"
-
-#ifdef _WIN32
-int isatty(int fd)
-{
- return (fd == 0);
-}
-#endif
-
-using android::hidl::IoDelegate;
-using android::base::Join;
-using android::base::Split;
-using std::cout;
-using std::endl;
-using std::string;
-using std::unique_ptr;
-
-void yylex_init(void **);
-void yylex_destroy(void *);
-void yyset_in(FILE *f, void *);
-int yyparse(Parser*);
-YY_BUFFER_STATE yy_scan_buffer(char *, size_t, void *);
-void yy_delete_buffer(YY_BUFFER_STATE, void *);
-
-
-Parser *Thing::ps_;
-Fields *Type::empty_fields_ = new Fields();
-
-Thing::Thing() {}
-Thing::Thing(string text) : text_(text) {}
-void Thing::Dump()
-{
- std::cout << "Implement Dump for "
- << TypeName() << endl;
-}
-
-Const::Const(Element *name, Element *value)
- : name_(name),
- value_(value)
-{
- (void)name_;
- (void)value_;
-}
-
-void Const::Dump()
-{
- cout << "Const: " << name_->GetText() << " = "
- << value_->GetText() << endl;
-}
-
-Element::Element(const string& text, const string& comments, int Line)
- : Thing(text),
- comments_(comments),
- line_(Line)
-{
-}
-Element::Element(const string& text, int Line)
- : Thing(text),
- comments_(""),
- line_(Line)
-{
-}
-
-CharElement::CharElement(const string& text, const string& comments, int line)
- : Element(text, comments, line)
-{}
-
-IntElement::IntElement(const string& text, const string& comments, int line)
- : Element(text, comments, line)
-{}
-
-NameElement::NameElement(const string& text, const string& comments, int line)
- : Element(text, comments, line)
-{}
-
-StringElement::StringElement(const string& text, int line)
- : Element(text, "", line)
-{}
-
-StringElement::StringElement(const string& text, const string& comments, int line)
- : Element(text, comments, line)
-{}
-
-CommentElement::CommentElement(const string& text, const string& comments, int line)
- : Element(text, comments, line)
-{}
-
-ErrorElement::ErrorElement(const string& text, const string& comments, int line)
- : Element(text, comments, line)
-{}
-
-void Element::Dump()
-{
- cout << "Element(" << ElementTypename() << "): " << GetText() << endl;
-}
-
-bool NameElement::HasScalarValue() const {
- return false; // TODO - look up name
-}
-bool NameElement::HasIntegerValue() const {
- return false; // TODO
-}
-bool NameElement::IsDefinedType() const
-{
- return false; // TODO
-}
-long NameElement::GetIntegerValue() const
-{
- CHECK(false) << "TODO - find const";
- return 0;
-}
-long NameElement::GetScalarValue() const
-{
- CHECK(false) << "TODO - find const";
- return 0;
-}
-long Element::GetIntegerValue() const
-{
- CHECK(false) << "Bad type for GetIntegerValue: "
- << ElementTypename();
- return 0;
-}
-void Element::AddDottedElement(Element *element) {
- CHECK(false); // TODO
-}
-
-BinaryExpression::BinaryExpression(Element *lhs, Element *rhs, const string& text, const string& comments, int Line)
- : Element(text, comments, Line),
- lhs_(lhs),
- rhs_(rhs)
-{
-}
-BinaryExpression::BinaryExpression(Element *lhs, Element *rhs, const string& text, int Line)
- : Element(text, Line),
- lhs_(lhs),
- rhs_(rhs)
-{
-}
-
-UnaryExpression::UnaryExpression(Element *rhs, const string& text, const string& comments, int Line)
- : Element(text, comments, Line),
- rhs_(rhs)
-{
-}
-UnaryExpression::UnaryExpression(Element *rhs, const string& text, int Line)
- : Element(text, Line),
- rhs_(rhs)
-{
-}
-
-ParenthesizedExpression::ParenthesizedExpression(Element *parenthesized, const string& text, const string& comments, int Line)
- : Element(text, comments, Line),
- parenthesized_(parenthesized)
-{
-}
-ParenthesizedExpression::ParenthesizedExpression(Element *parenthesized, const string& text, int Line)
- : Element(text, Line),
- parenthesized_(parenthesized)
-{
-}
-
-CompoundType::CompoundType(Fields *fields)
- : fields_(fields)
-{}
-
-StructType::StructType(Fields *fields)
- : CompoundType(fields)
-{}
-
-EnumType::EnumType(Type *type, Fields *fields)
- : CompoundType(fields),
- type_(type)
-{}
-
-UnionType::UnionType(Fields *fields) // Undiscriminated
- : CompoundType(fields),
- discriminator_(nullptr)
-{
- if (HasFixup()) {
- ps_->Error("Undiscriminated union type cannot have fixups (TODO: Line number)");
- }
-}
-
-UnionType::UnionType(Type* type, Fields *fields) // Discriminated
- : CompoundType(fields),
- discriminator_(type)
-{}
-
-DerivedType::DerivedType(Type *base)
- : base_(base)
-{}
-
-VecType::VecType(Type *base)
- : DerivedType(base)
-{}
-
-RefType::RefType(Type *base)
- : DerivedType(base)
-{
- if (base->HasFixup()) {
- ps_->Error("Ref types aren't allowed to have fixups (TODO: find Line number - sorry!)");
- }
-}
-
-ArrayType::ArrayType(Type *base, Element *dimension)
- : DerivedType(base),
- dimension_(dimension)
-{
- if (!dimension_->HasIntegerValue()) {
- ps_->Error(dimension_->Line(), "Array needs integer dimension, not '%s'",
- dimension_->c_str());
- }
-}
-
-NamedType::NamedType(Element *name)
- : name_(name)
-{
- base_ = ps_->GetDeclaredType(name);
- if (!base_) {
- ps_->Error(name_->Line(), "'%s' isn't declared as a type",
- name_->c_str());
- base_ = new OpaqueType();
- }
-}
-
-ScalarType::ScalarType(Element *name)
- : name_(name)
-{}
-
-HandleType::HandleType() {}
-
-OpaqueType::OpaqueType() {}
-
-StringType::StringType() {}
-
-TypeDecl::TypeDecl(Element *name, Type *base)
- : DerivedType(base),
- name_(name)
-{}
-
-TypedefDecl::TypedefDecl(Element *name, Type *base)
- : TypeDecl(name, base)
-{}
-EnumDecl::EnumDecl(Element *name, Type *base)
- : TypeDecl(name, base)
-{}
-StructDecl::StructDecl(Element *name, Type *base)
- : TypeDecl(name, base)
-{}
-UnionDecl::UnionDecl(Element *name, Type *base)
- : TypeDecl(name, base)
-{}
-ImportDecl::ImportDecl(Element *name)
- : TypeDecl(name, new ImportType())
-{}
-ImportType::ImportType()
-{}
-
-
-bool Type::HasFixup()
-{
- return HasFdFixup() || HasPtrFixup();
-}
-
-bool Fields::HasPtrFixup()
-{
- for (auto & field : fields_) {
- if (field->GetType() && field->GetType()->HasPtrFixup()) {
- return true;
- }
- }
- return false;
-}
-
-bool Fields::HasFdFixup()
-{
- for (auto & field : fields_) {
- if (field->GetType() && field->GetType()->HasFdFixup()) {
- return true;
- }
- }
- return false;
-}
-
-void StructType::Dump()
-{
- cout << "Struct fields:" << endl;
- fields_->Dump();
-}
-
-void ImportType::Dump()
-{
- cout << "Import type:" << endl;
-}
-
-void EnumType::Dump()
-{
- cout << "(Enum_type " << type_->GetText() << "): ";
- fields_->Dump();
- cout << endl;
-}
-
-void UnionType::Dump()
-{
- cout << "Union ";
- if (discriminator_) {
- cout << " (discriminator ";
- discriminator_->Dump();
- cout << ") ";
- }
- cout << " with fields:" << endl;
- fields_->Dump();
-}
-
-void VecType::Dump()
-{
- cout << "Vec<";
- base_->Dump();
- cout << "> ";
-}
-
-void RefType::Dump()
-{
- cout << "Ref<";
- base_->Dump();
- cout << "> ";
-}
-
-void ArrayType::Dump()
-{
- base_->Dump();
- cout << "[";
- dimension_->Dump();
- cout << "] ";
-}
-
-void NamedType::Dump()
-{
- cout << "(Type:";
- base_->Dump();
- cout << ") ";
-}
-
-void ScalarType::Dump()
-{
- cout << "Scalar:";
- name_->Dump();
-}
-
-void HandleType::Dump()
-{
- cout << "Handle ";
-}
-
-void OpaqueType::Dump()
-{
- cout << "Opaque ";
-}
-
-void StringType::Dump()
-{
- cout << "String ";
-}
-
-void TypedefDecl::Dump()
-{
- cout << "Typedef: ";
- base_->Dump();
- cout << " AS ";
- name_->Dump();
-}
-
-void EnumDecl::Dump()
-{
- cout << "Enum ";
- name_->Dump();
- cout << " { ";
- base_->Dump();
- cout << " } ";
-}
-
-void StructDecl::Dump()
-{
- cout << "Struct ";
- name_->Dump();
- cout << " { ";
- base_->Dump();
- cout << " } ";
-}
-
-void UnionDecl::Dump()
-{
- cout << "Union ";
- name_->Dump();
- cout << " { ";
- base_->Dump();
- cout << " } ";
-}
-
-void ImportDecl::Dump()
-{
- cout << "Import ";
- name_->Dump();
-}
-
-void Thing::SetParser(Parser *ps) {ps_=ps;}
-
-void Header::Dump()
-{
- cout << endl << endl << "HIDL DUMP" << endl << endl;
-}
-
-void Fields::Dump()
-{
- for (auto & field : fields_) {
- field->Dump();
- }
-}
-
-// Used for discriminated union entry (tells what vals select it)
-Field::Field(Element* name,
- vector<Element*>* selectors)
- : name_(name),
- selectors_(selectors)
-{
-}
-
-TypedField::TypedField(Type *type, Element* name,
- vector<Element*>* selectors)
- : Field(name, selectors),
- type_(type)
-{
- BuildText();
-}
-
-TypedField::TypedField(Type *type, Element *name)
- : Field(name),
- type_(type)
-{
- BuildText();
-}
-
-
-// Used for scalar that selects a discriminated union
-Field::Field(Element *name, Element *selected)
- : name_(name),
- selected_(selected)
-{
-}
-TypedField::TypedField(Type *type, Element *name, Element *selected)
- : Field(name, selected),
- type_(type)
-{
- (void)comments_;
- BuildText();
-}
-
-Field::Field(Element *name)
- : name_(name)
-{
-}
-EnumField::EnumField(Element *name)
- : Field(name)
-{
- BuildText();
-}
-
-EnumValueField::EnumValueField(Element *name, Element *value)
- : EnumField(name),
- value_(value)
-{
- BuildText();
-}
-
-void Field::Dump()
-{
- cout << "<F>" << text_;
-}
-
-void TypedField::BuildText()
-{
- text_ = type_->GetText();
- text_.append(" ");
- text_.append(name_->GetText());
-}
-void EnumField::BuildText()
-{
- text_ = name_->GetText();
-}
-void EnumValueField::BuildText()
-{
- text_ = name_->GetText();
- text_.append("=");
- text_.append(value_->GetText());
-}
-
-string NamedType::SubtypeSuffix() const
-{
- if (base_->TypeName() == "named_type") {
- return base_->SubtypeSuffix();
- } else {
- return "_" + base_->TypeName();
- }
-}
-
-Annotation::Annotation(Element *name)
- : name_(name)
-{
-}
-
-Annotation::Annotation(Element *name, AnnotationValues *values)
- : name_(name),
- values_(values)
-{
-}
-
-Annotation::Annotation(Element *name,
- AnnotationEntries *entries)
- : entries_(entries),
- name_(name)
-{
-}
-
-AnnotationValue::AnnotationValue(Element *value)
- : value_(value)
-{
-}
-
-AnnotationValue::AnnotationValue(Annotation *annotation)
- : annotation_(annotation)
-{
-}
-
-void Annotations::Add(Annotation *annotation)
-{
- annotations_.push_back(annotation);
-}
-
-Function::Function(Annotations* annotations,
- bool oneway,
- Element* name,
- Fields *fields,
- Fields *generates)
- : annotations_(annotations),
- fields_(fields),
- generates_(generates),
- name_(name),
- oneway_(oneway)
-{
- std::map<string, Field*>params;
- for (auto & f : fields->GetVec()) {
- if (params.find(f->NameText()) != params.end()) {
- ps_->Error(f->Line(),
- "Duplicate param name %s",
- f->NameText().c_str());
- }
- params[f->NameText()] = f;
- }
- for (auto & a : annotations->GetAs()) {
- if (a->NameText() == "param") {
- if (!a->Entries()) {
- ps_->Error(a->Line(), "'param' annotation needs entries including 'name'");
- }
- AnnotationEntries::iterator name_entry =
- a->Entries()->find("name");
- if (name_entry == a->Entries()->end()) {
- ps_->Error(a->Line(), "'param' annotation needs 'name' entry");
- }
- string name = name_entry->second->front()->GetValue()->NoQuoteText();
- std::map<string, Field*>::iterator field_entry =
- params.find(name);
- if (field_entry != params.end()) {
- field_entry->second->SetAnnotation(a);
- } else {
- ps_->Error(a->Line(), "Param name '%s' not in function", name.c_str());
- }
- }
- }
-}
-
-void Function::Dump()
-{
- cout << "Function: " << name_->GetText() << " with fields: ";
- fields_->Dump();
- cout << " oneway " << oneway_;
- annotations_->Dump();
- if (generates_) {
- cout << endl << " generating ";
- generates_->Dump();
- }
- cout << endl;
-}
-
-void Annotations::Dump()
-{
- cout << "TODO: Annotation Dump" << endl;
- /* if (annotations_->size() > 0) {
- cout << endl << " annotations: ";
- for (auto & annotation : *annotations_) {
- cout << *annotation << ", ";
- }
- } else {
- cout << " no annotations; ";
- }*/
-}
diff --git a/ast.h b/ast.h
deleted file mode 100644
index 821fe8a..0000000
--- a/ast.h
+++ /dev/null
@@ -1,751 +0,0 @@
-#ifndef HIDL_HIDL_LANGUAGE_H_
-#define HIDL_HIDL_LANGUAGE_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-#include <map>
-#include "io_delegate.h"
-#include "logging.h"
-#include "options.h"
-
-using std::string;
-using std::vector;
-using std::pair;
-
-struct yy_buffer_state;
-typedef yy_buffer_state* YY_BUFFER_STATE;
-
-class Parser;
-
-using Subs = vector<pair<string, string>>;
-
-struct FieldContext {
- string var_prefix;
- string designator;
- string base_pointer;
- int next_var;
- FieldContext vp(string s) {var_prefix = s; return *this;}
-};
-
-class Thing {
- public:
- Thing();
- Thing(string text);
- virtual const string GetText() const { return text_; }
- const string& GetTokenText() const { return text_; }
- void SetTokenText(string text) { text_ = text; }
- const char *c_str() const { return text_.c_str(); }
- const string& GetComments() const { return comments_; }
- virtual const string TypeName() const = 0;
- virtual int Line() const { return -1; }
-
- virtual void Dump();
- virtual const string Generate(string /*section*/) const { return ""; }
- static void SetParser(Parser *ps);
- static Parser *GetParser() { return ps_; }
- virtual const Subs GetSubs(string /*section*/) const { Subs subs; return subs; }
- virtual const Subs GetSubsC(string /*section*/, const FieldContext& /*context*/) const { Subs subs; return subs; }
- protected:
- static Parser *ps_; // At least it's not global :-)
- string text_;
- string comments_;
-};
-
-class Header : public Thing {
- public:
- void Dump() override;
- const string Generate(string section) const override;
- const string TypeName() const override { return "header"; };
-};
-
-class Element : public Thing {
- public:
- const string& GetComments() const { return comments_; }
- virtual long GetScalarValue() const {CHECK(false); return false;}
- virtual bool HasIntegerValue() const { return false; }
- virtual bool HasScalarValue() const { return false; }
- virtual bool IsDefinedType() const { return false; }
- virtual long GetIntegerValue() const;
- virtual string NoQuoteText() const { return GetText();}
- virtual bool HasStringValue() const { return false; }
- void AddDottedElement(Element *element);
- int Line() const override { return line_; }
- void Dump() override;
- const string Generate(string section) const override;
- const string TypeName() const override { return "element"; }
- virtual const string ElementTypename() const = 0;
-
- protected:
- Element(const string& text, const string& comments, int Line);
- Element(const string& text, int Line);
-
- private:
- string comments_;
- int line_;
- DISALLOW_COPY_AND_ASSIGN(Element);
-};
-
-class CharElement : public Element {
- public:
- CharElement(const string& text, const string& comments, int Line);
- CharElement(const string& text, int Line);
- virtual const string ElementTypename() const override { return "char"; }
- virtual bool HasScalarValue() const { return true; }
- DISALLOW_COPY_AND_ASSIGN(CharElement);
-};
-
-class IntElement : public Element {
- public:
- IntElement(const string& text, const string& comments, int Line);
- // IntElement(const string& text, int Line);
- virtual const string ElementTypename() const override { return "int"; }
- virtual bool HasScalarValue() const { return true; }
- virtual bool HasIntegerValue() const { return true; }
- virtual long GetIntegerValue() const override { return stoi(text_); }
- DISALLOW_COPY_AND_ASSIGN(IntElement);
-};
-
-class NameElement : public Element {
- public:
- NameElement(const string& text, const string& comments, int Line);
- // NameElement(const string& text, int Line);
- virtual const string ElementTypename() const override { return "name"; }
- virtual bool HasScalarValue() const override; // need to look up name
- virtual bool HasIntegerValue() const override;
- virtual long GetScalarValue() const override; // need to look up name
- virtual long GetIntegerValue() const override;
- virtual bool IsDefinedType() const override;
- DISALLOW_COPY_AND_ASSIGN(NameElement);
-};
-
-class StringElement : public Element {
- public:
- StringElement(const string& text, const string& comments, int Line);
- StringElement(const string& text, int Line);
- virtual const string ElementTypename() const override { return "string"; }
- virtual string NoQuoteText() const override { return GetText().substr(1,GetText().length()-2); }
- virtual bool HasStringValue() const { return true; }
-
- DISALLOW_COPY_AND_ASSIGN(StringElement);
-};
-
-class CommentElement : public Element {
- public:
- CommentElement(const string& text, const string& comments, int Line);
- // CommentElement(const string& text, int Line);
- virtual const string ElementTypename() const override { return "comment"; }
-
- DISALLOW_COPY_AND_ASSIGN(CommentElement);
-};
-
-class ErrorElement : public Element {
- public:
- ErrorElement(const string& text, const string& comments, int Line);
- // ErrorElement(const string& text, int Line);
- virtual const string ElementTypename() const override { return "error"; }
-
- DISALLOW_COPY_AND_ASSIGN(ErrorElement);
-};
-
-class BinaryExpression : public Element {
- public:
- BinaryExpression(Element *lhs, Element *rhs, const string& text, const string& comments, int Line);
- BinaryExpression(Element *lhs, Element *rhs, const string& text, int Line);
- const Element *GetLeftHandSide() const { return lhs_; }
- const Element *GetRightHandSide() const { return rhs_; }
- const string& GetOperation() const { return GetTokenText(); }
- virtual const string GetText() const override {
- return lhs_->GetText() + " " + GetOperation() + " " + rhs_->GetText();
- }
- virtual const string ElementTypename() const override { return "binary_expression"; }
- virtual bool HasIntegerValue() const { return lhs_->HasIntegerValue() && rhs_->HasIntegerValue(); }
- virtual bool HasScalarValue() const { return lhs_->HasScalarValue() && rhs_->HasScalarValue(); }
-
- private:
- Element *lhs_;
- Element *rhs_;
-
- DISALLOW_COPY_AND_ASSIGN(BinaryExpression);
-};
-
-class UnaryExpression : public Element {
- public:
- UnaryExpression(Element *rhs, const string& text, const string& comments, int Line);
- UnaryExpression(Element *rhs, const string& text, int Line);
- const string& GetOperation() const { return GetTokenText(); }
- virtual const string GetText() const override {
- return GetOperation() + rhs_->GetText();
- }
- virtual const string ElementTypename() const override { return "unary_expression"; }
- virtual bool HasIntegerValue() const { return rhs_->HasIntegerValue(); }
- virtual bool HasScalarValue() const { return rhs_->HasScalarValue(); }
-
- private:
- Element *rhs_;
-
- DISALLOW_COPY_AND_ASSIGN(UnaryExpression);
-};
-
-class ParenthesizedExpression : public Element {
- public:
- ParenthesizedExpression(Element *parenthesized, const string& text, const string& comments, int Line);
- ParenthesizedExpression(Element *parenthesized, const string& text, int Line);
- const Element *GetParenthesized() const { return parenthesized_; }
- virtual const string GetText() const override {
- return "(" + GetParenthesized()->GetText() + ")";
- }
- virtual const string ElementTypename() const override { return "parenthesized_expression"; }
- virtual bool HasIntegerValue() const { return parenthesized_->HasIntegerValue(); }
- virtual bool HasScalarValue() const { return parenthesized_->HasScalarValue(); }
-
- private:
- Element *parenthesized_;
-
- DISALLOW_COPY_AND_ASSIGN(ParenthesizedExpression);
-};
-
-class Const : public Thing {
- public:
- Const(Element *name, Element *value);
- const string GetName() const { return name_->GetText(); }
- const Element *GetNameElement() const { return name_; }
- const Element *GetValue() const { return value_; }
- void Dump() override;
- const string Generate(string ) const override;
- const Subs GetSubs(string section) const override;
- const string TypeName() const override { return "const"; }
-
- private:
- Element *name_;
- Element *value_;
- DISALLOW_COPY_AND_ASSIGN(Const);
-};
-
-class Field;
-class Type;
-
-class Fields {
- public:
- void Add(Field *field) { fields_.push_back(field); }
- string GenCommaList(string section, string prev, bool out_params);
- string GenCommaList(string section, string prev) {return GenCommaList(section, prev, false);}
- string GenCommaList(string section) {return GenCommaList(section, "", false);}
- string GenCommaNameList(string section, string prev_list, string snippet = "", string name_prefix = "");
-
- string GenSemiList(string section, const FieldContext &context = FieldContext{"","","",0});
- string GenByType(string section, string prefix);
- string TextByPrefix(string section, string prefix, string name_prefix = "");
-
- // TODO(zhuoyao): move to TypedFields once split.
- // Generate the list of typed field description required by vts.
- // label: indicate whether the field is an input parameter or a return value.
- // Used by function type.
- // snippet_name: the snippet that should be replaced.
- string GenVtsTypedFieldList(string section, string label,
- string snippet_name);
-
- // TODO(zhuoyao): move to EnumFields once split.
- // Generate the list of enum field description required by vts.
- string GenVtsEnumFieldList(string section);
-
- int Size() { return fields_.size(); }
- void Dump();
- bool HasPtrFixup();
- bool HasFdFixup();
- vector<Field *> GetVec() { return fields_; }
-
- private:
- vector<Field *> fields_;
-};
-
-class Type : public Thing {
- public:
- Type() = default;
-
- virtual bool IsVec() { return false; }
- virtual bool IsRef() { return false; }
- virtual bool IsArray() { return false; }
- virtual bool IsHandle() { return false; }
- virtual bool IsString() { return false; }
- virtual bool IsCompound() { return false; }
- virtual bool IsPrimitive() { return false; }
- virtual Fields *GetFields() const { return(empty_fields_); }
- virtual bool HasFdFixup() { return false; }
- virtual bool HasPtrFixup() { return false; }
- virtual const Subs GetSubsC(string section, const FieldContext &/*context*/) const
- { return GetSubs(section); }
- virtual const string FixupText(string /*section*/, const FieldContext &/*context*/, string /*prefix*/) const
- { return " // No fixup needed for " + TypeName(); }
- virtual string VtsType() const { return "VtsTypeUnknown"; }
- virtual string SubtypeSuffix() const { return ""; }
- virtual const string GetName() const { return ""; }
- virtual const string Description(string section) const { return Generate(section); }
- virtual const string TypeSuffix(bool subtype) const { return subtype ? "UNUSED" : TypeName(); }
- virtual string TypeOfEnum(string /*section*/) { return "Error, not enum type"; }
- // Return the type name required by vts.
- virtual string VtsTypeName() const { return "TYPE_UNKNOW"; };
- // Return the type description required by vts.
- virtual string VtsTypeDesc(string section);
-
- bool HasFixup();
-
- private:
- static Fields *empty_fields_;
- DISALLOW_COPY_AND_ASSIGN(Type);
-};
-
-class CompoundType : public Type {
- public:
- CompoundType(Fields *fields);
- bool IsCompound() override { return true; }
- Fields *GetFields() const override { return fields_; }
- virtual bool HasPtrFixup() override { return fields_->HasPtrFixup(); }
- virtual bool HasFdFixup() override { return fields_->HasFdFixup(); }
-
- protected:
- Fields *fields_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CompoundType);
-};
-
-class StructType : public CompoundType {
- public:
- StructType(Fields *fields);
- void Dump() override;
- const string TypeName() const override { return "struct_type"; }
- virtual const string FixupText(string section, const FieldContext &context, string prefix) const override;
- const string Generate(string prefix) const override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(StructType);
-};
-
-class EnumType : public CompoundType {
- public:
- EnumType(Type* type, Fields* fields);
- void Dump() override;
- const string TypeName() const override { return "enum_type"; }
- virtual const string TypeSuffix(bool subtype) const override;
- const string Generate(string prefix) const override;
- string TypeOfEnum(string section) override { return type_->Generate(section); }
-
- private:
- Type *type_;
-
- DISALLOW_COPY_AND_ASSIGN(EnumType);
-};
-
-class UnionType : public CompoundType {
- public:
- UnionType(Fields *fields); // Undiscriminated
- UnionType(Type* type, Fields* fields); // Disc
- void Dump() override;
- const string TypeName() const override { return "union_type"; }
- virtual const string FixupText(string section, const FieldContext &context, string prefix) const override;
- const string Generate(string prefix) const override;
-
- private:
- Type *discriminator_;
-
- DISALLOW_COPY_AND_ASSIGN(UnionType);
-};
-
-class DerivedType : public Type {
- public:
- DerivedType(Type *base);
- DerivedType() = default;
- virtual bool HasFdFixup() override { return base_->HasFdFixup(); }
- virtual bool HasPtrFixup() override { return base_->HasPtrFixup(); }
- virtual Type *GetBase() const { return base_; }
- virtual const string TypeSuffix(bool subtype) const override;
-
- protected:
- Type *base_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DerivedType);
-};
-
-class VecType : public DerivedType {
- public:
- VecType(Type *type);
- void Dump() override;
- const Subs GetSubs(string section) const override;
- const Subs GetSubsC(string section, const FieldContext& context) const override;
- bool IsVec() override { return true; }
- const string TypeName() const override { return "vec"; }
- virtual const string FixupText(string section, const FieldContext &context, string prefix) const override;
- const string Description(string section) const;
- const string Generate(string prefix) const override;
- virtual bool HasPtrFixup() override { return true; }
- string VtsTypeName() const override { return "TYPE_VECTOR"; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(VecType);
-};
-
-class RefType : public DerivedType {
- public:
- RefType(Type *type);
- void Dump() override;
- bool IsRef() override { return true; }
- const Subs GetSubs(string section) const override;
- const string TypeName() const override { return "ref"; }
- const string Generate(string section) const override;
- virtual bool HasFdFixup() override { return true; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RefType);
-};
-
-class ArrayType : public DerivedType {
- public:
- ArrayType(Type *type, Element *dimension);
- void Dump() override;
- bool IsArray() override { return true; }
- const Subs GetSubs(string section) const override;
- const Subs GetSubsC(string section, const FieldContext& context) const override;
- const string TypeName() const override { return "array"; }
- virtual const string FixupText(string section, const FieldContext &context, string prefix) const override;
- const string Generate(string section) const override;
- const string GenerateDimension() const { return dimension_->GetText(); }
-
- private:
- Element *dimension_;
-
- DISALLOW_COPY_AND_ASSIGN(ArrayType);
-};
-
-class NamedType : public DerivedType {
- public:
- NamedType(Element *name);
- const string GetName() const override { return name_->GetText(); }
- void Dump() override;
- const Subs GetSubs(string section) const override;
- const Subs GetSubsC(string section, const FieldContext& context) const override;
- const string TypeName() const override { return "named_type"; }
- virtual const string TypeSuffix(bool subtype) const override { return base_->TypeSuffix(subtype); }
- const string Generate(string section) const override;
- const string Description(string section) const;
- virtual const string FixupText(string section, const FieldContext &context, string prefix) const override
- { return GetBase()->FixupText(section, context, prefix); }
- virtual string SubtypeSuffix() const override;
- string VtsTypeName() const override { return base_->VtsTypeName(); }
-
- private:
- Element *name_;
- DISALLOW_COPY_AND_ASSIGN(NamedType);
-};
-
-class ScalarType : public Type {
- public:
- ScalarType(Element *name);
- virtual bool IsPrimitive() override { return true; }
- void Dump() override;
- const string TypeName() const override { return "scalar"; }
- const string Generate(string section) const override;
- const Subs GetSubs(string section) const override;
- virtual bool HasPtrFixup() override { return false; }
- virtual bool HasFdFixup() override { return false; }
- virtual string VtsType() const override { return name_->GetText(); }
- virtual string SubtypeSuffix() const override { return "_" + name_->GetText(); }
- virtual const string TypeSuffix(bool subtype) const override;
- string VtsTypeName() const override { return "TYPE_SCALAR"; };
- private:
- Element *name_;
- DISALLOW_COPY_AND_ASSIGN(ScalarType);
-};
-
-class HandleType : public Type {
- public:
- HandleType();
- void Dump() override;
- bool IsHandle() override { return true; }
- const string TypeName() const override { return "handle"; }
- const string Generate(string section) const override;
- virtual const string FixupText(string section, const FieldContext &context, string prefix) const override;
- virtual bool HasPtrFixup() override { return true; }
- virtual bool HasFdFixup() override { return true; }
- string VtsTypeName() const override { return "TYPE_HANDLE"; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(HandleType);
-};
-
-class OpaqueType : public Type {
- public:
- OpaqueType();
- void Dump() override;
- const string TypeName() const override { return "opaque"; }
- const string Generate(string section) const override;
- virtual bool HasPtrFixup() override { return false; }
- virtual bool HasFdFixup() override { return false; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(OpaqueType);
-};
-
-class ImportType : public Type {
- public:
- ImportType();
- void Dump() override;
- const string TypeName() const override { return "import"; }
- const string Generate(string /*section*/) const override { return "ImportTypeGen"; }
- virtual bool HasPtrFixup() override { return false; }
- virtual bool HasFdFixup() override { return false; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ImportType);
-};
-
-class StringType : public Type {
- public:
- StringType();
- void Dump() override;
- bool IsString() override { return true; }
- const string TypeName() const override { return "string"; }
- virtual const string FixupText(string section, const FieldContext &context, string prefix) const override;
- const string Generate(string section) const override;
- virtual bool HasPtrFixup() override { return true; }
- virtual bool HasFdFixup() override { return false; }
- string VtsTypeName() const override { return "TYPE_STRING"; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(StringType);
-};
-
-class TypeDecl : public DerivedType {
- public:
- TypeDecl(Element *name, Type *base);
- const string GetName() const override { return name_->GetText(); };
- virtual const string TypeSuffix(bool subtype) const override { return base_->TypeSuffix(subtype); }
- int Line() const override { return name_->Line(); }
- const string Description(string section) const;
-
- protected:
- Element *name_;
- private:
- DISALLOW_COPY_AND_ASSIGN(TypeDecl);
-};
-
-class TypedefDecl : public TypeDecl {
- public:
- TypedefDecl(Element *name, Type *type);
- void Dump() override;
- const string TypeName() const override { return "typedef_decl"; }
- const Subs GetSubs(string section) const override;
- const string Generate(string section) const override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TypedefDecl);
-};
-
-class EnumDecl : public TypeDecl {
- public:
- EnumDecl(Element *name, Type *type);
- void Dump() override;
- const string TypeName() const override { return "enum_decl"; }
- const Subs GetSubs(string section) const override;
- string VtsTypeName() const override { return "TYPE_ENUM"; };
-
- private:
- DISALLOW_COPY_AND_ASSIGN(EnumDecl);
-};
-
-class StructDecl : public TypeDecl {
- public:
- StructDecl(Element *name, Type *type);
- void Dump() override;
- const string TypeName() const override { return "struct_decl"; }
- const Subs GetSubs(string section) const override {return GetSubsC(section, FieldContext{"","","",0}); }
- const Subs GetSubsC(string section, const FieldContext &context) const override;
- virtual const string FixupText(string section, const FieldContext &context, string prefix) const override
- { return GetBase()->FixupText(section, context, prefix); }
- string VtsTypeName() const override { return "TYPE_STRUCT"; };
-
- private:
- DISALLOW_COPY_AND_ASSIGN(StructDecl);
-};
-
-class UnionDecl : public TypeDecl {
- public:
- UnionDecl(Element *name, Type *type);
- void Dump() override;
- const string TypeName() const override { return "union_decl"; }
- const Subs GetSubs(string section) const override;
- virtual const string FixupText(string section, const FieldContext &context, string prefix) const override
- { return GetBase()->FixupText(section, context, prefix); }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(UnionDecl);
-};
-
-class ImportDecl : public TypeDecl {
- public:
- ImportDecl(Element *name);
- void Dump() override;
- const string TypeName() const override { return "import_decl"; }
- const Subs GetSubs(string section) const override;
- const string Generate(string section) const override;
- string VtsTypeName() const override { return "TYPE_HIDL_CALLBACK"; };
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ImportDecl);
-};
-
-class Annotation;
-
-class Field : public Thing {
- public:
- void Dump() override;
- int Line() const { return name_->Line(); }
- const string Generate(string section) const override;
- virtual Type *GetType() const { return nullptr; }
- const string TypeName() const override { return "field"; }
- string GetName() { return name_->GetText(); }
- virtual Element *GetValue() { return nullptr; }
- const string& GetComments() const { return comments_; }
- const Subs GetSubs(string section) const override;
- virtual const Subs GetSubsC(string section, const FieldContext &context) const override;
- const string NameText() { return name_->GetText(); }
- void SetAnnotation(Annotation *a) { annotation_ = a; }
- string GenVtsValues(string section);
- virtual string GetInitText();
- virtual bool HasFixup() const { return false; }
-
- protected:
- virtual void BuildText() = 0;
- Field(Element *name, vector<Element*>* selectors);
- Field(Element *name, Element *selected);
- Field(Element *name);
-
- Annotation *annotation_ = nullptr;
- string comments_;
- Element *initializer_ = nullptr;
- Element *name_ = nullptr;
- Element *selected_ = nullptr;
- std::vector<Element*> *selectors_;
- DISALLOW_COPY_AND_ASSIGN(Field);
-};
-
-class TypedField : public Field {
- public:
- TypedField(Type *type, Element* name,
- std::vector<Element*>* selectors);
- TypedField(Type *type, Element *name); // Basic
- TypedField(Type *type, Element *name, Element *selected);
- virtual bool HasFixup() const override { return type_->HasFixup(); }
- virtual Type *GetType() const override { return type_; }
-
- private:
- virtual void BuildText() override;
-
- Type *type_;
- DISALLOW_COPY_AND_ASSIGN(TypedField);
-};
-
-class EnumField : public Field {
- public:
- EnumField(Element *name);
-
- private:
- virtual void BuildText() override;
-
- DISALLOW_COPY_AND_ASSIGN(EnumField);
-};
-
-class EnumValueField : public EnumField {
- public:
- EnumValueField(Element *name, Element *value);
- virtual Element *GetValue() override { return value_; }
- private:
- virtual void BuildText() override;
-
- Element *value_ = nullptr;
-
- DISALLOW_COPY_AND_ASSIGN(EnumValueField);
-};
-
- //class Annotation;
-
-class AnnotationValue : public Thing {
- public:
- AnnotationValue(Element *value);
- AnnotationValue(Annotation *annotation);
- const string TypeName() const override { return "AnnotationValue"; };
- Element *GetValue() { return value_; }
- Annotation *GetAnnotation() { return annotation_; }
- string NoQuoteText();
-
- private:
- Element *value_ = nullptr;
- Annotation *annotation_ = nullptr;
- DISALLOW_COPY_AND_ASSIGN(AnnotationValue);
-};
-
-using AnnotationValues = std::vector<AnnotationValue*>;
-using AnnotationEntry = std::pair<const string, AnnotationValues*>;
-using AnnotationEntries = std::map<string, AnnotationValues*>;
-
-class Annotation : public Thing {
- public:
- Annotation(Element *name);
- Annotation(Element *name, AnnotationValues *values);
- Annotation(Element *name,
- AnnotationEntries *entries);
- const string TypeName() const override { return "Annotation"; };
- const string NameText() { return name_->GetText(); }
- int Line() const { return name_->Line(); }
- AnnotationEntries *Entries() { return entries_; }
- bool HasKey(string key);
- AnnotationValues *GetValues(string key);
- AnnotationValues *GetUnnamedValues() { return values_; }
-
- private:
- AnnotationEntries *entries_ = nullptr;
- Element *name_;
- AnnotationValues *values_ = nullptr;
- DISALLOW_COPY_AND_ASSIGN(Annotation);
-};
-
-class Annotations : public Thing {
- public:
- Annotations() = default;
- void Add(Annotation *a);
- void Dump();
- const string TypeName() const override { return "Annotations"; };
- const vector<Annotation*>GetAs() { return annotations_; }
- Annotation *GetAnnotation(string key);
- bool HasKey(string key);
- string GenVtsCalls(string section, string anno_name, string out_label);
-
- private:
- std::vector<Annotation*>annotations_;
- DISALLOW_COPY_AND_ASSIGN(Annotations);
-};
-
-class Function : public Thing {
- public:
- Function(Annotations* annotations,
- bool oneway,
- Element* name,
- Fields *fields,
- Fields *generates);
- void Dump() override;
- virtual const Subs GetSubs(string section) const override;
- const string TypeName() const override { return "function"; }
- const string GetName() { return name_->GetText(); }
- string GenCallflow(string section) const;
-
- private:
- Annotations* annotations_;
- Fields *fields_;
- Fields *generates_;
- Element* name_;
- bool oneway_;
- DISALLOW_COPY_AND_ASSIGN(Function);
-};
-
-#endif // HIDL_HIDL_LANGUAGE_H_
diff --git a/binder/Android.mk b/binder/Android.mk
deleted file mode 100644
index 90cd7c2..0000000
--- a/binder/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := hidl_test_service
-LOCAL_SRC_FILES := TestService.cpp TestServiceStubs.cpp
-LOCAL_SHARED_LIBRARIES := libhwbinder libbase libcutils libutils
-LOCAL_C_INCLUDES := system/libhwbinder/include
-#include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := hidl_test_client
-LOCAL_SRC_FILES := TestClient.cpp TestServiceProxy.cpp
-LOCAL_SHARED_LIBRARIES := libhwbinder libbase libcutils libutils
-LOCAL_C_INCLUDES := system/libhwbinder/include
-#include $(BUILD_EXECUTABLE)
diff --git a/binder/ITestService.hal b/binder/ITestService.hal
deleted file mode 100644
index c99b2a8..0000000
--- a/binder/ITestService.hal
+++ /dev/null
@@ -1,18 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-interface ITestService {
-
- struct simple_t {
- uint32_t int1;
- uint32_t int2;
- vec<uint8_t> data;
- };
-
- struct lots_of_data {
- uint8_t[4096] buffer;
- };
- echoInteger(int32_t echo_me, simple_t my_struct) generates (int32_t ret);
- // Use of ref<T> is deprecated.
- shareBufferWithRef(ref<lots_of_data> buffer) generates (int32_t ret);
-};
diff --git a/binder/TestClient.cpp b/binder/TestClient.cpp
deleted file mode 100644
index 822fd10..0000000
--- a/binder/TestClient.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * 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.
- */
-
-#include <iostream>
-
-#include <android-base/logging.h>
-#include <hwbinder/IServiceManager.h>
-#include <utils/String16.h>
-#include <utils/StrongPointer.h>
-
-#include "android/hardware/tests/ITestService.h"
-
-// libutils:
-using android::OK;
-using android::sp;
-using android::status_t;
-using android::String16;
-
-// libbinder:
-using android::hardware::getService;
-using android::hardware::hidl_version;
-using android::hardware::make_hidl_version;
-using android::hardware::gen_ref;
-using android::hardware::from_ref;
-
-// generated
-using android::hardware::tests::ITestService;
-
-using std::cerr;
-using std::cout;
-using std::endl;
-
-namespace android {
-namespace hardware {
-namespace tests {
-namespace client {
-
-const char kServiceName[] = "android.hardware.tests.ITestService";
-
-bool GetService(sp<ITestService>* service, hidl_version version) {
- cout << "Retrieving test service binder" << endl;
- status_t status = getService(String16(kServiceName), version, service);
- if (status != OK) {
- cerr << "Failed to get service binder: '" << kServiceName
- << "' status=" << status << endl;
- return false;
- }
- return true;
-}
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
-
-#define DATA_BUFFER_SIZE 32
-int main(int /* argc */, char * argv []) {
- uint8_t data_buffer[DATA_BUFFER_SIZE];
- for (int i = 0; i < DATA_BUFFER_SIZE; i++) {
- data_buffer[i] = i;
- }
- android::base::InitLogging(argv, android::base::StderrLogger);
- sp<ITestService> service;
- namespace client_tests = android::hardware::tests::client;
-
- hidl_version version = make_hidl_version(4,0);
- if (!client_tests::GetService(&service, version)) return 1;
-
- ITestService::simple_t my_struct;
- my_struct.int1 = 1481;
- my_struct.int2 = 2592;
- my_struct.data.buffer = data_buffer;
- my_struct.data.count = DATA_BUFFER_SIZE;
-
- service->echoInteger(32, &my_struct, [](auto ret) {
- cout << "Got response from binder service: " << ret << endl;
- }
- );
- // Generate a ref<lots_of_data>
- ITestService::lots_of_data *data_ptr;
- int fd = -1;
- gen_ref(&fd, &data_ptr);
- cout << "gen_ref generated file descriptor " << fd << endl;
- // Now fill up the buffer with fun data
- for (size_t i = 0; i < sizeof(ITestService::lots_of_data); i++) {
- data_ptr->buffer[i] = i & 0xFF;
- }
- if (fd >= 0) {
- service->shareBufferWithRef(fd, [](auto ret) {
- cout << "Got response from binder service: " << ret << endl;
- }
- );
- } else {
- cerr << "Failed to generate a reference" << endl;
- }
- return 0;
-}
diff --git a/binder/TestService.cpp b/binder/TestService.cpp
deleted file mode 100644
index 847b06f..0000000
--- a/binder/TestService.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-#include <iostream>
-#include <map>
-
-#include <unistd.h>
-
-#include <hwbinder/IInterface.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/IServiceManager.h>
-#include <hwbinder/ProcessState.h>
-#include <hwbinder/Status.h>
-#include <utils/Errors.h>
-#include <utils/Log.h>
-#include <utils/Looper.h>
-#include <utils/StrongPointer.h>
-
-#include <android/hardware/tests/BnTestService.h>
-// libutils:
-using android::Looper;
-using android::LooperCallback;
-using android::OK;
-using android::sp;
-using android::String16;
-
-// libhwbinder:
-using android::hardware::BnInterface;
-using android::hardware::defaultServiceManager;
-using android::hardware::IInterface;
-using android::hardware::IPCThreadState;
-using android::hardware::Parcel;
-using android::hardware::ProcessState;
-using android::hardware::Status;
-using android::hardware::hidl_version;
-using android::hardware::make_hidl_version;
-using android::hardware::from_ref;
-
-// Standard library
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::map;
-using std::string;
-using std::unique_ptr;
-using std::vector;
-
-// Generated HIDL files
-using android::hardware::tests::BnTestService;
-
-namespace {
-
-class BinderCallback : public LooperCallback {
- public:
- BinderCallback() {}
- ~BinderCallback() override {}
-
- int handleEvent(int /* fd */, int /* events */, void* /* data */) override {
- IPCThreadState::self()->handlePolledCommands();
- return 1; // Continue receiving callbacks.
- }
-};
-
-class TestService : public BnTestService {
- public:
- TestService() {}
- virtual ~TestService() = default;
-
- virtual Status echoInteger(int32_t echo_me, const ITestService::simple_t* my_struct, ITestService::echoInteger_cb callback) {
- std::cout << "struct at addr " << (void *)my_struct << std::endl;
- std::cout << "int1 " << my_struct->int1 << " int2 " << my_struct->int2 << std::endl;
- std::cout << "uint8 at position 18 is " << static_cast<int>(my_struct->data.buffer[18]) << std::endl;
- callback(echo_me);
- printf("Value is %d\n", my_struct->data.buffer[18]);
- return Status::ok();
- }
- virtual Status shareBufferWithRef(int buffer, ITestService::shareBufferWithRef_cb callback) {
- // Map back to struct lots_of_data
- ITestService::lots_of_data* dataPtr;
- if (from_ref(buffer, &dataPtr)) {
- // Failed
- callback(1);
- } else {
- cout << "Data element at position 1481 is " << unsigned(dataPtr->buffer[1481]) << endl;
- callback(0);
- }
-
- return Status::ok();
- }
- private:
-};
-
-int Run() {
- android::sp<TestService> service = new TestService;
- sp<Looper> looper(Looper::prepare(0 /* opts */));
-
- int binder_fd = -1;
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- IPCThreadState::self()->disableBackgroundScheduling(true);
- IPCThreadState::self()->setupPolling(&binder_fd);
- ALOGI("Got binder FD %d", binder_fd);
- if (binder_fd < 0) return -1;
-
- sp<BinderCallback> cb(new BinderCallback);
- if (looper->addFd(binder_fd, Looper::POLL_CALLBACK, Looper::EVENT_INPUT, cb,
- nullptr) != 1) {
- ALOGE("Failed to add binder FD to Looper");
- return -1;
- }
- hidl_version version = android::hardware::make_hidl_version(4,1);
- defaultServiceManager()->addService(service->getInterfaceDescriptor(),
- service, version);
-
- ALOGI("Entering loop");
- while (true) {
- const int result = looper->pollAll(-1 /* timeoutMillis */);
- ALOGI("Looper returned %d", result);
- }
- return 0;
-
-}
-
-} // namespace
-
-int main(int /* argc */, char* /* argv */ []) {
- return Run();
-}
diff --git a/binder/TestServiceProxy.cpp b/binder/TestServiceProxy.cpp
deleted file mode 100644
index 7a0bb58..0000000
--- a/binder/TestServiceProxy.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/TemplateProxy.cpp
-#include <android/hardware/tests/ITestService.h>
-#include <android/hardware/tests/BpTestService.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-IMPLEMENT_HWBINDER_META_INTERFACE(TestService, "android.hardware.tests.ITestService");
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#include <android/hardware/tests/BpTestService.h>
-#include <binder/Parcel.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-BpTestService::BpTestService(const ::android::sp<::android::hardware::IBinder>& _aidl_impl)
- : BpInterface<ITestService>(_aidl_impl){
-}
-::android::hardware::Status BpTestService::echoInteger(int32_t echo_me, const ITestService::simple_t* my_struct , ITestService::echoInteger_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- uint64_t buffer_handle;
- int32_t ret;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeInt32(echo_me);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeBuffer((void *)my_struct, sizeof(*my_struct), &buffer_handle);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeEmbeddedBuffer((void *)my_struct->data.buffer, my_struct->data.count * sizeof(*my_struct->data.buffer), nullptr, buffer_handle, 8);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = remote()->transact(ITestService::ECHOINTEGER, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&ret);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- _cb(ret);
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpTestService::shareBufferWithRef(hidl_ref<lots_of_data> buffer , ITestService::shareBufferWithRef_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- int32_t ret;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeFileDescriptor(buffer);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(ITestService::SHAREBUFFERWITHREF, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&ret);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- _cb(ret);
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
diff --git a/binder/TestServiceStubs.cpp b/binder/TestServiceStubs.cpp
deleted file mode 100644
index 9283600..0000000
--- a/binder/TestServiceStubs.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/TemplateStubs.cpp
-#include <android/hardware/tests/ITestService.h>
-#include <android/hardware/tests/BpTestService.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-IMPLEMENT_HWBINDER_META_INTERFACE(TestService, "android.hardware.tests.ITestService");
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-#include <iostream>
-#include <android/hardware/tests/BnTestService.h>
-#include <binder/Parcel.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-::android::status_t BnTestService::onTransact(uint32_t _aidl_code, const ::android::hardware::Parcel& _aidl_data, ::android::hardware::Parcel* _aidl_reply, uint32_t _aidl_flags, TransactCallback _cb) {
- ::android::status_t _aidl_ret_status = ::android::OK;
- switch (_aidl_code) {
- case Call::ECHOINTEGER:
- {
- /*
-field_decl_named_type_struct_decl
- */
-int32_t echo_me;
- ITestService::simple_t *my_struct ;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readInt32(&echo_me);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- my_struct = (simple_t *)_aidl_data.readBuffer(nullptr);
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- echoInteger(echo_me, my_struct,
- [&](auto ret ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(ret);
-
- // Callback
- _cb(*_aidl_reply);
- }
- ));
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
- break;
- }
- case Call::SHAREBUFFERWITHREF:
- {
- /*
-field_decl_named_type_struct_decl
- */
-hidl_ref<lots_of_data> buffer;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- buffer = _aidl_data.readFileDescriptor();
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- shareBufferWithRef(buffer,
- [&](auto ret ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(ret);
-
- // Callback
- _cb(*_aidl_reply);
- }
- ));
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
- break;
- }
-
- default:
- {
- _aidl_ret_status = ::android::hardware::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
- }
- break;
- }
- if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
- _aidl_ret_status = ::android::hardware::Status::fromExceptionCode(::android::hardware::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
- }
- return _aidl_ret_status;
-}
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
diff --git a/binder/android/hardware/tests/BnTestService.h b/binder/android/hardware/tests/BnTestService.h
deleted file mode 100644
index 3d9d6e0..0000000
--- a/binder/android/hardware/tests/BnTestService.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BN_TestService_H_
-#define HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BN_TestService_H_
-
-#include <hwbinder/IInterface.h>
-#include <android/hardware/tests/ITestService.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-class BnTestService : public ::android::hardware::BnInterface<ITestService> {
-public:
- ::android::status_t onTransact(uint32_t _aidl_code, const ::android::hardware::Parcel& _aidl_data, ::android::hardware::Parcel* _aidl_reply, uint32_t _aidl_flags = 0, TransactCallback _callback = nullptr) override;
-}; // class BnTestService
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BN_TestService_H_
diff --git a/binder/android/hardware/tests/BpTestService.h b/binder/android/hardware/tests/BpTestService.h
deleted file mode 100644
index 354946c..0000000
--- a/binder/android/hardware/tests/BpTestService.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BP_TestService_H_
-#define HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BP_TestService_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <utils/Errors.h>
-#include <android/hardware/tests/ITestService.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-class BpTestService : public ::android::hardware::BpInterface<ITestService> {
-public:
-explicit BpTestService(const ::android::sp<::android::hardware::IBinder>& _aidl_impl);
-virtual ~BpTestService() = default;
-::android::hardware::Status echoInteger(int32_t echo_me, const ITestService::simple_t *my_struct , ITestService::echoInteger_cb _cb ) override;
-::android::hardware::Status shareBufferWithRef(hidl_ref<lots_of_data> buffer , ITestService::shareBufferWithRef_cb _cb ) override;
-
-}; // class BpTestService
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BP_TestService_H_
diff --git a/binder/android/hardware/tests/ITestService.h b/binder/android/hardware/tests/ITestService.h
deleted file mode 100644
index 5c3a140..0000000
--- a/binder/android/hardware/tests/ITestService.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/ITemplate.h
-#ifndef HIDL_GENERATED_android_hardware_tests_I_TestService_H_
-#define HIDL_GENERATED_android_hardware_tests_I_TestService_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <hwbinder/Status.h>
-#include <cstdint>
-#include <utils/StrongPointer.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-template<typename T>
-using hidl_ref = int;
-
-class ITestService : public ::android::hardware::IInterface {
-public:
-template<typename T>
-struct hidl_vec {
- T *buffer;
- size_t count;
-};
-
-DECLARE_HWBINDER_META_INTERFACE(TestService);
-typedef struct {
-uint32_t int1;
-uint32_t int2;
-hidl_vec<uint8_t> data;
-
-} simple_t;
-
-typedef struct {
-uint8_t buffer[4096] ;
-
-} lots_of_data;
-
-
- using echoInteger_cb = std::function<void(int32_t ret)>;
- using shareBufferWithRef_cb = std::function<void(int32_t ret)>;
-
-
- virtual ::android::hardware::Status echoInteger(int32_t echo_me, const ITestService::simple_t *my_struct , echoInteger_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status shareBufferWithRef(hidl_ref<lots_of_data> buffer, shareBufferWithRef_cb _cb = nullptr ) = 0;
-
-enum Call {
- ECHOINTEGER = ::android::hardware::IBinder::FIRST_CALL_TRANSACTION + 0,
-
- SHAREBUFFERWITHREF,
-};
-}; // class ITestService
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_android_hardware_tests_I_TestService_H_
diff --git a/bptest/Android.bp b/bptest/Android.bp
deleted file mode 100644
index ff7c4ae..0000000
--- a/bptest/Android.bp
+++ /dev/null
@@ -1,21 +0,0 @@
-hidl_output {
- name: "ifoo",
- output_name: "ITestService.h",
- output_type: "i_h",
- srcs: ["ITestService.hal"],
-}
-hidl_output {
- name: "fooproxy",
- output_name: "TestServiceProxy.cpp",
- output_type: "proxy_cpp",
- srcs: ["ITestService.hal"],
-}
-
-cc_binary {
- name: "test_hidl_build",
- srcs: ["foo.cpp"],
- generated_headers: ["ifoo"],
- generated_sources: ["fooproxy"],
- include_dirs: ["system/libhwbinder/include", "system/core/base/include"],
-}
-
diff --git a/bptest/ITestService.hal b/bptest/ITestService.hal
deleted file mode 100644
index 5b9dc64..0000000
--- a/bptest/ITestService.hal
+++ /dev/null
@@ -1,10 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-interface ITestService {
- struct lots_of_data {
- uint8_t[4096] buffer;
- };
- echoInteger(int32_t echo_me) generates (int32_t ret);
- shareBufferWithRef(ref<lots_of_data> buffer) generates (int32_t ret);
-};
diff --git a/bptest/foo.cpp b/bptest/foo.cpp
deleted file mode 100644
index e43ce5b..0000000
--- a/bptest/foo.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <ITestService.h>
-#include <stdio.h>
-int main(int, char**)
-{
- printf("Hi world\n");
- return 0;
-}
diff --git a/code_writer.cpp b/code_writer.cpp
deleted file mode 100644
index ad576ea..0000000
--- a/code_writer.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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.
- */
-
-#include "code_writer.h"
-
-#include <iostream>
-#include <stdarg.h>
-
-#include <android-base/stringprintf.h>
-
-using std::cerr;
-using std::endl;
-
-namespace android {
-namespace hidl {
-
-namespace {
-
-class StringCodeWriter : public CodeWriter {
- public:
- StringCodeWriter(std::string* output_buffer) : output_(output_buffer) {}
- virtual ~StringCodeWriter() = default;
-
- bool Write(const char* format, ...) override {
- va_list ap;
- va_start(ap, format);
- android::base::StringAppendV(output_, format, ap);
- va_end(ap);
- return true;
- }
-
- bool Close() override { return true; }
-
- private:
- std::string* output_;
-}; // class StringCodeWriter
-
-class FileCodeWriter : public CodeWriter {
- public:
- FileCodeWriter(FILE* output_file, bool close_on_destruction)
- : output_(output_file),
- close_on_destruction_(close_on_destruction) {}
- virtual ~FileCodeWriter() {
- if (close_on_destruction_ && output_ != nullptr) {
- fclose(output_);
- }
- }
-
- bool Write(const char* format, ...) override {
- bool success;
- va_list ap;
- va_start(ap, format);
- success = vfprintf(output_, format, ap) >= 0;
- va_end(ap);
- no_error_ = no_error_ && success;
- return success;
- }
-
- bool Close() override {
- if (output_ != nullptr) {
- no_error_ = fclose(output_) == 0 && no_error_;
- output_ = nullptr;
- }
- return no_error_;
- }
-
- private:
- bool no_error_ = true;
- FILE* output_;
- bool close_on_destruction_;
-}; // class StringCodeWriter
-
-} // namespace
-
-CodeWriterPtr GetFileWriter(const std::string& output_file) {
- CodeWriterPtr result;
- FILE* to = nullptr;
- bool close_on_destruction = true;
- if (output_file == "-") {
- to = stdout;
- close_on_destruction = false;
- } else {
- // open file in binary mode to ensure that the tool produces the
- // same output on all platforms !!
- to = fopen(output_file.c_str(), "wb");
- }
-
- if (to != nullptr) {
- result.reset(new FileCodeWriter(to, close_on_destruction));
- } else {
- cerr << "unable to open " << output_file << " for Write" << endl;
- }
-
- return result;
-}
-
-CodeWriterPtr GetStringWriter(std::string* output_buffer) {
- return CodeWriterPtr(new StringCodeWriter(output_buffer));
-}
-
-} // namespace hidl
-} // namespace android
diff --git a/code_writer.h b/code_writer.h
deleted file mode 100644
index 8c55a68..0000000
--- a/code_writer.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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 HIDL_CODE_WRITER_H_
-#define HIDL_CODE_WRITER_H_
-
-#include <memory>
-#include <string>
-
-#include <stdio.h>
-
-#include <android-base/macros.h>
-
-namespace android {
-namespace hidl {
-
-class CodeWriter {
- public:
- // Write a formatted string to this writer in the usual printf sense.
- // Returns false on Error.
- virtual bool Write(const char* format, ...) = 0;
- virtual bool Close() = 0;
- virtual ~CodeWriter() = default;
-}; // class CodeWriter
-
-using CodeWriterPtr = std::unique_ptr<CodeWriter>;
-
-// Get a CodeWriter that writes to |output_file|.
-CodeWriterPtr GetFileWriter(const std::string& output_file);
-
-// Get a CodeWriter that writes to a string buffer.
-// Caller retains ownership of the buffer.
-// The buffer must outlive the CodeWriter.
-CodeWriterPtr GetStringWriter(std::string* output_buffer);
-
-} // namespace hidl
-} // namespace android
-
-#endif // HIDL_CODE_WRITER_H_
diff --git a/fast_msgq/Android.mk b/fast_msgq/Android.mk
deleted file mode 100644
index 2ed96e2..0000000
--- a/fast_msgq/Android.mk
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# Copyright (C) 2016 The Android Open Source Project
-#
-# 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := mq_test_service
-LOCAL_SRC_FILES := \
- common/MessageQueueDesc.cpp \
- TestMsgQService.cpp \
- ITestMsgQ.hal
-
-LOCAL_SHARED_LIBRARIES := libhwbinder libbase libcutils libutils
-LOCAL_C_INCLUDES := system/libhwbinder/include
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_REQUIRED_MODULES := libgtest
-LOCAL_SRC_FILES := common/MessageQueueDesc.cpp \
- TestMsgQClient.cpp \
- test_main.cpp \
- ITestMsgQ.hal
-
-LOCAL_SHARED_LIBRARIES := libhwbinder libbase libcutils libutils
-LOCAL_STATIC_LIBRARIES := libgtest
-LOCAL_MODULE := mq_test_client
-LOCAL_C_INCLUDES := system/libhwbinder/include
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_REQUIRED_MODULES := libgtest
-LOCAL_SRC_FILES := common/MessageQueueDesc.cpp \
- MQTest.cpp \
- test_main.cpp
-LOCAL_STATIC_LIBRARIES := libutils libcutils liblog libgtest
-LOCAL_SHARED_LIBRARIES := libhwbinder
-LOCAL_C_INCLUDES := system/libhwbinder/include
-LOCAL_MODULE := mq_tests
-include $(BUILD_EXECUTABLE)
-
diff --git a/fast_msgq/ITestMsgQ.hal b/fast_msgq/ITestMsgQ.hal
deleted file mode 100644
index 69d8d68..0000000
--- a/fast_msgq/ITestMsgQ.hal
+++ /dev/null
@@ -1,29 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-interface ITestMsgQ {
-
- struct shm_t {
- uint32_t fdIndex;
- uint32_t offset;
- uint32_t extent;
- };
- struct WireGrantorDescriptor {
- uint32_t flags;
- shm_t shm;
- };
-
- struct WireMQDescriptor {
- vec<WireGrantorDescriptor> grantors;
- handle mq_handle;
- uint32_t quantum;
- uint32_t nQuanta;
- uint32_t flags;
- };
-
-
- configure() generates ( WireMQDescriptor mq_desc );
- requestWrite (int32_t count) generates (int32_t ret);
- requestRead(int32_t count) generates (int32_t ret);
-
-};
diff --git a/fast_msgq/MQTest.cpp b/fast_msgq/MQTest.cpp
deleted file mode 100644
index b005af1..0000000
--- a/fast_msgq/MQTest.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * 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.
- */
-
-#include <asm-generic/mman.h>
-#include <cutils/ashmem.h>
-#include <gtest/gtest.h>
-#include <cstdlib>
-#include <sstream>
-#include "common/MessageQueue.h"
-
-static const int queue_size = 1024;
-typedef uint64_t mq_position_t;
-
-class MQTests : public ::testing::Test {
- protected:
- virtual void TearDown() {
- if (fmsgq) {
- delete fmsgq;
- }
- }
-
- virtual void SetUp() {
- size_t eventQueueTotal = 4096;
- int ashmemFd = ashmem_create_region("MessageQueue", eventQueueTotal);
- ashmem_set_prot_region(ashmemFd, PROT_READ | PROT_WRITE);
- ASSERT_TRUE(ashmemFd >= 0);
- native_handle_t* mq_handle = native_handle_create(1, 0);
- ASSERT_TRUE(mq_handle != nullptr);
- std::vector<android::hardware::GrantorDescriptor> Grantors(
- MINIMUM_GRANTOR_COUNT);
- /*
- * The native handle will contain the fds to be
- * mapped.
- */
- mq_handle->data[0] = ashmemFd;
-
- /*
- * Create Grantor Descriptors for read, write pointers and the data
- * buffer.
- */
- Grantors[android::hardware::READPTRPOS] = {0, 0, 0, sizeof(mq_position_t)};
- Grantors[android::hardware::WRITEPTRPOS] = {0, 0, sizeof(mq_position_t),
- sizeof(mq_position_t)};
- Grantors[android::hardware::DATAPTRPOS] = {0, 0, 2 * sizeof(mq_position_t),
- queue_size};
- android::hardware::MQDescriptor mydesc(Grantors, mq_handle, 0, sizeof(uint8_t));
- fmsgq = new android::hardware::MessageQueue<uint8_t>(mydesc);
- ASSERT_TRUE(fmsgq != nullptr);
- ASSERT_TRUE(fmsgq->isValid());
- }
-
- android::hardware::MessageQueue<uint8_t>* fmsgq;
-};
-
-/*
- * Verify that a few bytes of data can be successfully written and read.
- */
-TEST_F(MQTests, SmallInputTest1) {
- const int data_len = 16;
- int write_count = -1;
- ASSERT_TRUE(data_len <= queue_size);
- uint8_t data[data_len];
- for (int i = 0; i < data_len; i++) {
- data[i] = i & 0xFF;
- }
- ASSERT_TRUE(fmsgq->write(data, data_len));
- uint8_t read_data[data_len] = {};
- ASSERT_TRUE(fmsgq->read(read_data, data_len));
- ASSERT_TRUE(memcmp(data, read_data, data_len) == 0);
-}
-
-/*
- * Verify that read() returns false when trying to read from an empty queue.
- */
-TEST_F(MQTests, ReadWhenEmpty) {
- ASSERT_TRUE(fmsgq->availableToRead() == 0);
- const int data_len = 2;
- ASSERT_TRUE(data_len < queue_size);
- uint8_t read_data[data_len];
- ASSERT_FALSE(fmsgq->read(read_data, data_len));
-}
-
-/*
- * Write the queue when full. Verify that subsequent writes fail.
- * Verify that availableToWrite() returns 0 as expected.
- */
-
-TEST_F(MQTests, WriteWhenFull) {
- ASSERT_TRUE(fmsgq->availableToRead() == 0);
- uint8_t* data = new uint8_t[queue_size];
- for (int i = 0; i < queue_size; i++) {
- data[i] = i & 0xFF;
- }
- ASSERT_TRUE(fmsgq->write(data, queue_size));
- ASSERT_TRUE(fmsgq->availableToWrite() == 0);
- ASSERT_FALSE(fmsgq->write(data, 1));
-
- uint8_t* read_data = new uint8_t[queue_size]();
- ASSERT_TRUE(fmsgq->read(read_data, queue_size));
- ASSERT_TRUE(memcmp(data, read_data, queue_size) == 0);
-
- delete[] data;
- delete[] read_data;
-}
-
-/*
- * Write a chunk of data equal to the queue size.
- * Verify that the write is successful and the subsequent read
- * returns the expected data.
- */
-TEST_F(MQTests, LargeInputTest1) {
- uint8_t* data = new uint8_t[queue_size];
- for (int i = 0; i < queue_size; i++) {
- data[i] = i & 0xFF;
- }
- ASSERT_TRUE(fmsgq->write(data, queue_size));
- uint8_t* read_data = new uint8_t[queue_size]();
- ASSERT_TRUE(fmsgq->read(read_data, queue_size));
- ASSERT_TRUE(memcmp(data, read_data, queue_size) == 0);
- delete[] data;
- delete[] read_data;
-}
-
-/*
- * Attempt to write a chunk of data larger than the queue size.
- * Verify that it fails. Verify that a subsequent read fails and
- * the queue is still empty.
- */
-TEST_F(MQTests, LargeInputTest2) {
- ASSERT_TRUE(fmsgq->availableToRead() == 0);
- const int data_len = 4096;
- ASSERT_TRUE(data_len > queue_size);
- uint8_t* data = new uint8_t[data_len];
- for (int i = 0; i < data_len; i++) {
- data[i] = i & 0xFF;
- }
- ASSERT_FALSE(fmsgq->write(data, data_len));
- uint8_t* read_data = new uint8_t[queue_size]();
- ASSERT_FALSE(fmsgq->read(read_data, queue_size));
- ASSERT_FALSE(memcmp(data, read_data, queue_size) == 0);
- ASSERT_TRUE(fmsgq->availableToRead() == 0);
- delete[] data;
- delete[] read_data;
-}
-
-/*
- * After the queue is full, try to write more data. Verify that
- * the attempt returns false. Verify that the attempt did not
- * affect the pre-existing data in the queue.
- */
-TEST_F(MQTests, LargeInputTest3) {
- uint8_t* data = new uint8_t[queue_size];
- for (int i = 0; i < queue_size; i++) {
- data[i] = i & 0xFF;
- }
- ASSERT_TRUE(fmsgq->write(data, queue_size));
- ASSERT_FALSE(fmsgq->write(data, 1));
- uint8_t* read_data = new uint8_t[queue_size];
- ASSERT_TRUE(fmsgq->read(read_data, queue_size));
- ASSERT_TRUE(memcmp(read_data, data, queue_size) == 0);
- delete[] data;
- delete[] read_data;
-}
-/*
- * Verify that multiple reads one after the other return expected data.
- */
-TEST_F(MQTests, MultipleRead) {
- const int chunkSize = 100;
- const int chunkNum = 5;
- const size_t data_len = chunkSize * chunkNum;
- ASSERT_TRUE(data_len <= queue_size);
- uint8_t data[data_len];
- for (unsigned int i = 0; i < data_len; i++) {
- data[i] = i & 0xFF;
- }
- ASSERT_TRUE(fmsgq->write(data, data_len));
- uint8_t read_data[data_len] = {};
- for (unsigned int i = 0; i < chunkNum; i++) {
- ASSERT_TRUE(fmsgq->read(read_data + i * chunkSize, chunkSize));
- }
- ASSERT_TRUE(memcmp(read_data, data, data_len) == 0);
-}
-
-/*
- * Verify that multiple writes one after the other happens correctly.
- */
-TEST_F(MQTests, MultipleWrite) {
- const int chunkSize = 100;
- const int chunkNum = 5;
- const size_t data_len = chunkSize * chunkNum;
- ASSERT_TRUE(data_len <= queue_size);
- uint8_t data[data_len];
- for (unsigned int i = 0; i < data_len; i++) {
- data[i] = i & 0xFF;
- }
- for (unsigned int i = 0; i < chunkNum; i++) {
- ASSERT_TRUE(fmsgq->write(data + i * chunkSize, chunkSize));
- }
- uint8_t read_data[data_len] = {};
- ASSERT_TRUE(fmsgq->read(read_data, data_len));
- ASSERT_TRUE(memcmp(read_data, data, data_len) == 0);
-}
-
-/*
- * Write enough messages into the FMQ to fill half of it
- * and read back the same.
- * Write queue_size messages into the queue. This will cause a
- * wrap around. Read and verify the data.
- */
-TEST_F(MQTests, ReadWriteWrapAround) {
- size_t numMessages = queue_size / 2;
- uint8_t* data = new uint8_t[queue_size];
- uint8_t* read_data = new uint8_t[queue_size]();
- for (int i = 0; i < queue_size; i++) {
- data[i] = i & 0xFF;
- }
- ASSERT_TRUE(fmsgq->write(data, numMessages));
- ASSERT_TRUE(fmsgq->read(read_data, numMessages));
- ASSERT_TRUE(fmsgq->write(data, queue_size));
- ASSERT_TRUE(fmsgq->read(read_data, queue_size));
- ASSERT_TRUE(memcmp(read_data, data, queue_size) == 0);
- delete[] data;
- delete[] read_data;
-}
diff --git a/fast_msgq/TestMsgQClient.cpp b/fast_msgq/TestMsgQClient.cpp
deleted file mode 100644
index 85ee64f..0000000
--- a/fast_msgq/TestMsgQClient.cpp
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
-* Copyright (C) 2016 The Android Open Source Project
-*
-* 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.
-*/
-
-#include <ITestMsgQ.h>
-#include <android-base/logging.h>
-#include <asm-generic/mman.h>
-#include <cutils/ashmem.h>
-#include <gtest/gtest.h>
-#include <hwbinder/IServiceManager.h>
-#include <utils/String16.h>
-#include <utils/StrongPointer.h>
-#include <cstdlib>
-#include <iostream>
-#include <sstream>
-#include "common/MessageQueue.h"
-
-// libutils:
-using android::OK;
-using android::sp;
-using android::status_t;
-using android::String16;
-
-// libbinder:
-using android::hardware::getService;
-using android::hardware::hidl_version;
-using android::hardware::make_hidl_version;
-using android::hardware::gen_ref;
-using android::hardware::from_ref;
-
-// generated
-using android::hardware::tests::ITestMsgQ;
-
-using std::cerr;
-using std::cout;
-using std::endl;
-
-static int numMessagesMax;
-
-namespace android {
-namespace hardware {
-namespace tests {
-namespace client {
-
-const char kServiceName[] = "android.hardware.tests.ITestMsgQ";
-
-bool GetService(sp<ITestMsgQ>* service, hidl_version version) {
- status_t status = getService(String16(kServiceName), version, service);
- if (status != OK) {
- cerr << "Failed to get service binder: '" << kServiceName
- << "' status=" << status << endl;
- return false;
- }
- return true;
-}
-
-} // namespace client
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-class MQTestClient : public ::testing::Test {
- protected:
- virtual void TearDown() {
- if (fmsg_queue) {
- delete fmsg_queue;
- }
- }
-
- virtual void SetUp() {
- namespace client_tests = android::hardware::tests::client;
-
- hidl_version version = make_hidl_version(4, 0);
- if (!client_tests::GetService(&service, version)) return;
- service->configure([this](const ITestMsgQ::WireMQDescriptor& in) {
- create_mq_from_wiremqdesc(&this->fmsg_queue, &in);
- });
- ASSERT_TRUE(fmsg_queue != nullptr);
- ASSERT_TRUE(fmsg_queue->isValid());
- numMessagesMax = fmsg_queue->getQuantumCount();
- }
- sp<ITestMsgQ> service;
- android::hardware::MessageQueue<uint16_t>* fmsg_queue;
-
- private:
- void create_mq_from_wiremqdesc(android::hardware::MessageQueue<uint16_t>** rbIn,
- const ITestMsgQ::WireMQDescriptor* wmq_desc) {
- /*
- * Create a copy of the native handle from the WireMQDescriptor.
- */
- native_handle_t* mq_handle = native_handle_create(
- wmq_desc->mq_handle->numFds, wmq_desc->mq_handle->numInts);
- if (mq_handle == nullptr) return;
- for (int i = 0; i < wmq_desc->mq_handle->numFds; i++)
- mq_handle->data[i] = wmq_desc->mq_handle->data[i];
- memcpy(&mq_handle->data[mq_handle->numFds],
- &wmq_desc->mq_handle->data[mq_handle->numFds],
- mq_handle->numInts * sizeof(int));
-
- /*
- * Create the vector of GrantorDescriptors.
- */
- std::vector<android::hardware::GrantorDescriptor> Grantors(
- MINIMUM_GRANTOR_COUNT);
- Grantors[android::hardware::READPTRPOS] = {
- 0, wmq_desc->grantors.buffer[android::hardware::READPTRPOS].shm.fdIndex,
- wmq_desc->grantors.buffer[android::hardware::READPTRPOS].shm.offset,
- wmq_desc->grantors.buffer[android::hardware::READPTRPOS].shm.extent};
- Grantors[android::hardware::WRITEPTRPOS] = {
- 0, wmq_desc->grantors.buffer[android::hardware::WRITEPTRPOS].shm.fdIndex,
- wmq_desc->grantors.buffer[android::hardware::WRITEPTRPOS].shm.offset,
- wmq_desc->grantors.buffer[android::hardware::WRITEPTRPOS].shm.extent};
-
- Grantors[android::hardware::DATAPTRPOS] = {
- 0, wmq_desc->grantors.buffer[android::hardware::DATAPTRPOS].shm.fdIndex,
- wmq_desc->grantors.buffer[android::hardware::DATAPTRPOS].shm.offset,
- wmq_desc->grantors.buffer[android::hardware::DATAPTRPOS].shm.extent};
-
- android::hardware::MQDescriptor mq_desc(Grantors, mq_handle, 0,
- sizeof(uint16_t));
- *rbIn = new android::hardware::MessageQueue<uint16_t>(mq_desc);
- }
-};
-
-/*
- * Utility function to verify data read from the fast message queue.
- */
-bool verifyData(uint16_t* data, int count) {
- for (int i = 0; i < count; i++) {
- if (data[i] != i) return false;
- }
- return true;
-}
-
-/* Request service to write a small number of messages
- * to the FMQ. Read and verify data.
- */
-TEST_F(MQTestClient, SmallInputReaderTest1) {
- const int data_len = 16;
- ASSERT_TRUE(data_len <= numMessagesMax);
- int write_count = -1;
- service->requestWrite(data_len,
- [&write_count](auto ret) { write_count = ret; });
- ASSERT_EQ(write_count, data_len);
- uint16_t read_data[data_len] = {};
- ASSERT_TRUE(fmsg_queue->read(read_data, data_len));
- ASSERT_TRUE(verifyData(read_data, data_len));
-}
-
-/*
- * Write a small number of messages to FMQ. Request
- * service to read and verify that the write was succesful.
- */
-TEST_F(MQTestClient, SmallInputWriterTest1) {
- const int data_len = 16;
- ASSERT_TRUE(data_len <= numMessagesMax);
- size_t original_count = fmsg_queue->availableToWrite();
- uint16_t data[data_len];
- for (int i = 0; i < data_len; i++) {
- data[i] = i;
- }
- ASSERT_TRUE(fmsg_queue->write(data, data_len));
- int read_count = -1;
- service->requestRead(data_len, [&read_count](auto ret) { read_count = ret; });
- ASSERT_EQ(read_count, data_len);
- size_t available_count = fmsg_queue->availableToWrite();
- ASSERT_EQ(original_count, available_count);
-}
-
-/*
- * Verify that the FMQ is empty and read fails when it is empty.
- */
-TEST_F(MQTestClient, ReadWhenEmpty) {
- ASSERT_TRUE(fmsg_queue->availableToRead() == 0);
- const int numMessages = 2;
- ASSERT_TRUE(numMessages <= numMessagesMax);
- uint16_t read_data[numMessages];
- ASSERT_FALSE(fmsg_queue->read(read_data, numMessages));
-}
-
-/*
- * Verify FMQ is empty.
- * Write enough messages to fill it.
- * Verify availableToWrite() method returns is zero.
- * Try writing another message and verify that
- * the attempted write was unsuccesful. Request service
- * to read and verify the messages in the FMQ.
- */
-
-TEST_F(MQTestClient, WriteWhenFull) {
- uint16_t* data = new uint16_t[numMessagesMax];
- for (int i = 0; i < numMessagesMax; i++) {
- data[i] = i;
- }
- ASSERT_TRUE(fmsg_queue->write(data, numMessagesMax));
- ASSERT_TRUE(fmsg_queue->availableToWrite() == 0);
- ASSERT_FALSE(fmsg_queue->write(data, 1));
- int read_count = -1;
- service->requestRead(numMessagesMax,
- [&read_count](auto ret) { read_count = ret; });
- ASSERT_EQ(read_count, numMessagesMax);
- delete[] data;
-}
-
-/*
- * Verify FMQ is empty.
- * Request service to write data equal to queue size.
- * Read and verify data in fmsg_queue.
- */
-TEST_F(MQTestClient, LargeInputTest1) {
- int write_count = -1;
- service->requestWrite(numMessagesMax,
- [&write_count](auto ret) { write_count = ret; });
- ASSERT_EQ(write_count, numMessagesMax);
- uint16_t* read_data = new uint16_t[numMessagesMax]();
- ASSERT_TRUE(fmsg_queue->read(read_data, numMessagesMax));
- ASSERT_TRUE(verifyData(read_data, numMessagesMax));
- delete[] read_data;
-}
-
-/*
- * Request service to write more than maximum number of messages to the FMQ.
- * Verify that the write fails. Verify that availableToRead() method
- * still returns 0 and verify that attempt to read fails.
- */
-TEST_F(MQTestClient, LargeInputTest2) {
- ASSERT_TRUE(fmsg_queue->availableToRead() == 0);
- const int numMessages = 2048;
- ASSERT_TRUE(numMessages > numMessagesMax);
- int write_count = -1, expected_count = 0;
- service->requestWrite(numMessages,
- [&write_count](auto ret) { write_count = ret; });
- ASSERT_EQ(write_count, expected_count);
- uint16_t read_data;
- ASSERT_TRUE(fmsg_queue->availableToRead() == 0);
- ASSERT_FALSE(fmsg_queue->read(&read_data, 1));
-}
-
-/*
- * Write until FMQ is full.
- * Verify that the number of messages available to write
- * is equal to numMessagesMax.
- * Verify that another write attempt fails.
- * Request service to read. Verify read count.
- */
-TEST_F(MQTestClient, LargeInputTest3) {
- uint16_t* data = new uint16_t[numMessagesMax];
- for (int i = 0; i < numMessagesMax; i++) {
- data[i] = i;
- }
-
- ASSERT_TRUE(fmsg_queue->write(data, numMessagesMax));
- ASSERT_TRUE(fmsg_queue->availableToWrite() == 0);
- ASSERT_FALSE(fmsg_queue->write(data, 1));
-
- int read_count = -1;
- service->requestRead(numMessagesMax,
- [&read_count](auto ret) { read_count = ret; });
- ASSERT_EQ(read_count, numMessagesMax);
- delete[] data;
-}
-
-/*
- * Confirm that the FMQ is empty. Request service to write to FMQ.
- * Do multiple reads to empty FMQ and verify data.
- */
-TEST_F(MQTestClient, MultipleRead) {
- const int chunkSize = 100;
- const int chunkNum = 5;
- const int numMessages = chunkSize * chunkNum;
- ASSERT_TRUE(numMessages <= numMessagesMax);
- int availableToRead = fmsg_queue->availableToRead();
- int expected_count = 0;
- ASSERT_EQ(availableToRead, expected_count);
- int write_count = 0;
- service->requestWrite(numMessages,
- [&write_count](auto ret) { write_count = ret; });
- ASSERT_EQ(write_count, numMessages);
- uint16_t read_data[numMessages] = {};
- for (int i = 0; i < chunkNum; i++) {
- ASSERT_TRUE(fmsg_queue->read(read_data + i * chunkSize, chunkSize));
- }
- ASSERT_TRUE(verifyData(read_data, numMessages));
-}
-
-/*
- * Write to FMQ in bursts.
- * Request service to read data. Verify read_count.
- */
-TEST_F(MQTestClient, MultipleWrite) {
- const int chunkSize = 100;
- const int chunkNum = 5;
- const int numMessages = chunkSize * chunkNum;
- ASSERT_TRUE(numMessages <= numMessagesMax);
- uint16_t data[numMessages];
- for (int i = 0; i < numMessages; i++) {
- data[i] = i;
- }
- for (int i = 0; i < chunkNum; i++) {
- ASSERT_TRUE(fmsg_queue->write(data + i * chunkSize, chunkSize));
- }
- int read_count = -1;
- service->requestRead(numMessages,
- [&read_count](auto ret) { read_count = ret; });
- ASSERT_TRUE(read_count == numMessages);
-}
-
-/*
- * Write enough messages into the FMQ to fill half of it.
- * Request service to read back the same.
- * Write numMessagesMax messages into the queue. This should cause a
- * wrap around. Request service to read and verify the data.
- */
-TEST_F(MQTestClient, ReadWriteWrapAround) {
- int numMessages = numMessagesMax / 2;
- uint16_t* data = new uint16_t[numMessagesMax];
- for (int i = 0; i < numMessagesMax; i++) {
- data[i] = i;
- }
- ASSERT_TRUE(fmsg_queue->write(data, numMessages));
- int read_count = -1;
- service->requestRead(numMessages,
- [&read_count](auto ret) { read_count = ret; });
- ASSERT_TRUE(read_count == numMessages);
- ASSERT_TRUE(fmsg_queue->write(data, numMessagesMax));
- read_count = -1;
- service->requestRead(numMessagesMax,
- [&read_count](auto ret) { read_count = ret; });
- ASSERT_TRUE(read_count == numMessagesMax);
- delete[] data;
-}
diff --git a/fast_msgq/TestMsgQService.cpp b/fast_msgq/TestMsgQService.cpp
deleted file mode 100644
index 9f3b255..0000000
--- a/fast_msgq/TestMsgQService.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-#include <iostream>
-#include <map>
-
-#include <unistd.h>
-
-#include <BnTestMsgQ.h>
-#include <common/MessageQueue.h>
-#include <hwbinder/IInterface.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/IServiceManager.h>
-#include <hwbinder/ProcessState.h>
-#include <hwbinder/Status.h>
-#include <utils/Errors.h>
-#include <utils/Log.h>
-#include <utils/Looper.h>
-#include <utils/StrongPointer.h>
-// libutils:
-using android::Looper;
-using android::LooperCallback;
-using android::OK;
-using android::sp;
-using android::String16;
-
-// libhwbinder:
-using android::hardware::BnInterface;
-using android::hardware::defaultServiceManager;
-using android::hardware::IInterface;
-using android::hardware::IPCThreadState;
-using android::hardware::Parcel;
-using android::hardware::ProcessState;
-using android::hardware::Status;
-using android::hardware::hidl_version;
-using android::hardware::make_hidl_version;
-using android::hardware::from_ref;
-
-// Standard library
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::map;
-using std::string;
-using std::unique_ptr;
-using std::vector;
-
-// Generated HIDL files
-using android::hardware::tests::BnTestMsgQ;
-
-typedef uint64_t ringbuffer_position_t;
-
-namespace {
-
-class BinderCallback : public LooperCallback {
- public:
- BinderCallback() {}
- ~BinderCallback() override {}
-
- int handleEvent(int /* fd */, int /* events */, void* /* data */) override {
- IPCThreadState::self()->handlePolledCommands();
- return 1; // Continue receiving callbacks.
- }
-};
-
-class TestMsgQ : public BnTestMsgQ {
- public:
- TestMsgQ() : fmsg_queue(nullptr) {}
- virtual ~TestMsgQ() {
- if (fmsg_queue) {
- delete fmsg_queue;
- }
- }
-
- // TODO:: Change callback argument to bool.
- virtual Status requestWrite(int count, ITestMsgQ::requestWrite_cb callback) {
- uint16_t* data = new uint16_t[count];
- for (int i = 0; i < count; i++) {
- data[i] = i;
- }
- if (fmsg_queue->write(data, count)) {
- callback(count);
- } else {
- callback(0);
- }
- delete[] data;
- return Status::ok();
- }
- // TODO:: Change callback argument to bool.
- virtual Status requestRead(int count, ITestMsgQ::requestRead_cb callback) {
- uint16_t* data = new uint16_t[count];
- if (fmsg_queue->read(data, count) && verifyData(data, count)) {
- callback(count);
- } else {
- callback(0);
- }
- delete[] data;
- return Status::ok();
- }
-
- virtual Status configure(ITestMsgQ::configure_cb callback) {
- size_t eventQueueTotal = 4096;
- const size_t eventQueueDataSize = 2048;
- int ashmemFd = ashmem_create_region("MessageQueue", eventQueueTotal);
- ashmem_set_prot_region(ashmemFd, PROT_READ | PROT_WRITE);
- /*
- * The native handle will contain the fds to be mapped.
- */
- native_handle_t* mq_handle = native_handle_create(1, 0);
- if (!mq_handle) {
- ALOGE("Unable to create native_handle_t");
- return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
- }
-
- std::vector<android::hardware::GrantorDescriptor> Grantors(
- MINIMUM_GRANTOR_COUNT);
-
- mq_handle->data[0] = ashmemFd;
-
- /*
- * Create Grantor Descriptors for read, write pointers and the data buffer.
- */
- Grantors[android::hardware::READPTRPOS] = {0, 0, 0,
- sizeof(ringbuffer_position_t)};
- Grantors[android::hardware::WRITEPTRPOS] = {0, 0, sizeof(ringbuffer_position_t),
- sizeof(ringbuffer_position_t)};
- Grantors[android::hardware::DATAPTRPOS] = {
- 0, 0, 2 * sizeof(ringbuffer_position_t), eventQueueDataSize};
-
- android::hardware::MQDescriptor mydesc(Grantors, mq_handle, 0,
- sizeof(uint16_t));
- if (fmsg_queue) {
- delete fmsg_queue;
- }
- fmsg_queue = new android::hardware::MessageQueue<uint16_t>(mydesc);
- ITestMsgQ::WireMQDescriptor* wmsgq_desc = CreateWireMQDescriptor(mydesc);
- callback(*wmsgq_desc);
- delete[] wmsgq_desc->grantors.buffer;
- delete wmsgq_desc;
- return Status::ok();
- }
- android::hardware::MessageQueue<uint16_t>* fmsg_queue;
-
- private:
- /*
- * Utility function to verify data read from the fast message queue.
- */
- bool verifyData(uint16_t* data, int count) {
- for (int i = 0; i < count; i++) {
- if (data[i] != i) return false;
- }
-
- return true;
- }
-
- /*
- * Create WireMQDescriptor from MQDescriptor.
- */
- ITestMsgQ::WireMQDescriptor* CreateWireMQDescriptor(
- android::hardware::MQDescriptor& rb_desc) {
- ITestMsgQ::WireMQDescriptor* wmq_desc = new ITestMsgQ::WireMQDescriptor;
- const vector<android::hardware::GrantorDescriptor>& vec_gd =
- rb_desc.getGrantors();
- wmq_desc->grantors.count = vec_gd.size();
- wmq_desc->grantors.buffer =
- new ITestMsgQ::WireGrantorDescriptor[wmq_desc->grantors.count];
- for (size_t i = 0; i < wmq_desc->grantors.count; i++) {
- wmq_desc->grantors.buffer[i] = {
- 0, {vec_gd[i].fdIndex, vec_gd[i].offset, vec_gd[i].extent}};
- }
- wmq_desc->mq_handle = (rb_desc.getHandle())->handle();
- wmq_desc->quantum = rb_desc.getQuantum();
- wmq_desc->flags = rb_desc.getFlags();
- return wmq_desc;
- }
-};
-
-int Run() {
- android::sp<TestMsgQ> service = new TestMsgQ;
- sp<Looper> looper(Looper::prepare(0 /* opts */));
-
- int binder_fd = -1;
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- IPCThreadState::self()->disableBackgroundScheduling(true);
- IPCThreadState::self()->setupPolling(&binder_fd);
- if (binder_fd < 0) return -1;
-
- sp<BinderCallback> cb(new BinderCallback);
- if (looper->addFd(binder_fd, Looper::POLL_CALLBACK, Looper::EVENT_INPUT, cb,
- nullptr) != 1) {
- ALOGE("Failed to add binder FD to Looper");
- return -1;
- }
- hidl_version version = android::hardware::make_hidl_version(4, 0);
- defaultServiceManager()->addService(service->getInterfaceDescriptor(),
- service, version);
-
- ALOGI("Entering loop");
- while (true) {
- const int result = looper->pollAll(-1 /* timeoutMillis */);
- ALOGI("Looper returned %d", result);
- }
- return 0;
-}
-
-} // namespace
-
-int main(int /* argc */, char* /* argv */ []) { return Run(); }
diff --git a/fast_msgq/common/MessageQueue.h b/fast_msgq/common/MessageQueue.h
deleted file mode 100644
index cf042ae..0000000
--- a/fast_msgq/common/MessageQueue.h
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * 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 HIDL_MQ_H
-#define HIDL_MQ_H
-
-#include <atomic>
-#include "MessageQueueDesc.h"
-
-#define MINIMUM_GRANTOR_COUNT 3
-
-namespace android {
-namespace hardware {
-
-template <typename T>
-struct MessageQueue {
- MessageQueue(const MQDescriptor& Desc);
- ~MessageQueue();
- size_t availableToWrite() const;
- size_t availableToRead() const;
- size_t getQuantumSize() const;
- size_t getQuantumCount() const;
- bool isValid() const;
-
- bool write(const T* data);
- bool read(T* data);
- bool write(const T* data, size_t count);
- bool read(T* data, size_t count);
- const MQDescriptor* getDesc() const { return &mDesc; }
-
- private:
- struct region {
- uint8_t* address;
- size_t length;
- };
- struct transaction {
- region first;
- region second;
- };
-
- size_t writeBytes(const uint8_t* data, size_t size);
- transaction beginWrite(size_t nBytesDesired) const;
- void commitWrite(size_t nBytesWritten);
-
- size_t readBytes(uint8_t* data, size_t size);
- transaction beginRead(size_t nBytesDesired) const;
- void commitRead(size_t nBytesRead);
-
- MessageQueue(const MessageQueue& other) = delete;
- MessageQueue& operator=(const MessageQueue& other) = delete;
- MessageQueue();
-
- MQDescriptor mDesc;
- uint8_t* mRing;
- std::atomic<uint64_t>* mReadPtr;
- std::atomic<uint64_t>* mWritePtr;
-};
-
-template <typename T>
-MessageQueue<T>::MessageQueue(const MQDescriptor& Desc) : mDesc(Desc) {
- /*
- * Verify that the the Descriptor contains the minimum number of grantors
- * the native_handle is valid and T matches quantum size.
- */
- if ((Desc.getHandle() == nullptr) ||
- (Desc.getGrantors().size() < MINIMUM_GRANTOR_COUNT) ||
- (Desc.getQuantum() != sizeof(T)))
- return;
-
- mReadPtr = (std::atomic<uint64_t>*)mDesc.mapGrantorDescr(READPTRPOS);
- mWritePtr = (std::atomic<uint64_t>*)mDesc.mapGrantorDescr(WRITEPTRPOS);
- mReadPtr->store(0, std::memory_order_acquire);
- mWritePtr->store(0, std::memory_order_acquire);
- mRing = (uint8_t*)mDesc.mapGrantorDescr(DATAPTRPOS);
-}
-
-template <typename T>
-MessageQueue<T>::~MessageQueue() {
- if (mReadPtr) mDesc.unmapGrantorDescr(mReadPtr, READPTRPOS);
- if (mWritePtr) mDesc.unmapGrantorDescr(mWritePtr, WRITEPTRPOS);
- if (mRing) mDesc.unmapGrantorDescr(mRing, DATAPTRPOS);
-}
-template <typename T>
-bool MessageQueue<T>::write(const T* data) {
- return write(data, 1);
-}
-
-template <typename T>
-bool MessageQueue<T>::read(T* data) {
- return read(data, 1);
-}
-template <typename T>
-bool MessageQueue<T>::write(const T* data, size_t count) {
- if (availableToWrite() < sizeof(T) * count) {
- return false;
- }
-
- return (writeBytes(reinterpret_cast<const uint8_t*>(data),
- sizeof(T) * count) == sizeof(T) * count);
-}
-
-template <typename T>
-bool MessageQueue<T>::read(T* data, size_t count) {
- if (availableToRead() < sizeof(T) * count) {
- return false;
- }
- return readBytes(reinterpret_cast<uint8_t*>(data), sizeof(T) * count) ==
- sizeof(T) * count;
-}
-
-template <typename T>
-size_t MessageQueue<T>::availableToWrite() const {
- return mDesc.getSize() - availableToRead();
-}
-
-template <typename T>
-size_t MessageQueue<T>::writeBytes(const uint8_t* data, size_t size) {
- transaction tx = beginWrite(size);
- memcpy(tx.first.address, data, tx.first.length);
- memcpy(tx.second.address, data + tx.first.length, tx.second.length);
- size_t result = tx.first.length + tx.second.length;
- commitWrite(result);
- return result;
-}
-
-/*
- * The below method does not check for available space since it was already
- * checked by write() API which invokes writeBytes() which in turn calls
- * beginWrite().
- */
-template <typename T>
-typename MessageQueue<T>::transaction MessageQueue<T>::beginWrite(
- size_t nBytesDesired) const {
- transaction result;
- auto readPtr = mReadPtr->load(std::memory_order_acquire);
- auto writePtr = mWritePtr->load(std::memory_order_relaxed);
- size_t writeOffset = writePtr % mDesc.getSize();
- size_t contiguous = mDesc.getSize() - writeOffset;
- if (contiguous < nBytesDesired) {
- result = {{mRing + writeOffset, contiguous},
- {mRing, nBytesDesired - contiguous}};
- } else {
- result = {
- {mRing + writeOffset, nBytesDesired}, {0, 0},
- };
- }
- return result;
-}
-
-template <typename T>
-void MessageQueue<T>::commitWrite(size_t nBytesWritten) {
- auto writePtr = mWritePtr->load(std::memory_order_relaxed);
- writePtr += nBytesWritten;
- mWritePtr->store(writePtr, std::memory_order_release);
-}
-
-template <typename T>
-size_t MessageQueue<T>::availableToRead() const {
- /*
- * Doing relaxed loads here because these accesses don't carry dependencies.
- * Dependent accesses won't happen until after a call to beginWrite or
- * beginRead
- * which do proper acquire/release.
- */
- return mWritePtr->load(std::memory_order_relaxed) -
- mReadPtr->load(std::memory_order_relaxed);
-}
-
-template <typename T>
-size_t MessageQueue<T>::readBytes(uint8_t* data, size_t size) {
- transaction tx = beginRead(size);
- memcpy(data, tx.first.address, tx.first.length);
- memcpy(data + tx.first.length, tx.second.address, tx.second.length);
- size_t result = tx.first.length + tx.second.length;
- commitRead(result);
- return result;
-}
-
-/*
- * The below method does not check whether nBytesDesired bytes are available
- * to read because the check is performed in the read() method before
- * readBytes() is invoked.
- */
-template <typename T>
-typename MessageQueue<T>::transaction MessageQueue<T>::beginRead(
- size_t nBytesDesired) const {
- transaction result;
- auto writePtr = mWritePtr->load(std::memory_order_acquire);
- auto readPtr = mReadPtr->load(std::memory_order_relaxed);
-
- size_t readOffset = readPtr % mDesc.getSize();
- size_t contiguous = mDesc.getSize() - readOffset;
-
- if (contiguous < nBytesDesired) {
- result = {{mRing + readOffset, contiguous},
- {mRing, nBytesDesired - contiguous}};
- } else {
- result = {
- {mRing + readOffset, nBytesDesired}, {0, 0},
- };
- }
-
- return result;
-}
-
-template <typename T>
-void MessageQueue<T>::commitRead(size_t nBytesRead) {
- auto readPtr = mReadPtr->load(std::memory_order_relaxed);
- readPtr += nBytesRead;
- mReadPtr->store(readPtr, std::memory_order_release);
-}
-
-template <typename T>
-size_t MessageQueue<T>::getQuantumSize() const {
- return mDesc.getQuantum();
-}
-
-template <typename T>
-size_t MessageQueue<T>::getQuantumCount() const {
- return mDesc.getSize() / mDesc.getQuantum();
-}
-
-template <typename T>
-bool MessageQueue<T>::isValid() const {
- return mRing != nullptr && mReadPtr != nullptr && mWritePtr != nullptr;
-}
-} // namespace hardware
-} // namespace android
-#endif // HIDL_MQ_H
diff --git a/fast_msgq/common/MessageQueueDesc.cpp b/fast_msgq/common/MessageQueueDesc.cpp
deleted file mode 100644
index d714c42..0000000
--- a/fast_msgq/common/MessageQueueDesc.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * 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.
- */
-
-#include "MessageQueueDesc.h"
-
-namespace android {
-namespace hardware {
-
-MQDescriptor::MQDescriptor(const std::vector<GrantorDescriptor>& grantors,
- native_handle_t* nhandle, int32_t flags, size_t size)
- : mGrantors(grantors), mQuantum(size), mFlags(flags) {
- mHandle = NativeHandle::create(nhandle, true);
-}
-
-/*
- * TODO: Modify design to send access flags over WireMQDescriptor
- * as well and use the same for the mmap call.
- */
-void* MQDescriptor::mapGrantorDescr(uint32_t grantor_idx) {
- const native_handle_t* handle = mHandle->handle();
- int fdIndex = mGrantors[grantor_idx].fdIndex;
- /*
- * Offset for mmap must be a multiple of PAGE_SIZE.
- */
- int mapOffset = (mGrantors[grantor_idx].offset / PAGE_SIZE) * PAGE_SIZE;
- int mapLength =
- mGrantors[grantor_idx].offset - mapOffset + mGrantors[grantor_idx].extent;
- void* address = mmap(0, mapLength, PROT_READ | PROT_WRITE, MAP_SHARED,
- handle->data[fdIndex], mapOffset);
- return (address == MAP_FAILED)
- ? nullptr
- : (uint8_t*)address + (mGrantors[grantor_idx].offset - mapOffset);
-}
-
-void MQDescriptor::unmapGrantorDescr(void* address, uint32_t grantor_idx) {
- const native_handle_t* handle = mHandle->handle();
- int mapOffset = (mGrantors[grantor_idx].offset / PAGE_SIZE) * PAGE_SIZE;
- int mapLength =
- mGrantors[grantor_idx].offset - mapOffset + mGrantors[grantor_idx].extent;
- void* baseAddress =
- (uint8_t*)address - (mGrantors[grantor_idx].offset - mapOffset);
- if (baseAddress) munmap(baseAddress, mapLength);
-}
-} // namespace hardware
-} // namespace android
diff --git a/fast_msgq/common/MessageQueueDesc.h b/fast_msgq/common/MessageQueueDesc.h
deleted file mode 100644
index 9e6a7af..0000000
--- a/fast_msgq/common/MessageQueueDesc.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * 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 _FMSGQ_DESCRIPTOR_H
-#define _FMSGQ_DESCRIPTOR_H
-
-#include <cutils/native_handle.h>
-#include <sys/mman.h>
-#include <utils/NativeHandle.h>
-#include <vector>
-
-namespace android {
-namespace hardware {
-
-struct GrantorDescriptor {
- uint32_t flags;
- uint32_t fdIndex;
- uint32_t offset;
- uint32_t extent;
-};
-
-enum GrantorType : int { READPTRPOS = 0, WRITEPTRPOS, DATAPTRPOS };
-
-struct MQDescriptor {
- MQDescriptor(const std::vector<GrantorDescriptor>& grantors,
- native_handle_t* nhandle, int32_t flags, size_t size);
-
- size_t getSize() const;
-
- size_t getQuantum() const;
-
- int32_t getFlags() const;
- const sp<NativeHandle> getHandle() const;
- const std::vector<GrantorDescriptor> getGrantors() const;
- void* mapGrantorDescr(uint32_t grantor_idx);
- void unmapGrantorDescr(void* address, uint32_t grantor_idx);
-
- private:
- MQDescriptor();
-
- sp<NativeHandle> mHandle = nullptr;
- std::vector<GrantorDescriptor> mGrantors;
- size_t mQuantum = 0;
- int32_t mFlags = 0;
-};
-
-inline size_t MQDescriptor::getSize() const {
- return mGrantors[DATAPTRPOS].extent;
-}
-
-inline size_t MQDescriptor::getQuantum() const { return mQuantum; }
-
-inline int32_t MQDescriptor::getFlags() const { return mFlags; }
-
-inline const sp<NativeHandle> MQDescriptor::getHandle() const {
- return mHandle;
-}
-
-inline const std::vector<GrantorDescriptor> MQDescriptor::getGrantors() const {
- return mGrantors;
-} // namespace hardware
-} // namespace android
-} // namespace android
-#endif // FMSGQ_DESCRIPTOR_H
diff --git a/fast_msgq/test_main.cpp b/fast_msgq/test_main.cpp
deleted file mode 100644
index 5d6a031..0000000
--- a/fast_msgq/test_main.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * 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.
- */
-
-#include <gtest/gtest.h>
-
-int main(int argc, char **argv)
-{
- ::testing::InitGoogleTest(&argc, argv);
- int ret = RUN_ALL_TESTS();
- return ret;
-}
diff --git a/generate.cpp b/generate.cpp
deleted file mode 100644
index 1e2b9ec..0000000
--- a/generate.cpp
+++ /dev/null
@@ -1,751 +0,0 @@
-#include <algorithm>
-#include <android-base/strings.h>
-#include <iostream>
-#include <map>
-#include <string>
-#include <regex>
-
-#include "generator_utility.h"
-#include "parser.h"
-
-using std::cout;
-using std::endl;
-
-#define CB_VAR_PREFIX "_cb_"
-
-string Type::VtsTypeDesc(string section)
-{
- string output = GeneratorUtility::Snip(section, "vts_type_" + TypeName(),
- GetSubs(section));
- return GeneratorUtility::trim(output);
-}
-
-const string Header::Generate(string section) const
-{
- Subs subs {};
- return GeneratorUtility::Snip(section, "header", subs);
-}
-const string Const::Generate(string section) const
-{
- Subs subs {{"NAME", name_->GetText()}, {"VAL", value_->GetText()}};
- return GeneratorUtility::Snip(section, "const", subs);
-}
-const string OpaqueType::Generate(string /*section*/) const
-{
- return "opaque";
-}
-const string StringType::Generate(string /*section*/) const
-{
- return "hidl_string";
-}
-const string HandleType::Generate(string /*section*/) const
-{
- return "native_handle";
-}
-
-const string TypedefDecl::Generate(string section) const
-{
- string out {"typedef "};
- out += base_->Generate(section) + " " + name_->Generate(section) + ";\n";
- return out;
-}
-const string ImportDecl::Generate(string section) const
-{
- return "Import code goes here for name " + name_->Generate(section) + "\n";
-}
-const string NamedType::Generate(string section) const
-{
- return name_->GetText();
-}
-const string RefType::Generate(string section) const
-{
- return "hidl_ref<" + base_->Generate(section) + ">";
- // return "int";
-}
-const string UnionType::Generate(string section) const
-{
- string out {"union {\n"};
- out += fields_->GenSemiList(section);
- out += '}';
- return out;
-}
-const string VecType::Generate(string section) const
-{
- return "generate.cpp VecType: Don't use this anymore";
-}
-const string EnumType::Generate(string section) const
-{
- return "enum {" + fields_->GenCommaList(section) + "}";
-}
-
-
-const string Element::Generate(string section) const
-{
- return GetText();
-}
-
-const string Field::Generate(string section) const
-{
- // TODO
- return "Field (TODO)";
-}
-
-const Subs Field::GetSubs(string section) const
-{
- return GetSubsC(section, FieldContext{"","","",0});
-}
-
-const Subs Field::GetSubsC(string section, const FieldContext &context) const
-{
- // string type_name { type_->TypeName() };
- Subs subs{{"param_name", context.var_prefix + name_->GetText()},
- {"package_name", GetParser()->GetPackageName()},
- {"init_value", initializer_ ? initializer_->GetText() : ""}};
- Type *type = GetType();
- if (type) {
- Subs type_subs {type->GetSubsC(section, context)};
- //PrintSubs("FieldTypeSubs", type_subs);
- subs.insert(subs.end(), type_subs.begin(), type_subs.end());
- } else {
- cout << "Null type!" << endl;
- }
- //PrintSubs("Field subs", subs);
- return subs;
-}
-
-const Subs VecType::GetSubs(string section) const
-{
- Subs subs{{"vec_name", "myVecName"},
- {"decl_base_type", GetBase()->Generate(section)},
- {"vts_base_type_description", GetBase()->VtsTypeDesc(section) }};
- return subs;
-}
-
-const Subs TypedefDecl::GetSubs(string section) const
-{
- return base_->GetSubs(section);
-}
-
-const Subs NamedType::GetSubs(string section) const
-{
- Subs base_subs{ base_->GetSubs(section) };
- Subs subs{{"named_type_name", name_->GetText()}};
- subs.insert(subs.end(), base_subs.begin(), base_subs.end());
- return subs;
-}
-
-const Subs NamedType::GetSubsC(string section, const FieldContext& context) const
-{
- Subs base_subs{ base_->GetSubsC(section, context) };
- Subs subs{{"named_type_name", name_->GetText()}};
- subs.insert(subs.end(), base_subs.begin(), base_subs.end());
- return subs;
-}
-
-const Subs RefType::GetSubs(string section) const
-{
- Subs subs{{"base_type_name", base_->Generate(section)}};
- return subs;
-}
-
-const Subs ArrayType::GetSubs(string section) const
-{
- Subs subs{{"array_name", "myArrayName"},
- {"array_size", dimension_->GetText()},
- {"base_type_name", base_->Description(section)}};
- return subs;
-}
-
-const Subs ScalarType::GetSubs(string section) const
-{
- Subs subs{{"field_type_vts", VtsType()},
- {"base_type_name", name_->GetText()}};
- return subs;
-}
-
-const Subs Function::GetSubs(string section) const
-{
- string callback_param;
- if (generates_->Size()) {
- Subs subs{{"function_name", name_->GetText()},
- {"package_name", GetParser()->GetPackageName()}};
- callback_param = GeneratorUtility::make_inline(
- GeneratorUtility::Snip(section, "callback_param", subs));
- }
- string call_param_list = fields_->GenCommaList(section, "");
- string params_and_callback;
- if (call_param_list == "" || callback_param == "") {
- params_and_callback = call_param_list + callback_param;
- } else {
- params_and_callback = call_param_list + ", " + callback_param;
- }
- string callback_invocation;
- if (generates_->Size() > 0) {
- string return_param_names = generates_->GenCommaNameList(
- section, "", "callback_var_", CB_VAR_PREFIX);
- Subs subs{{"return_param_names", return_param_names}};
- callback_invocation =
- GeneratorUtility::Snip(section, "callback_invocation", subs);
- }
- string function_params_stubs{fields_->GenCommaNameList(section, "", "stub_param_decl_")};
- string function_callback_text;
- string callback_check;
- if (generates_->Size()) {
- Subs subs{
- {"param_ret_write_snips",
- generates_->TextByPrefix(section, "param_ret_write_")},
- {"return_params_stubs",
- generates_->GenCommaNameList(section, "", "return_param_decl_")},
- };
- function_callback_text =
- GeneratorUtility::Snip(section, "callback_code", subs);
- callback_check = GeneratorUtility::Snip(section, "callback_check", Subs{});
- }
- string stub_arguments;
- if (function_callback_text == "" || function_params_stubs == "") {
- stub_arguments = function_params_stubs + function_callback_text;
- } else {
- stub_arguments = function_params_stubs + ", " + function_callback_text;
- }
- Subs subs{
- {"function_name", name_->GetText()},
- {"package_name", GetParser()->GetInterface()->GetText()},
- {"params_and_callback", params_and_callback},
- {"call_param_list", call_param_list},
- {"return_param_list", generates_->GenCommaList(section, "")},
- {"stub_arguments", stub_arguments},
- {"callback_check", callback_check},
- {"param_ret_read_snips",
- generates_->TextByPrefix(section, "param_ret_read_", CB_VAR_PREFIX)},
- {"param_write_snips", fields_->TextByPrefix(section, "param_write_")},
- {"param_read_snips", fields_->TextByPrefix(section, "param_read_")},
- {"func_name_as_enum", GeneratorUtility::upcase(name_->GetText())},
- {"param_decls", fields_->GenSemiList(section)},
- {"callback_invocation", callback_invocation},
- {"generates_variables",
- generates_->GenSemiList(section,
- FieldContext{"", "", "", 0}.vp(CB_VAR_PREFIX))},
- {"vts_args",
- generates_->GenVtsTypedFieldList(section, "return_type_hidl",
- "vts_args") +
- fields_->GenVtsTypedFieldList(section, "arg", "vts_args")},
- {"vts_callflow", GenCallflow(section)},
- };
- return subs;
-}
-
-string AnnotationValue::NoQuoteText()
-{
- return value_->NoQuoteText();
-}
-
-string Annotations::GenVtsCalls(string section, string anno_name, string out_label)
-{
- string out;
- Annotation *calls = GetAnnotation(anno_name);
- if (calls) {
- if (calls->GetUnnamedValues() && calls->GetUnnamedValues()->size() > 0) {
- for (auto &value : *calls->GetUnnamedValues()) {
- Subs subs{{"callflow_label", out_label},
- {"callflow_func_name", value->GetValue()->GetText()}};
- out += GeneratorUtility::Snip(section, "anno_calls", subs);
- }
- } else {
- GetParser()->Error(
- calls->Line(),
- "Call-graph annotation '%s' needs 1 or more unnamed string values",
- anno_name.c_str());
- }
- }
- // cout << "VtsCalls " << out << endl;
- return out;
-}
-
-string Function::GenCallflow(string section) const
-{
- string next_text = annotations_->GenVtsCalls(section, "next_calls", "next");
- string prev_text = annotations_->GenVtsCalls(section, "prev_calls", "prev");
- string entry_text = annotations_->HasKey("entry")
- ? GeneratorUtility::Snip(section, "anno_entry")
- : "";
- string exit_text = annotations_->HasKey("exit")
- ? GeneratorUtility::Snip(section, "anno_exit")
- : "";
- Subs subs{{"anno_entry", entry_text},
- {"anno_exit", exit_text},
- {"anno_calls", next_text + prev_text}};
- if (entry_text + exit_text + next_text + prev_text == "") {
- return "";
- }
- return GeneratorUtility::Snip(section, "vts_callflow", subs);
-}
-
-bool Annotation::HasKey(string key)
-{
- if (!entries_) {
- return false;
- }
- AnnotationEntries::iterator it = entries_->find(key);
- return it != entries_->end();
-
-}
-
-bool Annotations::HasKey(string key)
-{
- return !!GetAnnotation(key);
-}
-
-Annotation *Annotations::GetAnnotation(string key)
-{
- for (auto & a : annotations_) {
- if (a->NameText() == key) {
- return a;
- }
- }
- return nullptr;
-}
-
-AnnotationValues *Annotation::GetValues(string key)
-{
- return (*entries_)[key];
-}
-
-string Fields::GenVtsTypedFieldList(string section, string label,
- string snippet_name)
-{
- string output;
- for (auto &field : fields_) {
- Subs subs{{"arg_or_ret_type", label},
- {"vts_field_name", field->NameText()},
- {"vts_type_name", field->GetType()->VtsTypeName()},
- {"vts_type_description", field->GetType()->VtsTypeDesc(section)}};
- output += GeneratorUtility::Snip(section, snippet_name, subs);
- }
- return output;
-}
-
-string Fields::GenVtsEnumFieldList(string section)
-{
- string output;
- for (auto &field : fields_) {
- Subs subs{{"vts_enum_name", field->NameText()},
- {"vts_enum_value",
- field->GetValue() ? field->GetValue()->GetText() : ""}};
- output += GeneratorUtility::Snip(section, "vts_enum_field", subs);
- }
- return output;
-}
-
-string Field::GenVtsValues(string section)
-{
- if (!annotation_ || !annotation_->HasKey("normal")) {
- return "";
- }
- string output;
- for (auto &value : *annotation_->GetValues("normal")) {
- if (!value->GetValue()) {
- GetParser()->Error(annotation_->Line(),
- "'normal' annotation needs values!");
- continue;
- }
- Subs subs{{"type_name", GetType()->VtsType()},
- {"the_value", value->GetValue()->GetText()}};
- output += GeneratorUtility::Snip(section, "vts_values", subs);
- }
- return output;
-}
-
-
-string Fields::GenCommaNameList(string section, string prev_list, string snippet_prefix, string name_prefix)
-{
- string output{prev_list};
- for (auto &field : fields_) {
- if (output != "") {
- output += ", ";
- }
- string name = name_prefix + field->GetName();
- if (snippet_prefix == "") {
- output += name;
- } else {
- Subs subs{
- {"param_name", name},
- {"package_name", field->GetParser()->GetPackageName()},
- {"type_desc", field->GetType() ? field->GetType()->GetName() : ""}};
- string s;
- if (field->GetType()) {
- s = GeneratorUtility::make_inline(GeneratorUtility::Snip(
- section, snippet_prefix + field->GetType()->TypeSuffix(false),
- subs));
- }
- if (s == "") {
- s = GeneratorUtility::make_inline(
- GeneratorUtility::Snip(section, snippet_prefix + "default", subs));
- // if (field->GetType()) s += " Not found: " + snippet_prefix +
- // field->GetType()->TypeSuffix(false);
- }
- output += s;
- }
- }
- return output;
-}
-
-string Fields::GenCommaList(string section, string prev, bool out_params)
-{
- string output {prev};
- for (auto & field : fields_) {
- if (output != "") {
- output += ", ";
- }
- string special_string;
- if (field->GetType()) {
- special_string =
- GeneratorUtility::Snip(
- section, "param_decl_" + field->GetType()->TypeSuffix(true),
- field->GetSubs(section)) +
- GeneratorUtility::Snip(
- section, "param_decl_" + field->GetType()->TypeSuffix(false),
- field->GetSubs(section)) +
- GeneratorUtility::Snip(section,
- "param_decl_" + field->GetType()->TypeName(),
- field->GetSubs(section));
- }
- if (special_string != "") {
- output += (section == "json")
- ? special_string
- : GeneratorUtility::make_inline(special_string);
- } else {
- if (field->GetType()) { // Enum fields don't have a type
- output += field->GetType()->Generate(section);
- }
- if (!out_params) {
- output += " " + field->GetName();
- }
- if (field->GetValue()) { // some Enum fields have this
- output += " = " + field->GetValue()->GetText();
- }
- }
- }
- return output;
-}
-
-const string VecType::Description(string section) const
-{
- Subs subs{{"base_type_name", GetBase()->Description(section)}};
- return GeneratorUtility::Snip(section, "describe_type_vec", subs);
-}
-
-const string NamedType::Description(string section) const
-{
- Subs subs{{"package_name", GetParser()->GetPackageName()},
- {"the_type_name", GetName()}};
- return GeneratorUtility::Snip(section, "describe_named_type", subs);
-}
-
-const string TypeDecl::Description(string section) const
-{
- Subs subs{{"package_name", GetParser()->GetPackageName()},
- {"the_type_name", GetName()}};
- return GeneratorUtility::Snip(section, "describe_named_type", subs);
-}
-
-string Fields::GenSemiList(string section, const FieldContext &context)
-{
- string output {""};
- for (auto & field : fields_) {
- string special_string;
- if (field->GetType()) {
- special_string =
- GeneratorUtility::Snip(
- section, "field_decl_" + field->GetType()->TypeSuffix(true),
- field->GetSubsC(section, context)) +
- GeneratorUtility::Snip(
- section, "field_decl_" + field->GetType()->TypeSuffix(false),
- field->GetSubsC(section, context));
- }
- if (special_string != "") {
- output += GeneratorUtility::make_inline(special_string);
- } else {
- output += field->GetType()->Description(section) + " " +
- context.var_prefix + field->GetName() + field->GetInitText();
- }
- output += ";\n";
- }
- return output;
-}
-
-string Fields::GenByType(string section, string prefix)
-{
- string output{""};
- for (auto &field : fields_) {
- Subs subs = field->GetSubs(section);
- output += GeneratorUtility::Snip(
- section, prefix + field->GetType()->TypeName(), subs);
- }
- return output;
-}
-
-const string ArrayType::FixupText(string section, const FieldContext &context,
- string prefix) const
-{
- Type *base = GetBase();
- string base_fixup, base_ret_fixup;
- if (!base->HasFixup()) {
- base_fixup =
- "// Fixup not needed for this array " + base->Generate(section);
- } else {
- // TODO clean up this cut-and-paste hack job
- FieldContext new_context{"", context.designator, context.base_pointer,
- context.next_var + 1};
- new_context.designator += "[i" + std::to_string(new_context.next_var) + "]";
- string inner_array_fixup = base->FixupText(section, new_context, prefix);
- Subs subs{
- {"inner_array_fixup", inner_array_fixup},
- {"loop_var", "i" + std::to_string(new_context.next_var)},
- {"array_length", GenerateDimension()},
- };
- base_fixup = GeneratorUtility::Snip(section, "array_fixup_loop", subs);
- }
- Subs subs{
- {"array_fixup_loop", base_fixup},
- };
- return GeneratorUtility::Snip(section, prefix + "fixup_array", subs);
-}
-
-const string UnionType::FixupText(string section, const FieldContext &context,
- string prefix) const
-{
- Subs subs{{"param_name", context.designator}};
- return "Union Fixup Needed\n";
-}
-
-const string HandleType::FixupText(string section, const FieldContext &context,
- string prefix) const
-{
- Subs subs{{"param_name", context.designator},
- {"base_pointer", context.base_pointer}};
- return GeneratorUtility::Snip(section, prefix + "fixup_handle", subs);
-}
-
-const string StringType::FixupText(string section, const FieldContext &context,
- string prefix) const
-{
- Subs subs{{"param_name", context.designator},
- {"base_pointer", context.base_pointer}};
- return GeneratorUtility::Snip(section, prefix + "fixup_string", subs);
-}
-
-const string StructType::FixupText(string section, const FieldContext &context,
- string prefix) const
-{
- string struct_fixup_writer{" // struct fixup " + prefix + "\n"};
- for (auto &field : GetFields()->GetVec()) {
- Type *type{field->GetType()};
- if (!type->HasFixup()) {
- struct_fixup_writer +=
- "\n//field " + field->GetName() + " doesn't need fixup\n";
- continue;
- }
- FieldContext new_context{"", context.designator + "." + field->GetName(),
- context.base_pointer, context.next_var};
- struct_fixup_writer += type->FixupText(section, new_context, prefix);
- }
- return struct_fixup_writer;
-}
-
-const string VecType::FixupText(string section, const FieldContext &context,
- string prefix) const
-{
- Type *base = GetBase();
- string base_fixup, base_ret_fixup;
- if (!base->HasFixup()) {
- base_fixup = "// Fixup not needed for this vec " + base->Generate(section);
- base_ret_fixup = base_fixup;
- } else {
- // TODO clean up this cut-and-paste hack job
- FieldContext new_context{"", context.designator,
- context.designator, context.next_var+1};
-
- string outer_base_pointer = new_context.base_pointer;
- new_context.base_pointer = new_context.designator+".buffer";
- new_context.designator += ".buffer[i"+std::to_string(new_context.next_var)+"]";
- string inner_vec_fixup = base->FixupText(section, new_context, prefix);
- Subs subs{
- {"inner_vec_fixup", inner_vec_fixup},
- {"inner_ret_vec_fixup", inner_vec_fixup},
- {"loop_var", "i"+std::to_string(new_context.next_var)},
- {"base_pointer", outer_base_pointer},
- {"param_name", context.designator},
- };
- base_fixup = GeneratorUtility::Snip(section, "vec_fixup_loop", subs);
- base_ret_fixup =
- GeneratorUtility::Snip(section, "vec_ret_fixup_loop", subs);
- }
- Subs subs{{"param_name", context.designator},
- {"package_name", base->GetParser()->GetPackageName()},
- {"vec_base_type", base->Description(section)},
- {"base_pointer", context.base_pointer},
- {"vec_fixup_loop", base_fixup},
- {"vec_ret_fixup_loop", base_ret_fixup}};
- return GeneratorUtility::Snip(section, prefix + "fixup_vec", subs);
-}
-
-const Subs StructDecl::GetSubsC(string section,
- const FieldContext &context) const
-{
- Subs subs{
- {"struct_fields", base_->GetFields()->GenSemiList(section)},
- {"struct_name", name_->GetText()},
- {"struct_gen_fields",
- base_->GetFields()->GenByType(section, "struct_field_")},
- {"fixup_write_struct", GetBase()->FixupText(section, context, "write_")},
- {"fixup_ret_write_struct",
- GetBase()->FixupText(section, context, "write_ret_")},
- {"fixup_read_struct", GetBase()->FixupText(section, context, "read_")},
- {"fixup_ret_read_struct",
- GetBase()->FixupText(section, context, "read_ret_")},
- {"struct_type_description",
- GeneratorUtility::make_inline(Description(section))},
- {"offset_calculator", "0 /* offset_calculator */"},
- {"vts_type_name", VtsTypeName()},
- {"vts_struct_field", base_->GetFields()->GenVtsTypedFieldList(
- section, "", "vts_struct_field")},
- };
- return subs;
-}
-
-const Subs VecType::GetSubsC(string section, const FieldContext &context) const
-{
-
- Subs subs {
- {"fixup_write_vec", FixupText(section, context, "write_")},
- {"fixup_ret_write_vec", FixupText(section, context, "write_ret_")},
- {"fixup_read_vec", FixupText(section, context, "read_")},
- {"fixup_ret_read_vec", FixupText(section, context, "read_ret_")},
- {"decl_base_type", GetBase()->Description(section)},
- };
- return subs;
-}
-
-const Subs ArrayType::GetSubsC(string section,
- const FieldContext &context) const
-{
- Subs subs{
- {"fixup_write_array", FixupText(section, context, "write_")},
- {"fixup_ret_write_array", FixupText(section, context, "write_ret_")},
- {"array_size", dimension_->GetText()},
- {"base_type_name", base_->Description(section)},
- {"decl_base_type", GetBase()->Description(section)},
- };
- return subs;
-}
-
-const Subs UnionDecl::GetSubs(string section) const
-{
- Subs subs {
- {"union_fields", base_->GetFields()->GenSemiList(section)},
- {"union_name", name_->GetText()},
- {"union_gen_fields", base_->GetFields()->GenByType(section, "union_field_")},
- };
- return subs;
-}
-
-const Subs ImportDecl::GetSubs(string section) const
-{
- Subs subs {
- {"import_name", name_->GetText()},
- };
- return subs;
-}
-
-const Subs Const::GetSubs(string section) const
-{
- Subs subs {
- {"const_name", GetName()},
- {"const_value", GetValue()->GetText()},
- {"const_vts_type", GetValue()->HasStringValue() ? "bytes" : "int32_t"},
- };
- return subs;
-}
-
-const Subs EnumDecl::GetSubs(string section) const
-{
- Subs subs{
- {"enum_fields", base_->GetFields()->GenCommaList(section)},
- {"enum_name", name_->GetText()},
- {"enum_base_type", base_->TypeOfEnum(section)},
- {"quoted_fields_of_enum",
- base_->GetFields()->GenCommaNameList(section, "", "enum_quoted_name_")},
- {"vts_type_name", VtsTypeName()},
- {"vts_enum_field", base_->GetFields()->GenVtsEnumFieldList(section)},
- };
- return subs;
-}
-
-const string ArrayType::Generate(string section) const
-{
- string out = base_->Generate(section);
- out += '[' + dimension_->Generate(section) + ']';
- return out;
-}
-
-const string ScalarType::Generate(string section) const
-{
- return name_->GetText();
-}
-
-const string StructType::Generate(string section) const
-{
- string out {"struct {\n"};
- out += fields_->GenSemiList(section);
- out += '}';
- return out;
-}
-
-const string EnumType::TypeSuffix(bool subtype) const
-{
- if (subtype) {
- return TypeName() + "_" + type_->TypeSuffix(subtype);
- } else {
- return TypeName() + "_all";
- }
-}
-
-const string DerivedType::TypeSuffix(bool subtype) const
-{
- if (subtype) {
- return TypeName() + "_" + base_->TypeSuffix(subtype);
- } else {
- return TypeName() + "_all";
- }
-}
-
-const string ScalarType::TypeSuffix(bool subtype) const
-{
- if (subtype) {
- return TypeName() + SubtypeSuffix();
- } else {
- return TypeName() + "_all";
- }
-}
-
-string Fields::TextByPrefix(string section, string prefix, string name_prefix)
-{
- string out;
- // cout << " <<< TBP " << prefix << endl;
- for (auto &thing : fields_) {
- string thing_name = name_prefix + thing->GetName();
- if (prefix == "param_read_" || prefix == "param_ret_read_") {
- thing_name = "(*" + thing_name + ")";
- }
- FieldContext fc{name_prefix, thing_name, "&" + thing_name, 0};
- out += GeneratorUtility::Snip(section,
- prefix + thing->GetType()->TypeSuffix(true),
- thing->GetSubsC(section, fc));
- out += GeneratorUtility::Snip(section,
- prefix + thing->GetType()->TypeSuffix(false),
- thing->GetSubsC(section, fc));
- // cout << " type '" << (prefix+thing->TypeName()) << "' size " <<
- // out.size() << endl;
- }
- return out;
-}
diff --git a/generator_utility.cpp b/generator_utility.cpp
deleted file mode 100644
index 5f410cf..0000000
--- a/generator_utility.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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.
- */
-
-#include "generator_utility.h"
-#include "parser.h"
-
-extern bool generator_verbose_mode;
-
-// TODO use std::stringstream foo; foo << "string"; foo.str() instead of +...+
-using std::cout;
-using std::endl;
-
-string GeneratorUtility::Snip(const string §ion, const string &name,
- const Subs &subs, bool print) {
- SnipMapMap::iterator smm_it = snippets_cpp.find(section);
- if (smm_it == snippets_cpp.end()) {
- std::cerr << "Warning: Section " << section << " not found in snippets"
- << endl;
- return "";
- }
- SnipMap snip_map(smm_it->second);
-
- SnipMap::iterator it = snip_map.find(name);
- if (it == snip_map.end()) {
- if (print)
- std::cout << " Snip '" << name << "' not found in section '" << section
- << "'" << endl;
- return ""; // This is legal, e.g. many types don't need code
- }
- string snippet(it->second);
- // First, replace all the keys with uglified versions, in case the
- // key also appears in replacement text
- // TODO: Regex-escape the keys, or use a non-regex search/replace
- for (auto &sub : subs) {
- std::regex re(sub.first);
- snippet = std::regex_replace(snippet, re, sub.first + "####");
- }
- // Then, replace the uglified keys with the replacement text
- for (auto &sub : subs) {
- std::regex re(sub.first + "####");
- snippet = std::regex_replace(snippet, re, sub.second);
- }
- if (print)
- cout << "* * Final snippet for '" << name << "': '" << snippet << "' * *"
- << endl;
- if (generator_verbose_mode && snippet != "") {
- snippet = "// START " + name + "\n" + snippet + "\n// END " + name + "\n";
- }
- return snippet;
-}
-
-string GeneratorUtility::Snip(const string §ion, const string &name) {
- Subs subs{};
- return Snip(section, name, subs);
-}
-
-string GeneratorUtility::upcase(const string in) {
- string out{in};
- for (auto &ch : out) ch = toupper(ch);
- return out;
-}
-
-string GeneratorUtility::make_inline(const string in) {
- string out{in};
- std::replace(out.begin(), out.end(), '\n', ' ');
- return out;
-}
-
-string GeneratorUtility::trim(const string in) {
- string out{in};
- out.erase(out.find_last_not_of("\n") + 1);
- return out;
-}
-
-void GeneratorUtility::PrintSubs(const string &msg, const Subs subs)
-{
- cout << msg << ": \n";
- for (auto & sub : subs) {
- cout << " '" << sub.first << "' -> '" << sub.second << "'" << endl;
- }
-}
diff --git a/generator_utility.h b/generator_utility.h
deleted file mode 100644
index 96bc72b..0000000
--- a/generator_utility.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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 GENERATOR_UTILITY_H_
-#define GENERATOR_UTILITY_H_
-
-#include "snippets.h"
-#include <android-base/macros.h>
-#include <android-base/strings.h>
-
-#include <algorithm>
-#include <iostream>
-#include <map>
-#include <memory>
-#include <string>
-#include <regex>
-
-using std::string;
-using std::vector;
-using std::pair;
-
-using Subs = vector<pair<string, string>>;
-
-// Contains utility methods that used to generate the output files by hidl-gen.
-class GeneratorUtility {
- public:
- GeneratorUtility() {};
- virtual ~GeneratorUtility() {};
-
- static string Snip(const string §ion, const string &name,
- const Subs &subs, bool print = false);
-
- static string Snip(const string §ion, const string &name);
-
- static void PrintSubs(const string &msg, const Subs subs);
- static string upcase(const string in);
- static string make_inline(const string in);
- static string trim(const string in);
-
- private:
-
- DISALLOW_COPY_AND_ASSIGN(GeneratorUtility);
-};
-
-#endif // GENERATOR_UTILITY_H_
diff --git a/hidl.h b/hidl.h
deleted file mode 100644
index f3caa5b..0000000
--- a/hidl.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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 HIDL_HIDL_H_
-#define HIDL_HIDL_H_
-
-#include <limits>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "ast.h"
-#include "io_delegate.h"
-#include "options.h"
-//#include "type_namespace.h"
-
-namespace android {
-namespace hidl {
-
-enum class HidlError {
- UNKOWN = std::numeric_limits<int32_t>::min(),
- BAD_PRE_PROCESSED_FILE,
- PARSE_ERROR,
- FOUND_PARCELABLE,
- BAD_PACKAGE,
- BAD_IMPORT,
- BAD_TYPE,
- BAD_METHOD_ID,
- GENERATION_ERROR,
-
- OK = 0,
-};
-
-int Compile_hidl_to_cpp(const CppOptions& options,
- const IoDelegate& io_delegate);
-int Compile_hidl_to_cpp(const CppOptions& options,
- const IoDelegate& io_delegate);
-
-namespace internals {
-
-bool Parse_preprocessed_file(const IoDelegate& io_delegate,
- const std::string& filename);
-
-} // namespace internals
-
-} // namespace android
-} // namespace hidl
-
-#endif // HIDL_HIDL_H_
diff --git a/hidl_language_l.ll b/hidl_language_l.ll
deleted file mode 100644
index e797abb..0000000
--- a/hidl_language_l.ll
+++ /dev/null
@@ -1,153 +0,0 @@
-%{
-#include <string.h>
-#include <stdlib.h>
-
-#include "ast.h"
-#include "hidl_language_y.h"
-
-#define YY_USER_ACTION yylloc->columns(yyleng);
-%}
-
-%option yylineno
-%option noyywrap
-%option reentrant
-%option bison-bridge
-%option bison-locations
-
-%x LONG_COMMENT LINE_COMMENT STRING
-
-identifier [_a-zA-Z]([_a-zA-Z0-9]|\:\:)*
-whitespace ([ \t\r]+)
-intvalue [-+]?(0[0-7']*|[1-9][0-9']*|0[xX][0-9a-fA-F']+|0[bB][01']+)((l|L|ll|LL)?(u|U)?|(u|U)?(l|L|ll|LL)?)
-
-%%
-%{
- /* This happens at every call to yylex (every time we receive one token) */
- std::string extra_text;
- yylloc->step();
-%}
-
-
-\/\* { extra_text = yytext; BEGIN(LONG_COMMENT); }
-<LONG_COMMENT>\*+\/ { extra_text += yytext;
- yylval->element = new CommentElement(extra_text, "",
- yylloc->begin.line);
- yylloc->step(); BEGIN(INITIAL); /*return yy::parser::token::COMMENT;*/ }
-<LONG_COMMENT>\*+ { extra_text += yytext; }
-<LONG_COMMENT>\n+ { extra_text += yytext; yylloc->lines(yyleng); }
-<LONG_COMMENT>[^*\n]+ { extra_text += yytext; }
-
-
-\"([^\"]|\\\")*\" { yylval->element = new StringElement(yytext,
- yylloc->begin.line);
- return yy::parser::token::C_STR; }
-
-\'([^\\']|\\.)\' { yylval->element = new IntElement(yytext, extra_text,
- yylloc->begin.line);
- return yy::parser::token::C_CHAR; }
-
-\/\/.*\n { yylval->element = new CommentElement(yytext, "",
- yylloc->begin.line);
- yylloc->lines(1);
- yylloc->step();
- /*return yy::parser::token::COMMENT;*/ }
-
-\n+ { yylloc->lines(yyleng); yylloc->step(); }
-{whitespace} {}
-<<EOF>> { yyterminate(); }
-
- /* symbols */
-; { return ';'; }
-: { return ':'; }
-\{ { return '{'; }
-\} { return '}'; }
-= { return '='; }
-, { return ','; }
-@ { return '@'; }
-\. { return '.'; }
-\( { return '('; }
-\) { return ')'; }
-\[ { return '['; }
-\] { return ']'; }
-\< { return '<'; }
-\> { return '>'; }
-\|\| { return yy::parser::token::OR; }
-&& { return yy::parser::token::AND; }
-\| { return '|'; }
-\^ { return '^'; }
-& { return '&'; }
-== { return yy::parser::token::EQ; }
-!= { return yy::parser::token::NE; }
-\<= { return yy::parser::token::LE; }
-\>= { return yy::parser::token::GE; }
-\>\> { return yy::parser::token::RSHIFT; }
-\<\< { return yy::parser::token::LSHIFT; }
-\+ { return '+'; }
-- { return '-'; }
-\* { return '*'; }
-\/ { return '/'; }
-% { return '%'; }
-~ { return '~'; }
-! { return '!'; }
-
-
- /* keywords */
-const { return yy::parser::token::CONST; }
-oneway { return yy::parser::token::ONEWAY; }
-struct { return yy::parser::token::STRUCT; }
-union { return yy::parser::token::UNION; }
-enum { return yy::parser::token::ENUM; }
-typedef { return yy::parser::token::TYPEDEF; }
-version { return yy::parser::token::VERSION; }
-package { return yy::parser::token::PACKAGE; }
-interface { return yy::parser::token::INTERFACE; }
-generates { return yy::parser::token::GENERATES; }
-selects { return yy::parser::token::SELECTS; }
-import { return yy::parser::token::IMPORT; }
-ref { return yy::parser::token::REF; }
-vec { return yy::parser::token::VEC; }
-on { return yy::parser::token::ON; }
-
-int8_t { yylval->type = new ScalarType(new NameElement(yytext, extra_text,
- yylloc->begin.line)); return yy::parser::token::INT8; }
-int16_t { yylval->type = new ScalarType(new NameElement(yytext, extra_text,
- yylloc->begin.line)); return yy::parser::token::INT16; }
-int32_t { yylval->type = new ScalarType(new NameElement(yytext, extra_text,
- yylloc->begin.line)); return yy::parser::token::INT32; }
-int64_t { yylval->type = new ScalarType(new NameElement(yytext, extra_text,
- yylloc->begin.line)); return yy::parser::token::INT64; }
-uint8_t { yylval->type = new ScalarType(new NameElement(yytext, extra_text,
- yylloc->begin.line)); return yy::parser::token::UINT8; }
-uint16_t { yylval->type = new ScalarType(new NameElement(yytext, extra_text,
- yylloc->begin.line)); return yy::parser::token::UINT16; }
-uint32_t { yylval->type = new ScalarType(new NameElement(yytext, extra_text,
- yylloc->begin.line)); return yy::parser::token::UINT32; }
-uint64_t { yylval->type = new ScalarType(new NameElement(yytext, extra_text,
- yylloc->begin.line)); return yy::parser::token::UINT64; }
-char { yylval->type = new ScalarType(new NameElement(yytext, extra_text,
- yylloc->begin.line)); return yy::parser::token::CHAR; }
-opaque { yylval->type = new ScalarType(new NameElement(yytext, extra_text,
- yylloc->begin.line)); return yy::parser::token::OPAQUE; }
-handle { yylval->type = new HandleType(); return yy::parser::token::HANDLE; }
-string { yylval->type = new StringType(); return yy::parser::token::STRINGTOK; }
-
-
- /* scalars */
-{identifier} { yylval->element = new NameElement(yytext, extra_text,
- yylloc->begin.line);
- return yy::parser::token::IDENTIFIER;
- }
-{intvalue} { yylval->element = new IntElement(yytext, extra_text,
- yylloc->begin.line);
- return yy::parser::token::INTVALUE; }
-
- /* syntax Error! */
-. { printf("UNKNOWN(%s)", yytext);
- yylval->element = new ErrorElement(yytext, extra_text, yylloc->begin.line);
- return yy::parser::token::IDENTIFIER;
- }
-
-%%
-
-// comment and whitespace handling
-// ================================================
diff --git a/hidl_language_y.yy b/hidl_language_y.yy
deleted file mode 100644
index 9cf6320..0000000
--- a/hidl_language_y.yy
+++ /dev/null
@@ -1,362 +0,0 @@
-%{
-#include "ast.h"
-#include "hidl_language_y.h"
-#include "parser.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int yylex(yy::parser::semantic_type *, yy::parser::location_type *, void *);
-
-#define lex_scanner ps->Scanner()
-
-%}
-
-%parse-param { Parser* ps }
-%lex-param { void *lex_scanner }
-
-%pure-parser
-%skeleton "glr.cc"
-
-%union {
- Element *element;
- std::vector<Element *> *elements;
- Field *field;
- Fields *fields;
- Type *type;
- AnnotationEntry *annotation_entry;
- AnnotationEntries *annotation_entries;
- AnnotationValues *annotation_values;
- Annotation *annotation;
- AnnotationValue *annotation_value;
- Annotations *annotations;
- int integer;
- bool boolean;
- std::string *str;
- std::vector<std::string *> *strings;
-}
-
-%token '(' ')' ',' '@' '=' '[' ']' '.' '{' '}' ';'
-
-%left OR
-%left AND
-%left '|'
-%left '^'
-%left '&'
-%left EQ NE
-%left '<' LE '>' GE
-%left RSHIFT LSHIFT
-%left '+' '-'
-%left '*' '/' '%'
-%right '~' '!' UMINUS UPLUS
-
-%token CONST STRUCT UNION ENUM TYPEDEF VERSION INTERFACE
-%token PACKAGE GENERATES IMPORT REF VEC ON SELECTS
-%token INT8 INT16 INT32 INT64 UINT8 UINT16 UINT32 UINT64
-%token CHAR OPAQUE HANDLE STRINGTOK ONEWAY
-
-%token<str> C_CHAR;
-%token<element> IDENTIFIER
-%token<element> COMMENT
-%token<element> INTVALUE C_STR
-
-%type<strings> namespace
-%type<annotations> annotations
-%type<element> dotted_ids
-%type<str> imports
-%type<annotation_entry> annotation_entry
-%type<annotation> annotation
-%type<annotation_entries> annotation_entries
-%type<str> typedef_decl
-%type<annotation_value> annotation_value
-%type<annotation_values> annotation_values
-%type<boolean> oneway
-%type<element> scalar_value scalar_expr const_expr
-%type<elements> id_list namespace_list
-%type<field> disc_union_field enum_field var_decl
-%type<fields> enum_fields disc_union_fields var_decls_semi func_args
-%type<type> union_type disc_union_type struct_type any_type one_word_type scalar_type
-%type<token> error
-%%
-
-document
- : comments intro '{' decls '}' ';' comments {}
-
-comments
- :
- | comments COMMENT { ps->AddComment($2); }
-
-intro
- : version namespace imports annotations INTERFACE IDENTIFIER
- { ps->SetInterface($4, $6); }
-
-version
- : VERSION INTVALUE '.' INTVALUE ';'
- { ps->SetVersion($2->GetIntegerValue(), $4->GetIntegerValue()); }
-
-namespace
- : PACKAGE namespace_list ';'
- { ps->SetNamespace($2); }
-
-imports
- : {}
- | imports import {}
-
-import
- : IMPORT namespace_list ';'
- { ps->AddImport($2); }
-
-namespace_list
- : IDENTIFIER
- { $$ = new std::vector<Element *>; $$->push_back($1); }
- | namespace_list '.' IDENTIFIER
- { $1->push_back($3); }
-
-decls
- : comments
- | decls decl comments
-
-decl
- : struct_decl {}
- | enum_decl {}
- | const_decl {}
- | function_decl {}
- | union_decl {}
- | typedef_decl {}
-
-struct_decl
- : STRUCT IDENTIFIER '{' var_decls_semi '}' ';'
- { ps->AddStruct(new StructDecl($2, new StructType($4))); }
-
-const_decl
- : CONST IDENTIFIER '=' const_expr ';'
- { ps->AddConst(new Const($2, $4)); }
-
-const_expr
- : scalar_expr {}
- | C_STR {}
-
-scalar_expr
- : scalar_value {}
- | scalar_expr OR scalar_expr
- { $$ = new BinaryExpression($1, $3, "||", $1->Line()); }
- | scalar_expr AND scalar_expr
- { $$ = new BinaryExpression($1, $3, "&&", $1->Line()); }
- | scalar_expr '|' scalar_expr
- { $$ = new BinaryExpression($1, $3, "|", $1->Line()); }
- | scalar_expr '^' scalar_expr
- { $$ = new BinaryExpression($1, $3, "^", $1->Line()); }
- | scalar_expr '&' scalar_expr
- { $$ = new BinaryExpression($1, $3, "&", $1->Line()); }
- | scalar_expr EQ scalar_expr
- { $$ = new BinaryExpression($1, $3, "==", $1->Line()); }
- | scalar_expr NE scalar_expr
- { $$ = new BinaryExpression($1, $3, "!=", $1->Line()); }
- | scalar_expr '<' scalar_expr
- { $$ = new BinaryExpression($1, $3, "<", $1->Line()); }
- | scalar_expr LE scalar_expr
- { $$ = new BinaryExpression($1, $3, "<=", $1->Line()); }
- | scalar_expr '>' scalar_expr
- { $$ = new BinaryExpression($1, $3, ">", $1->Line()); }
- | scalar_expr GE scalar_expr
- { $$ = new BinaryExpression($1, $3, ">=", $1->Line()); }
- | scalar_expr RSHIFT scalar_expr
- { $$ = new BinaryExpression($1, $3, ">>", $1->Line()); }
- | scalar_expr LSHIFT scalar_expr
- { $$ = new BinaryExpression($1, $3, "<<", $1->Line()); }
- | scalar_expr '+' scalar_expr
- { $$ = new BinaryExpression($1, $3, "+", $1->Line()); }
- | scalar_expr '-' scalar_expr
- { $$ = new BinaryExpression($1, $3, "-", $1->Line()); }
- | scalar_expr '*' scalar_expr
- { $$ = new BinaryExpression($1, $3, "*", $1->Line()); }
- | scalar_expr '/' scalar_expr
- { $$ = new BinaryExpression($1, $3, "/", $1->Line()); }
- | scalar_expr '%' scalar_expr
- { $$ = new BinaryExpression($1, $3, "%", $1->Line()); }
- | '(' scalar_expr ')'
- { $$ = new ParenthesizedExpression($2, "()", $2->Line()); }
- | '~' scalar_expr
- { $$ = new UnaryExpression($2, "~", $2->Line()); }
- | '!' scalar_expr
- { $$ = new UnaryExpression($2, "!", $2->Line()); }
- | '+' scalar_expr %prec UMINUS
- { $$ = new UnaryExpression($2, "+", $2->Line()); }
- | '-' scalar_expr %prec UPLUS
- { $$ = new UnaryExpression($2, "-", $2->Line()); }
-
-scalar_value
- : C_CHAR {}
- | INTVALUE {}
- | IDENTIFIER {}
-
-enum_decl
- : ENUM IDENTIFIER ':' scalar_type '{' enum_fields '}' ';'
- { ps->AddEnum(new EnumDecl($2, new EnumType($4, $6))); }
-
-function_decl
- : annotations oneway IDENTIFIER '(' func_args ')' ';'
- { ps->AddFunction(new Function($1, $2, $3, $5, new Fields)); }
- | annotations oneway IDENTIFIER '(' func_args ')' GENERATES '(' func_args ')' ';'
- { ps->AddFunction(new Function($1, $2, $3, $5, $9)); }
-
-
-func_args
- :
- { $$ = new Fields; }
- | var_decl
- { $$ = new Fields; $$->Add($1); }
- | func_args ',' var_decl
- { $$->Add($3); }
-
-var_decls_semi
- : var_decl ';'
- { $$ = new Fields; $$->Add($1); }
- | var_decls_semi var_decl ';'
- { $$->Add($2); }
-
-var_decl
- : any_type IDENTIFIER
- { $$ = new TypedField($1, $2); }
- | any_type IDENTIFIER SELECTS '(' dotted_ids ')'
- { $$ = new TypedField($1, $2, $5); }
-
-dotted_ids
- : IDENTIFIER {}
- | dotted_ids '.' IDENTIFIER
- { $1->AddDottedElement($3); }
-
-
-union_decl
- : UNION IDENTIFIER '{' var_decls_semi '}' ';'
- { ps->AddUnion(new UnionDecl($2, new UnionType($4))); }
- | UNION IDENTIFIER ':' IDENTIFIER '{' disc_union_fields '}' ';'
- { ps->AddUnion(new UnionDecl($2, new UnionType(new NamedType($4), $6))); }
-
-typedef_decl
- : TYPEDEF any_type IDENTIFIER ';'
- { ps->AddTypedef(new TypedefDecl($3, $2)); }
-
-disc_union_fields
- : disc_union_field
- { $$ = new Fields; $$->Add($1); }
- | disc_union_fields disc_union_field
- { $1->Add($2); }
-
-disc_union_field
- : any_type IDENTIFIER ON '(' id_list ')' ';'
- { $$ = new TypedField($1, $2, $5); }
-
-id_list
- : IDENTIFIER
- { $$ = new std::vector<Element *>; $$->push_back($1); }
- | id_list ',' IDENTIFIER
- { $1->push_back($3); }
-
-enum_fields
- : enum_field
- { $$ = new Fields; $$->Add($1); }
- | enum_fields ',' enum_field
- { $1->Add($3); }
-
-enum_field
- : IDENTIFIER
- { $$ = new EnumField($1); }
- | IDENTIFIER '=' scalar_expr
- { $$ = new EnumValueField($1, $3); }
-
-annotations
- : {$$ = new Annotations();}
- | annotations annotation { $$->Add($2); }
-
-annotation
- : '@' IDENTIFIER
- { $$ = new Annotation($2); }
- | '@' IDENTIFIER '(' annotation_value ')'
- { $$ = new Annotation($2, new AnnotationValues{$4}); }
- | '@' IDENTIFIER '(' '{' annotation_values '}' ')'
- { $$ = new Annotation($2, $5); }
- | '@' IDENTIFIER '(' annotation_entries ')'
- { $$ = new Annotation($2, $4); }
-
-annotation_entries
- : annotation_entry
- { $$ = new AnnotationEntries();
- $$->emplace(*$1); } // TODO: delete $1 ?
- | annotation_entries ',' annotation_entry
- { $$->emplace(*$3); }
-
-annotation_entry
- : IDENTIFIER '=' annotation_value
- { $$ = new AnnotationEntry{$1->GetText(), new AnnotationValues{$3}}; } // TODO: delete $1?
- | IDENTIFIER '=' '{' annotation_values '}'
- { $$ = new AnnotationEntry{$1->GetText(), $4}; }
-
-annotation_values
- : annotation_value
- { $$ = new AnnotationValues{$1}; }
- | annotation_values ',' annotation_value
- { $$->push_back($3); }
-
-annotation_value
- : const_expr
- { $$ = new AnnotationValue($1); }
- | annotation
- { $$ = new AnnotationValue($1); }
-
-scalar_type
- : UINT8 { }
- | UINT16 { }
- | UINT32 { }
- | UINT64 { }
- | INT8 { }
- | INT16 { }
- | INT32 { }
- | INT64 { }
- | CHAR { }
- | IDENTIFIER { $$ = new NamedType($1); } // Check at runtime if this is really scalar
-
-one_word_type
- : scalar_type
- | HANDLE { }
- | STRINGTOK { }
- | OPAQUE { }
-
-any_type
- : one_word_type {}
- | any_type '[' scalar_expr ']'
- { $$=new ArrayType($1, $3); }
- | struct_type {}
- | union_type {}
- | disc_union_type {}
- | VEC '<' any_type '>'
- { $$=new VecType($3); }
- | REF '<' any_type '>'
- { $$=new RefType($3); }
-
-
-struct_type
- : STRUCT '{' var_decls_semi '}'
- { $$=new StructType($3); }
-
-union_type
- : UNION '{' var_decls_semi '}'
- { $$=new UnionType($3); }
-
-disc_union_type
- : UNION ':' scalar_type '{' disc_union_fields '}'
- { $$=new UnionType($3, $5); }
-
-oneway
- : { $$ = false;}
- | ONEWAY { $$ = true;}
-
-%%
-
-#include <ctype.h>
-#include <stdio.h>
-
-void yy::parser::error(const yy::parser::location_type& l,
- const std::string& errstr) {
- ps->Error(l.begin.line, "%s", errstr.c_str());
-}
diff --git a/io_delegate.cpp b/io_delegate.cpp
deleted file mode 100644
index 93934ac..0000000
--- a/io_delegate.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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.
- */
-
-#include "io_delegate.h"
-
-#include <cstring>
-#include <fstream>
-#include <vector>
-
-#ifdef _WIN32
-#include <direct.h>
-#else
-#include <sys/stat.h>
-#include <unistd.h>
-#endif
-
-#include <android-base/strings.h>
-
-#include "logging.h"
-#include "os.h"
-
-using std::string;
-using std::unique_ptr;
-using std::vector;
-
-using android::base::Split;
-
-namespace android {
-namespace hidl {
-
-unique_ptr<string> IoDelegate::GetFileContents(
- const string& filename,
- const string& content_suffix) const {
- unique_ptr<string> contents;
- std::ifstream in(filename, std::ios::in | std::ios::binary);
- if (!in) {
- return contents;
- }
- contents.reset(new string);
- in.seekg(0, std::ios::end);
- ssize_t file_size = in.tellg();
- contents->resize(file_size + content_suffix.length());
- in.seekg(0, std::ios::beg);
- // Read the file contents into the beginning of the string
- in.read(&(*contents)[0], file_size);
- // Drop the suffix in at the end.
- contents->replace(file_size, content_suffix.length(), content_suffix);
- in.close();
-
- return contents;
-}
-
-unique_ptr<LineReader> IoDelegate::GetLineReader(
- const string& file_path) const {
- return LineReader::ReadFromFile(file_path);
-}
-
-bool IoDelegate::FileIsReadable(const string& path) const {
-#ifdef _WIN32
- // check that the file exists and is not Write-only
- return (0 == _access(path.c_str(), 0)) && // mode 0=exist
- (0 == _access(path.c_str(), 4)); // mode 4=readable
-#else
- return (0 == access(path.c_str(), R_OK));
-#endif
-}
-
-bool IoDelegate::CreatedNestedDirs(
- const string& caller_base_dir,
- const vector<string>& nested_subdirs) const {
- string base_dir = caller_base_dir;
- if (base_dir.empty()) {
- base_dir = ".";
- }
- for (const string& subdir : nested_subdirs) {
- if (base_dir[base_dir.size() - 1] != OS_PATH_SEPARATOR) {
- base_dir += OS_PATH_SEPARATOR;
- }
- base_dir += subdir;
- bool success;
-#ifdef _WIN32
- success = _mkdir(base_dir.c_str()) == 0;
-#else
- success = mkdir(base_dir.c_str(),
- S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0;
-#endif
- // On darwin when you try to mkdir("/", ...) we get EISDIR.
- if (!success && (errno != EEXIST && errno != EISDIR)) {
- LOG(ERROR) << "Error while creating directories: " << strerror(errno);
- return false;
- }
- }
- return true;
-}
-
-bool IoDelegate::CreatePathForFile(const string& path) const {
- if (path.empty()) {
- return true;
- }
-
- string base = ".";
- if (path[0] == OS_PATH_SEPARATOR) {
- base = "/";
- }
-
- auto split = Split(path, string{1u, OS_PATH_SEPARATOR});
- split.pop_back();
-
- return CreatedNestedDirs(base, split);
-}
-
-unique_ptr<CodeWriter> IoDelegate::GetCodeWriter(
- const string& file_path) const {
- return GetFileWriter(file_path);
-}
-
-void IoDelegate::RemovePath(const std::string& file_path) const {
-#ifdef _WIN32
- _unlink(file_path.c_str());
-#else
- unlink(file_path.c_str());
-#endif
-}
-
-} // namespace android
-} // namespace hidl
diff --git a/io_delegate.h b/io_delegate.h
deleted file mode 100644
index 5f5f377..0000000
--- a/io_delegate.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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 HIDL_IO_DELEGATE_H_
-#define HIDL_IO_DELEGATE_H_
-
-// #include <android-base/macros.h>
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "code_writer.h"
-#include "line_reader.h"
-
-namespace android {
-namespace hidl {
-
-class IoDelegate {
- public:
- IoDelegate() = default;
- virtual ~IoDelegate() = default;
-
- // Returns a unique_ptr to the contents of |filename|.
- // Will append the optional |content_suffix| to the returned contents.
- virtual std::unique_ptr<std::string> GetFileContents(
- const std::string& filename,
- const std::string& content_suffix = "") const;
-
- virtual std::unique_ptr<LineReader> GetLineReader(
- const std::string& file_path) const;
-
- virtual bool FileIsReadable(const std::string& path) const;
-
- virtual bool CreatedNestedDirs(
- const std::string& base_dir,
- const std::vector<std::string>& nested_subdirs) const;
-
- bool CreatePathForFile(const std::string& path) const;
-
- virtual std::unique_ptr<CodeWriter> GetCodeWriter(
- const std::string& file_path) const;
-
- virtual void RemovePath(const std::string& file_path) const;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(IoDelegate);
-}; // class IoDelegate
-
-} // namespace android
-} // namespace hidl
-
-#endif // HIDL_IO_DELEGATE_H_
diff --git a/line_reader.cpp b/line_reader.cpp
deleted file mode 100644
index 189bbc7..0000000
--- a/line_reader.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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.
- */
-
-#include "line_reader.h"
-
-#include <fstream>
-#include <sstream>
-
-using std::istringstream;
-using std::ifstream;
-using std::string;
-using std::unique_ptr;
-
-namespace android {
-namespace hidl {
-
-class FileLineReader : public LineReader {
- public:
- FileLineReader() = default;
- virtual ~FileLineReader() {
- input_stream_.close();
- }
-
- bool Init(const std::string& file_path) {
- input_stream_.open(file_path, ifstream::in | ifstream::binary);
- return input_stream_.is_open() && input_stream_.good();
- }
-
- bool ReadLine(string* Line) override {
- if (!input_stream_.good()) {
- return false;
- }
- Line->clear();
- std::getline(input_stream_, *Line);
- return true;
- }
-
- private:
- ifstream input_stream_;
-
- DISALLOW_COPY_AND_ASSIGN(FileLineReader);
-}; // class FileLineReader
-
-class MemoryLineReader : public LineReader {
- public:
- MemoryLineReader(const string& contents) : input_stream_(contents) {}
- virtual ~MemoryLineReader() = default;
-
- bool ReadLine(string* Line) override {
- if (!input_stream_.good()) {
- return false;
- }
- Line->clear();
- std::getline(input_stream_, *Line);
- return true;
- }
-
- private:
- istringstream input_stream_;
-
- DISALLOW_COPY_AND_ASSIGN(MemoryLineReader);
-}; // class MemoryLineReader
-
-unique_ptr<LineReader> LineReader::ReadFromFile(const string& file_path) {
- unique_ptr<FileLineReader> file_reader(new FileLineReader());
- unique_ptr<LineReader> ret;
- if (file_reader->Init(file_path)) {
- ret.reset(file_reader.release());
- }
- return ret;
-}
-
-unique_ptr<LineReader> LineReader::ReadFromMemory(const string& contents) {
- return unique_ptr<LineReader>(new MemoryLineReader(contents));
-}
-
-} // namespace android
-} // namespace hidl
diff --git a/line_reader.h b/line_reader.h
deleted file mode 100644
index 46197a6..0000000
--- a/line_reader.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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 HIDL_LINE_READER_H_
-#define HIDL_LINE_READER_H_
-
-#include <memory>
-#include <string>
-
-#include <android-base/macros.h>
-
-namespace android {
-namespace hidl {
-
-class LineReader {
- public:
- LineReader() = default;
- virtual ~LineReader() = default;
- virtual bool ReadLine(std::string* Line) = 0;
-
- static std::unique_ptr<LineReader> ReadFromFile(
- const std::string& file_path);
- static std::unique_ptr<LineReader> ReadFromMemory(
- const std::string& contents);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(LineReader);
-}; // class LineReader
-
-} // namespace android
-} // namespace hidl
-
-#endif // HIDL_LINE_READER_H_
diff --git a/logging.h b/logging.h
deleted file mode 100644
index a48f3d8..0000000
--- a/logging.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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 AIDL_LOGGING_H_
-#define AIDL_LOGGING_H_
-
-// We must include windows.h before android-base/logging.h on Windows.
-#ifdef _WIN32
-//#include <windows.h>// TODO This suddenly caused a weird Error (enum started failing in auto-gen lex file) and I commented it out. Why? (It may be related that Va_start() suddenly became undeclared though I hadn't touched that code in days.) -- CJP
-#endif
-
-#include <android-base/logging.h>
-
-#endif // AIDL_LOGGING_H_
diff --git a/main_hidl.cpp b/main_hidl.cpp
deleted file mode 100644
index d111f66..0000000
--- a/main_hidl.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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.
- */
-
-#include <memory>
-
-#include "hidl.h"
-#include "io_delegate.h"
-#include "logging.h"
-#include "options.h"
-#include "parser.h"
-
-using android::hidl::CppOptions;
-
-int main(int argc, char** argv) {
- android::base::InitLogging(argv);
- LOG(DEBUG) << "hidl starting";
-
- CppOptions *options = CppOptions::Parse(argc, argv);
- if (!options) {
- return 1;
- }
-
- android::hidl::IoDelegate io_delegate;
- Parser p{io_delegate, options->Verbose()};
- Thing::SetParser(&p);
- p.ParseFile(options->InputFileName());
- if (options->PrintStuff()) {
- p.Dump();
- }
- p.WriteDepFileIfNeeded(*options, io_delegate);
- for (auto & job : options->OutputJobs()) {
- android::hidl::CodeWriterPtr writer = android::hidl::GetFileWriter(job.output_file_name);
- p.Write(job.type, std::move(writer));
- if (p.GetErrorCount()) {
- printf("Exit error count: %d writing %s to %s\n",
- p.GetErrorCount(),
- job.type.c_str(),
- job.output_file_name.c_str());
- return p.GetErrorCount();
- }
- }
- delete options;
- return 0;
-}
diff --git a/make_snippets.py b/make_snippets.py
deleted file mode 100644
index 6d673cd..0000000
--- a/make_snippets.py
+++ /dev/null
@@ -1,87 +0,0 @@
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# 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.
-#
-
-import re
-import sys
-
-
-snips = {}
-labels = []
-
-def read_file(fname):
- global snips, labels
- f = open(fname)
- text = f.read()
- lines = text.split("\n")
- f.close()
- section = ""
- snips[section] = {}
- for line in lines:
- start = re.search(r"//\s*START\s+(\S+)", line)
- alls = re.search(r"//\s*ALL\s+(\S+)", line)
- if start or alls:
- name = (start and start.group(1)) or alls.group(1)
- if len(labels) > 0:
- snips[labels[-1][0]][labels[-1][1]] += name + "\\n"
- labels.append( (section, name) )
- #print "after append sec %s name %s, labels is %s"%(section, name, labels)
- skip = re.search(r"//\s*SKIP", line)
- if len(labels) > 0 and not skip:
- if labels[-1][1] not in snips[labels[-1][0]]:
- snips[labels[-1][0]][labels[-1][1]] = ""
- match_magic = re.compile(r"\s*//\s*(START|END|SECTION|ALL|SKIP).*?$")
- line_text = match_magic.sub("", line)
- if re.match(r"\s*$", line_text) and not re.match(r"\s*$", line):
- line_text = ""
- else:
- line_text = line_text.replace("\\", "\\\\") + "\\n"
- line_text = line_text.replace("\"", "\\\"")
- snips[labels[-1][0]][labels[-1][1]] += line_text
- sec_match = re.search(r"//\s*SECTION\s+(\S+)", line)
- if sec_match:
- section = sec_match.group(1)
- snips[section] = {}
- end = re.search(r"//\s*END\s+(\S+)", line)
- alls = re.search(r"//\s*ALL\s+(\S+)", line)
- if end or alls:
- name = (end and end.group(1)) or alls.group(1)
- if labels[-1] != (section, name):
- print "Error, found END '[%s, %s]' but expected '%s'"%(section, name, labels[-1])
- sys.exit(1)
-
- labels.pop()
- if len(labels) > 0:
- print "Error, labels %s left over"%labels
- sys.exit(1)
-
-def write(fname):
- global snips
- f = open(fname, "w")
- f.write("// AUTO GENERATED - python snippets.py outfile infile infile...\n")
- f.write("#include \"snippets.h\"\n")
- f.write("SnipMapMap snippets_cpp {\n")
- for section, snip_dict in snips.iteritems():
- f.write(" {\"%s\",{\n"%section)
- for name, snip in snip_dict.iteritems():
- f.write(" {std::string(\"%s\"),\"%s\"},\n"%
- (name, snip.replace('"','\"')))
- f.write(" }},")
- f.write("};\n")
-
-for file in sys.argv[2:]:
- read_file(file)
-write(sys.argv[1])
-sys.exit(0)
diff --git a/options.cpp b/options.cpp
deleted file mode 100644
index 2f1820c..0000000
--- a/options.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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.
- */
-
-#include "options.h"
-
-#include <cstring>
-#include <iostream>
-#include <stdio.h>
-
-#include "logging.h"
-#include "os.h"
-
-#include "snippets.h"
-
-using std::cerr;
-using std::endl;
-using std::string;
-using std::unique_ptr;
-using std::vector;
-
-namespace android {
-namespace hidl
-{
-namespace {
-
-CppOptions *cpp_usage() {
- cerr << "usage: hidl-gen OPTIONS TYPE INPUT_FILE OUTPUT_FILE" << endl
- << "usage: hidl-gen OPTIONS all_cpps INPUT_FILE HEADER_DIR SRC_DIR" << endl
- << endl
- << "OPTIONS:" << endl
- // << " -I<DIR> search path for import statements" << endl
- << " -d<FILE> Generate dependency file" << endl
- << " -p print info from input file (for debugging)" << endl
- << " -v verbose: output files include all snippet names" << endl
- << endl
- << "TYPE:" << endl
- << " all_cpp Generate FooAll.cpp (combined proxy/stub)" << endl
- << " all_cpps Generate FooAll.cpp, *.h" << endl
- << " binder Generate Binder .h file" << endl
- << " bn_h Generate BnFoo.h" << endl
- << " bp_h Generate BpFoo.h" << endl
- << " i_h Generate IFoo.h" << endl
- << " json Generate Foo.json" << endl
- << " proxy_cpp Generate FooProxy.cpp" << endl
- << " stubs_cpp Generate FooStubs.cpp" << endl
- << " vts Generate Foo.vts" << endl
- << endl
- << "INPUT_FILE:" << endl
- << " a hidl interface file" << endl
- << "OUTPUT_FILE:" << endl
- << " path to Write generated file" << endl;
- return nullptr;
-}
-
-} // namespace
-
-CppOptions *CppOptions::Parse(int argc, const char* const* argv) {
- CppOptions *options(new CppOptions());
- int i = 1;
-
- // Parse flags, all of which start with '-'
- for ( ; i < argc; ++i) {
- const size_t len = strlen(argv[i]);
- const char *s = argv[i];
- if (s[0] != '-') {
- break; // On to the positional arguments.
- }
- if (len < 2) {
- cerr << "Invalid argument '" << s << "'." << endl;
- return cpp_usage();
- }
- const string the_rest = s + 2;
- /* if (s[1] == 'I') {
- options->import_paths_.push_back(the_rest);
- } else*/
- if (s[1] == 'd') {
- options->dep_file_name_ = the_rest;
- } else if (s[1] == 'p') {
- options->print_stuff_ = true;
- } else if (s[1] == 'v') {
- options->verbose_ = true;
- } else {
- cerr << "Invalid argument '" << s << "'." << endl;
- return cpp_usage();
- }
- }
-
- // There are exactly three positional arguments.
- const int remaining_args = argc - i;
- if (remaining_args == 4 && !strcmp(argv[i], "all_cpps")) {
- string type = argv[i++];
- options->input_file_name_ = argv[i++];
- string header_directory = argv[i++];
- string source_file = argv[i++];
- int slash_pos = options->input_file_name_.find_last_of('/');
- string package_name = options->input_file_name_.substr(
- slash_pos + 2,
- options->input_file_name_.length() - slash_pos - 6);
- options->outputs_.push_back(Job{"bn_h", header_directory+"/Bn"+package_name+".h"});
- options->outputs_.push_back(Job{"bp_h", header_directory+"/Bp"+package_name+".h"});
- options->outputs_.push_back(Job{"i_h", header_directory+"/I"+package_name+".h"});
- options->outputs_.push_back(Job{"vts", header_directory+"/"+package_name+".vts"});
- options->outputs_.push_back(Job{"all_cpp", source_file});
- options->output_file_name_ = source_file;
- } else if (remaining_args == 3) {
- Job job;
- job.type = argv[i++];
- options->input_file_name_ = argv[i++];
- job.output_file_name = argv[i++];
- options->output_file_name_ = job.output_file_name;
- options->outputs_.push_back(job);
- SnipMapMap::iterator smm_it = snippets_cpp.find(job.type);
- if (smm_it == snippets_cpp.end()) {
- std::cout << "File type " << job.type << " not found." << endl;
- return cpp_usage();
- }
- } else {
- cerr << "Expected 3 positional arguments but got " << remaining_args << "." << endl;
- return cpp_usage();
- }
-
- if (!EndsWith(options->input_file_name_, ".hal")) {
- cerr << "Expected .hal file for input but got " << options->input_file_name_ << endl;
- return cpp_usage();
- }
-
- return options;
-}
-
-bool EndsWith(const string& str, const string& suffix) {
- if (str.length() < suffix.length()) {
- return false;
- }
- return std::equal(str.crbegin(), str.crbegin() + suffix.length(),
- suffix.crbegin());
-}
-
-bool ReplaceSuffix(const string& old_suffix,
- const string& new_suffix,
- string* str) {
- if (!EndsWith(*str, old_suffix)) return false;
- str->replace(str->length() - old_suffix.length(),
- old_suffix.length(),
- new_suffix);
- return true;
-}
-
-
-
-} // namespace android
-} // namespace hidl
diff --git a/options.h b/options.h
deleted file mode 100644
index fd9c35e..0000000
--- a/options.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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 HIDL_OPTIONS_H_
-#define HIDL_OPTIONS_H_
-
-#include <memory>
-#include <string>
-#include <vector>
-
-#include <android-base/macros.h>
-#include <gtest/gtest_prod.h>
-
-namespace android {
-namespace hidl {
-
-struct Job {
- std::string type;
- std::string output_file_name;
-};
-
-class CppOptions final {
- public:
- enum e_out_type {IFOO, BNFOO, BPFOO, FOOSTUBS, FOOPROXY, VTS,
- BINDER};
-
- ~CppOptions() = default;
-
- // Parses the command Line and returns a non-null pointer to an CppOptions
- // object on success.
- // Prints the usage statement on failure.
- static CppOptions *Parse(int argc, const char* const* argv);
-
- std::string InputFileName() const { return input_file_name_; }
-
- std::vector<std::string> ImportPaths() const { return import_paths_; }
- std::vector<Job> OutputJobs() { return outputs_; }
- std::string OutputFileName() { return output_file_name_; }
- std::string DependencyFilePath() const { return dep_file_name_; }
- bool PrintStuff() const { return print_stuff_; }
- bool Verbose() const { return verbose_; }
-
- private:
- CppOptions() = default;
-
- bool print_stuff_ = false;
- bool verbose_ = false;
- std::string input_file_name_;
- std::string output_file_name_;
- std::vector<Job> outputs_;
- std::vector<std::string> import_paths_;
- std::string dep_file_name_;
-
- FRIEND_TEST(CppOptionsTests, ParsesCompileCpp);
- DISALLOW_COPY_AND_ASSIGN(CppOptions);
-};
-
-bool EndsWith(const std::string& str, const std::string& suffix);
-bool ReplaceSuffix(const std::string& old_suffix,
- const std::string& new_suffix,
- std::string* str);
-
-} // namespace android
-} // namespace hidl
-
-#endif // HIDL_OPTIONS_H_
diff --git a/os.h b/os.h
deleted file mode 100644
index 752ed47..0000000
--- a/os.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2015, The Android Open Source Project
- *
- * 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 AIDL_OS_H_
-#define AIDL_OS_H_
-
-#if defined(_WIN32)
-#define OS_PATH_SEPARATOR '\\'
-#else
-#define OS_PATH_SEPARATOR '/'
-#endif
-
-#endif // AIDL_OS_H_
diff --git a/parser.cpp b/parser.cpp
deleted file mode 100644
index e5c0c94..0000000
--- a/parser.cpp
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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.
- */
-
-#include "parser.h"
-
-#include "generator_utility.h"
-#include "hidl_language_y.h"
-
-using android::hidl::IoDelegate;
-using android::base::Join;
-using std::cout;
-using std::endl;
-using std::string;
-using std::unique_ptr;
-
-void yylex_init(void **);
-void yylex_destroy(void *);
-void yyset_in(FILE *f, void *);
-int yyparse(Parser *);
-YY_BUFFER_STATE yy_scan_buffer(char *, size_t, void *);
-void yy_delete_buffer(YY_BUFFER_STATE, void *);
-
-bool generator_verbose_mode;
-
-Parser::Parser(const IoDelegate &io_delegate, bool verbose_mode)
- : io_delegate_(io_delegate), verbose_mode_(verbose_mode) {
- yylex_init(&scanner_);
-}
-
-Parser::~Parser() {
- if (raw_buffer_) {
- yy_delete_buffer(buffer_, scanner_);
- raw_buffer_.reset();
- }
- yylex_destroy(scanner_);
- // TODO: Free/destroy the namespaces / data structures from the HIDL file
-}
-
-bool Parser::ParseFile(const string &filename) {
- // Make sure we can read the file first, before trashing previous state.
- unique_ptr<string> new_buffer = io_delegate_.GetFileContents(filename);
- if (!new_buffer) {
- LOG(ERROR) << "Error while opening file for parsing: '" << filename << "'";
- Error("Error while opening file for parsing: '%s'", filename.c_str());
- return false;
- }
-
- // Throw away old parsing state if we have any.
- if (raw_buffer_) {
- yy_delete_buffer(buffer_, scanner_);
- raw_buffer_.reset();
- }
-
- raw_buffer_ = std::move(new_buffer);
- // We're going to scan this buffer in place, and yacc demands we put two
- // nulls at the end.
- raw_buffer_->append(2u, '\0');
- filename_ = filename;
- error_ = 0;
-
- buffer_ = yy_scan_buffer(&(*raw_buffer_)[0], raw_buffer_->length(), scanner_);
-
- things_.push_back(new Header());
-
- if (yy::parser(this).parse() != 0) {
- return false;
- }
-
- Validate();
-
- if (error_ != 0) {
- return false;
- }
-
- return true;
-}
-
-void Parser::AddComment(Element *comment) { AddThing(comment); }
-
-void Parser::SetInterface(Annotations *annotations, Element *name) {
- if (interface_) {
- Error(name->Line(), "Only one interface per file please!");
- }
- name->SetTokenText(name->GetText().substr(1, string::npos));
- interface_ = name;
- interface_annotations_ = annotations;
-}
-
-void Parser::SetVersion(int major, int minor) {
- if (version_set_) {
- Error("Cannot set two versions");
- }
- version_set_ = true;
- version_major_ = major;
- version_minor_ = minor;
-}
-
-void Parser::SetNamespace(vector<Element *> *names) {
- if (namespace_) {
- Error("Only one namespace per file please!");
- }
- namespace_ = names;
-}
-
-void Parser::AddImport(const vector<Element *> *names) {
- imports_.push_back(names);
- RegisterType(new ImportDecl(names->back()));
-}
-
-void Parser::AddStruct(StructDecl *structure) {
- RegisterType(structure);
- AddThing(structure);
-}
-
-void Parser::RegisterType(TypeDecl *decl) {
- string name_text = decl->GetName();
-
- if (types_.count(name_text)) {
- Error(decl->Line(), "Type name %s already exists", name_text.c_str());
- }
- types_.emplace(name_text, decl);
-}
-void Parser::RegisterConstant(const Element *name, const Element *value) {
- string name_text = name->GetText();
-
- if (consts_.count(name_text)) {
- Error(name->Line(), "Type name %s already exists", name_text.c_str());
- }
- consts_.emplace(name_text, value);
-}
-
-void Parser::AddConst(Const *constant) {
- AddThing(constant);
-
- const Element *name = constant->GetNameElement();
- const Element *value = constant->GetValue();
- RegisterConstant(name, value);
-}
-
-string Parser::CallEnumList(string section) {
- bool first = true;
- string out;
- for (auto &thing : things_) {
- if (thing->TypeName() != "function") {
- continue;
- }
- string fname{GeneratorUtility::upcase(((Function *)thing)->GetName())};
- if (first) {
- first = false;
- Subs subs{{"call_enum_name", fname}};
- out += GeneratorUtility::Snip(section, "first_call_enum", subs);
- out += "\n";
- } else {
- out += " " + fname + ", ";
- }
- }
- return out;
-}
-
-string Parser::CallbackDeclList(string section) {
- string out;
- for (auto &thing : things_) {
- if (thing->TypeName() != "function") {
- continue;
- }
- out += GeneratorUtility::Snip(
- section, "callback_decl_line",
- static_cast<Function *>(thing)->GetSubs(section));
- }
- return out;
-}
-
-void Parser::BuildNamespaceText(string section,
- std::vector<Element *> *namespace_,
- string &namespace_open, string &namespace_close,
- string &namespace_slashes,
- string &namespace_dots,
- string &namespace_underscores) {
- namespace_open = "";
- namespace_close = "";
- namespace_slashes = "";
- namespace_dots = "";
- namespace_underscores = "";
- for (auto &name : *namespace_) {
- Subs subs{{"namespace_name", name->GetText()}};
- namespace_open +=
- GeneratorUtility::Snip(section, "namespace_open_line", subs);
- namespace_close =
- GeneratorUtility::Snip(section, "namespace_close_line", subs) +
- namespace_close;
- if (namespace_slashes != "") namespace_slashes += "/";
- namespace_slashes += name->GetText();
- if (namespace_dots != "") namespace_dots += ".";
- namespace_dots += name->GetText();
- if (namespace_underscores != "") namespace_underscores += "_";
- namespace_underscores += name->GetText();
- }
-}
-
-void Parser::AddFunction(Function *function) { AddThing(function); }
-
-void Parser::AddUnion(UnionDecl *type) {
- AddThing(type);
- RegisterType(type);
-}
-
-void Parser::AddEnum(EnumDecl *en) {
- AddThing(en);
- RegisterType(en);
- // TODO: Register constants from en's fields
-}
-
-string Field::GetInitText() {
- if (initializer_) {
- return " = " + initializer_->GetText();
- } else {
- return "";
- }
-}
-
-void Parser::AddTypedef(TypedefDecl *type) {
- Error(type->Line(), "Typedef isn't supported yet");
- RegisterType(type);
- AddThing(type);
-}
-
-void Parser::AddThing(Thing *thing) { things_.push_back(thing); }
-
-bool Parser::IsTypeDeclared(Element *name) {
- return (types_.count(name->GetText()));
-}
-
-TypeDecl *Parser::GetDeclaredType(Element *name) {
- TypeMap::iterator it = types_.find(name->GetText());
- if (it == types_.end()) {
- return nullptr;
- }
- return it->second;
-}
-
-void Parser::Dump() {
- cout << "Interface: " << interface_->GetText() << endl;
- cout << "Version: " << version_major_ << ':' << version_minor_ << endl;
- cout << "Namespace: ";
- for (auto &name : *namespace_) {
- cout << name->GetText() << ' ';
- }
- cout << endl;
- for (auto &import : imports_) {
- cout << "Import: ";
- for (auto &name : *import) {
- cout << name->GetText() << ' ';
- }
- cout << endl;
- }
- cout << endl;
- for (auto &thing : things_) {
- thing->Dump();
- }
-}
-
-void Parser::Validate() {
- if (!version_set_) {
- Error("Need a version");
- }
- if (!namespace_) {
- Error("Need a namespace");
- }
-}
-
-void Parser::VaError(const char *format, va_list args) {
- vprintf(format, args);
- printf("\n");
-}
-
-void Parser::Error(int Line, const char *format, ...) {
- error_++;
- va_list args;
- printf("Error: Line %d: ", Line);
- va_start(args, format);
- VaError(format, args);
- va_end(args);
-}
-
-void Parser::Error(const char *format, ...) {
- error_++;
- va_list args;
- printf("Error: ");
- va_start(args, format);
- VaError(format, args);
- va_end(args);
-}
-
-void Parser::Error(string &s) {
- cout << s;
- error_++;
-}
-
-void Parser::WriteDepFileIfNeeded(android::hidl::CppOptions &options,
- android::hidl::IoDelegate &io_delegate) {
- string dep_file_name = options.DependencyFilePath();
- if (dep_file_name.empty()) {
- return; // nothing to do
- }
- android::hidl::CodeWriterPtr writerP =
- io_delegate.GetCodeWriter(dep_file_name);
- if (!writerP) {
- LOG(ERROR) << "Could not open dependency file: " << dep_file_name;
- // Parser::Error tells the build system there was a problem
- Error("Build system error: Could not open dependency file: %s",
- dep_file_name.c_str());
- return;
- }
-
- vector<string> hidl_sources = {options.InputFileName()};
-
- android::hidl::CodeWriter *writer = writerP.get();
- string output_file = options.OutputFileName();
-
- // Encode that the output file depends on hidl input files.
- writer->Write("%s : \\\n", output_file.c_str());
- writer->Write(" %s", Join(hidl_sources, " \\\n ").c_str());
- writer->Write("\n\n");
-
- // Output "<input_hidl_file>: " so make won't fail if the input .hal file
- // has been deleted, moved or renamed in incremental build.
- for (const auto &src : hidl_sources) {
- writer->Write("%s :\n", src.c_str());
- }
-}
-
-string Parser::TextByPrefix(string section, string prefix)
-{
- string out;
- for (auto &thing : things_) {
- out += GeneratorUtility::Snip(section, prefix + thing->TypeName(),
- thing->GetSubs(section));
- }
- return out;
-}
-
-void Parser::Write(string out_type, android::hidl::CodeWriterPtr writer) {
- section_ = out_type;
- writer_ = std::move(writer);
- generator_verbose_mode = verbose_mode_;
- if (!interface_) {
- Error("Cannot Write output; don't have interface.");
- return;
- }
- string version{std::to_string(version_major_) + '.' +
- std::to_string(version_minor_)};
- string component_type;
- Annotation *c_type_a;
- if (interface_annotations_ &&
- (c_type_a = interface_annotations_->GetAnnotation("hal_type"))) {
- if (c_type_a->GetUnnamedValues() &&
- c_type_a->GetUnnamedValues()->front()->GetValue()->HasStringValue()) {
- Subs subs{{"vts_ct_enum",
- c_type_a->GetUnnamedValues()->front()->NoQuoteText()}};
- component_type =
- GeneratorUtility::Snip(section_, "component_type_enum", subs);
- } else {
- Error("hal_type annotation needs one string value");
- }
- }
- string namespace_open, namespace_close, namespace_slashes, namespace_dots,
- namespace_underscores;
- BuildNamespaceText(section_, namespace_, namespace_open, namespace_close,
- namespace_slashes, namespace_dots, namespace_underscores);
- string imports_section;
- for (auto &import : imports_) {
- Subs subs{{"import_name", import->back()->GetText()},
- {"namespace_slashes", namespace_slashes},
- {"namespace_dots", namespace_dots}};
- imports_section += GeneratorUtility::Snip(section_, "import_line", subs);
- }
- Subs subs{
- {"header_guard", GetPackageName()},
- {"version_string", version},
- {"version_major_string", std::to_string(version_major_)},
- {"version_minor_string", std::to_string(version_minor_)},
- {"imports_section", imports_section},
- {"component_type_enum", component_type},
- {"package_name", GetPackageName()},
- {"declarations", TextByPrefix(section_, "declare_")},
- {"code_snips", TextByPrefix(section_, "code_for_")},
- {"code2_snips", TextByPrefix(section_, "code2_for_")},
- {"call_enum_list", CallEnumList(section_)},
- {"callback_decls", CallbackDeclList(section_)},
- {"namespace_open_section", namespace_open},
- {"namespace_close_section", namespace_close},
- {"namespace_slashes", namespace_slashes},
- {"namespace_dots", namespace_dots},
- {"namespace_underscores", namespace_underscores},
- {"vars_writer", vars_.TextByPrefix(section_, "param_write_")},
- {"vars_reader", vars_.TextByPrefix(section_, "param_read_")},
- {"vars_decl", vars_.GenSemiList(section_)},
- };
- writer_->Write("%s", GeneratorUtility::Snip(section_, "file", subs).c_str());
-}
diff --git a/parser.h b/parser.h
deleted file mode 100644
index 16fb7d7..0000000
--- a/parser.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2015, The Android Open Source Project
- *
- * 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 PARSER_H_
-#define PARSER_H_
-
-#include <cstdarg>
-#include <map>
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "ast.h"
-#include "io_delegate.h"
-
-using TypeMap = std::map<string, TypeDecl*>;
-
-struct yy_buffer_state;
-typedef yy_buffer_state* YY_BUFFER_STATE;
-
-// Parser is the core part of hidl-gen. It reads from an input .hal file
-// and generates the internal ast (Abstract syntax tree) defined in ast.h.
-// It is also responsible for generating the required output of hidl-gen (e.g.
-// .h, .cpp, .vts etc.).
-// TODO(zhuoyao): Move Parser to namespace android::hidl.
-class Parser {
- public:
- explicit Parser(const android::hidl::IoDelegate &io_delegate,
- bool verbose_mode);
- ~Parser();
-
- // Parse contents of file |filename|.
- bool ParseFile(const string &filename);
-
- bool FoundNoErrors() const { return error_ == 0; }
- const string &FileName() const { return filename_; }
- void *Scanner() const { return scanner_; }
-
- std::vector<string> Package() const;
-
- void SetInterface(Annotations *annotations, Element *name);
- Element *GetInterface() { return interface_; }
- string GetPackageName() const { return interface_->GetText(); }
-
- void SetVersion(int major, int minor);
-
- void SetNamespace(std::vector<Element *> *names);
-
- void AddComment(const string &comment);
-
- void AddImport(const std::vector<Element *> *names);
-
- void AddFunction(Function *function);
-
- void AddStruct(StructDecl *structure);
-
- void AddConst(Const *constant);
-
- void AddComment(Element *comment);
-
- void AddUnion(UnionDecl *type);
-
- void AddEnum(EnumDecl *en);
-
- void AddTypedef(TypedefDecl *type);
-
- bool IsTypeDeclared(Element *name);
-
- TypeDecl *GetDeclaredType(Element *name); // nullptr if not found
-
- void Error(const char *format, ...);
-
- void Error(int Line, const char *format, ...);
-
- void Error(string &s);
- int GetErrorCount() { return error_; }
-
- void Dump();
- void Write(std::string out_type, android::hidl::CodeWriterPtr writer);
- string TextByPrefix(string section, string prefix);
- string CallEnumList(string section);
- string CallbackDeclList(string section);
- void BuildNamespaceText(string section, std::vector<Element *> *namespace_,
- string &namespace_open, string &namespace_close,
- string &namespace_slashes, string &namespace_dots,
- string &namespace_underscores);
- void WriteDepFileIfNeeded(android::hidl::CppOptions &options,
- android::hidl::IoDelegate &io_delegate);
-
- private:
- void AddThing(Thing *thing);
- void RegisterType(TypeDecl *decl);
- void RegisterConstant(const Element *name, const Element *value);
- void Validate(); // Will call Error() if any are found
- void VaError(const char *format, va_list args);
-
- const android::hidl::IoDelegate &io_delegate_;
- std::string section_;
- bool verbose_mode_;
- int error_ = 0;
- string filename_;
- void *scanner_ = nullptr;
- android::hidl::CodeWriterPtr writer_;
- std::unique_ptr<string> raw_buffer_;
- YY_BUFFER_STATE buffer_;
- bool version_set_ = false;
- int version_major_, version_minor_;
- std::vector<Element *> *namespace_ = nullptr;
- Element *interface_ = nullptr;
- Annotations *interface_annotations_ = nullptr;
- TypeMap types_;
- std::map<string, const Element *> consts_;
- Fields vars_;
- std::vector<const std::vector<Element *> *> imports_;
- std::vector<Thing *> things_;
-
- DISALLOW_COPY_AND_ASSIGN(Parser);
-};
-
-#endif // PARSER_H_
diff --git a/passthrough/Android.mk b/passthrough/Android.mk
deleted file mode 100644
index 81d8940..0000000
--- a/passthrough/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := passthrough-hal
-
-#LOCAL_LDFLAGS := -Wl
-LOCAL_SRC_FILES:= MathStub.cpp MathImplementation.cpp MathPassthroughEntry.cpp
-#LOCAL_CFLAGS := -Wall -Wextra -Wunused -Werror
-#LOCAL_CXX_STL := none
-LOCAL_C_INCLUDES := system/libhwbinder/include
-LOCAL_SHARED_LIBRARIES := libhwbinder libbase libcutils libutils
-
-#LOCAL_SANITIZE := never
-#include $(BUILD_SHARED_LIBRARY)
-
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := passthrough-client
-
-LOCAL_SHARED_LIBRARIES += libdl
-#LOCAL_LDFLAGS := -Wl
-LOCAL_SRC_FILES:= MathClient.cpp MathProxy.cpp
-#LOCAL_CFLAGS := -Wall -Wextra -Wunused -Werror
-LOCAL_C_INCLUDES := system/libhwbinder/include
-LOCAL_SHARED_LIBRARIES := libhwbinder libbase libcutils libutils
-
-#LOCAL_CXX_STL := none
-#LOCAL_SANITIZE := never
-#include $(BUILD_EXECUTABLE)
-
diff --git a/passthrough/BnMath.h b/passthrough/BnMath.h
deleted file mode 100644
index d0a8851..0000000
--- a/passthrough/BnMath.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BN_Math_H_
-#define HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BN_Math_H_
-
-#include <hwbinder/IInterface.h>
-#include <IMath.h>
-
-namespace android {
-
-namespace hardware {
-
-class BnMath : public hidl::BnInterface<IMath> {
-public:
- ::android::status_t onTransact(uint32_t _aidl_code, const hidl::Parcel& _aidl_data,
- hidl::Parcel* _aidl_reply, uint32_t _aidl_flags = 0) override;
-}; // class BnMath
-
-} // namespace hardware
-
-} // namespace android
-
-#endif // HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BN_Math_H_
diff --git a/passthrough/BpMath.h b/passthrough/BpMath.h
deleted file mode 100644
index b42b571..0000000
--- a/passthrough/BpMath.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BP_Math_H_
-#define HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BP_Math_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <utils/Errors.h>
-#include <IMath.h>
-
-namespace android {
-
-namespace hardware {
-
-class BpMath : public hidl::BpInterface<IMath> {
-public:
- explicit BpMath(const ::android::sp<::android::hardware::IBinder>& _aidl_impl) : BpInterface(_aidl_impl) {}
- virtual ~BpMath() = default;
- virtual status_t sayHi( );
- virtual status_t doCalc(int32_t i , std::function<void(int32_t sum, int32_t product)> callback = nullptr);
-
-}; // class BpMath
-
-} // namespace hardware
-
-} // namespace android
-
-#endif // HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BP_Math_H_
diff --git a/passthrough/IMath.h b/passthrough/IMath.h
deleted file mode 100644
index 4ccb5ed..0000000
--- a/passthrough/IMath.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/ITemplate.h
-#ifndef HIDL_GENERATED_ANDROID_HARDWARE_TESTS_I_Math_H_
-#define HIDL_GENERATED_ANDROID_HARDWARE_TESTS_I_Math_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <hwbinder/Status.h>
-#include <cstdint>
-#include <utils/StrongPointer.h>
-
-namespace android {
-
-namespace hardware {
-
-class IMath : public hidl::IInterface {
-public:
- DECLARE_META_INTERFACE(Math);
-
- virtual status_t sayHi( ) = 0;
- virtual status_t doCalc(int32_t i , std::function<void(int32_t sum, int32_t product)> callback = nullptr) = 0;
-
-enum Call {
- SAYHI = hidl::IBinder::FIRST_CALL_TRANSACTION + 0,
-
-DOCALC,
-};
-}; // class IMath
-
-} // namespace hardware
-
-} // namespace android
-
-#endif // HIDL_GENERATED_ANDROID_HARDWARE_TESTS_I_Math_H_
diff --git a/passthrough/IMath.hal b/passthrough/IMath.hal
deleted file mode 100644
index 841d263..0000000
--- a/passthrough/IMath.hal
+++ /dev/null
@@ -1,7 +0,0 @@
-version 1.0;
-package android.hardware.passthrough;
-
-interface IPassthrough {
- sayHi();
- doCalc(int32_t i) generates(int32_t sum, int32_t product);
-};
diff --git a/passthrough/MathClient.cpp b/passthrough/MathClient.cpp
deleted file mode 100644
index fed7a2b..0000000
--- a/passthrough/MathClient.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "MathClient.h"
-#include <errno.h>
-#include <stdio.h>
-#include <utils/RefBase.h>
-#include <hwbinder/BinderService.h>
-#include <functional>
-#include "time.h"
-
-/** Base path of the hal modules */
-#define HAL_LIBRARY_PATH "./passthrough-hal.so"
-
-namespace android {
-namespace hardware {
-void use2(int sum, int prod)
-{
- printf("sum %d, prod %d\n", sum, prod);
-}
-
-status_t localCalc(
- int i, std::function<void(int j, int k)> callback)
-{
- printf("localCalc: passed i %d\n", i);
-
- callback(i+i, i*i);
- return 0;
-}
-
-int go()
-{
- IMath *service;
- // hardware::version version = hardware::make_version(4,1);
- if (GetPassthroughService(HAL_LIBRARY_PATH /*, version*/, service) == 0) {
- service->sayHi();
- std::function<void(int,int)> cbk=[](int i, int j){ use2(i, j);};
- localCalc(11, cbk);
- fflush(stdout);
- service->doCalc(23,cbk);
- }
- return 0;
-}
-} // hardware
-} // android
-int main(int /*argc*/, char** /*argv*/)
-{printf("Starting main\n");
-
- ::android::hardware::go();
-}
diff --git a/passthrough/MathClient.h b/passthrough/MathClient.h
deleted file mode 100644
index bcb1e43..0000000
--- a/passthrough/MathClient.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "IMath.h"
-#include <string>
-
-namespace android {
-namespace hardware {
-status_t GetPassthroughService(std::string name, IMath* &iObject);
-}
-}
diff --git a/passthrough/MathImplementation.cpp b/passthrough/MathImplementation.cpp
deleted file mode 100644
index 96cac26..0000000
--- a/passthrough/MathImplementation.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-//#include <dlfcn.h>
-//#include <errno.h>
-//#include <stdio.h>
-//#include <iostream>
-//#include <functional>
-//#include "hidl_client.h"
-
-#include "MathImplementations.h"
-#include "BnMath.h"
-#include "BpMath.h"
-
-namespace android {
-namespace hardware {
-
-status_t MathImplementation::sayHi()
-{
- printf("HiWorld\n");
- return 0;
-}
-
-status_t MathImplementation::doCalc(
- int i, std::function<void(int j, int k)> callback)
-{
- printf("doCalc: passed i %d\n", i);
-
- callback(i+i, i*i);
- return 0;
-}
-
-} // namespace hardware
-} // namespace android
diff --git a/passthrough/MathImplementations.h b/passthrough/MathImplementations.h
deleted file mode 100644
index 945a1e3..0000000
--- a/passthrough/MathImplementations.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Human-written file, declaring class(es) that implement BnPassthrough
-
-#include "BnMath.h"
-#include <string>
-
-namespace android {
-namespace hardware {
-
-class MathImplementation : public BnMath {
- virtual status_t sayHi( );
- virtual status_t doCalc(int32_t i , std::function<void(int32_t sum, int32_t product)> callback = nullptr);
-
-}; // class MathImplementation
-
-} // namespace hardware
-
-} // namespace android
-
-
- // This, suitably templatized, will move to the HIDL-provided header files when
- // the interface stabilizes.
-void registerService(std::string name, ::android::hardware::IMath& service);
diff --git a/passthrough/MathPassthroughEntry.cpp b/passthrough/MathPassthroughEntry.cpp
deleted file mode 100644
index eabd0cc..0000000
--- a/passthrough/MathPassthroughEntry.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// Boilerplate code for the passthrough client to get a service
-// proxy object. Not auto-generated, but probably cut-and-pasted.
-
-#include "MathImplementations.h"
-#include <string>
-
-using android::hardware::MathImplementation;
-
-ptrdiff_t findServiceSingleton(std::string name)
-{
- (void)name;
- static MathImplementation serviceSingleton;
- // We don't need this anymore, since the handle we're returning is the object we're calling into
- // registerService(name, serviceSingleton);
- return (ptrdiff_t) &serviceSingleton;
-}
-extern "C" {
-struct {
- ptrdiff_t (*findService)(std::string name) = findServiceSingleton;
-} hidlServiceFinderFunctionHolder; // This name is magic
-}
diff --git a/passthrough/MathProxy.cpp b/passthrough/MathProxy.cpp
deleted file mode 100644
index 2718c68..0000000
--- a/passthrough/MathProxy.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-#include "PpMath.h"
-#include "MathClient.h"
-#include <cstring>
-#include <dlfcn.h>
-
-namespace android {
-namespace hardware {
-
-//IMPLEMENT_META_INTERFACE(Math, "android.hardware.IMath");
-IMath::IMath(){}
-IMath::~IMath(){}
-
-struct hidl_functions {
- status_t (*sayHi)(ptrdiff_t g_connection);
- status_t (*doCalc)(ptrdiff_t g_connection, int32_t i,
- std::function<void(int32_t, int32_t)> cb);
-};
-
-hidl_functions *g_funs;
-ptrdiff_t g_connection;
-
-status_t IMath::doCalc(int32_t i, std::function<void(int32_t, int32_t)> cb)
-{
- g_funs->doCalc(g_connection, i, cb);
- return 0;
-}
-
-status_t IMath::sayHi(void)
-{
- g_funs->sayHi(g_connection);
- return 0;
-}
-
-struct serverInitFunctionHolder {
- ptrdiff_t (*findService)(std::string name);
-};
-
-template<typename T>
-status_t GetSymbol(void *handle, std::string name, T* &pAddress)
-{
- pAddress = (T *)dlsym(handle, name.c_str());
- if (pAddress == NULL) {
- printf("load: couldn't find symbol %s", name.c_str());
- return -EINVAL;
- }
- return 0;
-}
-
-/**
- * Load the file defined by the variant and if successful
- * return the dlopen handle and the hmi.
- * @return 0 = success, !0 = failure.
- */
-status_t GetPassthroughService(std::string name, IMath *&bpObject)
-{
- static PpMath theBpObject; // singleton, thread-safe
- bpObject = &theBpObject;
-
- int status = -EINVAL;
- void *handle = NULL;
-
- /*
- * load the symbols resolving undefined symbols before
- * dlopen returns. Since RTLD_GLOBAL is not or'd in with
- * RTLD_NOW the external symbols will not be global
- */
- handle = dlopen(name.c_str(), RTLD_NOW);
- const char *serviceFinderHolderName = "hidlServiceFinderFunctionHolder";
- const char *hidlFunctionHolderName = "hidlFunctionTable";
- if (handle == NULL) {
- char const *err_str = dlerror();
- printf("load: module=%s\n%s\n", name.c_str(), err_str?err_str:"unknown");
- status = -EINVAL;
- goto done;
- }
-
- serverInitFunctionHolder *initHolder;
-
- if ((status = GetSymbol(handle, serviceFinderHolderName, initHolder)) ||
- (status = GetSymbol(handle, hidlFunctionHolderName, g_funs))) {
- goto done;
- }
- g_connection = (initHolder->findService)("GiveMeService!");
-
- if (!g_connection) {
- printf("Couldn't get a connection\n");
- status = -EINVAL;
- }
-
- /* success */
- status = 0;
-
-done:
- if (status != 0) {
- if (handle != NULL) {
- dlclose(handle);
- handle = NULL;
- }
- } else {
- printf("loaded HAL path=%s handle=%p\n", name.c_str(), handle);
- }
-
- return status;
-}
-} //namespace hardware
-} // namespace android
diff --git a/passthrough/MathStub.cpp b/passthrough/MathStub.cpp
deleted file mode 100644
index d89da2c..0000000
--- a/passthrough/MathStub.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-// This file will be auto-generated.
-#include "IMath.h"
-#include "BpMath.h"
-
-#include "BnMath.h"
-
-using android::hardware::BnMath;
-using android::status_t;
-
-namespace android {
-
-namespace hardware {
-
-IMPLEMENT_META_INTERFACE(Math, "android.hardware.tests.IMath");
-
-} // namespace hardware
-
-} // namespace android
-
-#include <binder/Parcel.h>
-
-namespace android {
-
-namespace hardware {
-
-::android::status_t BnMath::onTransact(uint32_t _aidl_code, const hidl::Parcel& _aidl_data, hidl::Parcel* _aidl_reply, uint32_t _aidl_flags) {
-::android::status_t _aidl_ret_status = ::android::OK;
-(void)_aidl_data;
-(void)_aidl_code;
-(void)_aidl_flags;
-(void)_aidl_reply;
-return _aidl_ret_status;
-}
-
-} // namespace hardware
-
-} // namespace android
-
-
-extern "C" {
-
-struct funs_t {
- status_t (*sayHi)(BnMath *obj);
- status_t (*doCalc)(BnMath *obj, int, std::function<void(int32_t, int32_t)> cb);
-};
-
-status_t sayHi(BnMath *obj)
-{
- return obj->sayHi();
-}
-status_t doCalc(BnMath *obj, int i, std::function<void(int32_t, int32_t)> cb)
-{
- return obj->doCalc(i, cb);
-}
-
-// The name "hidlFunctionTable" is magic
-funs_t hidlFunctionTable {sayHi, doCalc};
-
-} // extern "C"
diff --git a/passthrough/PpMath.h b/passthrough/PpMath.h
deleted file mode 100644
index 08d0169..0000000
--- a/passthrough/PpMath.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BP_Math_H_
-#define HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BP_Math_H_
-
-#include <hwbinder/IInterface.h>
-#include <utils/Errors.h>
-#include <IMath.h>
-
-namespace android {
-
-namespace hardware {
-
-class PpMath : public IMath {
-public:
- PpMath() = default;
- virtual ~PpMath() = default;
- virtual hidl::IBinder* onAsBinder() {return nullptr;}
- virtual status_t sayHi( );
- virtual status_t doCalc(int32_t i , std::function<void(int32_t sum, int32_t product)> callback = nullptr);
-
-}; // class PpMath
-
-} // namespace hardware
-
-} // namespace android
-
-#endif // HIDL_GENERATED_ANDROID_HARDWARE_TESTS_BP_Math_H_
diff --git a/passthrough/go.sh b/passthrough/go.sh
deleted file mode 100755
index 0b23326..0000000
--- a/passthrough/go.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-my=$PWD
-top=$(cd ../../../..;pwd)
-cd $top
-. build/envsetup.sh
-lunch angler-userdebug
-mmm -j44 $my
-$OUT/../../../host/linux-x86/bin/adb push $OUT/system/lib64/passthrough-hal.so /data/local/tmp
-$OUT/../../../host/linux-x86/bin/adb push $OUT/system/bin/passthrough-client /data/local/tmp
-adb shell "(cd /data/local/tmp && ./passthrough-client)"
diff --git a/sample.hal b/sample.hal
deleted file mode 100644
index 2306a04..0000000
--- a/sample.hal
+++ /dev/null
@@ -1,81 +0,0 @@
-/* License comment
-*/
-
-version 10.3;
-package android.hardware.foo;
-import android.hardware.bar;
-import android.hardware.baz;
-import android.hardware.cow;
-interface asdf {
-typedef int32_t int;
-typedef uint32_t u32;
-
-struct C {
- ref<int> r;
-};
-
-struct B {
- string s;
- handle bar;
-};
-
-union udfoo : int {
- ref<int> r on (A);
- ref<int> s on (B);
-};
-struct foo {
- vec<udfoo> baz;
- int[17] arr;
-};
- const C1 = 5;
- const CH2 = 'a';
- const CH3 = '\n';
- enum en : char {a,b = 2, c = 'a',d = C1};
- fun(char c, int i);
- fun_gen(char c, int i) generates(u32 foo);
- @foo @bar(2) @baz(a=5, b=7)
- oneway fun2(uint8_t u);
- union undisc_t {
- uint8_t a;
- char b;
- };
-
- enum u_disc_t : uint8_t {
- A,
- A_AGAIN = A,
- B = 17,
- ALSO_A,
- SOME_OTHER_ENUM
- };
-
- union u_t : u_disc_t {
- int a on(A, A_AGAIN, ALSO_A);
- char c on(C);
- uint8_t b on(B);
- };
-
- struct s_t {
- u_t u;
- u_disc_t disc selects (u);
- };
-
-// comment
-
- fun1(s_t info);
- fun2(u_t info, u_disc_t which selects(info));
- fun3(u_t info);
- fun4(s_t info, u_disc_t which selects(info.u));
- fun5(s_t info, u_disc_t which selects(info));
-
- struct whatever {
- union : u_disc_t {
- char a on(A);
- int a on(A);
- char a on(A);
- uint32_t b on(B);
- } the_union;
- char other_field;
- };
-};
-// Done
-/* Really done */
diff --git a/snippets.h b/snippets.h
deleted file mode 100644
index cfe90e7..0000000
--- a/snippets.h
+++ /dev/null
@@ -1,8 +0,0 @@
-// AUTO GENERATED - ruby snippets.rb
-#include <map>
-#include <string>
-auto cmp = [](const std::string& a, const std::string&b) {
- return a.compare(b) < 0; };
-typedef std::map<std::string, std::string> SnipMap;
-typedef std::map<std::string, SnipMap> SnipMapMap;
-extern SnipMapMap snippets_cpp;
diff --git a/templates/BnTemplate.h b/templates/BnTemplate.h
deleted file mode 100644
index 2b96264..0000000
--- a/templates/BnTemplate.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// SECTION bn_h
-// START file
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_namespace_underscores_BN_header_guard_H_
-#define HIDL_GENERATED_namespace_underscores_BN_header_guard_H_
-
-#include <hwbinder/IInterface.h>
-//#include <namespace_slashes/Ipackage_name.h>
-#include <Ipackage_name.h>
-
-// START namespace_open_section
-namespace namespace_name {//ALL namespace_open_line
-//END namespace_open_section
-
-class Bnpackage_name : public ::android::hardware::BnInterface<Ipackage_name> {
-public:
- ::android::status_t onTransact(uint32_t _aidl_code, const ::android::hardware::Parcel& _aidl_data, ::android::hardware::Parcel* _aidl_reply, uint32_t _aidl_flags = 0, TransactCallback _callback = nullptr) override;
-}; // class Bnpackage_name
-
-// START namespace_close_section
-} // namespace namespace_name //ALL namespace_close_line
-//END namespace_close_section
-
-#endif // HIDL_GENERATED_namespace_underscores_BN_header_guard_H_
-// END file
diff --git a/templates/BpTemplate.h b/templates/BpTemplate.h
deleted file mode 100644
index 33dfbe4..0000000
--- a/templates/BpTemplate.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#define param_list ::android::String16* _aidl_return
-// SECTION bp_h
-// START file
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_namespace_underscores_BP_header_guard_H_
-#define HIDL_GENERATED_namespace_underscores_BP_header_guard_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <utils/Errors.h>
-//#include <namespace_slashes/Ipackage_name.h>
-#include <Ipackage_name.h>
-
-// START namespace_open_section
-namespace namespace_name {//ALL namespace_open_line
-//END namespace_open_section
-
-class Bppackage_name : public ::android::hardware::BpInterface<Ipackage_name> {
-public:
-explicit Bppackage_name(const ::android::sp<::android::hardware::IBinder>& _aidl_impl);
-virtual ~Bppackage_name() = default;
- // START declarations
-/*
-Ipackage_name::function_name_cb _cb // ALL callback_param // Used in callback_description
-sp<import_name> param_name // ALL param_decl_import
-const hidl_vec<decl_base_type> ¶m_name // ALL param_decl_vec
-const Ipackage_name::struct_name ¶m_name // ALL param_decl_struct_type
-*/
-::android::hardware::Status function_name(params_and_callback) override; // ALL declare_function
- // END declarations
-}; // class Bppackage_name
-
-// START namespace_close_section
-} // namespace namespace_name //ALL namespace_close_line
-//END namespace_close_section
-
-#endif // HIDL_GENERATED_namespace_underscores_BP_header_guard_H_
-// END file
diff --git a/templates/ITemplate.h b/templates/ITemplate.h
deleted file mode 100644
index 8a4daf9..0000000
--- a/templates/ITemplate.h
+++ /dev/null
@@ -1,104 +0,0 @@
-#define param_list ::android::String16* _aidl_return
-// SECTION i_h
-// START file
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/ITemplate.h
-#ifndef HIDL_GENERATED_namespace_underscores_I_header_guard_H_
-#define HIDL_GENERATED_namespace_underscores_I_header_guard_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <hwbinder/Status.h>
-#include <cstdint>
-#include <utils/StrongPointer.h>
-// START imports_section
-//#include <namespace_slashes/import_name.h> // ALL import_line_old
-#include <import_name.h> // ALL import_line
-// END imports_section
-// START namespace_open_section
-namespace namespace_name {//ALL namespace_open_line
-//END namespace_open_section
-
-template<typename T>
-using hidl_ref = int;
-
-#ifndef HIDL_TYPES
-#define HIDL_TYPES
-template<typename T>
-struct hidl_vec {
- T *buffer;
- size_t count;
-};
-struct hidl_string {
- char *buffer;
- ptrdiff_t length;
-};
-#endif // HIDL_TYPES
-
-class Ipackage_name : public ::android::hardware::IInterface {
-public:
-
-DECLARE_HWBINDER_META_INTERFACE(package_name);
-
- // START code_snips
-
- //START code_for_const
-// constexpr const_name = const_value;
- //END code_for_const
-
-typedef struct { // START code_for_struct_decl
- int field_filler; // ALL struct_fields
-} struct_name;
-
- // END code_for_struct_decl
-typedef union { // START code_for_union_decl
- int field_filler; // ALL union_fields
-} union_name;
-
- // END code_for_union_decl
-
- // START code_for_enum_decl
- enum class enum_name : enum_base_type { enum_fields };
- const char* GetNameOf(enum_name f) {
- static const char* names[] = {quoted_fields_of_enum };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
-// END code_for_enum_decl
- // END code_snips
- // START callback_decls
-/*
-function_name_cb _cb = nullptr // ALL callback_param // Used in callback_description
-const Ipackage_name::struct_name ¶m_name // ALL param_decl_struct_type
-const hidl_vec<decl_base_type> ¶m_name // ALL param_decl_vec
-base_type_name param_name[array_size] // ALL param_decl_array_all
-base_type_name param_name[array_size] // ALL field_decl_array_all
-hidl_vec<decl_base_type> param_name// ALL field_decl_vec_all
-const native_handle_t *param_name// ALL field_decl_handle
-sp<import_name> param_name // ALL param_decl_import
-Ipackage_name::the_type_name//ALL describe_named_type
-hidl_vec<base_type_name>//ALL describe_type_vec
-*/
- using function_name_cb = std::function<void(return_param_list)>; // ALL callback_decl_line
- // END callback_decls
-
- // START declarations
- // START declare_function
- virtual ::android::hardware::Status function_name(params_and_callback) = 0;
- // END declare_function
- "param_name" // ALL enum_quoted_name_default
- // END declarations
-enum Call {
- // START call_enum_list
- call_enum_name = ::android::hardware::IBinder::FIRST_CALL_TRANSACTION + 0, // ALL first_call_enum
- // END call_enum_list
-};
-}; // class Ipackage_name
-
-// START namespace_close_section
-} // namespace namespace_name //ALL namespace_close_line
-//END namespace_close_section
-
-#endif // HIDL_GENERATED_namespace_underscores_I_header_guard_H_
-// END file
diff --git a/templates/Template.json b/templates/Template.json
deleted file mode 100644
index 28425d1..0000000
--- a/templates/Template.json
+++ /dev/null
@@ -1,61 +0,0 @@
-// SECTION json
-// START file
-hidl {
- version_major: version_major_string,
- version_minor: version_minor_string,
- name: "package_name",
- things: [
- // START declarations
- // START declare_struct_decl
- {
- type: "struct",
- name: "struct_name",
- fields: [
- // START struct_gen_fields
- { // START struct_field_array
- name: "param_name",
- type: "array",
- base_type: {
- type: "base_type_name",
- },
- dimension: array_size,
- }, // END struct_field_array
- { // START struct_field_scalar
- name: "param_name",
- type: "base_type_name",
- }, // END struct_field_scalar
- // END struct_gen_fields
- ],
- }, // END declare_struct_decl
- { // START declare_function
- type: "function",
- name: "function_name",
- params: [
- // START call_param_list
- { // START param_decl_scalar_all
- name: "param_name",
- type: "base_type_name"
- }// END param_decl_scalar_all
- { // START param_decl_named_type
- name: "param_name",
- type: "named_type_name"
- } // END param_decl_named_type
- { // START param_decl_ref_all
- name: "param_name",
- type: "ref",
- base_type: {
- type: "base_type_name"
- }
- } // END param_decl_ref_all
- // END call_param_list
- ],
- generates: [
- // ALL return_param_list
- ]
- }, // END declare_function
- // END declarations
- {} // comma fodder
- ]
-}
-
-// END file
diff --git a/templates/Template.vts b/templates/Template.vts
deleted file mode 100644
index 89a5a17..0000000
--- a/templates/Template.vts
+++ /dev/null
@@ -1,82 +0,0 @@
-// SECTION vts
-// START file
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/Template.vts
-component_class: HAL_HIDL
-component_type: vts_ct_enum // ALL component_type_enum
-component_type_version: version_string
-component_name: "Ipackage_name"
-
-// START imports_section
-import: "namespace_dots.import_name" // ALL import_line
-// END imports_section
-
-// START code_snips
-// START code_for_function
-api: {
- name: "function_name"
- // START vts_args
- arg_or_ret_type: {
- type: vts_type_name
- vts_type_description
- }
- // END vts_args
-
- // START vts_callflow
- callflow: {
- entry: true // ALL anno_entry
- exit: true // ALL anno_exit
- callflow_label: callflow_func_name // ALL anno_calls
- }
- // END vts_callflow
-}
-// END code_for_function
-
-// START code_for_struct_decl
-attribute: {
- name: "struct_name"
- type: vts_type_name
- struct_value: {
- // START vts_struct_field
- name: "vts_field_name"
- type: vts_type_name
- vts_type_description
- // END vts_struct_field
- }
-}
-// END code_for_struct_decl
-
-// START code_for_enum_decl
-attribute: {
- name: "enum_name"
- type: vts_type_name
- enum_value: {
- // START vts_enum_field
- enumerator: "vts_enum_name"
- value: vts_enum_value
- // END vts_enum_field
- }
-}
-// END code_for_enum_decl
-}
-// END code_snips
-
-// START declarations
-// START declare_const
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "const_vts_type"
- primitive_name: "const_name"
- primitive_value: {
- const_vts_type: const_value
- }
-}
-// END declare_const
-// END declarations
-
-// END file
-
-
-scalar_type: "base_type_name" // ALL vts_type_scalar
-predefined_type: "named_type_name" // ALL vts_type_named_type
-vector_value: { vts_base_type_description } // ALL vts_type_vec
\ No newline at end of file
diff --git a/templates/TemplateAll.cpp b/templates/TemplateAll.cpp
deleted file mode 100644
index 67315e7..0000000
--- a/templates/TemplateAll.cpp
+++ /dev/null
@@ -1,994 +0,0 @@
-// SECTION all_cpp
-// START file
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/TemplateAll.cpp
-//#include <namespace_slashes/Ipackage_name.h>
-//#include <namespace_slashes/Bppackage_name.h>
-#include <Ipackage_name.h>
-#include <Bppackage_name.h>
-#include <iostream>
-#include <stdio.h>
-using std::cout;
-using std::endl;
-
-// START namespace_open_section
-namespace namespace_name {//ALL namespace_open_line
-//END namespace_open_section
-
-IMPLEMENT_HWBINDER_META_INTERFACE(package_name, "namespace_dots.Ipackage_name");
-
-// START namespace_close_section
-} // namespace namespace_name //ALL namespace_close_line
-//END namespace_close_section
-
-//#include <namespace_slashes/Bppackage_name.h>
-#include <Bppackage_name.h>
-#include <binder/Parcel.h>
-
-namespace_open_section
-
-Bppackage_name::Bppackage_name(const ::android::sp<::android::hardware::IBinder>& _aidl_impl)
- : BpInterface<Ipackage_name>(_aidl_impl){
-}
-// START code_snips
-/*
-Ipackage_name::function_name_cb _cb // ALL callback_param // Used in callback_description
-const Ipackage_name::struct_name& param_name // ALL param_decl_struct_type
-const hidl_vec<decl_base_type> ¶m_name// ALL param_decl_vec
-sp<import_name> param_name // ALL param_decl_import
-Ipackage_name::the_type_name//ALL describe_named_type
-hidl_vec<base_type_name>//ALL describe_type_vec
-*/
-// START code_for_function
-::android::hardware::Status Bppackage_name::function_name(params_and_callback) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- generates_variables
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// START param_write_snips
-
-// START param_write_import
- _aidl_ret_status = _aidl_data.writeStrongBinder(IInterface::asBinder(param_name));
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_import
-
-// START param_write_enum_type_scalar_uint8_t
- _aidl_ret_status = _aidl_data.writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_uint8_t
-// START param_write_enum_type_scalar_int8_t
- _aidl_ret_status = _aidl_data.writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_int8_t
-// START param_write_enum_type_scalar_uint16_t
- _aidl_ret_status = _aidl_data.writeChar((char16_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_uint16_t
-// START param_write_enum_type_scalar_int16_t
- _aidl_ret_status = _aidl_data.writeChar((char16_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_int16_t
-
-// START param_write_enum_type_scalar_uint32_t
- _aidl_ret_status = _aidl_data.writeUint32((uint32_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_uint32_t
-// START param_write_enum_type_scalar_int32_t
- _aidl_ret_status = _aidl_data.writeInt32((int32_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_int32_t
-// START param_write_enum_type_scalar_uint64_t
- _aidl_ret_status = _aidl_data.writeUint64((uint64_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_uint64_t
-// START param_write_enum_type_scalar_int64_t
- _aidl_ret_status = _aidl_data.writeInt64((int64_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_int64_t
-
-// START param_write_enum_type_scalar_char
- _aidl_ret_status = _aidl_data.writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_char
-
-// START param_write_scalar_int8_t
- _aidl_ret_status = _aidl_data.writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_int8_t
-// START param_write_scalar_uint8_t
- _aidl_ret_status = _aidl_data.writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_uint8_t
-// START param_write_scalar_int16_t
- _aidl_ret_status = _aidl_data.writeChar((char16_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_int16_t
-// START param_write_scalar_uint16_t
- _aidl_ret_status = _aidl_data.writeChar((char16_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_uint16_t
-
-// START param_write_scalar_int32_t
- _aidl_ret_status = _aidl_data.writeInt32((int32_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_int32_t
-// START param_write_scalar_uint32_t
- _aidl_ret_status = _aidl_data.writeUint32((uint32_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_uint32_t
-// START param_write_scalar_int64_t
- _aidl_ret_status = _aidl_data.writeInt64((int64_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_int64_t
-// START param_write_scalar_uint64_t
- _aidl_ret_status = _aidl_data.writeUint64((uint64_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_uint64_t
-
-// START param_write_scalar_char
- _aidl_ret_status = _aidl_data.writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_char
-
- // START param_write_struct_type
- {
- size_t parent_handle;
- _aidl_ret_status = _aidl_data.writeBuffer((void *)¶m_name, sizeof(param_name), &parent_handle);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- fixup_write_struct
- }
- // END param_write_struct_type
-
- // START param_write_vec_all
- {
- size_t parent_handle;
-
- _aidl_ret_status = _aidl_data.writeBuffer((void *)¶m_name, sizeof(param_name), &parent_handle);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- fixup_write_vec
- }
- // END param_write_vec_all
- // START param_write_array_all
- {
- size_t parent_handle;
-
- _aidl_ret_status = _aidl_data.writeBuffer((void *)¶m_name, sizeof(param_name), &parent_handle);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- fixup_write_array
- }
- // END param_write_array_all
- // START vec_fixup_loop
- for (size_t loop_var = 0; loop_var < param_name.count; loop_var++) {
- /* fixup_write_vec */
- inner_vec_fixup
- }
- // END vec_fixup_loop
- // START array_fixup_loop
- for (size_t loop_var = 0; loop_var < array_length; loop_var++) {
- /* fixup_write_array */
- inner_array_fixup
- }
- // END array_fixup_loop
- // START param_write_string
- {
- size_t parent_handle;
- _aidl_ret_status = _aidl_data.writeBuffer((void *)¶m_name, sizeof(hidl_string), &parent_handle);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeEmbeddedBuffer((void *)param_name.buffer,
- (param_name.length < 0 ? strlen(param_name.buffer)+1 : param_name.length),
- nullptr, parent_handle, 0);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- }
- // END param_write_string
- // START param_write_handle
- _aidl_ret_status = _aidl_data.writeNativeHandleNoDup(param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // END param_write_handle
- // START write_fixup_string
- _aidl_ret_status = _aidl_data.writeEmbeddedBuffer((void *)param_name.buffer,
- (param_name.length < 0 ? strlen(param_name.buffer)+1 : param_name.length),
- nullptr, parent_handle,
- (size_t)((char *)&(param_name.buffer)-(char *)(base_pointer)));
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // END write_fixup_string
- // START write_fixup_handle
- _aidl_ret_status = _aidl_data.writeEmbeddedNativeHandle(param_name, parent_handle,
- (size_t)((char *)&(param_name)-(char *)(base_pointer)));
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // END write_fixup_handle
- // START write_fixup_vec
- {
- size_t child_handle;
- void *bufp = (void *)param_name.buffer;
- size_t size = sizeof(vec_base_type[param_name.count]);
- size_t off = (size_t)((char *)&(param_name.buffer)-(char *)(base_pointer));
- _aidl_ret_status = _aidl_data.writeEmbeddedBuffer(bufp,
- size,
- &child_handle,
- parent_handle,
- off /* offset_calculator */);
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- vec_fixup_loop
- }
- // END write_fixup_vec
- // START write_fixup_array
- array_fixup_loop
- // END write_fixup_array
- // START param_write_vec
- size_t parent_handle;
- _aidl_data.writeBuffer((void *)param_name.buffer, vec_size_expr, &parent_handle);
- write_vec_fixups
- // END param_write_vec
-
- // START param_write_ref_all
- _aidl_ret_status = _aidl_data.writeFileDescriptor(param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // END param_write_ref_all
- // END param_write_snips
- _aidl_ret_status = remote()->transact(Ipackage_name::func_name_as_enum, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
-// START param_ret_read_snips
-
-// START param_ret_read_scalar_int8_t
- _aidl_ret_status = _aidl_reply.readByte(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_int8_t
-// START param_ret_read_scalar_uint8_t
- _aidl_ret_status = _aidl_reply.readByte((int8_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_uint8_t
-// START param_ret_read_scalar_int16_t
- _aidl_ret_status = _aidl_reply.readChar((char16_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_int16_t
-// START param_ret_read_scalar_uint16_t
- _aidl_ret_status = _aidl_reply.readChar((char16_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_uint16_t
-
-// START param_ret_read_scalar_int32_t
- _aidl_ret_status = _aidl_reply.readInt32(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_int32_t
-// START param_ret_read_scalar_uint32_t
- _aidl_ret_status = _aidl_reply.readUint32(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_uint32_t
-// START param_ret_read_scalar_int64_t
- _aidl_ret_status = _aidl_reply.readInt64(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_int64_t
-// START param_ret_read_scalar_uint64_t
- _aidl_ret_status = _aidl_reply.readUint64(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_uint64_t
-
-// START param_ret_read_scalar_char
- _aidl_ret_status = _aidl_reply.readByte((int8_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_char
-
- // START param_ret_read_import
- _aidl_ret_status = _aidl_reply.readStrongBinder(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // END param_ret_read_import
-
-// START param_ret_read_enum_type_scalar_uint8_t
- _aidl_ret_status = _aidl_reply.readByte((int8_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_uint8_t
-// START param_ret_read_enum_type_scalar_int8_t
- _aidl_ret_status = _aidl_reply.readByte((int8_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_int8_t
-// START param_ret_read_enum_type_scalar_uint16_t
- _aidl_ret_status = _aidl_reply.readChar((char16_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_uint16_t
-// START param_ret_read_enum_type_scalar_int16_t
- _aidl_ret_status = _aidl_reply.readChar((char16_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_int16_t
-
-// START param_ret_read_enum_type_scalar_uint32_t
- _aidl_ret_status = _aidl_reply.readUint32((uint32_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_uint32_t
-// START param_ret_read_enum_type_scalar_int32_t
- _aidl_ret_status = _aidl_reply.readInt32((int32_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_int32_t
-// START param_ret_read_enum_type_scalar_uint64_t
- _aidl_ret_status = _aidl_reply.readUint64((uint64_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_uint64_t
-// START param_ret_read_enum_type_scalar_int64_t
- _aidl_ret_status = _aidl_reply.readInt64((int64_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_int64_t
-
-// START param_ret_read_enum_type_scalar_char
- _aidl_ret_status = _aidl_reply.readByte((int8_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_char
-
- // START param_ret_read_struct_type
- {
- size_t parent_handle;
- param_name = (struct_type_description*)_aidl_reply.readBuffer(&parent_handle);
- if ((param_name) == nullptr) {
- goto _aidl_error;
- }
- fixup_ret_read_struct
- }
- // END param_ret_read_struct_type
- // START param_ret_read_vec_all
- {
- size_t parent_handle;
-
- param_name = (hidl_vec<decl_base_type> *)_aidl_reply.readBuffer(&parent_handle);
- if ((param_name) == nullptr) {
- goto _aidl_error;
- }
- fixup_ret_read_vec
- }
- // END param_ret_read_vec_all
- // START param_ret_read_array_all
- {
- size_t parent_handle;
-
- param_name = _aidl_reply.readBuffer(&parent_handle);
- if (param_name == nullptr) {
- goto _aidl_error;
- }
- fixup_ret_read_array
- }
- // END param_ret_read_array_all
- // START param_ret_read_string
- {
- size_t parent_handle;
- param_name = _aidl_reply.readBuffer(&parent_handle);
- if (param_name == nullptr) {
- goto _aidl_error;
- }
- _aidl_ret_pointer = _aidl_reply.readEmbeddedBuffer(nullptr, parent_handle, 0);
- if (_aidl_ret_pointer == nullptr) {
- goto _aidl_error;
- }
- }
- // END param_ret_read_string
- // START param_ret_read_handle
- param_name = _aidl_reply.readNativeHandleNoDup();
- if (param_name == nullptr) {
- goto _aidl_error;
- }
- // END param_ret_read_handle
- // START read_ret_fixup_string
- _aidl_ret_pointer = _aidl_reply.readEmbeddedBuffer(nullptr, parent_handle,
- (size_t)((char *)&(param_name.buffer)-(char *)(base_pointer)));
- if (_aidl_ret_pointer == nullptr) {
- goto _aidl_error;
- }
- // END read_ret_fixup_string
- // START read_ret_fixup_handle
- _aidl_ret_pointer = _aidl_reply.readEmbeddedNativeHandle(parent_handle,
- (size_t)((char *)&(param_name)-(char *)(base_pointer)));
- if (_aidl_ret_pointer == nullptr) {
- goto _aidl_error;
- }
- // END read_ret_fixup_handle
- // START read_ret_fixup_vec
- {
- size_t child_handle;
- _aidl_ret_pointer = _aidl_reply.readEmbeddedBuffer(&child_handle, parent_handle,
- (size_t)((char *)&(param_name.buffer)-(char *)(base_pointer)));
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (_aidl_ret_pointer == nullptr) {
- goto _aidl_error;
- }
- vec_fixup_loop
- }
- // END read_ret_fixup_vec
- // START read_ret_fixup_array
- array_fixup_loop
- // END read_ret_fixup_array
-
-// END param_ret_read_snips
-
- // Invoke callback to client // START callback_invocation
- if (_cb != nullptr)
- _cb(return_param_names); // END callback_invocation
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-// END code_for_function
-param_name // ALL callback_var_default
-*param_name // ALL callback_var_struct_type
-// END code_snips
-
-namespace_close_section
-
-// START // hide
-auto param_name // ALL return_param_decl_default
-const Ipackage_name::type_desc & param_name // ALL return_param_decl_struct_type
-// END // hide
-//#include <namespace_slashes/Ipackage_name.h>
-//#include <namespace_slashes/Bppackage_name.h>
-#include <Ipackage_name.h>
-#include <Bppackage_name.h>
-
-
-#include <iostream>
-//#include <namespace_slashes/Bnpackage_name.h>
-#include <Bnpackage_name.h>
-#include <binder/Parcel.h>
-
-namespace_open_section
-
-::android::status_t Bnpackage_name::onTransact(uint32_t _aidl_code, const ::android::hardware::Parcel& _aidl_data, ::android::hardware::Parcel* _aidl_reply, uint32_t _aidl_flags, TransactCallback _cb) {
- ::android::status_t _aidl_ret_status = ::android::OK;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- switch (_aidl_code) {
-// START code2_snips
-// START code2_for_function
- case Call::func_name_as_enum:
- {
-// START param_decls
- Ipackage_name::struct_name *param_name // ALL field_decl_struct_type
- hidl_vec<decl_base_type> *param_name // ALL field_decl_vec_all
- sp<import_name> param_name // ALL field_decl_import
-// END param_decls
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
-// START param_read_snips
-
-// START param_read_scalar_int8_t
- _aidl_ret_status = _aidl_data.readByte(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_int8_t
-// START param_read_scalar_uint8_t
- _aidl_ret_status = _aidl_data.readByte((int8_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_uint8_t
-// START param_read_scalar_int16_t
- _aidl_ret_status = _aidl_data.readChar((char16_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_int16_t
-// START param_read_scalar_uint16_t
- _aidl_ret_status = _aidl_data.readChar((char16_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_uint16_t
-
-// START param_read_scalar_int32_t
- _aidl_ret_status = _aidl_data.readInt32(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_int32_t
-// START param_read_scalar_uint32_t
- _aidl_ret_status = _aidl_data.readUint32(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_uint32_t
-// START param_read_scalar_int64_t
- _aidl_ret_status = _aidl_data.readInt64(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_int64_t
-// START param_read_scalar_uint64_t
- _aidl_ret_status = _aidl_data.readUint64(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_uint64_t
-
-// START param_read_scalar_char
- _aidl_ret_status = _aidl_data.readByte((int8_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_char
-
- // START param_read_import
- _aidl_ret_status = _aidl_data.readStrongBinder(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- // END param_read_import
-// START param_read_enum_type_scalar_int8_t
- _aidl_ret_status = _aidl_data.readByte((int8_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_int8_t
-// START param_read_enum_type_scalar_uint8_t
- _aidl_ret_status = _aidl_data.readByte((int8_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_uint8_t
-// START param_read_enum_type_scalar_int16_t
- _aidl_ret_status = _aidl_data.readChar((char16_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_int16_t
-// START param_read_enum_type_scalar_uint16_t
- _aidl_ret_status = _aidl_data.readChar((char16_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_uint16_t
-// START param_read_enum_type_scalar_int32_t
- _aidl_ret_status = _aidl_data.readInt32((int32_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_int32_t
-// START param_read_enum_type_scalar_uint32_t
- _aidl_ret_status = _aidl_data.readUint32((uint32_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_uint32_t
-// START param_read_enum_type_scalar_int64_t
- _aidl_ret_status = _aidl_data.readInt64((int64_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_int64_t
-// START param_read_enum_type_scalar_uint64_t
- _aidl_ret_status = _aidl_data.readUint64((uint64_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_uint64_t
-// START param_read_enum_type_scalar_char
- _aidl_ret_status = _aidl_data.readByte((int8_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_char
-
- // START param_read_struct_type
- {
- size_t parent_handle;
- param_name = (struct_type_description*)_aidl_data.readBuffer(&parent_handle);
- if ((param_name) == nullptr) {
- break;
- }
- fixup_read_struct
- }
- // END param_read_struct_type
- // START param_read_vec_all
- {
- size_t parent_handle;
-
- param_name = (hidl_vec<decl_base_type> *)_aidl_data.readBuffer(&parent_handle);
- if ((param_name) == nullptr) {
- break;
- }
- fixup_read_vec
- }
- // END param_read_vec_all
- // START param_read_array_all
- {
- size_t parent_handle;
-
- param_name = _aidl_data.readBuffer(&parent_handle);
- if (param_name == nullptr) {
- break;
- }
- fixup_read_array
- }
- // END param_read_array_all
- // START param_read_string
- {
- size_t parent_handle;
- param_name = _aidl_data.readBuffer(&parent_handle);
- if (param_name == nullptr) {
- break;
- }
- _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(nullptr, parent_handle, 0);
- if (_aidl_ret_pointer == nullptr) {
- break;
- }
- }
- // END param_read_string
- // START param_read_handle
- param_name = _aidl_data.readNativeHandleNoDup();
- if (param_name == nullptr) {
- break;
- }
- // END param_read_handle
- // START read_fixup_string
- _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(nullptr, parent_handle,
- (size_t)((char *)&(param_name.buffer)-(char *)(base_pointer)));
- if (_aidl_ret_pointer == nullptr) {
- break;
- }
- // END read_fixup_string
- // START read_fixup_handle
- _aidl_ret_pointer = _aidl_data.readEmbeddedNativeHandle(parent_handle,
- (size_t)((char *)&(param_name)-(char *)(base_pointer)));
- if (_aidl_ret_pointer == nullptr) {
- break;
- }
- // END read_fixup_handle
- // START read_fixup_vec
- {
- size_t child_handle;
- _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(&child_handle, parent_handle,
- (size_t)((char *)&(param_name.buffer)-(char *)(base_pointer)));
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (_aidl_ret_pointer == nullptr) {
- break;
- }
- vec_fixup_loop
- }
- // END read_fixup_vec
- // START read_fixup_array
- array_fixup_loop
- // END read_fixup_array
-
-// START param_read_ref_all
- param_name = _aidl_data.readFileDescriptor();
-// END param_read_ref_all
-// END param_read_snips
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- function_name(stub_arguments));
-
- // START // Hide callback_code
-param_name// ALL stub_param_decl_default
-*param_name// ALL stub_param_decl_struct_type
-*param_name// ALL stub_param_decl_struct_decl
-*param_name// ALL stub_param_decl_vec_all
- // TODO add union and string and native_handle
- [&](return_params_stubs) { // START callback_code
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
-// START param_ret_write_snips
-
-// START param_ret_write_scalar_uint8_t
- _aidl_reply->writeByte((int8_t)param_name);
-// END param_ret_write_scalar_uint8_t
-// START param_ret_write_scalar_int8_t
- _aidl_reply->writeByte(param_name);
-// END param_ret_write_scalar_int8_t
-// START param_ret_write_scalar_uint16_t
- _aidl_reply->writeChar((char16_t)param_name);
-// END param_ret_write_scalar_uint16_t
-// START param_ret_write_scalar_int16_t
- _aidl_reply->writeChar((char16_t)param_name);
-// END param_ret_write_scalar_int16_t
-
-// START param_ret_write_scalar_uint32_t
- _aidl_reply->writeUint32(param_name);
-// END param_ret_write_scalar_uint32_t
-// START param_ret_write_scalar_int32_t
- _aidl_reply->writeInt32(param_name);
-// END param_ret_write_scalar_int32_t
-// START param_ret_write_scalar_uint64_t
- _aidl_reply->writeUint64(param_name);
-// END param_ret_write_scalar_uint64_t
-// START param_ret_write_scalar_int64_t
- _aidl_reply->writeInt64(param_name);
-// END param_ret_write_scalar_int64_t
-
-// START param_ret_write_scalar_char
- _aidl_reply->writeByte((int8_t)param_name);
-// END param_ret_write_scalar_char
-
-// START param_ret_write_enum_type_scalar_int8_t
- _aidl_ret_status = _aidl_reply->writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_int8_t
-// START param_ret_write_enum_type_scalar_uint8_t
- _aidl_ret_status = _aidl_reply->writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_uint8_t
-// START param_ret_write_enum_type_scalar_int16_t
- _aidl_ret_status = _aidl_reply->writeChar((char16_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_int16_t
-// START param_ret_write_enum_type_scalar_uint16_t
- _aidl_ret_status = _aidl_reply->writeChar((char16_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_uint16_t
-// START param_ret_write_enum_type_scalar_int32_t
- _aidl_ret_status = _aidl_reply->writeInt32((int32_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_int32_t
-// START param_ret_write_enum_type_scalar_uint32_t
- _aidl_ret_status = _aidl_reply->writeUint32((uint32_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_uint32_t
-// START param_ret_write_enum_type_scalar_int64_t
- _aidl_ret_status = _aidl_reply->writeInt64((int64_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_int64_t
-// START param_ret_write_enum_type_scalar_uint64_t
- _aidl_ret_status = _aidl_reply->writeUint64((uint64_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_uint64_t
-// START param_ret_write_enum_type_scalar_char
- _aidl_ret_status = _aidl_reply->writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_char
-// START param_ret_write_import
- _aidl_ret_status = _aidl_reply->writeStrongBinder(IInterface::asBinder(param_name));
- if (((_aidl_ret_status) != (::android::OK))) {
- // TODO(maco): Log/report all errors. See b/30476330
- return;
- }
-// END param_ret_write_import
-
- // START param_ret_write_struct_type
- {
- size_t parent_handle;
- _aidl_ret_status = _aidl_reply->writeBuffer((void *)¶m_name, sizeof(param_name), &parent_handle);
- fixup_ret_write_struct
- }
- // END param_ret_write_struct_type
- // START param_ret_write_array_all
- {
- size_t parent_handle;
-
- _aidl_ret_status = _aidl_reply->writeBuffer((void *)¶m_name, sizeof(param_name), &parent_handle);
- fixup_write_array
- }
- // END param_ret_write_array_all
- // START param_ret_write_vec_all
- {
- size_t parent_handle;
-
- _aidl_ret_status = _aidl_reply->writeBuffer((void *)¶m_name, sizeof(param_name), &parent_handle);
- fixup_ret_write_vec
- }
- // END param_ret_write_vec_all
- // START vec_ret_fixup_loop
- for (size_t loop_var = 0; loop_var < param_name.count; loop_var++) {
- /* fixup_write_vec */
- inner_ret_vec_fixup
- }
- // END vec_ret_fixup_loop
- // START param_ret_write_string
- {
- size_t parent_handle;
- _aidl_ret_status = _aidl_reply->writeBuffer((void *)¶m_name, sizeof(hidl_string), &parent_handle);
- if (((_aidl_ret_status) != (::android::OK))) {
- // TODO(maco): Log/report all errors. See b/30476330
- return;
- }
- _aidl_ret_status = _aidl_reply->writeEmbeddedBuffer((void *)param_name.buffer,
- (param_name.length < 0 ? strlen(param_name.buffer)+1 : param_name.length),
- nullptr, parent_handle, 0);
- if (((_aidl_ret_status) != (::android::OK))) {
- // TODO(maco): Log/report all errors. See b/30476330
- return;
- }
- }
- // END param_ret_write_string
- // START param_ret_write_handle
- _aidl_ret_status = _aidl_reply->writeNativeHandleNoDup(param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- // TODO(maco): Log/report all errors. See b/30476330
- return;
- }
- // END param_ret_write_handle
- // START write_ret_fixup_string
- _aidl_ret_status = _aidl_reply->writeEmbeddedBuffer((void *)param_name.buffer,
- (param_name.length < 0 ? strlen(param_name.buffer)+1 : param_name.length),
- nullptr, parent_handle,
- (size_t)((char *)&(param_name.buffer)-(char *)(base_pointer)));
- // END write_ret_fixup_string
- // START write_ret_fixup_handle
- _aidl_ret_status = _aidl_reply->writeEmbeddedNativeHandle(param_name, parent_handle,
- (size_t)((char *)&(param_name)-(char *)(base_pointer)));
- // END write_ret_fixup_handle
- // START write_ret_fixup_vec
- {
- size_t child_handle;
- void *bufp = (void *)param_name.buffer;
- size_t size = sizeof(vec_base_type[param_name.count]);
- size_t off = (size_t)((char *)&(param_name.buffer)-(char *)(base_pointer));
- _aidl_ret_status = _aidl_reply->writeEmbeddedBuffer(bufp,
- size,
- &child_handle,
- parent_handle,
- off /* offset_calculator */);
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- vec_ret_fixup_loop
- }
- // END write_ret_fixup_vec
- // START write_ret_fixup_array
- array_fixup_loop
- // END write_ret_fixup_array
- // START param_ret_write_vec
- size_t parent_handle;
- _aidl_reply->writeBuffer((void *)param_name.buffer, vec_size_expr, &parent_handle);
- write_ret_vec_fixups
- // END param_ret_write_vec
-
-
-// END param_ret_write_snips
- // Callback
- _cb(*_aidl_reply);
- } // END callback_code
- // END //
-
- if (!callback_called) { // START callback_check
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- } // END callback_check
- break;
- }
-// END code2_for_function
-// END code2_snips
- default:
- {
- _aidl_ret_status = ::android::hardware::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
- }
- break;
- }
- if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
- _aidl_ret_status = ::android::hardware::Status::fromExceptionCode(::android::hardware::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
- }
- return _aidl_ret_status;
-}
-
-namespace_close_section
-// END file
diff --git a/templates/TemplateBinder.h b/templates/TemplateBinder.h
deleted file mode 100644
index 85af41f..0000000
--- a/templates/TemplateBinder.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// SECTION binder
-// START file
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/TemplateBinder.h
-#ifndef I_HIDL_BINDER_header_guard_H
-#define I_HIDL_BINDER_header_guard_H
-
-#include "binder/Parcel.h"
-#include "binder/Parcelable.h"
-
-// START namespace_open_section
-namespace namespace_name {//ALL namespace_open_line
-//END namespace_open_section
-
- class package_name : public Parcelable {
-
- public:
- // START declarations
- // START declare_enum_decl
- enum class enum_name : enum_base_type {
- enum_fields
- };
- // END declare_enum_decl
- function_name(param_list) function_code // ALL declare_function
-
- // END declarations
-
- virtual status_t writeToParcel(Parcel* parcel) const override {
- //START vars_writer
- parcel->writeFileDescriptor(mFd, false); // ALL param_write_ref
- parcel->writeInt32((int32_t) mRegionType); // ALL param_write_named_type_enum
- parcel->writeInt64(mOffset); // ALL param_write_scalar_int64_t
- parcel->writeUint64(mSize); // ALL param_write_scalar_uint64_t
- // END vars_writer
- return parcel->errorCheck();
- }
-
- virtual status_t readFromParcel(const Parcel* parcel) override {
- // START vars_reader
- param_name = parcel->readFileDescriptor(); // ALL param_read_ref
- param_name = (enum_name) parcel->readInt32(); // ALL param_read_named_type_enum
- param_name = parcel->readInt64(); // ALL param_read_scalar_int64_t
- param_name = parcel->readUint64(); // ALL param_read_scalar_uint64_t
- // END vars_reader
- return parcel->errorCheck();
- }
-
- private:
- // START vars_decl
- int mFd = -1;
- MappingType mRegionType = MappingType::UNDEFINED_MAPPING;
- off64_t mOffset;
- size_t mSize = 0;
- // END vars_decl
- };
-
-// START namespace_close_section
-} // namespace namespace_name //ALL namespace_close_line
-//END namespace_close_section
-
-#endif // I_HIDL_BINDER_header_guard_H
-// END file
diff --git a/templates/TemplateProxy.cpp b/templates/TemplateProxy.cpp
deleted file mode 100644
index b0ac023..0000000
--- a/templates/TemplateProxy.cpp
+++ /dev/null
@@ -1,335 +0,0 @@
-// SECTION proxy_cpp
-// START file
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/TemplateProxy.cpp
-#include <namespace_slashes/Ipackage_name.h>
-#include <namespace_slashes/Bppackage_name.h>
-
-// START namespace_open_section
-namespace namespace_name {//ALL namespace_open_line
-//END namespace_open_section
-
-IMPLEMENT_HWBINDER_META_INTERFACE(package_name, "namespace_dots.Ipackage_name");
-
-// START namespace_close_section
-} // namespace namespace_name //ALL namespace_close_line
-//END namespace_close_section
-
-#include <namespace_slashes/Bppackage_name.h>
-#include <binder/Parcel.h>
-
-namespace_open_section
-
-Bppackage_name::Bppackage_name(const ::android::sp<::android::hardware::IBinder>& _aidl_impl)
- : BpInterface<Ipackage_name>(_aidl_impl){
-}
-// START code_snips
-/*
-Ipackage_name::function_name_cb _cb // ALL callback_param // Used in callback_description
-const Ipackage_name::struct_name* param_name // ALL param_decl_struct_type
-sp<import_name> param_name // ALL param_decl_import
-struct_name *param_name; // ALL field_decl_struct_type
-
-*/
-// START code_for_function
-::android::hardware::Status Bppackage_name::function_name(params_and_callback) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- generates_variables
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// START param_write_snips
-
-// START param_write_import
- _aidl_ret_status = _aidl_data.writeStrongBinder(IInterface::asBinder(param_name));
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_import
-
-// START param_write_enum_type_scalar_uint8_t
- _aidl_ret_status = _aidl_data.writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_uint8_t
-// START param_write_enum_type_scalar_int8_t
- _aidl_ret_status = _aidl_data.writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_int8_t
-// START param_write_enum_type_scalar_uint16_t
- _aidl_ret_status = _aidl_data.writeChar((char16_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_uint16_t
-// START param_write_enum_type_scalar_int16_t
- _aidl_ret_status = _aidl_data.writeChar((char16_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_int16_t
-
-// START param_write_enum_type_scalar_uint32_t
- _aidl_ret_status = _aidl_data.writeUint32((uint32_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_uint32_t
-// START param_write_enum_type_scalar_int32_t
- _aidl_ret_status = _aidl_data.writeInt32((int32_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_int32_t
-// START param_write_enum_type_scalar_uint64_t
- _aidl_ret_status = _aidl_data.writeUint64((uint64_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_uint64_t
-// START param_write_enum_type_scalar_int64_t
- _aidl_ret_status = _aidl_data.writeInt64((int64_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_int64_t
-
-// START param_write_enum_type_scalar_char
- _aidl_ret_status = _aidl_data.writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_enum_type_scalar_char
-
-// START param_write_scalar_int8_t
- _aidl_ret_status = _aidl_data.writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_int8_t
-// START param_write_scalar_uint8_t
- _aidl_ret_status = _aidl_data.writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_uint8_t
-// START param_write_scalar_int16_t
- _aidl_ret_status = _aidl_data.writeChar((char16_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_int16_t
-// START param_write_scalar_uint16_t
- _aidl_ret_status = _aidl_data.writeChar((char16_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_uint16_t
-
-// START param_write_scalar_int32_t
- _aidl_ret_status = _aidl_data.writeInt32((int32_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_int32_t
-// START param_write_scalar_uint32_t
- _aidl_ret_status = _aidl_data.writeUint32((uint32_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_uint32_t
-// START param_write_scalar_int64_t
- _aidl_ret_status = _aidl_data.writeInt64((int64_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_int64_t
-// START param_write_scalar_uint64_t
- _aidl_ret_status = _aidl_data.writeUint64((uint64_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_uint64_t
-
-// START param_write_scalar_char
- _aidl_ret_status = _aidl_data.writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_write_scalar_char
-
- // START param_write_struct_type
- _aidl_ret_status = _aidl_data.writeBuffer((void *)param_name, sizeof(param_name), nullptr);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // END param_write_struct_type
- // START param_write_ref_all
- _aidl_ret_status = _aidl_data.writeFileDescriptor(param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // END param_write_ref_all
-// END param_write_snips
- _aidl_ret_status = remote()->transact(Ipackage_name::func_name_as_enum, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
-// START param_ret_read_snips
-
-// START param_ret_read_scalar_int8_t
- _aidl_ret_status = _aidl_reply.readByte(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_int8_t
-// START param_ret_read_scalar_uint8_t
- _aidl_ret_status = _aidl_reply.readByte((int8_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_uint8_t
-// START param_ret_read_scalar_int16_t
- _aidl_ret_status = _aidl_reply.readChar((char16_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_int16_t
-// START param_ret_read_scalar_uint16_t
- _aidl_ret_status = _aidl_reply.readChar((char16_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_uint16_t
-
-// START param_ret_read_scalar_int32_t
- _aidl_ret_status = _aidl_reply.readInt32(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_int32_t
-// START param_ret_read_scalar_uint32_t
- _aidl_ret_status = _aidl_reply.readUint32(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_uint32_t
-// START param_ret_read_scalar_int64_t
- _aidl_ret_status = _aidl_reply.readInt64(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_int64_t
-// START param_ret_read_scalar_uint64_t
- _aidl_ret_status = _aidl_reply.readUint64(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_uint64_t
-
-// START param_ret_read_scalar_char
- _aidl_ret_status = _aidl_reply.readByte((int8_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_scalar_char
-
- // START param_ret_read_import
- _aidl_ret_status = _aidl_reply.readStrongBinder(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // END param_ret_read_import
-
-// START param_ret_read_enum_type_scalar_uint8_t
- _aidl_ret_status = _aidl_reply.readByte((int8_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_uint8_t
-// START param_ret_read_enum_type_scalar_int8_t
- _aidl_ret_status = _aidl_reply.readByte((int8_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_int8_t
-// START param_ret_read_enum_type_scalar_uint16_t
- _aidl_ret_status = _aidl_reply.readChar((char16_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_uint16_t
-// START param_ret_read_enum_type_scalar_int16_t
- _aidl_ret_status = _aidl_reply.readChar((char16_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_int16_t
-
-// START param_ret_read_enum_type_scalar_uint32_t
- _aidl_ret_status = _aidl_reply.readUint32((uint32_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_uint32_t
-// START param_ret_read_enum_type_scalar_int32_t
- _aidl_ret_status = _aidl_reply.readInt32((int32_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_int32_t
-// START param_ret_read_enum_type_scalar_uint64_t
- _aidl_ret_status = _aidl_reply.readUint64((uint64_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_uint64_t
-// START param_ret_read_enum_type_scalar_int64_t
- _aidl_ret_status = _aidl_reply.readInt64((int64_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_int64_t
-
-// START param_ret_read_enum_type_scalar_char
- _aidl_ret_status = _aidl_reply.readByte((int8_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_read_enum_type_scalar_char
-
-// START param_ret_read_struct_type
- param_name = (Ipackage_name::struct_name *)_aidl_data.readBuffer();
-// END param_ret_read_struct_type
-// END param_ret_read_snips
-
- // Invoke callback to client // START callback_invocation
- if (_cb != nullptr)
- _cb(return_param_names); // END callback_invocation
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-// END code_for_function
-param_name // ALL callback_var_default
-*param_name // ALL callback_var_struct_type
-// END code_snips
-
-namespace_close_section
-
-// END file
diff --git a/templates/TemplateStubs.cpp b/templates/TemplateStubs.cpp
deleted file mode 100644
index 7bee173..0000000
--- a/templates/TemplateStubs.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-// SECTION stubs_cpp
-/*
-auto param_name // ALL return_param_decl_default
-*/
-// START file
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/TemplateStubs.cpp
-#include <namespace_slashes/Ipackage_name.h>
-#include <namespace_slashes/Bppackage_name.h>
-
-// START namespace_open_section
-namespace namespace_name {//ALL namespace_open_line
-//END namespace_open_section
-
-IMPLEMENT_HWBINDER_META_INTERFACE(package_name, "namespace_dots.Ipackage_name");
-
-// START namespace_close_section
-} // namespace namespace_name //ALL namespace_close_line
-//END namespace_close_section
-
-#include <iostream>
-#include <namespace_slashes/Bnpackage_name.h>
-#include <binder/Parcel.h>
-
-namespace_open_section
-
-::android::status_t Bnpackage_name::onTransact(uint32_t _aidl_code, const ::android::hardware::Parcel& _aidl_data, ::android::hardware::Parcel* _aidl_reply, uint32_t _aidl_flags, TransactCallback _cb) {
- ::android::status_t _aidl_ret_status = ::android::OK;
- switch (_aidl_code) {
-// START code_snips
-// START code_for_function
- case Call::func_name_as_enum:
- {
-// START param_decls
- /*
- Ipackage_name::struct_name *param_name // ALL field_decl_struct_type
- sp<import_name> param_name // ALL field_decl_import
- */
- int32_t should_be_replaced; // These will be replaced
- int32_t ret_FOO; // with auto-generated declarations
-// END param_decls
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
-// START param_read_snips
-
-// START param_read_scalar_int8_t
- _aidl_ret_status = _aidl_data.readByte(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_int8_t
-// START param_read_scalar_uint8_t
- _aidl_ret_status = _aidl_data.readByte((int8_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_uint8_t
-// START param_read_scalar_int16_t
- _aidl_ret_status = _aidl_data.readChar((char16_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_int16_t
-// START param_read_scalar_uint16_t
- _aidl_ret_status = _aidl_data.readChar((char16_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_uint16_t
-
-// START param_read_scalar_int32_t
- _aidl_ret_status = _aidl_data.readInt32(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_int32_t
-// START param_read_scalar_uint32_t
- _aidl_ret_status = _aidl_data.readUint32(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_uint32_t
-// START param_read_scalar_int64_t
- _aidl_ret_status = _aidl_data.readInt64(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_int64_t
-// START param_read_scalar_uint64_t
- _aidl_ret_status = _aidl_data.readUint64(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_uint64_t
-
-// START param_read_scalar_char
- _aidl_ret_status = _aidl_data.readByte((int8_t*)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_scalar_char
-
- // START param_read_import
- _aidl_ret_status = _aidl_data.readStrongBinder(¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // END param_read_import
-// START param_read_enum_type_scalar_int8_t
- _aidl_ret_status = _aidl_data.readByte((int8_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_int8_t
-// START param_read_enum_type_scalar_uint8_t
- _aidl_ret_status = _aidl_data.readByte((int8_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_uint8_t
-// START param_read_enum_type_scalar_int16_t
- _aidl_ret_status = _aidl_data.readChar((char16_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_int16_t
-// START param_read_enum_type_scalar_uint16_t
- _aidl_ret_status = _aidl_data.readChar((char16_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_uint16_t
-// START param_read_enum_type_scalar_int32_t
- _aidl_ret_status = _aidl_data.readInt32((int32_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_int32_t
-// START param_read_enum_type_scalar_uint32_t
- _aidl_ret_status = _aidl_data.readUint32((uint32_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_uint32_t
-// START param_read_enum_type_scalar_int64_t
- _aidl_ret_status = _aidl_data.readInt64((int64_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_int64_t
-// START param_read_enum_type_scalar_uint64_t
- _aidl_ret_status = _aidl_data.readUint64((uint64_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_uint64_t
-// START param_read_enum_type_scalar_char
- _aidl_ret_status = _aidl_data.readByte((int8_t *)¶m_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-// END param_read_enum_type_scalar_char
-// START param_read_ref_all
- param_name = _aidl_data.readFileDescriptor();
-// END param_read_ref_all
- // START param_read_struct_type
- param_name = (Ipackage_name::struct_name *)_aidl_data.readBuffer();
- // END param_read_struct_type
-// END param_read_snips
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- function_name(stub_arguments));
-
- // START // Hide callback_code
-param_name// ALL stub_param_decl_default
-*param_name// ALL stub_param_decl_struct_type
- [&](return_params_stubs) { // START callback_code
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
-// START param_ret_write_snips
-
-// START param_ret_write_struct_type
- std::cout << "Struct type passed to cb" << std::endl;
-// END param_ret_write_struct_type
-
-// START param_ret_write_scalar_uint8_t
- _aidl_reply->writeByte((int8_t)param_name);
-// END param_ret_write_scalar_uint8_t
-// START param_ret_write_scalar_int8_t
- _aidl_reply->writeByte(param_name);
-// END param_ret_write_scalar_int8_t
-// START param_ret_write_scalar_uint16_t
- _aidl_reply->writeChar((char16_t)param_name);
-// END param_ret_write_scalar_uint16_t
-// START param_ret_write_scalar_int16_t
- _aidl_reply->writeChar((char16_t)param_name);
-// END param_ret_write_scalar_int16_t
-
-// START param_ret_write_scalar_uint32_t
- _aidl_reply->writeUint32(param_name);
-// END param_ret_write_scalar_uint32_t
-// START param_ret_write_scalar_int32_t
- _aidl_reply->writeInt32(param_name);
-// END param_ret_write_scalar_int32_t
-// START param_ret_write_scalar_uint64_t
- _aidl_reply->writeUint64(param_name);
-// END param_ret_write_scalar_uint64_t
-// START param_ret_write_scalar_int64_t
- _aidl_reply->writeInt64(param_name);
-// END param_ret_write_scalar_int64_t
-
-// START param_ret_write_scalar_char
- _aidl_reply->writeByte((int8_t)param_name);
-// END param_ret_write_scalar_char
-
-// START param_ret_write_enum_type_scalar_int8_t
- _aidl_ret_status = _aidl_reply->writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_int8_t
-// START param_ret_write_enum_type_scalar_uint8_t
- _aidl_ret_status = _aidl_reply->writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_uint8_t
-// START param_ret_write_enum_type_scalar_int16_t
- _aidl_ret_status = _aidl_reply->writeChar((char16_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_int16_t
-// START param_ret_write_enum_type_scalar_uint16_t
- _aidl_ret_status = _aidl_reply->writeChar((char16_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_uint16_t
-// START param_ret_write_enum_type_scalar_int32_t
- _aidl_ret_status = _aidl_reply->writeInt32((int32_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_int32_t
-// START param_ret_write_enum_type_scalar_uint32_t
- _aidl_ret_status = _aidl_reply->writeUint32((uint32_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_uint32_t
-// START param_ret_write_enum_type_scalar_int64_t
- _aidl_ret_status = _aidl_reply->writeInt64((int64_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_int64_t
-// START param_ret_write_enum_type_scalar_uint64_t
- _aidl_ret_status = _aidl_reply->writeUint64((uint64_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_uint64_t
-// START param_ret_write_enum_type_scalar_char
- _aidl_ret_status = _aidl_reply->writeByte((int8_t)param_name);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-// END param_ret_write_enum_type_scalar_char
-// START param_ret_write_import
- _aidl_ret_status = _aidl_reply->writeStrongBinder(IInterface::asBinder(param_name));
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-// END param_ret_write_import
-// END param_ret_write_snips
- // Callback
- _cb(*_aidl_reply);
- } // END callback_code
- // END //
-
- if (!callback_called) { // START callback_check
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- } // END callback_check
- break;
- }
-// END code_for_function
-// END code_snips
- default:
- {
- _aidl_ret_status = ::android::hardware::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
- }
- break;
- }
- if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
- _aidl_ret_status = ::android::hardware::Status::fromExceptionCode(::android::hardware::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
- }
- return _aidl_ret_status;
-}
-
-namespace_close_section
-// END file
diff --git a/templates/template.cpp b/templates/template.cpp
deleted file mode 100644
index 4a96cce..0000000
--- a/templates/template.cpp
+++ /dev/null
@@ -1,348 +0,0 @@
-// START const
-#define NAME (VAL)
-// END const
-
-#include <string.h> // START header
-#include <cstdlib>
-#include <cstdint>
-#include <stddef.h>
-#include <stdio.h>
-
-using FdType = int;
-typedef uint64_t opaque;
-
-
-struct native_handle
-{
- int version; /* sizeof(native_handle_t) */
- int numFds; /* number of file-descriptors at &data[0] */
- int numInts; /* number of ints at &data[numFds] */
- int data[0]; /* numFds + numInts ints */
-};
-
-typedef int32_t ref;
-typedef int32_t fd;
-
-template<typename T>
-struct vec {
- size_t count;
- T *ptr;
-};
-
-struct HidlString {
- ptrdiff_t n_bytes;
- char *buffer;
-};
-
-
-
-
-struct FunStruct {
- alignas(8) FunStruct *self_ptr;
- alignas(8) size_t n_fds;
-};
-
-#define ALIGNMENT (8)
-#define ALIGNED(size) (((size_t)(size) + ALIGNMENT - 1) & ~(ALIGNMENT - 1))
-#define PALIGNED(ptr) ((char *)ALIGNED((size_t)(ptr)))
-
-template<typename T>
-size_t bytes_needed(T var)
-{
- (void)var; return sizeof(T);
-}
-size_t bytes_needed(HidlString& var)
-{
- ptrdiff_t buf_len = (var.n_bytes == -1) ? strlen(var.buffer) : var.n_bytes;
- return sizeof(HidlString) + ALIGNED(buf_len);
-}
-size_t bytes_needed(native_handle &var)
-{
- (void)var;
- return 5;
-}
-
-template<typename T>
-size_t fds_needed(T &var)
-{
- (void)var;
- return 0;
-}
-size_t fds_needed(native_handle &var)
-{
- return var.numFds;
-}
-size_t fds_needed(ref &var)
-{
- (void)var;
- return 1;
-}
-
-void extract_fds(FdType **ppFds, ref var)
-{
- *(*ppFds++) = (FdType)var;
-}
-
-void extract_fds(FdType **ppFds, native_handle& var)
-{
- for (int i = 0; i < var.numFds; i++) {
- *(*ppFds++) = (FdType)var.data[i];
- }
-}
-void replace_fds(FdType **ppFds, native_handle* var)
-{
- for (int i = 0; i < var->numFds; i++) {
- *(*ppFds++) = (FdType)var->data[i];
- }
-}
-
-size_t fix_pointers(native_handle *var, ptrdiff_t fix)
-{
- (void)var;
- (void)fix;
- return 5; // TODO
-}
-
-void fill_data(char **ppData, native_handle& var)
-{
- (void)ppData;
- (void)var; // TODO
-}
-// END header
-
-
-struct C {
- ref r;
-};
-size_t bytes_needed(C &var)
-{
- (void)var;
- return sizeof(C);
-}
-size_t fds_needed(C &var)
-{
- (void)var;
- return 1;
-}
-void extract_fds(FdType **ppFds, C& var)
-{
- *(*ppFds++) = var.r;
-}
-void replace_fds(FdType **ppFds, C& var)
-{
- var.r = *(*ppFds++);
-}
-
-struct B {
- HidlString s;
-};
-size_t bytes_needed(B &var)
-{
- (void)var;
- return 5;
-}
-size_t fds_needed(B &var)
-{
- (void)var;
- return 5;
-}
-void extract_fds(FdType **ppFds, B& var)
-{
- (void)ppFds; (void)var;
-}
-void replace_fds(FdType **ppFds, B& var)
-{
- (void)ppFds;(void)var;
-}
-
-#define array_size 3
-#define array_base C
-#define vec_name b
-#define array_name c
-
-// START struct_code
-struct struct_type {
- // ALL field_declarations
- vec<B> vec_name; // SKIP
- array_base array_name[array_size]; // SKIP
-};
-typedef struct_type A; // SKIP
-
-size_t bytes_needed(struct_type &var)
-{
- size_t sum = 0, temp_size, i;
- sum += sizeof(struct_type);
- // START b_n_fields
- temp_size = 0; // START b_n_vec
- for (i = 0; i < var.vec_name.count; i++) {
- temp_size += bytes_needed(var.vec_name.ptr[i]);
- }
- sum += ALIGNED(temp_size); // END b_n_vec
- temp_size = 0; // START b_n_array
- for (i = 0; i < array_size; i++) {
- temp_size += ALIGNED(bytes_needed(var.array_name[i]) - sizeof(array_base));
- }
- sum += temp_size; // END b_n_array
- // END b_n_fields
- return sum;
-}
-
-size_t fds_needed(struct_type& var)
-{
- size_t sum = 0;
- size_t i;
- // START fd_n_fields
- for (i = 0; i < var.vec_name.count; i++) { // START fd_n_vec
- sum += fds_needed(var.vec_name.ptr[i]);
- } // END fd_n_vec
- for (i = 0; i < array_size; i++) { // START fd_n_array
- sum += fds_needed(var.array_name[i]);
- } // END fd_n_array
- // END fd_n_fields
- return sum;
-}
-
-void extract_fds(FdType **ppFds, struct_type& var)
-{
- size_t i;
- // START xfd_fields
- for (i = 0; i < var.vec_name.count; i++) { // START xfd_vec
- extract_fds(ppFds, var.vec_name.ptr[i]);
- } // END xfd_vec
- for (i = 0; i < array_size; i++) { // START xfd_array
- extract_fds(ppFds, var.array_name[i]);
- } // END xfd_array
- // END xfd_fields
-}
-
-void replace_fds(FdType **ppFds, struct_type* var)
-{
- size_t i;
- // START rfd_fields
- for (i = 0; i < var->vec_name.count; i++) { // START rfd_vec
- replace_fds(ppFds, var->vec_name.ptr[i]);
- } // END rfd_vec
- for (i = 0; i < array_size; i++) { // START rfd_array
- replace_fds(ppFds, var->array_name[i]);
- } // END rfd_array
- // END rfd_fields
-}
-
-void fill_data(char **ppData, struct_type& var)
-{
- (void)ppData;
- (void)var; // TODO
-}
-
-size_t fix_pointers(struct_type *var, ptrdiff_t fix)
-{
- (void)var;
- (void)fix;
- return 5; // TODO
-}
-//END struct_code
-
-void dispatch_to_fun(char *wirebuf);
-
-
-void kernel_trap_for_funcall(char* buf, size_t len)
-{
- char *raw_buf = (char *)malloc(len + ALIGNMENT);
- char *new_buf = PALIGNED(raw_buf);
- memcpy(new_buf, buf, len);
- printf("Pointers should be between %p and %p\n", new_buf, new_buf+len);
- FunStruct *pFS = (FunStruct *)new_buf;
- pFS->self_ptr = pFS;
- int *pFds = (FdType *)(new_buf + ALIGNED(sizeof(FunStruct)));
- for (size_t i = 0; i < pFS->n_fds; i++) {
- pFds[i] *= 3;
- }
-
- dispatch_to_fun(new_buf);
- (void)len;
-}
-
-#define type A
-void fun( // START proxy
- type& arg // ALL param
- , native_handle &h // SKIP
-)
-{
- size_t bytes_sum = sizeof(FunStruct);
- bytes_sum += ALIGNED(bytes_needed(arg)); // ALL sum_bytes
- bytes_sum += ALIGNED(bytes_needed(h)); // SKIP
- size_t fds_sum = 0;
- fds_sum += fds_needed(arg); // ALL sum_fds
- fds_sum += fds_needed(h); // SKIP
- size_t buf_size = ALIGNED(bytes_sum) +
- ALIGNED(fds_sum * sizeof(FdType));
- char *raw_buf = (char *)malloc(buf_size + ALIGNMENT);
- char *wire_buf = PALIGNED(raw_buf);
- FunStruct *pFS = (FunStruct *)wire_buf;
- pFS->self_ptr = pFS;
- int *pFds = (FdType *)(wire_buf + ALIGNED(sizeof(FunStruct)));
- char *pData = wire_buf + ALIGNED(sizeof(FunStruct)) +
- ALIGNED(fds_sum * sizeof(FdType));
- extract_fds(&pFds, arg); // ALL get_fds
- extract_fds(&pFds, h); // SKIP
- fill_data(&pData, arg); // START move_data
- pData = PALIGNED(pData); // END move_data
- fill_data(&pData, h); // SKIP
- pData = PALIGNED(pData); // SKIP
- kernel_trap_for_funcall(wire_buf, buf_size);
- free(raw_buf);
-} // END proxy
-
-void targetFun(A& a, native_handle& h);
-
-void dispatch_to_fun(char *wire_buf) {
- // Assumes wire_buf is aligned to ALIGNMENT!
- FunStruct *pFS = (FunStruct *)wire_buf;
- char *pData;
- ptrdiff_t ptr_fixup = (char *)pFS - (char *)pFS->self_ptr;
- fd *pFds = (fd *)(wire_buf + ALIGNED(sizeof(FunStruct)));
- pData = PALIGNED(wire_buf + (pFS->n_fds * sizeof(FdType)));
- A *a_ptr = (A *)pData;
- pData += fix_pointers(a_ptr, ptr_fixup);
- pData = PALIGNED(pData);
- native_handle *h_ptr = (native_handle *)pData;
- pData += fix_pointers(h_ptr, ptr_fixup);
- pData = PALIGNED(pData);
- replace_fds(&pFds, a_ptr);
- replace_fds(&pFds, h_ptr);
- targetFun(*a_ptr, *h_ptr);
-}
-
-void targetFun(A& a, native_handle& h)
-{
- printf("Target acquired... h[0] is %d\n", h.data[0]);
- printf("a.c values are %d, %d, %d\n", a.c[0].r, a.c[1].r, a.c[2].r);
- printf("a.b strings are %s and %s\n", a.b.ptr[0].s.buffer,
- a.b.ptr[1].s.buffer);
- printf("Addresses are %p, %p, %p, %p\n", &a, &h, a.b.ptr,
- a.b.ptr[0].s.buffer);
-}
-
-int main(int argc, char *argv[])
-{
- (void)argc;
- (void)argv;
- printf("Hello world\n");
- int h_space[6];
- native_handle *h = (native_handle *)&h_space;
- h->numFds = 1;
- int *pData = h->data;
- pData[0] = 2;
- A a;
- B b[2];
- a.b.ptr = b;
- a.b.count = 2;
- a.c[0].r = 5;
- a.c[1].r = 42;
- a.c[2].r = 13;
- b[0].s.n_bytes = -1;
- b[0].s.buffer = (char *)"Kilroy was here"; // this is bad form
- b[1].s.n_bytes = -1;
- b[1].s.buffer = (char *)"Where's Waldo?";
- fun(a, *h);
-}
diff --git a/tests/IBadType.hal b/tests/IBadType.hal
deleted file mode 100644
index 10c1d2d..0000000
--- a/tests/IBadType.hal
+++ /dev/null
@@ -1,6 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-interface ITestService {
- echoInteger(int48_t echo_me) generates (int32_t _aidl_return);
-};
diff --git a/tests/IEverything.hal b/tests/IEverything.hal
deleted file mode 100644
index faa139c..0000000
--- a/tests/IEverything.hal
+++ /dev/null
@@ -1,16 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-interface IEverything {
-
- struct simple_t {
- uint32_t int1;
- uint32_t int2;
- };
-
- struct lots_of_data {
- uint8_t[4096] buffer;
- };
- echoInteger(int32_t echo_me, simple_t my_struct) generates (int32_t ret);
- shareBufferWithRef(ref<lots_of_data> buffer) generates (int32_t ret);
-};
diff --git a/tests/IExpression.hal b/tests/IExpression.hal
deleted file mode 100644
index 0e49b0f..0000000
--- a/tests/IExpression.hal
+++ /dev/null
@@ -1,22 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-@hal_type("LIGHT")
-
-interface IExpression {
-
- const SIMPLE_EXPRESSION = 4;
- const BOOLEAN_EXPRESSION = 1 == 7 && !((3 != 4 || (2 < 3 <= 3 > 4)) >= 0);
- const BITWISE_EXPRESSION = ~42 & (1 << 3 | 16 >> 2) ^ 7;
- const ARITHMETIC_EXPRESSION = 2 + 3 - 4 * -7 / (6 % 3);
- const MESSY_EXPRESSION = 2 + (-3&4 / 7);
-
- struct expressionist_t {
- uint8_t[1 << 10] buffer;
- vec<vec<uint8_t> > expmap;
- };
-
- @param(name = "mask", normal = 1 << 5)
- setExpression(expressionist_t state, int32_t mask) generates (int32_t ret);
-};
-
diff --git a/tests/INfc.hal b/tests/INfc.hal
deleted file mode 100644
index f5451dc..0000000
--- a/tests/INfc.hal
+++ /dev/null
@@ -1,97 +0,0 @@
-version 1.0;
-package android.hardware.nfc;
-
-
-import android.hardware.nfc.INfcClientCallback;
-
-interface INfc {
- enum nfc_event_t : uint32_t {
- HAL_NFC_OPEN_CPLT_EVT = 0,
- HAL_NFC_CLOSE_CPLT_EVT = 1,
- HAL_NFC_POST_INIT_CPLT_EVT = 2,
- HAL_NFC_PRE_DISCOVER_CPLT_EVT = 3,
- HAL_NFC_REQUEST_CONTROL_EVT = 4,
- HAL_NFC_RELEASE_CONTROL_EVT = 5,
- HAL_NFC_ERROR_EVT = 6
- };
-
- enum nfc_status_t : uint32_t {
- HAL_NFC_STATUS_OK = 0,
- HAL_NFC_STATUS_FAILED = 1,
- HAL_NFC_STATUS_ERR_TRANSPORT = 2,
- HAL_NFC_STATUS_ERR_CMD_TIMEOUT = 3,
- HAL_NFC_STATUS_REFUSED = 4
- };
-
- struct nfc_data_t {
- vec<uint8_t> data;
- };
-
- /*
- * Opens the NFC controller device and performs initialization.
- * This may include patch download and other vendor-specific initialization.
- *
- * If open completes successfully, the controller should be ready to perform
- * NCI initialization - ie accept CORE_RESET and subsequent commands through
- * the write() call.
- *
- * If open() returns 0, the NCI stack will wait for a HAL_NFC_OPEN_CPLT_EVT
- * before continuing.
- *
- * If open() returns any other value, the NCI stack will stop.
- *
- */
- open(INfcClientCallback clientCallback) generates (int32_t retval);
-
- /*
- * Performs an NCI write.
- *
- * This method may queue writes and return immediately. The only
- * requirement is that the writes are executed in order.
- */
- write(nfc_data_t data) generates (int32_t retval);
-
- /*
- * core_initialized() is called after the CORE_INIT_RSP is received from the NFCC.
- * At this time, the HAL can do any chip-specific configuration.
- *
- * If core_initialized() returns 0, the NCI stack will wait for a HAL_NFC_POST_INIT_CPLT_EVT
- * before continuing.
- *
- * If core_initialized() returns any other value, the NCI stack will continue
- * immediately.
- */
- core_initialized(vec<uint8_t> data) generates (int32_t retval);
-
- /*
- * pre_discover is called every time before starting RF discovery.
- * It is a good place to do vendor-specific configuration that must be
- * performed every time RF discovery is about to be started.
- *
- * If pre_discover() returns 0, the NCI stack will wait for a HAL_NFC_PRE_DISCOVER_CPLT_EVT
- * before continuing.
- *
- * If pre_discover() returns any other value, the NCI stack will start
- * RF discovery immediately.
- */
- pre_discover() generates (int32_t retval);
-
- /*
- * Close the NFC controller. Should free all resources.
- */
- close() generates (int32_t retval);
-
- /*
- * Grant HAL the exclusive control to send NCI commands.
- * Called in response to HAL_REQUEST_CONTROL_EVT.
- * Must only be called when there are no NCI commands pending.
- * HAL_RELEASE_CONTROL_EVT will notify when HAL no longer needs exclusive control.
- */
- control_granted() generates (int32_t retval);
-
- /*
- * Restart controller by power cyle;
- * HAL_OPEN_CPLT_EVT will notify when operation is complete.
- */
- power_cycle() generates (int32_t retval);
-};
diff --git a/tests/INfcClientCallback.hal b/tests/INfcClientCallback.hal
deleted file mode 100644
index 616b15f..0000000
--- a/tests/INfcClientCallback.hal
+++ /dev/null
@@ -1,39 +0,0 @@
-version 1.0;
-package android.hardware.nfc;
-
-
-interface INfcClientCallback {
- struct nfc_data_t {
- vec<uint8_t> data;
- };
-
- enum nfc_event_t : uint32_t {
- HAL_NFC_OPEN_CPLT_EVT = 0,
- HAL_NFC_CLOSE_CPLT_EVT = 1,
- HAL_NFC_POST_INIT_CPLT_EVT = 2,
- HAL_NFC_PRE_DISCOVER_CPLT_EVT = 3,
- HAL_NFC_REQUEST_CONTROL_EVT = 4,
- HAL_NFC_RELEASE_CONTROL_EVT = 5,
- HAL_NFC_ERROR_EVT = 6
- };
-
- enum nfc_status_t : uint32_t {
- HAL_NFC_STATUS_OK = 0,
- HAL_NFC_STATUS_FAILED = 1,
- HAL_NFC_STATUS_ERR_TRANSPORT = 2,
- HAL_NFC_STATUS_ERR_CMD_TIMEOUT = 3,
- HAL_NFC_STATUS_REFUSED = 4
- };
-
- /*
- * The callback passed in from the NFC stack that the HAL
- * can use to pass events back to the stack.
- */
- sendEvent(nfc_event_t event, nfc_status_t event_status);
-
- /*
- * The callback passed in from the NFC stack that the HAL
- * can use to pass incomming data to the stack.
- */
- sendData(nfc_data_t data);
-};
diff --git a/tests/ITest.hal b/tests/ITest.hal
deleted file mode 100644
index 3657bd8..0000000
--- a/tests/ITest.hal
+++ /dev/null
@@ -1,7 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-interface ITestService {
- echoInteger(int32_t echo_me) generates (int32_t _aidl_return);
- AddMul(int32_t op1, int32_t op2) generates (int32_t sum, int32_t product);
-};
diff --git a/tests/ITestService.hal b/tests/ITestService.hal
deleted file mode 100644
index c428710..0000000
--- a/tests/ITestService.hal
+++ /dev/null
@@ -1,16 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-interface ITestService {
-
- struct simple_t {
- uint32_t int1;
- uint32_t int2;
- };
-
- struct lots_of_data {
- uint8_t[4096] buffer;
- };
- echoInteger(int32_t echo_me, simple_t my_struct) generates (int32_t ret);
- shareBufferWithRef(ref<lots_of_data> buffer) generates (int32_t ret);
-};
diff --git a/tests/ITypes.hal b/tests/ITypes.hal
deleted file mode 100644
index 5de30a1..0000000
--- a/tests/ITypes.hal
+++ /dev/null
@@ -1,87 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-import ISmallTest;
-
-interface ITypes {
-
- struct simple_t {
- uint32_t int1;
- uint32_t int2;
- };
-
- enum eu8 : uint8_t { U8F = 34, max = 255, min = 0};
- enum es8 : int8_t { S8F = 104, max = 127, min = -128 };
- enum eu16 : uint16_t { U16F = 234, max = 65535, min = 0 };
- enum es16 : int16_t { S16F = 334, max = 32767, min = -32768 };
- enum eu32 : uint32_t { U32F = 434, max = 0xffff'f'fff, min = 0};
- enum es32 : int32_t { S32F = 534, max = 0x7fff'f'fff, min = -2147483648 };
- enum eu64 : uint64_t { U64F = 634, max = 0xffff'ffff'ffff'f'fffuLL, min = 0 };
- enum es64 : int64_t { S64F = 734, max=9223372036854775807LL, min=-9223372036854775807LL };
- enum ec : char { CF = 43, min=0, max=255 };
-
- struct lots_of_data {
- uint8_t[4096] buffer;
- };
-
- enum disc : uint32_t { US, UF, UI, UC };
-
- struct s2 {
- int32_t i;
- };
-
- union u1 : disc {
- string s on(US);
- ref<uint8_t> fd on(UF);
- int64_t i on(UI);
- s2 s2m on(UC);
- };
-
- struct s1s {
- string str1;
- };
-
- struct s1u {
- disc dm1;
- u1 u1m1;
- };
-
- struct s0 {
- s1s s1m1;
- vec<s1s> s1v2;
- };
-
- struct shm_t {
- uint32_t fdIndex;
- uint32_t offset;
- uint32_t extent;
- };
- struct GrantorDescriptor {
- uint32_t flags;
- shm_t shm;
- };
-
- struct MQDescriptor {
- vec<GrantorDescriptor> grantors;
- handle mq_handles;
- uint32_t quantum;
- uint32_t nQuanta;
- uint32_t flags;
- };
-
- echoInteger(int32_t echo_me, simple_t my_struct) generates (int32_t ret);
- echoEnum(eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i)
- generates(eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i);
- echoScalar(uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i)
- generates(uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i);
- echoStruct(s0 s) generates (s0 s);
-
- // EchoInterface passes an ISmalltest around and verifies that
- // its functions can be called on the server side.
- echoInterface(ISmallTest cb_t) generates (ISmallTest cb_t);
-
- // Use of ref<T> is deprecated.
- shareBufferWithRef(ref<lots_of_data> buffer) generates (int32_t ret);
- getHash() generates (uint64_t hash);
- quit();
-};
diff --git a/tests/IanBinder.hal b/tests/IanBinder.hal
deleted file mode 100644
index 112c88c..0000000
--- a/tests/IanBinder.hal
+++ /dev/null
@@ -1,16 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-interface IMappableRegion {
-
- enum MappingType : int32_t {
- UNDEFINED_MAPPING,
- ASHMEM_MAPPING,
- FILE_MAPPING
- };
- var ref<char> mFd = -1;
- var MappingType mRegionType = MappingType::UNDEFINED_MAPPING;
- var int64_t mOffset;
- var uint64_t mSize = 0;
-
-};
diff --git a/tests/canonical/BnNfc.h b/tests/canonical/BnNfc.h
deleted file mode 100644
index bbf070f..0000000
--- a/tests/canonical/BnNfc.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_android_hardware_nfc_BN_Nfc_H_
-#define HIDL_GENERATED_android_hardware_nfc_BN_Nfc_H_
-
-#include <hwbinder/IInterface.h>
-//#include <android/hardware/nfc/INfc.h>
-#include <INfc.h>
-
-namespace android {
-namespace hardware {
-namespace nfc {
-
-
-class BnNfc : public ::android::hardware::BnInterface<INfc> {
-public:
- ::android::status_t onTransact(uint32_t _aidl_code, const ::android::hardware::Parcel& _aidl_data, ::android::hardware::Parcel* _aidl_reply, uint32_t _aidl_flags = 0, TransactCallback _callback = nullptr) override;
-}; // class BnNfc
-
-} // namespace nfc
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_android_hardware_nfc_BN_Nfc_H_
diff --git a/tests/canonical/BnTestService.h b/tests/canonical/BnTestService.h
deleted file mode 100644
index 3f51d39..0000000
--- a/tests/canonical/BnTestService.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_android_hardware_tests_BN_TestService_H_
-#define HIDL_GENERATED_android_hardware_tests_BN_TestService_H_
-
-#include <hwbinder/IInterface.h>
-//#include <android/hardware/tests/ITestService.h>
-#include <ITestService.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-class BnTestService : public ::android::hardware::BnInterface<ITestService> {
-public:
- ::android::status_t onTransact(uint32_t _aidl_code, const ::android::hardware::Parcel& _aidl_data, ::android::hardware::Parcel* _aidl_reply, uint32_t _aidl_flags = 0, TransactCallback _callback = nullptr) override;
-}; // class BnTestService
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_android_hardware_tests_BN_TestService_H_
diff --git a/tests/canonical/BnTypes.h b/tests/canonical/BnTypes.h
deleted file mode 100644
index bdea7d3..0000000
--- a/tests/canonical/BnTypes.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_android_hardware_tests_BN_Types_H_
-#define HIDL_GENERATED_android_hardware_tests_BN_Types_H_
-
-#include <hwbinder/IInterface.h>
-//#include <android/hardware/tests/ITypes.h>
-#include <ITypes.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-class BnTypes : public ::android::hardware::BnInterface<ITypes> {
-public:
- ::android::status_t onTransact(uint32_t _aidl_code, const ::android::hardware::Parcel& _aidl_data, ::android::hardware::Parcel* _aidl_reply, uint32_t _aidl_flags = 0, TransactCallback _callback = nullptr) override;
-}; // class BnTypes
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_android_hardware_tests_BN_Types_H_
diff --git a/tests/canonical/BpNfc.h b/tests/canonical/BpNfc.h
deleted file mode 100644
index 4a74d5c..0000000
--- a/tests/canonical/BpNfc.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_android_hardware_nfc_BP_Nfc_H_
-#define HIDL_GENERATED_android_hardware_nfc_BP_Nfc_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <utils/Errors.h>
-//#include <android/hardware/nfc/INfc.h>
-#include <INfc.h>
-
-namespace android {
-namespace hardware {
-namespace nfc {
-
-
-class BpNfc : public ::android::hardware::BpInterface<INfc> {
-public:
-explicit BpNfc(const ::android::sp<::android::hardware::IBinder>& _aidl_impl);
-virtual ~BpNfc() = default;
-::android::hardware::Status open(sp<INfcClientCallback> clientCallback , INfc::open_cb _cb ) override;
-::android::hardware::Status write(const INfc::nfc_data_t &data , INfc::write_cb _cb ) override;
-::android::hardware::Status core_initialized(const hidl_vec<uint8_t> &data , INfc::core_initialized_cb _cb ) override;
-::android::hardware::Status pre_discover(INfc::pre_discover_cb _cb ) override;
-::android::hardware::Status close(INfc::close_cb _cb ) override;
-::android::hardware::Status control_granted(INfc::control_granted_cb _cb ) override;
-::android::hardware::Status power_cycle(INfc::power_cycle_cb _cb ) override;
-
-}; // class BpNfc
-
-} // namespace nfc
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_android_hardware_nfc_BP_Nfc_H_
diff --git a/tests/canonical/BpTestService.h b/tests/canonical/BpTestService.h
deleted file mode 100644
index 3ebeea5..0000000
--- a/tests/canonical/BpTestService.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_android_hardware_tests_BP_TestService_H_
-#define HIDL_GENERATED_android_hardware_tests_BP_TestService_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <utils/Errors.h>
-//#include <android/hardware/tests/ITestService.h>
-#include <ITestService.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-class BpTestService : public ::android::hardware::BpInterface<ITestService> {
-public:
-explicit BpTestService(const ::android::sp<::android::hardware::IBinder>& _aidl_impl);
-virtual ~BpTestService() = default;
-::android::hardware::Status echoInteger(int32_t echo_me, const ITestService::simple_t &my_struct , ITestService::echoInteger_cb _cb ) override;
-::android::hardware::Status shareBufferWithRef(hidl_ref<lots_of_data> buffer, ITestService::shareBufferWithRef_cb _cb ) override;
-
-}; // class BpTestService
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_android_hardware_tests_BP_TestService_H_
diff --git a/tests/canonical/BpTypes.h b/tests/canonical/BpTypes.h
deleted file mode 100644
index 97e4f7e..0000000
--- a/tests/canonical/BpTypes.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/BpTemplate.h
-#ifndef HIDL_GENERATED_android_hardware_tests_BP_Types_H_
-#define HIDL_GENERATED_android_hardware_tests_BP_Types_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <utils/Errors.h>
-//#include <android/hardware/tests/ITypes.h>
-#include <ITypes.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-class BpTypes : public ::android::hardware::BpInterface<ITypes> {
-public:
-explicit BpTypes(const ::android::sp<::android::hardware::IBinder>& _aidl_impl);
-virtual ~BpTypes() = default;
-::android::hardware::Status echoInteger(int32_t echo_me, const ITypes::simple_t &my_struct , ITypes::echoInteger_cb _cb ) override;
-::android::hardware::Status echoEnum(eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i, ITypes::echoEnum_cb _cb ) override;
-::android::hardware::Status echoScalar(uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i, ITypes::echoScalar_cb _cb ) override;
-::android::hardware::Status echoStruct(const ITypes::s0 &s , ITypes::echoStruct_cb _cb ) override;
-::android::hardware::Status echoInterface(sp<ISmallTest> cb_t , ITypes::echoInterface_cb _cb ) override;
-::android::hardware::Status shareBufferWithRef(hidl_ref<lots_of_data> buffer, ITypes::shareBufferWithRef_cb _cb ) override;
-::android::hardware::Status getHash(ITypes::getHash_cb _cb ) override;
-::android::hardware::Status quit() override;
-
-}; // class BpTypes
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_android_hardware_tests_BP_Types_H_
diff --git a/tests/canonical/Everything.json b/tests/canonical/Everything.json
deleted file mode 100644
index 00c94ee..0000000
--- a/tests/canonical/Everything.json
+++ /dev/null
@@ -1,83 +0,0 @@
-hidl {
- version_major: 1,
- version_minor: 0,
- name: "Everything",
- things: [
- {
- type: "struct",
- name: "simple_t",
- fields: [
- {
- name: "int1",
- type: "uint32_t",
- },
- {
- name: "int2",
- type: "uint32_t",
- },
-
- ],
- },
- {
- type: "struct",
- name: "lots_of_data",
- fields: [
- {
- name: "buffer",
- type: "array",
- base_type: {
- type: "uint8_t",
- },
- dimension: 4096,
- },
-
- ],
- },
- {
- type: "function",
- name: "echoInteger",
- params: [
- {
- name: "echo_me",
- type: "int32_t"
- }
-, {
- name: "my_struct",
- type: "simple_t"
- }
-
- ],
- generates: [
- {
- name: "ret",
- type: "int32_t"
- }
-
- ]
- },
- {
- type: "function",
- name: "shareBufferWithRef",
- params: [
- {
- name: "buffer",
- type: "ref",
- base_type: {
- type: "lots_of_data"
- }
- }
-
- ],
- generates: [
- {
- name: "ret",
- type: "int32_t"
- }
-
- ]
- },
-
- {} // comma fodder
- ]
-}
-
diff --git a/tests/canonical/Expression_all.cpp b/tests/canonical/Expression_all.cpp
deleted file mode 100644
index ef68a64..0000000
--- a/tests/canonical/Expression_all.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/TemplateAll.cpp
-//#include <android/hardware/tests/IExpression.h>
-//#include <android/hardware/tests/BpExpression.h>
-#include <IExpression.h>
-#include <BpExpression.h>
-#include <iostream>
-#include <stdio.h>
-using std::cout;
-using std::endl;
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-IMPLEMENT_HWBINDER_META_INTERFACE(Expression, "android.hardware.tests.IExpression");
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-//#include <android/hardware/tests/BpExpression.h>
-#include <BpExpression.h>
-#include <binder/Parcel.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-BpExpression::BpExpression(const ::android::sp<::android::hardware::IBinder>& _aidl_impl)
- : BpInterface<IExpression>(_aidl_impl){
-}
-::android::hardware::Status BpExpression::setExpression(const IExpression::expressionist_t& state , int32_t mask, IExpression::setExpression_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- int32_t _cb_ret;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- {
- size_t parent_handle;
- _aidl_ret_status = _aidl_data.writeBuffer((void *)&state, sizeof(state), &parent_handle);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // struct fixup write_
-
-//field buffer doesn't need fixup
- {
- size_t child_handle;
- void *bufp = (void *)state.expmap.buffer;
- size_t size = sizeof(hidl_vec<uint8_t>
-[state.expmap.count]);
- size_t off = (size_t)((char *)&(state.expmap.buffer)-(char *)(&state));
- _aidl_ret_status = _aidl_data.writeEmbeddedBuffer(bufp,
- size,
- &child_handle,
- parent_handle,
- off /* offset_calculator */);
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- for (size_t i1 = 0; i1 < state.expmap.count; i1++) {
- /* fixup_write_vec */
- {
- size_t child_handle;
- void *bufp = (void *)state.expmap.buffer[i1].buffer;
- size_t size = sizeof(uint8_t[state.expmap.buffer[i1].count]);
- size_t off = (size_t)((char *)&(state.expmap.buffer[i1].buffer)-(char *)(state.expmap.buffer));
- _aidl_ret_status = _aidl_data.writeEmbeddedBuffer(bufp,
- size,
- &child_handle,
- parent_handle,
- off /* offset_calculator */);
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // Fixup not needed for this vec uint8_t
- }
-
- }
-
- }
-
- }
- _aidl_ret_status = _aidl_data.writeInt32((int32_t)mask);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(IExpression::SETEXPRESSION, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_ret);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_ret );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-//
-//#include <android/hardware/tests/IExpression.h>
-//#include <android/hardware/tests/BpExpression.h>
-#include <IExpression.h>
-#include <BpExpression.h>
-
-
-#include <iostream>
-//#include <android/hardware/tests/BnExpression.h>
-#include <BnExpression.h>
-#include <binder/Parcel.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-::android::status_t BnExpression::onTransact(uint32_t _aidl_code, const ::android::hardware::Parcel& _aidl_data, ::android::hardware::Parcel* _aidl_reply, uint32_t _aidl_flags, TransactCallback _cb) {
- ::android::status_t _aidl_ret_status = ::android::OK;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- switch (_aidl_code) {
- case Call::SETEXPRESSION:
- {
- IExpression::expressionist_t *state ;
-int32_t mask;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- {
- size_t parent_handle;
- state = (IExpression::expressionist_t *)_aidl_data.readBuffer(&parent_handle);
- if ((state) == nullptr) {
- break;
- }
- // struct fixup read_
-
-//field buffer doesn't need fixup
- {
- size_t child_handle;
- _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(&child_handle, parent_handle,
- (size_t)((char *)&((*state).expmap.buffer)-(char *)(&(*state))));
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (_aidl_ret_pointer == nullptr) {
- break;
- }
- for (size_t i1 = 0; i1 < (*state).expmap.count; i1++) {
- /* fixup_write_vec */
- {
- size_t child_handle;
- _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(&child_handle, parent_handle,
- (size_t)((char *)&((*state).expmap.buffer[i1].buffer)-(char *)((*state).expmap.buffer)));
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (_aidl_ret_pointer == nullptr) {
- break;
- }
- // Fixup not needed for this vec uint8_t
- }
-
- }
-
- }
-
- }
- _aidl_ret_status = _aidl_data.readInt32(&mask);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- setExpression(*state , mask , [&](auto ret ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(ret);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
-
- default:
- {
- _aidl_ret_status = ::android::hardware::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
- }
- break;
- }
- if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
- _aidl_ret_status = ::android::hardware::Status::fromExceptionCode(::android::hardware::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
- }
- return _aidl_ret_status;
-}
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
diff --git a/tests/canonical/Expression_i.h b/tests/canonical/Expression_i.h
deleted file mode 100644
index b03ff48..0000000
--- a/tests/canonical/Expression_i.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/ITemplate.h
-#ifndef HIDL_GENERATED_android_hardware_tests_I_Expression_H_
-#define HIDL_GENERATED_android_hardware_tests_I_Expression_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <hwbinder/Status.h>
-#include <cstdint>
-#include <utils/StrongPointer.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-template<typename T>
-using hidl_ref = int;
-
-#ifndef HIDL_TYPES
-#define HIDL_TYPES
-template<typename T>
-struct hidl_vec {
- T *buffer;
- size_t count;
-};
-struct hidl_string {
- char *buffer;
- ptrdiff_t length;
-};
-#endif // HIDL_TYPES
-
-class IExpression : public ::android::hardware::IInterface {
-public:
-
-DECLARE_HWBINDER_META_INTERFACE(Expression);
-
-// constexpr SIMPLE_EXPRESSION = 4;
-// constexpr BOOLEAN_EXPRESSION = 1 == 7 && !((3 != 4 || (2 < 3 <= 3 > 4)) >= 0);
-// constexpr BITWISE_EXPRESSION = ~42 & (1 << 3 | 16 >> 2) ^ 7;
-// constexpr ARITHMETIC_EXPRESSION = 2 + 3 - 4 * -7 / (6 % 3);
-// constexpr MESSY_EXPRESSION = 2 + (-3 & 4 / 7);
-typedef struct {
-uint8_t buffer[1 << 10] ;
-hidl_vec<hidl_vec<uint8_t> > expmap ;
-
-} expressionist_t;
-
-
- using setExpression_cb = std::function<void(int32_t ret)>;
-
-
- virtual ::android::hardware::Status setExpression(const IExpression::expressionist_t &state , int32_t mask, setExpression_cb _cb = nullptr ) = 0;
-
-enum Call {
- SETEXPRESSION = ::android::hardware::IBinder::FIRST_CALL_TRANSACTION + 0,
-
-
-};
-}; // class IExpression
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_android_hardware_tests_I_Expression_H_
diff --git a/tests/canonical/INfc.h b/tests/canonical/INfc.h
deleted file mode 100644
index eefdab3..0000000
--- a/tests/canonical/INfc.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/ITemplate.h
-#ifndef HIDL_GENERATED_android_hardware_nfc_I_Nfc_H_
-#define HIDL_GENERATED_android_hardware_nfc_I_Nfc_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <hwbinder/Status.h>
-#include <cstdint>
-#include <utils/StrongPointer.h>
-#include <INfcClientCallback.h>
-
-namespace android {
-namespace hardware {
-namespace nfc {
-
-
-template<typename T>
-using hidl_ref = int;
-
-#ifndef HIDL_TYPES
-#define HIDL_TYPES
-template<typename T>
-struct hidl_vec {
- T *buffer;
- size_t count;
-};
-struct hidl_string {
- char *buffer;
- ptrdiff_t length;
-};
-#endif // HIDL_TYPES
-
-class INfc : public ::android::hardware::IInterface {
-public:
-
-DECLARE_HWBINDER_META_INTERFACE(Nfc);
-
- enum class nfc_event_t : uint32_t { HAL_NFC_OPEN_CPLT_EVT = 0, HAL_NFC_CLOSE_CPLT_EVT = 1, HAL_NFC_POST_INIT_CPLT_EVT = 2, HAL_NFC_PRE_DISCOVER_CPLT_EVT = 3, HAL_NFC_REQUEST_CONTROL_EVT = 4, HAL_NFC_RELEASE_CONTROL_EVT = 5, HAL_NFC_ERROR_EVT = 6 };
- const char* GetNameOf(nfc_event_t f) {
- static const char* names[] = { "HAL_NFC_OPEN_CPLT_EVT" , "HAL_NFC_CLOSE_CPLT_EVT" , "HAL_NFC_POST_INIT_CPLT_EVT" , "HAL_NFC_PRE_DISCOVER_CPLT_EVT" , "HAL_NFC_REQUEST_CONTROL_EVT" , "HAL_NFC_RELEASE_CONTROL_EVT" , "HAL_NFC_ERROR_EVT" };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
- enum class nfc_status_t : uint32_t { HAL_NFC_STATUS_OK = 0, HAL_NFC_STATUS_FAILED = 1, HAL_NFC_STATUS_ERR_TRANSPORT = 2, HAL_NFC_STATUS_ERR_CMD_TIMEOUT = 3, HAL_NFC_STATUS_REFUSED = 4 };
- const char* GetNameOf(nfc_status_t f) {
- static const char* names[] = { "HAL_NFC_STATUS_OK" , "HAL_NFC_STATUS_FAILED" , "HAL_NFC_STATUS_ERR_TRANSPORT" , "HAL_NFC_STATUS_ERR_CMD_TIMEOUT" , "HAL_NFC_STATUS_REFUSED" };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
-typedef struct {
-hidl_vec<uint8_t> data ;
-
-} nfc_data_t;
-
-
- using open_cb = std::function<void(int32_t retval)>;
- using write_cb = std::function<void(int32_t retval)>;
- using core_initialized_cb = std::function<void(int32_t retval)>;
- using pre_discover_cb = std::function<void(int32_t retval)>;
- using close_cb = std::function<void(int32_t retval)>;
- using control_granted_cb = std::function<void(int32_t retval)>;
- using power_cycle_cb = std::function<void(int32_t retval)>;
-
-
- virtual ::android::hardware::Status open(sp<INfcClientCallback> clientCallback , open_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status write(const INfc::nfc_data_t &data , write_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status core_initialized(const hidl_vec<uint8_t> &data , core_initialized_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status pre_discover(pre_discover_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status close(close_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status control_granted(control_granted_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status power_cycle(power_cycle_cb _cb = nullptr ) = 0;
-
-enum Call {
- OPEN = ::android::hardware::IBinder::FIRST_CALL_TRANSACTION + 0,
-
- WRITE, CORE_INITIALIZED, PRE_DISCOVER, CLOSE, CONTROL_GRANTED, POWER_CYCLE,
-};
-}; // class INfc
-
-} // namespace nfc
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_android_hardware_nfc_I_Nfc_H_
diff --git a/tests/canonical/ITestService.h b/tests/canonical/ITestService.h
deleted file mode 100644
index 6b82baa..0000000
--- a/tests/canonical/ITestService.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/ITemplate.h
-#ifndef HIDL_GENERATED_android_hardware_tests_I_TestService_H_
-#define HIDL_GENERATED_android_hardware_tests_I_TestService_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <hwbinder/Status.h>
-#include <cstdint>
-#include <utils/StrongPointer.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-template<typename T>
-using hidl_ref = int;
-
-#ifndef HIDL_TYPES
-#define HIDL_TYPES
-template<typename T>
-struct hidl_vec {
- T *buffer;
- size_t count;
-};
-struct hidl_string {
- char *buffer;
- ptrdiff_t length;
-};
-#endif // HIDL_TYPES
-
-class ITestService : public ::android::hardware::IInterface {
-public:
-
-DECLARE_HWBINDER_META_INTERFACE(TestService);
-
-typedef struct {
-uint32_t int1;
-uint32_t int2;
-
-} simple_t;
-
-typedef struct {
-uint8_t buffer[4096] ;
-
-} lots_of_data;
-
-
- using echoInteger_cb = std::function<void(int32_t ret)>;
- using shareBufferWithRef_cb = std::function<void(int32_t ret)>;
-
-
- virtual ::android::hardware::Status echoInteger(int32_t echo_me, const ITestService::simple_t &my_struct , echoInteger_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status shareBufferWithRef(hidl_ref<lots_of_data> buffer, shareBufferWithRef_cb _cb = nullptr ) = 0;
-
-enum Call {
- ECHOINTEGER = ::android::hardware::IBinder::FIRST_CALL_TRANSACTION + 0,
-
- SHAREBUFFERWITHREF,
-};
-}; // class ITestService
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_android_hardware_tests_I_TestService_H_
diff --git a/tests/canonical/ITypes.h b/tests/canonical/ITypes.h
deleted file mode 100644
index 08a8017..0000000
--- a/tests/canonical/ITypes.h
+++ /dev/null
@@ -1,209 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/ITemplate.h
-#ifndef HIDL_GENERATED_android_hardware_tests_I_Types_H_
-#define HIDL_GENERATED_android_hardware_tests_I_Types_H_
-
-#include <hwbinder/IBinder.h>
-#include <hwbinder/IInterface.h>
-#include <hwbinder/Status.h>
-#include <cstdint>
-#include <utils/StrongPointer.h>
-#include <ISmallTest.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-template<typename T>
-using hidl_ref = int;
-
-#ifndef HIDL_TYPES
-#define HIDL_TYPES
-template<typename T>
-struct hidl_vec {
- T *buffer;
- size_t count;
-};
-struct hidl_string {
- char *buffer;
- ptrdiff_t length;
-};
-#endif // HIDL_TYPES
-
-class ITypes : public ::android::hardware::IInterface {
-public:
-
-DECLARE_HWBINDER_META_INTERFACE(Types);
-
-typedef struct {
-uint32_t int1;
-uint32_t int2;
-
-} simple_t;
-
- enum class eu8 : uint8_t { U8F = 34, max = 255, min = 0 };
- const char* GetNameOf(eu8 f) {
- static const char* names[] = { "U8F" , "max" , "min" };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
- enum class es8 : int8_t { S8F = 104, max = 127, min = -128 };
- const char* GetNameOf(es8 f) {
- static const char* names[] = { "S8F" , "max" , "min" };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
- enum class eu16 : uint16_t { U16F = 234, max = 65535, min = 0 };
- const char* GetNameOf(eu16 f) {
- static const char* names[] = { "U16F" , "max" , "min" };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
- enum class es16 : int16_t { S16F = 334, max = 32767, min = -32768 };
- const char* GetNameOf(es16 f) {
- static const char* names[] = { "S16F" , "max" , "min" };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
- enum class eu32 : uint32_t { U32F = 434, max = 0xffff'f'fff, min = 0 };
- const char* GetNameOf(eu32 f) {
- static const char* names[] = { "U32F" , "max" , "min" };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
- enum class es32 : int32_t { S32F = 534, max = 0x7fff'f'fff, min = -2147483648 };
- const char* GetNameOf(es32 f) {
- static const char* names[] = { "S32F" , "max" , "min" };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
- enum class eu64 : uint64_t { U64F = 634, max = 0xffff'ffff'ffff'f'fffuLL, min = 0 };
- const char* GetNameOf(eu64 f) {
- static const char* names[] = { "U64F" , "max" , "min" };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
- enum class es64 : int64_t { S64F = 734, max = 9223372036854775807LL, min = -9223372036854775807LL };
- const char* GetNameOf(es64 f) {
- static const char* names[] = { "S64F" , "max" , "min" };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
- enum class ec : char { CF = 43, min = 0, max = 255 };
- const char* GetNameOf(ec f) {
- static const char* names[] = { "CF" , "min" , "max" };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
-typedef struct {
-uint8_t buffer[4096] ;
-
-} lots_of_data;
-
- enum class disc : uint32_t { US, UF, UI, UC };
- const char* GetNameOf(disc f) {
- static const char* names[] = { "US" , "UF" , "UI" , "UC" };
- //do errror checking
- return names[int(f)];
-}
- // size_t enum_limits<foo>::max() { return 1; }
-typedef struct {
-int32_t i;
-
-} s2;
-
-typedef union {
-hidl_string s;
-hidl_ref<uint8_t> fd;
-int64_t i;
-ITypes::s2
- s2m;
-
-} u1;
-
-typedef struct {
-hidl_string str1;
-
-} s1s;
-
-typedef struct {
-ITypes::disc
- dm1;
-ITypes::u1
- u1m1;
-
-} s1u;
-
-typedef struct {
-ITypes::s1s
- s1m1;
-hidl_vec<ITypes::s1s > s1v2 ;
-
-} s0;
-
-typedef struct {
-uint32_t fdIndex;
-uint32_t offset;
-uint32_t extent;
-
-} shm_t;
-
-typedef struct {
-uint32_t flags;
-ITypes::shm_t
- shm;
-
-} GrantorDescriptor;
-
-typedef struct {
-hidl_vec<ITypes::GrantorDescriptor > grantors ;
-const native_handle_t *mq_handles ;
-uint32_t quantum;
-uint32_t nQuanta;
-uint32_t flags;
-
-} MQDescriptor;
-
-
- using echoInteger_cb = std::function<void(int32_t ret)>;
- using echoEnum_cb = std::function<void(eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i)>;
- using echoScalar_cb = std::function<void(uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i)>;
- using echoStruct_cb = std::function<void(const ITypes::s0 &s )>;
- using echoInterface_cb = std::function<void(sp<ISmallTest> cb_t )>;
- using shareBufferWithRef_cb = std::function<void(int32_t ret)>;
- using getHash_cb = std::function<void(uint64_t hash)>;
- using quit_cb = std::function<void()>;
-
-
- virtual ::android::hardware::Status echoInteger(int32_t echo_me, const ITypes::simple_t &my_struct , echoInteger_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status echoEnum(eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i, echoEnum_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status echoScalar(uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i, echoScalar_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status echoStruct(const ITypes::s0 &s , echoStruct_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status echoInterface(sp<ISmallTest> cb_t , echoInterface_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status shareBufferWithRef(hidl_ref<lots_of_data> buffer, shareBufferWithRef_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status getHash(getHash_cb _cb = nullptr ) = 0;
- virtual ::android::hardware::Status quit() = 0;
-
-enum Call {
- ECHOINTEGER = ::android::hardware::IBinder::FIRST_CALL_TRANSACTION + 0,
-
- ECHOENUM, ECHOSCALAR, ECHOSTRUCT, ECHOINTERFACE, SHAREBUFFERWITHREF, GETHASH, QUIT,
-};
-}; // class ITypes
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#endif // HIDL_GENERATED_android_hardware_tests_I_Types_H_
diff --git a/tests/canonical/IanBinder.h b/tests/canonical/IanBinder.h
deleted file mode 100644
index 2cee42d..0000000
--- a/tests/canonical/IanBinder.h
+++ /dev/null
@@ -1,81 +0,0 @@
-#ifndef I_HIDL_BINDER_MappableRegion_H
-#define I_HIDL_BINDER_MappableRegion_H
-
-#include "binder/Parcel.h"
-#include "binder/Parcelable.h"
-
-namespace android {
- namespace service {
- namespace media {
- namespace rtstreams {
-
- class MappableRegion : public Parcelable {
-
- public:
- enum class MappingType : int32_t {
- UNDEFINED_MAPPING, ASHMEM_MAPPING, FILE_MAPPING
- };
-
- MappableRegion() {}
-
-
- MappableRegion(int fd, MappingType regionType, off64_t offset, size_t size) : mFd(
- fd), mRegionType(regionType), mOffset(offset), mSize(size) { }
-
- int getFd() const {
- return mFd;
- }
-
- MappingType getRegionType() const {
- return mRegionType;
- }
-
- off64_t getOffset() const {
- return mOffset;
- }
-
- size_t getSize() const {
- return mSize;
- }
-
- bool operator == (const MappableRegion& other) const {
- return (mFd == other.mFd
- && mRegionType == other.mRegionType
- && mOffset == other.mOffset
- && mSize == other.mSize);
- }
-
- bool isValid() {
- return mRegionType != MappingType::UNDEFINED_MAPPING;
- }
-
-
- virtual status_t writeToParcel(Parcel* parcel) const override {
- parcel->writeFileDescriptor(mFd, false);
- parcel->writeInt32((int32_t) mRegionType);
- parcel->writeInt64(mOffset);
- parcel->writeUint64(mSize);
- return parcel->errorCheck();
- }
-
- virtual status_t readFromParcel(const Parcel* parcel) override {
- mFd = parcel->readFileDescriptor();
- mRegionType = (MappingType) parcel->readInt32();
- mOffset = parcel->readInt64();
- mSize = parcel->readUint64();
-
- return parcel->errorCheck();
- }
-
- private:
- int mFd = -1;
- MappingType mRegionType = MappingType::UNDEFINED_MAPPING;
- off64_t mOffset;
- size_t mSize = 0;
- };
-
- }
- }
- }
-}
-#endif // I_HIDL_BINDER_MappableRegion_H
diff --git a/tests/canonical/NfcAll.cpp b/tests/canonical/NfcAll.cpp
deleted file mode 100644
index be913ce..0000000
--- a/tests/canonical/NfcAll.cpp
+++ /dev/null
@@ -1,687 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/TemplateAll.cpp
-//#include <android/hardware/nfc/INfc.h>
-//#include <android/hardware/nfc/BpNfc.h>
-#include <INfc.h>
-#include <BpNfc.h>
-#include <iostream>
-#include <stdio.h>
-using std::cout;
-using std::endl;
-
-namespace android {
-namespace hardware {
-namespace nfc {
-
-
-IMPLEMENT_HWBINDER_META_INTERFACE(Nfc, "android.hardware.nfc.INfc");
-
-} // namespace nfc
-} // namespace hardware
-} // namespace android
-
-
-//#include <android/hardware/nfc/BpNfc.h>
-#include <BpNfc.h>
-#include <binder/Parcel.h>
-
-namespace android {
-namespace hardware {
-namespace nfc {
-
-
-BpNfc::BpNfc(const ::android::sp<::android::hardware::IBinder>& _aidl_impl)
- : BpInterface<INfc>(_aidl_impl){
-}
-::android::hardware::Status BpNfc::open(sp<INfcClientCallback> clientCallback , INfc::open_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- int32_t _cb_retval;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeStrongBinder(IInterface::asBinder(clientCallback));
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(INfc::OPEN, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_retval);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_retval );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpNfc::write(const INfc::nfc_data_t& data , INfc::write_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- int32_t _cb_retval;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- {
- size_t parent_handle;
- _aidl_ret_status = _aidl_data.writeBuffer((void *)&data, sizeof(data), &parent_handle);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // struct fixup write_
- {
- size_t child_handle;
- void *bufp = (void *)data.data.buffer;
- size_t size = sizeof(uint8_t[data.data.count]);
- size_t off = (size_t)((char *)&(data.data.buffer)-(char *)(&data));
- _aidl_ret_status = _aidl_data.writeEmbeddedBuffer(bufp,
- size,
- &child_handle,
- parent_handle,
- off /* offset_calculator */);
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // Fixup not needed for this vec uint8_t
- }
-
- }
-
- _aidl_ret_status = remote()->transact(INfc::WRITE, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_retval);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_retval );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpNfc::core_initialized(const hidl_vec<uint8_t> &data , INfc::core_initialized_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- int32_t _cb_retval;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- {
- size_t parent_handle;
-
- _aidl_ret_status = _aidl_data.writeBuffer((void *)&data, sizeof(data), &parent_handle);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- {
- size_t child_handle;
- void *bufp = (void *)data.buffer;
- size_t size = sizeof(uint8_t[data.count]);
- size_t off = (size_t)((char *)&(data.buffer)-(char *)(&data));
- _aidl_ret_status = _aidl_data.writeEmbeddedBuffer(bufp,
- size,
- &child_handle,
- parent_handle,
- off /* offset_calculator */);
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // Fixup not needed for this vec uint8_t
- }
-
- }
-
- _aidl_ret_status = remote()->transact(INfc::CORE_INITIALIZED, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_retval);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_retval );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpNfc::pre_discover(INfc::pre_discover_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- int32_t _cb_retval;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(INfc::PRE_DISCOVER, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_retval);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_retval );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpNfc::close(INfc::close_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- int32_t _cb_retval;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(INfc::CLOSE, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_retval);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_retval );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpNfc::control_granted(INfc::control_granted_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- int32_t _cb_retval;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(INfc::CONTROL_GRANTED, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_retval);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_retval );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpNfc::power_cycle(INfc::power_cycle_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- int32_t _cb_retval;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(INfc::POWER_CYCLE, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_retval);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_retval );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-
-} // namespace nfc
-} // namespace hardware
-} // namespace android
-
-
-//
-//#include <android/hardware/nfc/INfc.h>
-//#include <android/hardware/nfc/BpNfc.h>
-#include <INfc.h>
-#include <BpNfc.h>
-
-
-#include <iostream>
-//#include <android/hardware/nfc/BnNfc.h>
-#include <BnNfc.h>
-#include <binder/Parcel.h>
-
-namespace android {
-namespace hardware {
-namespace nfc {
-
-
-::android::status_t BnNfc::onTransact(uint32_t _aidl_code, const ::android::hardware::Parcel& _aidl_data, ::android::hardware::Parcel* _aidl_reply, uint32_t _aidl_flags, TransactCallback _cb) {
- ::android::status_t _aidl_ret_status = ::android::OK;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- switch (_aidl_code) {
- case Call::OPEN:
- {
- sp<INfcClientCallback> clientCallback ;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readStrongBinder(&clientCallback);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- open(clientCallback , [&](auto retval ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(retval);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::WRITE:
- {
- INfc::nfc_data_t *data ;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- {
- size_t parent_handle;
- data = (INfc::nfc_data_t *)_aidl_data.readBuffer(&parent_handle);
- if ((data) == nullptr) {
- break;
- }
- // struct fixup read_
- {
- size_t child_handle;
- _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(&child_handle, parent_handle,
- (size_t)((char *)&((*data).data.buffer)-(char *)(&(*data))));
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (_aidl_ret_pointer == nullptr) {
- break;
- }
- // Fixup not needed for this vec uint8_t
- }
-
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- write(*data , [&](auto retval ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(retval);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::CORE_INITIALIZED:
- {
- hidl_vec<uint8_t> *data ;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- {
- size_t parent_handle;
-
- data = (hidl_vec<uint8_t> *)_aidl_data.readBuffer(&parent_handle);
- if ((data) == nullptr) {
- break;
- }
- {
- size_t child_handle;
- _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(&child_handle, parent_handle,
- (size_t)((char *)&((*data).buffer)-(char *)(&(*data))));
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (_aidl_ret_pointer == nullptr) {
- break;
- }
- // Fixup not needed for this vec uint8_t
- }
-
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- core_initialized(*data , [&](auto retval ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(retval);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::PRE_DISCOVER:
- {
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- pre_discover( [&](auto retval ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(retval);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::CLOSE:
- {
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- close( [&](auto retval ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(retval);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::CONTROL_GRANTED:
- {
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- control_granted( [&](auto retval ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(retval);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::POWER_CYCLE:
- {
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- power_cycle( [&](auto retval ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(retval);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
-
- default:
- {
- _aidl_ret_status = ::android::hardware::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
- }
- break;
- }
- if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
- _aidl_ret_status = ::android::hardware::Status::fromExceptionCode(::android::hardware::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
- }
- return _aidl_ret_status;
-}
-
-} // namespace nfc
-} // namespace hardware
-} // namespace android
-
diff --git a/tests/canonical/TestServiceProxy.cpp b/tests/canonical/TestServiceProxy.cpp
deleted file mode 100644
index 303abe4..0000000
--- a/tests/canonical/TestServiceProxy.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/TemplateProxy.cpp
-#include <android/hardware/tests/ITestService.h>
-#include <android/hardware/tests/BpTestService.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-IMPLEMENT_HWBINDER_META_INTERFACE(TestService, "android.hardware.tests.ITestService");
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#include <android/hardware/tests/BpTestService.h>
-#include <binder/Parcel.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-BpTestService::BpTestService(const ::android::sp<::android::hardware::IBinder>& _aidl_impl)
- : BpInterface<ITestService>(_aidl_impl){
-}
-::android::hardware::Status BpTestService::echoInteger(int32_t echo_me, const ITestService::simple_t* my_struct , ITestService::echoInteger_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- int32_t _cb_ret;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeInt32((int32_t)echo_me);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeBuffer((void *)my_struct, sizeof(my_struct), nullptr);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(ITestService::ECHOINTEGER, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_ret);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_ret );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpTestService::shareBufferWithRef(hidl_ref<lots_of_data> buffer, ITestService::shareBufferWithRef_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- int32_t _cb_ret;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeFileDescriptor(buffer);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(ITestService::SHAREBUFFERWITHREF, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_ret);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_ret );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
diff --git a/tests/canonical/TestServiceStubs.cpp b/tests/canonical/TestServiceStubs.cpp
deleted file mode 100644
index 86c11c2..0000000
--- a/tests/canonical/TestServiceStubs.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/TemplateStubs.cpp
-#include <android/hardware/tests/ITestService.h>
-#include <android/hardware/tests/BpTestService.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-IMPLEMENT_HWBINDER_META_INTERFACE(TestService, "android.hardware.tests.ITestService");
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-#include <iostream>
-#include <android/hardware/tests/BnTestService.h>
-#include <binder/Parcel.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-::android::status_t BnTestService::onTransact(uint32_t _aidl_code, const ::android::hardware::Parcel& _aidl_data, ::android::hardware::Parcel* _aidl_reply, uint32_t _aidl_flags, TransactCallback _cb) {
- ::android::status_t _aidl_ret_status = ::android::OK;
- switch (_aidl_code) {
- case Call::ECHOINTEGER:
- {
-int32_t echo_me;
- ITestService::simple_t *my_struct ;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readInt32(&echo_me);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- my_struct = (ITestService::simple_t *)_aidl_data.readBuffer();
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- echoInteger(echo_me , *my_struct , [&](auto ret ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(ret);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::SHAREBUFFERWITHREF:
- {
-hidl_ref<lots_of_data> buffer;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- buffer = _aidl_data.readFileDescriptor();
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- shareBufferWithRef(buffer , [&](auto ret ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(ret);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
-
- default:
- {
- _aidl_ret_status = ::android::hardware::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
- }
- break;
- }
- if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
- _aidl_ret_status = ::android::hardware::Status::fromExceptionCode(::android::hardware::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
- }
- return _aidl_ret_status;
-}
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
diff --git a/tests/canonical/TypesAll.cpp b/tests/canonical/TypesAll.cpp
deleted file mode 100644
index c77c98b..0000000
--- a/tests/canonical/TypesAll.cpp
+++ /dev/null
@@ -1,1141 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/TemplateAll.cpp
-//#include <android/hardware/tests/ITypes.h>
-//#include <android/hardware/tests/BpTypes.h>
-#include <ITypes.h>
-#include <BpTypes.h>
-#include <iostream>
-#include <stdio.h>
-using std::cout;
-using std::endl;
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-IMPLEMENT_HWBINDER_META_INTERFACE(Types, "android.hardware.tests.ITypes");
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-//#include <android/hardware/tests/BpTypes.h>
-#include <BpTypes.h>
-#include <binder/Parcel.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-BpTypes::BpTypes(const ::android::sp<::android::hardware::IBinder>& _aidl_impl)
- : BpInterface<ITypes>(_aidl_impl){
-}
-::android::hardware::Status BpTypes::echoInteger(int32_t echo_me, const ITypes::simple_t& my_struct , ITypes::echoInteger_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- int32_t _cb_ret;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeInt32((int32_t)echo_me);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- {
- size_t parent_handle;
- _aidl_ret_status = _aidl_data.writeBuffer((void *)&my_struct, sizeof(my_struct), &parent_handle);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // struct fixup write_
-
-//field int1 doesn't need fixup
-
-//field int2 doesn't need fixup
-
- }
-
- _aidl_ret_status = remote()->transact(ITypes::ECHOINTEGER, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_ret);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_ret );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpTypes::echoEnum(eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i, ITypes::echoEnum_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- ITypes::eu8
- _cb_a;
-ITypes::es8
- _cb_b;
-ITypes::eu16
- _cb_c;
-ITypes::es16
- _cb_d;
-ITypes::eu32
- _cb_e;
-ITypes::es32
- _cb_f;
-ITypes::eu64
- _cb_g;
-ITypes::es64
- _cb_h;
-ITypes::ec
- _cb_i;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeByte((int8_t)a);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeByte((int8_t)b);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeChar((char16_t)c);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeChar((char16_t)d);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeUint32((uint32_t)e);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeInt32((int32_t)f);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeUint64((uint64_t)g);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeInt64((int64_t)h);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeByte((int8_t)i);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(ITypes::ECHOENUM, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readByte((int8_t *)&_cb_a);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readByte((int8_t *)&_cb_b);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readChar((char16_t *)&_cb_c);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readChar((char16_t *)&_cb_d);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readUint32((uint32_t *)&_cb_e);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readInt32((int32_t *)&_cb_f);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readUint64((uint64_t *)&_cb_g);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readInt64((int64_t *)&_cb_h);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readByte((int8_t *)&_cb_i);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_a , _cb_b , _cb_c , _cb_d , _cb_e , _cb_f , _cb_g , _cb_h , _cb_i );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpTypes::echoScalar(uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i, ITypes::echoScalar_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- uint8_t _cb_a;
-int8_t _cb_b;
-uint16_t _cb_c;
-int16_t _cb_d;
-uint32_t _cb_e;
-int32_t _cb_f;
-uint64_t _cb_g;
-int64_t _cb_h;
-char _cb_i;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeByte((int8_t)a);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeByte((int8_t)b);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeChar((char16_t)c);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeChar((char16_t)d);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeUint32((uint32_t)e);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeInt32((int32_t)f);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeUint64((uint64_t)g);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeInt64((int64_t)h);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeByte((int8_t)i);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(ITypes::ECHOSCALAR, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readByte((int8_t*)&_cb_a);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readByte(&_cb_b);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readChar((char16_t*)&_cb_c);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readChar((char16_t*)&_cb_d);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readUint32(&_cb_e);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_f);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readUint64(&_cb_g);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readInt64(&_cb_h);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_reply.readByte((int8_t*)&_cb_i);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_a , _cb_b , _cb_c , _cb_d , _cb_e , _cb_f , _cb_g , _cb_h , _cb_i );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpTypes::echoStruct(const ITypes::s0& s , ITypes::echoStruct_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- ITypes::s0 *_cb_s ;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- {
- size_t parent_handle;
- _aidl_ret_status = _aidl_data.writeBuffer((void *)&s, sizeof(s), &parent_handle);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- // struct fixup write_
- // struct fixup write_
- _aidl_ret_status = _aidl_data.writeEmbeddedBuffer((void *)s.s1m1.str1.buffer,
- (s.s1m1.str1.length < 0 ? strlen(s.s1m1.str1.buffer)+1 : s.s1m1.str1.length),
- nullptr, parent_handle,
- (size_t)((char *)&(s.s1m1.str1.buffer)-(char *)(&s)));
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- {
- size_t child_handle;
- void *bufp = (void *)s.s1v2.buffer;
- size_t size = sizeof(ITypes::s1s
-[s.s1v2.count]);
- size_t off = (size_t)((char *)&(s.s1v2.buffer)-(char *)(&s));
- _aidl_ret_status = _aidl_data.writeEmbeddedBuffer(bufp,
- size,
- &child_handle,
- parent_handle,
- off /* offset_calculator */);
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- for (size_t i1 = 0; i1 < s.s1v2.count; i1++) {
- /* fixup_write_vec */
- // struct fixup write_
- _aidl_ret_status = _aidl_data.writeEmbeddedBuffer((void *)s.s1v2.buffer[i1].str1.buffer,
- (s.s1v2.buffer[i1].str1.length < 0 ? strlen(s.s1v2.buffer[i1].str1.buffer)+1 : s.s1v2.buffer[i1].str1.length),
- nullptr, parent_handle,
- (size_t)((char *)&(s.s1v2.buffer[i1].str1.buffer)-(char *)(s.s1v2.buffer)));
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- }
-
- }
-
- }
-
- _aidl_ret_status = remote()->transact(ITypes::ECHOSTRUCT, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- {
- size_t parent_handle;
- _cb_s = (ITypes::s0 *)_aidl_reply.readBuffer(&parent_handle);
- if ((_cb_s) == nullptr) {
- goto _aidl_error;
- }
- // struct fixup read_ret_
- // struct fixup read_ret_
- _aidl_ret_pointer = _aidl_reply.readEmbeddedBuffer(nullptr, parent_handle,
- (size_t)((char *)&((*_cb_s).s1m1.str1.buffer)-(char *)(&(*_cb_s))));
- if (_aidl_ret_pointer == nullptr) {
- goto _aidl_error;
- }
- {
- size_t child_handle;
- _aidl_ret_pointer = _aidl_reply.readEmbeddedBuffer(&child_handle, parent_handle,
- (size_t)((char *)&((*_cb_s).s1v2.buffer)-(char *)(&(*_cb_s))));
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (_aidl_ret_pointer == nullptr) {
- goto _aidl_error;
- }
- for (size_t i1 = 0; i1 < (*_cb_s).s1v2.count; i1++) {
- /* fixup_write_vec */
- // struct fixup read_ret_
- _aidl_ret_pointer = _aidl_reply.readEmbeddedBuffer(nullptr, parent_handle,
- (size_t)((char *)&((*_cb_s).s1v2.buffer[i1].str1.buffer)-(char *)((*_cb_s).s1v2.buffer)));
- if (_aidl_ret_pointer == nullptr) {
- goto _aidl_error;
- }
-
- }
-
- }
-
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(*_cb_s );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpTypes::echoInterface(sp<ISmallTest> cb_t , ITypes::echoInterface_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- sp<ISmallTest> _cb_cb_t ;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeStrongBinder(IInterface::asBinder(cb_t));
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(ITypes::ECHOINTERFACE, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readStrongBinder(&_cb_cb_t);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_cb_t );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpTypes::shareBufferWithRef(hidl_ref<lots_of_data> buffer, ITypes::shareBufferWithRef_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- int32_t _cb_ret;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_data.writeFileDescriptor(buffer);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(ITypes::SHAREBUFFERWITHREF, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readInt32(&_cb_ret);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_ret );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpTypes::getHash(ITypes::getHash_cb _cb ) {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- uint64_t _cb_hash;
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(ITypes::GETHASH, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
- _aidl_ret_status = _aidl_reply.readUint64(&_cb_hash);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
-
- // Invoke callback to client
- if (_cb != nullptr)
- _cb(_cb_hash );
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-::android::hardware::Status BpTypes::quit() {
- ::android::hardware::Parcel _aidl_data;
- ::android::hardware::Parcel _aidl_reply;
- ::android::status_t _aidl_ret_status = ::android::OK;
- ::android::hardware::Status _aidl_status;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
-
- _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor());
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
-
- _aidl_ret_status = remote()->transact(ITypes::QUIT, _aidl_data, &_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply);
- if (((_aidl_ret_status) != (::android::OK))) {
- goto _aidl_error;
- }
- if (!_aidl_status.isOk()) {
- return _aidl_status;
- }
-
-
-
-
-_aidl_error:
- _aidl_status.setFromStatusT(_aidl_ret_status);
- return _aidl_status;
-}
-
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
-
-//
-//#include <android/hardware/tests/ITypes.h>
-//#include <android/hardware/tests/BpTypes.h>
-#include <ITypes.h>
-#include <BpTypes.h>
-
-
-#include <iostream>
-//#include <android/hardware/tests/BnTypes.h>
-#include <BnTypes.h>
-#include <binder/Parcel.h>
-
-namespace android {
-namespace hardware {
-namespace tests {
-
-
-::android::status_t BnTypes::onTransact(uint32_t _aidl_code, const ::android::hardware::Parcel& _aidl_data, ::android::hardware::Parcel* _aidl_reply, uint32_t _aidl_flags, TransactCallback _cb) {
- ::android::status_t _aidl_ret_status = ::android::OK;
- const void *_aidl_ret_pointer; // For checking if all the nested buffers are OK
- switch (_aidl_code) {
- case Call::ECHOINTEGER:
- {
-int32_t echo_me;
- ITypes::simple_t *my_struct ;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readInt32(&echo_me);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- {
- size_t parent_handle;
- my_struct = (ITypes::simple_t *)_aidl_data.readBuffer(&parent_handle);
- if ((my_struct) == nullptr) {
- break;
- }
- // struct fixup read_
-
-//field int1 doesn't need fixup
-
-//field int2 doesn't need fixup
-
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- echoInteger(echo_me , *my_struct , [&](auto ret ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(ret);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::ECHOENUM:
- {
-ITypes::eu8
- a;
-ITypes::es8
- b;
-ITypes::eu16
- c;
-ITypes::es16
- d;
-ITypes::eu32
- e;
-ITypes::es32
- f;
-ITypes::eu64
- g;
-ITypes::es64
- h;
-ITypes::ec
- i;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readByte((int8_t *)&a);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readByte((int8_t *)&b);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readChar((char16_t *)&c);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readChar((char16_t *)&d);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readUint32((uint32_t *)&e);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readInt32((int32_t *)&f);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readUint64((uint64_t *)&g);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readInt64((int64_t *)&h);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readByte((int8_t *)&i);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- echoEnum(a , b , c , d , e , f , g , h , i , [&](auto a , auto b , auto c , auto d , auto e , auto f , auto g , auto h , auto i ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_ret_status = _aidl_reply->writeByte((int8_t)a);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
- _aidl_ret_status = _aidl_reply->writeByte((int8_t)b);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
- _aidl_ret_status = _aidl_reply->writeChar((char16_t)c);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
- _aidl_ret_status = _aidl_reply->writeChar((char16_t)d);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
- _aidl_ret_status = _aidl_reply->writeUint32((uint32_t)e);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
- _aidl_ret_status = _aidl_reply->writeInt32((int32_t)f);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
- _aidl_ret_status = _aidl_reply->writeUint64((uint64_t)g);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
- _aidl_ret_status = _aidl_reply->writeInt64((int64_t)h);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
- _aidl_ret_status = _aidl_reply->writeByte((int8_t)i);
- if (((_aidl_ret_status) != (::android::OK))) {
- return;
- }
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::ECHOSCALAR:
- {
-uint8_t a;
-int8_t b;
-uint16_t c;
-int16_t d;
-uint32_t e;
-int32_t f;
-uint64_t g;
-int64_t h;
-char i;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readByte((int8_t*)&a);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readByte(&b);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readChar((char16_t*)&c);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readChar((char16_t*)&d);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readUint32(&e);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readInt32(&f);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readUint64(&g);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readInt64(&h);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
- _aidl_ret_status = _aidl_data.readByte((int8_t*)&i);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- echoScalar(a , b , c , d , e , f , g , h , i , [&](auto a , auto b , auto c , auto d , auto e , auto f , auto g , auto h , auto i ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeByte((int8_t)a);
- _aidl_reply->writeByte(b);
- _aidl_reply->writeChar((char16_t)c);
- _aidl_reply->writeChar((char16_t)d);
- _aidl_reply->writeUint32(e);
- _aidl_reply->writeInt32(f);
- _aidl_reply->writeUint64(g);
- _aidl_reply->writeInt64(h);
- _aidl_reply->writeByte((int8_t)i);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::ECHOSTRUCT:
- {
- ITypes::s0 *s ;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- {
- size_t parent_handle;
- s = (ITypes::s0 *)_aidl_data.readBuffer(&parent_handle);
- if ((s) == nullptr) {
- break;
- }
- // struct fixup read_
- // struct fixup read_
- _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(nullptr, parent_handle,
- (size_t)((char *)&((*s).s1m1.str1.buffer)-(char *)(&(*s))));
- if (_aidl_ret_pointer == nullptr) {
- break;
- }
- {
- size_t child_handle;
- _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(&child_handle, parent_handle,
- (size_t)((char *)&((*s).s1v2.buffer)-(char *)(&(*s))));
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- if (_aidl_ret_pointer == nullptr) {
- break;
- }
- for (size_t i1 = 0; i1 < (*s).s1v2.count; i1++) {
- /* fixup_write_vec */
- // struct fixup read_
- _aidl_ret_pointer = _aidl_data.readEmbeddedBuffer(nullptr, parent_handle,
- (size_t)((char *)&((*s).s1v2.buffer[i1].str1.buffer)-(char *)((*s).s1v2.buffer)));
- if (_aidl_ret_pointer == nullptr) {
- break;
- }
-
- }
-
- }
-
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- echoStruct(*s , [&](const ITypes::s0 & s ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- {
- size_t parent_handle;
- _aidl_ret_status = _aidl_reply->writeBuffer((void *)&s, sizeof(s), &parent_handle);
- // struct fixup write_ret_
- // struct fixup write_ret_
- _aidl_ret_status = _aidl_reply->writeEmbeddedBuffer((void *)s.s1m1.str1.buffer,
- (s.s1m1.str1.length < 0 ? strlen(s.s1m1.str1.buffer)+1 : s.s1m1.str1.length),
- nullptr, parent_handle,
- (size_t)((char *)&(s.s1m1.str1.buffer)-(char *)(&s)));
- {
- size_t child_handle;
- void *bufp = (void *)s.s1v2.buffer;
- size_t size = sizeof(ITypes::s1s
-[s.s1v2.count]);
- size_t off = (size_t)((char *)&(s.s1v2.buffer)-(char *)(&s));
- _aidl_ret_status = _aidl_reply->writeEmbeddedBuffer(bufp,
- size,
- &child_handle,
- parent_handle,
- off /* offset_calculator */);
- // Redefining a variable inside braces works like a static stack.
- size_t parent_handle = child_handle;
- for (size_t i1 = 0; i1 < s.s1v2.count; i1++) {
- /* fixup_write_vec */
- // struct fixup write_ret_
- _aidl_ret_status = _aidl_reply->writeEmbeddedBuffer((void *)s.s1v2.buffer[i1].str1.buffer,
- (s.s1v2.buffer[i1].str1.length < 0 ? strlen(s.s1v2.buffer[i1].str1.buffer)+1 : s.s1v2.buffer[i1].str1.length),
- nullptr, parent_handle,
- (size_t)((char *)&(s.s1v2.buffer[i1].str1.buffer)-(char *)(s.s1v2.buffer)));
-
- }
-
- }
-
- }
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::ECHOINTERFACE:
- {
- sp<ISmallTest> cb_t ;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- _aidl_ret_status = _aidl_data.readStrongBinder(&cb_t);
- if (((_aidl_ret_status) != (::android::OK))) {
- break;
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- echoInterface(cb_t , [&](auto cb_t ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_ret_status = _aidl_reply->writeStrongBinder(IInterface::asBinder(cb_t));
- if (((_aidl_ret_status) != (::android::OK))) {
- // TODO(maco): Log/report all errors. See b/30476330
- return;
- }
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::SHAREBUFFERWITHREF:
- {
-hidl_ref<lots_of_data> buffer;
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
- buffer = _aidl_data.readFileDescriptor();
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- shareBufferWithRef(buffer , [&](auto ret ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeInt32(ret);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::GETHASH:
- {
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- getHash( [&](auto hash ) {
- callback_called = true;
- // Write "OK" to parcel
- ::android::hardware::Status::ok().writeToParcel(_aidl_reply);
- // Serialize
- _aidl_reply->writeUint64(hash);
-
- // Callback
- _cb(*_aidl_reply);
- }
-));
-
-//
-
- if (!callback_called) {
- // Callback not called, the call must have returned an error
- // TODO set something like ERR_NO_CALLBACK if the call retuned OK
- _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
- }
-
- break;
- }
- case Call::QUIT:
- {
-
- bool callback_called;
- if (!(_aidl_data.checkInterface(this))) {
- _aidl_ret_status = ::android::BAD_TYPE;
- break;
- }
-
- // Make the call into the server
- ::android::hardware::Status _aidl_status(
- quit());
-
-//
-
-
- break;
- }
-
- default:
- {
- _aidl_ret_status = ::android::hardware::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
- }
- break;
- }
- if (_aidl_ret_status == ::android::UNEXPECTED_NULL) {
- _aidl_ret_status = ::android::hardware::Status::fromExceptionCode(::android::hardware::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply);
- }
- return _aidl_ret_status;
-}
-
-} // namespace tests
-} // namespace hardware
-} // namespace android
-
diff --git a/tests/canonical/vts_gps.vts b/tests/canonical/vts_gps.vts
deleted file mode 100644
index bdae2c0..0000000
--- a/tests/canonical/vts_gps.vts
+++ /dev/null
@@ -1,64 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/Template.vts
-component_class: HAL_HIDL
-component_type: GPS
-
-component_type_version: 1.0
-component_name: "ISampleGpsHalServiceWithVtsCallFlowAnnotation"
-
-
-
-api: {
- name: "start"
- return_type_hidl: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
-
-
- callflow: {
- entry: true
-
-
- next: "stop"
-
- }
-
-}
-api: {
- name: "stop"
- return_type_hidl: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
-
-
- callflow: {
-
-
- next: "cleanup"
-
- }
-
-}
-api: {
- name: "cleanup"
-
-
- callflow: {
-
- exit: true
-
- next: "cleanup"
-
- }
-
-}
-
-
-
-
diff --git a/tests/canonical/vts_lights.vts b/tests/canonical/vts_lights.vts
deleted file mode 100644
index ac7af02..0000000
--- a/tests/canonical/vts_lights.vts
+++ /dev/null
@@ -1,41 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/Template.vts
-component_class: HAL_HIDL
-component_type: LIGHT
-
-component_type_version: 1.0
-component_name: "ISampleLightsHalServiceWithVtsAnnotation"
-
-
-
-attribute: {
- name: "light_state_t"
- type: TYPE_STRUCT
- struct_value: {
- name: "s"
- type: TYPE_STRING
-
- name: "bar"
- type: TYPE_HANDLE
-
-
- }
-}
-api: {
- name: "setLight"
- return_type_hidl: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_STRUCT
- predefined_type: "light_state_t"
- }
-
-
-
-}
-
-
-
-
diff --git a/tests/canonical/vts_lights_hal.vts b/tests/canonical/vts_lights_hal.vts
deleted file mode 100644
index 223a505..0000000
--- a/tests/canonical/vts_lights_hal.vts
+++ /dev/null
@@ -1,154 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/Template.vts
-component_class: HAL_HIDL
-component_type: LIGHT
-
-component_type_version: 1.0
-component_name: "ISampleLightsHalServiceWithVtsAnnotation"
-
-
-
-attribute: {
- name: "light_state_t"
- type: TYPE_STRUCT
- struct_value: {
- name: "color"
- type: TYPE_SCALAR
- scalar_type: "uint32_t"
- name: "flashMode"
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- name: "flashOnMs"
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- name: "flashOffMs"
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- name: "brightnessMode"
- type: TYPE_SCALAR
- scalar_type: "int32_t"
-
- }
-}
-api: {
- name: "setLight"
- return_type_hidl: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_STRUCT
- predefined_type: "light_state_t"
- }
-
-
-
-}
-
-
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "int32_t"
- primitive_name: "LIGHT_FLASH_NONE"
- primitive_value: {
- int32_t: 0
- }
-}
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "int32_t"
- primitive_name: "LIGHT_FLASH_TIMED"
- primitive_value: {
- int32_t: 1
- }
-}
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "int32_t"
- primitive_name: "LIGHT_FLASH_HARDWARE"
- primitive_value: {
- int32_t: 2
- }
-}
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "int32_t"
- primitive_name: "BRIGHTNESS_MODE_USER"
- primitive_value: {
- int32_t: 0
- }
-}
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "int32_t"
- primitive_name: "BRIGHTNESS_MODE_SENSOR"
- primitive_value: {
- int32_t: 1
- }
-}
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "bytes"
- primitive_name: "LIGHT_ID_BACKLIGHT"
- primitive_value: {
- bytes: "backlight"
- }
-}
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "bytes"
- primitive_name: "LIGHT_ID_KEYBOARD"
- primitive_value: {
- bytes: "keyboard"
- }
-}
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "bytes"
- primitive_name: "LIGHT_ID_BUTTONS"
- primitive_value: {
- bytes: "buttons"
- }
-}
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "bytes"
- primitive_name: "LIGHT_ID_BATTERY"
- primitive_value: {
- bytes: "battery"
- }
-}
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "bytes"
- primitive_name: "LIGHT_ID_NOTIFICATIONS"
- primitive_value: {
- bytes: "notifications"
- }
-}
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "bytes"
- primitive_name: "LIGHT_ID_ATTENTION"
- primitive_value: {
- bytes: "attention"
- }
-}
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "bytes"
- primitive_name: "LIGHT_ID_BLUETOOTH"
- primitive_value: {
- bytes: "bluetooth"
- }
-}
-aggregate_type_name: "const"
-aggregate_type_definition: {
- primitive_type: "bytes"
- primitive_name: "LIGHT_ID_WIFI"
- primitive_value: {
- bytes: "wifi"
- }
-}
-
-
diff --git a/tests/canonical/vts_nfc.vts b/tests/canonical/vts_nfc.vts
deleted file mode 100644
index 19de4d6..0000000
--- a/tests/canonical/vts_nfc.vts
+++ /dev/null
@@ -1,144 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/Template.vts
-component_class: HAL_HIDL
-
-component_type_version: 1.0
-component_name: "INfc"
-
-import: "android.hardware.nfc.INfcClientCallback"
-
-
-attribute: {
- name: "nfc_event_t"
- type: TYPE_ENUM
- enum_value: {
- enumerator: "HAL_NFC_OPEN_CPLT_EVT"
- value: 0
- enumerator: "HAL_NFC_CLOSE_CPLT_EVT"
- value: 1
- enumerator: "HAL_NFC_POST_INIT_CPLT_EVT"
- value: 2
- enumerator: "HAL_NFC_PRE_DISCOVER_CPLT_EVT"
- value: 3
- enumerator: "HAL_NFC_REQUEST_CONTROL_EVT"
- value: 4
- enumerator: "HAL_NFC_RELEASE_CONTROL_EVT"
- value: 5
- enumerator: "HAL_NFC_ERROR_EVT"
- value: 6
-
- }
-}
-attribute: {
- name: "nfc_status_t"
- type: TYPE_ENUM
- enum_value: {
- enumerator: "HAL_NFC_STATUS_OK"
- value: 0
- enumerator: "HAL_NFC_STATUS_FAILED"
- value: 1
- enumerator: "HAL_NFC_STATUS_ERR_TRANSPORT"
- value: 2
- enumerator: "HAL_NFC_STATUS_ERR_CMD_TIMEOUT"
- value: 3
- enumerator: "HAL_NFC_STATUS_REFUSED"
- value: 4
-
- }
-}
-attribute: {
- name: "nfc_data_t"
- type: TYPE_STRUCT
- struct_value: {
- name: "data"
- type: TYPE_VECTOR
- vector_value: { scalar_type: "uint8_t" }
-
- }
-}
-api: {
- name: "open"
- return_type_hidl: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_HIDL_CALLBACK
- predefined_type: "INfcClientCallback"
- }
-
-
-
-}
-api: {
- name: "write"
- return_type_hidl: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_STRUCT
- predefined_type: "nfc_data_t"
- }
-
-
-
-}
-api: {
- name: "core_initialized"
- return_type_hidl: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_VECTOR
- vector_value: { scalar_type: "uint8_t" }
- }
-
-
-
-}
-api: {
- name: "pre_discover"
- return_type_hidl: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
-
-
-
-}
-api: {
- name: "close"
- return_type_hidl: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
-
-
-
-}
-api: {
- name: "control_granted"
- return_type_hidl: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
-
-
-
-}
-api: {
- name: "power_cycle"
- return_type_hidl: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
-
-
-
-}
-
-
-
-
diff --git a/tests/canonical/vts_nfc_client_callback.vts b/tests/canonical/vts_nfc_client_callback.vts
deleted file mode 100644
index c9f7d87..0000000
--- a/tests/canonical/vts_nfc_client_callback.vts
+++ /dev/null
@@ -1,85 +0,0 @@
-// AUTO_GENERATED FILE - DO NOT EDIT
-// see system/tools/hidl/templates/Template.vts
-component_class: HAL_HIDL
-
-component_type_version: 1.0
-component_name: "INfcClientCallback"
-
-
-
-attribute: {
- name: "nfc_data_t"
- type: TYPE_STRUCT
- struct_value: {
- name: "data"
- type: TYPE_VECTOR
- vector_value: { scalar_type: "uint8_t" }
-
- }
-}
-attribute: {
- name: "nfc_event_t"
- type: TYPE_ENUM
- enum_value: {
- enumerator: "HAL_NFC_OPEN_CPLT_EVT"
- value: 0
- enumerator: "HAL_NFC_CLOSE_CPLT_EVT"
- value: 1
- enumerator: "HAL_NFC_POST_INIT_CPLT_EVT"
- value: 2
- enumerator: "HAL_NFC_PRE_DISCOVER_CPLT_EVT"
- value: 3
- enumerator: "HAL_NFC_REQUEST_CONTROL_EVT"
- value: 4
- enumerator: "HAL_NFC_RELEASE_CONTROL_EVT"
- value: 5
- enumerator: "HAL_NFC_ERROR_EVT"
- value: 6
-
- }
-}
-attribute: {
- name: "nfc_status_t"
- type: TYPE_ENUM
- enum_value: {
- enumerator: "HAL_NFC_STATUS_OK"
- value: 0
- enumerator: "HAL_NFC_STATUS_FAILED"
- value: 1
- enumerator: "HAL_NFC_STATUS_ERR_TRANSPORT"
- value: 2
- enumerator: "HAL_NFC_STATUS_ERR_CMD_TIMEOUT"
- value: 3
- enumerator: "HAL_NFC_STATUS_REFUSED"
- value: 4
-
- }
-}
-api: {
- name: "sendEvent"
- arg: {
- type: TYPE_ENUM
- predefined_type: "nfc_event_t"
- }
- arg: {
- type: TYPE_ENUM
- predefined_type: "nfc_status_t"
- }
-
-
-
-}
-api: {
- name: "sendData"
- arg: {
- type: TYPE_STRUCT
- predefined_type: "nfc_data_t"
- }
-
-
-
-}
-
-
-
-
diff --git a/tests/testAll.py b/tests/testAll.py
deleted file mode 100644
index 8c7d933..0000000
--- a/tests/testAll.py
+++ /dev/null
@@ -1,141 +0,0 @@
-"""Integration test runner for hidl-cpp.
-
-Runs hidl-cpp on a bunch of files and tests the result.
-Exit code is 0 iff all tests pass.
-
-Usage (intended to be called from Android.mk):
-
-testAll.py path_to_hidl_cpp output_dir test_dir
-
-The output files will all go in output_dir
-The input files come from test_dir
-Some output files are compared with files of the same
- name in test_dir/canonical
-
-All tests are called from Tester::RunTests(). Available
- checks include the value of the return code,
- any text printed, and whether an output and canonical file
- are equal.
-"""
-
-import subprocess
-import sys
-
-
-class Tester(object):
- """The entirety of the program."""
-
- def __init__(self, hidl_cpp_path, test_dir, output_dir):
- """Stashes the paths the program will need."""
- self.hidl_cpp_path = hidl_cpp_path
- self.output_dir = output_dir + "/"
- self.test_dir = test_dir + "/"
- self.errors = 0 # Number of failed tests
- # Many of these are for convenience in writing small
- # function calls in the RunTests() function.
- self.last_stdout = "" # Return string from last command
- self.last_stderr = "" # Return string from last command
- self.last_return = 0 # Exit code from last command
- self.last_out_path = "" # Last output file generated
- self.last_out_text = "" # Last output file's text
- self.last_hidl_name = "" # Last .hal file processed
- self.last_out_type = "" # last file-type parameter
-
- def RunTests(self):
- """Runs all the tests."""
- self.ProcessFile("IBadType.hal", "foo", "bn_h")
- self.Test(self.last_return != 0)
- self.Test(Has(self.last_stdout, "int48_t"))
- self.ProcessFile("ITest.hal", "foo", "bn_h")
- self.Test(self.last_return == 0)
- self.TestOutput("vts_gps.hal", "vts_gps.vts", "vts")
- # , True) # echoes stdout from hidl-gen, for debugging
- self.TestOutput("vts_lights.hal", "vts_lights.vts", "vts")
- self.TestOutput("vts_lights_hal.hal", "vts_lights_hal.vts", "vts")
- self.TestOutput("ITestService.hal", "ITestService.h", "i_h")
- self.TestOutput("ITestService.hal", "BnTestService.h", "bn_h")
- self.TestOutput("ITestService.hal", "BpTestService.h", "bp_h")
- self.TestOutput("ITestService.hal", "TestServiceProxy.cpp", "proxy_cpp")
- self.TestOutput("ITestService.hal", "TestServiceStubs.cpp", "stubs_cpp")
- self.TestOutput("IEverything.hal", "Everything.json", "json")
- self.TestOutput("IExpression.hal", "Expression_all.cpp", "all_cpp")
- self.TestOutput("IExpression.hal", "Expression_i.h", "i_h")
- self.TestOutput("INfc.hal", "NfcAll.cpp", "all_cpp")
- self.TestOutput("INfc.hal", "INfc.h", "i_h")
- self.TestOutput("INfc.hal", "BnNfc.h", "bn_h")
- self.TestOutput("INfc.hal", "BpNfc.h", "bp_h")
- self.TestOutput("INfc.hal", "vts_nfc.vts", "vts")
- self.TestOutput("INfcClientCallback.hal", "vts_nfc_client_callback.vts", "vts")
- self.TestOutput("ITypes.hal", "TypesAll.cpp", "all_cpp")
- self.TestOutput("ITypes.hal", "ITypes.h", "i_h")
- self.TestOutput("ITypes.hal", "BnTypes.h", "bn_h")
- self.TestOutput("ITypes.hal", "BpTypes.h", "bp_h")
-
- def RunCommand(self, command):
- """Runs a unix command and stashes the result."""
-# print command
- proc = subprocess.Popen(command,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- self.last_stdout, self.last_stderr = proc.communicate()
- self.last_return = proc.returncode
-# print "Ret from RunC is %d" % self.last_return
-
- def TestOutput(self, hidl_name, out_name, out_type, print_out = None):
- self.ProcessFile(hidl_name, out_name, out_type, print_out)
- if self.last_return != 0:
- self.Error("hidl-gen error on file %s (type %s): %s" % (
- hidl_name, out_type, self.last_stdout + self.last_stderr))
- return
- canonical_path = self.test_dir + "canonical/" + out_name
- with open(canonical_path) as canonical:
- good_text = canonical.read()
- if good_text != self.last_out_text:
- self.Error(("Output file %s (%s) is wrong for hidl file %s\n"
- "meld %s %s") % (out_name, out_type, hidl_name,
- canonical_path,
- self.last_out_path))
-
- def Error(self, string):
- """Prints an error message and increments error count."""
- print string
- self.errors += 1
-
- def ProcessFile(self, hidl_name, out_name, out_type, print_out=None):
- self.last_hidl_name = hidl_name
- self.last_out_type = out_type
- hidl_path = self.test_dir + hidl_name
- self.last_out_path = self.output_dir + out_name
- self.RunCommand([self.hidl_cpp_path, out_type,
- hidl_path, self.last_out_path])
- if print_out:
- print self.last_stdout
- if self.last_return == 0:
- with open(self.last_out_path) as out_file:
- self.last_out_text = out_file.read()
- else:
- self.last_out_text = " * * INVALID * * "
-
- def Test(self, bool_value, text=""):
- if not bool_value:
- self.Error(("File %s (type %s) error: %s\n" % (
- self.last_hidl_name, self.last_out_type, text)) +
- (" (stdout: %s\n stderr: %s\n)" % (
- self.last_stdout, self.last_stderr)))
-
-
-def Has(string, substr):
- """Syntactic sugar: true iff str contains substr."""
- return string.find(substr) != -1
-
-
-if __name__ == "__main__":
- if len(sys.argv) != 4:
- print "Usage: python testAll.py hidl-cpp-path test-dir out-dir"
- sys.exit(1)
-
- tester = Tester(sys.argv[1], sys.argv[2], sys.argv[3])
- tester.RunTests()
- if tester.errors:
- print "hidl_cpp test: %d errors" % tester.errors
- sys.exit(tester.errors)
diff --git a/tests/vts_gps.hal b/tests/vts_gps.hal
deleted file mode 100644
index 4e9ce8b..0000000
--- a/tests/vts_gps.hal
+++ /dev/null
@@ -1,17 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-@hal_type("GPS")
-interface ISampleGpsHalServiceWithVtsCallFlowAnnotation {
- @param(name="mode", normal={1, 2, 3})
- @next_calls({"stop"})
- @entry
- start(int32_t mode) generates (int32_t _retcode);
-
- @next_calls({"cleanup"})
- stop() generates (int32_t _retcode);
-
- @next_calls({"cleanup"})
- @exit
- cleanup();
-};
diff --git a/tests/vts_lights.hal b/tests/vts_lights.hal
deleted file mode 100644
index 3e49905..0000000
--- a/tests/vts_lights.hal
+++ /dev/null
@@ -1,11 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-@hal_type("LIGHT")
-interface ISampleLightsHalServiceWithVtsAnnotation {
- struct light_state_t {
- string s;
- handle bar;
- };
- setLight(light_state_t state) generates (int32_t _hidl_return);
-};
diff --git a/tests/vts_lights_hal.hal b/tests/vts_lights_hal.hal
deleted file mode 100644
index 29cd784..0000000
--- a/tests/vts_lights_hal.hal
+++ /dev/null
@@ -1,29 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-@hal_type("LIGHT")
-
-interface ISampleLightsHalServiceWithVtsAnnotation {
- const LIGHT_FLASH_NONE = 0;
- const LIGHT_FLASH_TIMED = 1;
- const LIGHT_FLASH_HARDWARE = 2;
- const BRIGHTNESS_MODE_USER = 0;
- const BRIGHTNESS_MODE_SENSOR = 1;
- const LIGHT_ID_BACKLIGHT = "backlight";
- const LIGHT_ID_KEYBOARD = "keyboard";
- const LIGHT_ID_BUTTONS = "buttons";
- const LIGHT_ID_BATTERY = "battery";
- const LIGHT_ID_NOTIFICATIONS = "notifications";
- const LIGHT_ID_ATTENTION = "attention";
- const LIGHT_ID_BLUETOOTH = "bluetooth";
- const LIGHT_ID_WIFI = "wifi";
- struct light_state_t {
- uint32_t color;
- int32_t flashMode;
- int32_t flashOnMs;
- int32_t flashOffMs;
- int32_t brightnessMode;
- };
- setLight(light_state_t state) generates (int32_t _hidl_return);
-};
-
diff --git a/types/Android.mk b/types/Android.mk
deleted file mode 100644
index 5923116..0000000
--- a/types/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := hidl-types-service
-LOCAL_SRC_FILES := Server.cpp ITypes.hal ISmallTest.hal hasher.cpp
-LOCAL_SHARED_LIBRARIES := libhwbinder libbase libcutils libutils
-LOCAL_C_INCLUDES := system/libhwbinder/include
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := hidl-types-client
-LOCAL_SRC_FILES := Client.cpp ITypes.hal ISmallTest.hal hasher.cpp
-LOCAL_SHARED_LIBRARIES := libhwbinder libbase libcutils libutils
-LOCAL_C_INCLUDES := system/libhwbinder/include
-include $(BUILD_EXECUTABLE)
diff --git a/types/Client.cpp b/types/Client.cpp
deleted file mode 100644
index 36c9a26..0000000
--- a/types/Client.cpp
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * 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.
- */
-
-#include "hasher.h"
-#include <iostream>
-
-#include <android-base/logging.h>
-#include <hwbinder/IServiceManager.h>
-#include <utils/String16.h>
-#include <utils/StrongPointer.h>
-
-#include "ITypes.h"
-#include "ISmallTest.h"
-#include "BnSmallTest.h"
-
-using std::string;
-// libutils:
-using android::OK;
-using android::sp;
-using android::status_t;
-using android::String16;
-
-// libbinder:
-using android::hardware::getService;
-using android::hardware::hidl_version;
-using android::hardware::make_hidl_version;
-using android::hardware::gen_ref;
-using android::hardware::from_ref;
-
-// generated
-using android::hardware::tests::ITypes;
-
-using std::cerr;
-using std::cout;
-using std::endl;
-
-namespace android {
-namespace hardware {
-namespace tests {
-namespace client {
-
-const char kServiceName[] = "android.hardware.tests.ITypes";
-
-bool GetService(sp<ITypes>* service, hidl_version version) {
- //cout << "Retrieving test service binder" << endl;
- status_t status = getService(String16(kServiceName), version, service);
- if (status != OK) {
- cerr << "Failed to get service binder: '" << kServiceName
- << "' status=" << status << endl;
- return false;
- }
- return true;
-}
-
-} // namespace client
-} // namespace tests
-} // namespace aidl
-} // namespace android
-
-void testHash(sp<ITypes> service, string message = "")
-{
- static int calls = 0;
- calls++;
- uint64_t hash;
- service->getHash([&hash](auto ret){hash = ret;});
- if (hash != getHash()) {
- cout << "Hash mismatch: " << hash << " vs. " << getHash();
- cout << " on call # " << calls << " - " << message << endl;
- }
-}
-using eu8 = ::android::hardware::tests::ITypes::eu8;
-using es8 = ::android::hardware::tests::ITypes::es8;
-using eu16 = ::android::hardware::tests::ITypes::eu16;
-using es16 = ::android::hardware::tests::ITypes::es16;
-using eu32 = ::android::hardware::tests::ITypes::eu32;
-using es32 = ::android::hardware::tests::ITypes::es32;
-using eu64 = ::android::hardware::tests::ITypes::eu64;
-using es64 = ::android::hardware::tests::ITypes::es64;
-using ec = ::android::hardware::tests::ITypes::ec;
-
-void enumTestSmall(sp<ITypes> service)
-{
- service->echoEnum(eu8::U8F, es8::S8F, eu16::U16F, es16::S16F, eu32::U32F, es32::S32F, eu64::U64F, es64::S64F, ec::CF,
- [](eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i) {
- // enum elements have gone through hidl-gen, so I don't fully trust them in a
- // test program - it's ugly but I'd rather retype all the numbers.
- if (sizeof(a) != 1 || sizeof(b) != 1 || sizeof(c) != 2 || sizeof(d) != 2 ||
- sizeof(e) != 4 || sizeof(f) != 4 || sizeof(g) != 8 || sizeof(h) != 8 ||
- sizeof(i) != 1) {
- cout << "Wrong size of enum" << endl;
- }
- if ((uint8_t)a != 34) cout << "a wrong" << endl;
- if ((int8_t)b != 104) cout << "b wrong" << endl;
- if ((uint16_t)c != 234) cout << "c wrong" << endl;
- if ((int16_t)d != 334) cout << "d wrong" << endl;
- if ((uint32_t)e != 434) cout << "e wrong" << endl;
- if ((int32_t)f != 534) cout << "f wrong" << endl;
- if ((uint64_t)g != 634) cout << "g wrong" << endl;
- if ((int64_t)h != 734) cout << "h wrong" << endl;
- if ((uint8_t)i != 43) cout << "i wrong" << endl;
- addHash((uint8_t)a);
- addHash((int8_t)b);
- addHash((uint16_t)c);
- addHash((int16_t)d);
- addHash((uint32_t)e);
- addHash((int32_t)f);
- addHash((uint64_t)g);
- addHash((int64_t)h);
- addHash((uint8_t)i);
- });
- testHash(service, "after enumTestSmall");
-}
-void enumTestMin(sp<ITypes> service)
-{
- service->echoEnum(eu8::min, es8::min, eu16::min, es16::min, eu32::min, es32::min, eu64::min, es64::min, ec::min,
- [](eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i) {
- if ((uint8_t)a != 0) cout << "a wrong" << endl;
- if ((int8_t)b != -128) cout << "b wrong" << endl;
- if ((uint16_t)c != 0) cout << "c wrong" << endl;
- if ((int16_t)d != -32768) cout << "d wrong" << endl;
- if ((uint32_t)e != 0) cout << "e wrong" << endl;
- if ((int32_t)f != -2147483648) cout << "f wrong" << endl;
- if ((uint64_t)g != 0) cout << "g wrong" << endl;
- if ((int64_t)h != -9223372036854775807LL) cout << "h wrong" << endl;
- if ((uint8_t)i != 0) cout << "i wrong" << endl;
- addHash((uint8_t)a);
- addHash((int8_t)b);
- addHash((uint16_t)c);
- addHash((int16_t)d);
- addHash((uint32_t)e);
- addHash((int32_t)f);
- addHash((uint64_t)g);
- addHash((int64_t)h);
- addHash((uint8_t)i);
- });
- testHash(service, "after enumTestMin");
-}
-void enumTestMax(sp<ITypes> service)
-{
- service->echoEnum(eu8::max, es8::max, eu16::max, es16::max, eu32::max, es32::max, eu64::max, es64::max, ec::max,
- [](eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i) {
- if ((uint8_t)a != 255) cout << "a wrong" << endl;
- if ((int8_t)b != 127) cout << "b wrong" << endl;
- if ((uint16_t)c != 65535) cout << "c wrong" << endl;
- if ((int16_t)d != 32767) cout << "d wrong" << endl;
- if ((uint32_t)e != 0xffffffff) cout << "e wrong" << endl;
- if ((int32_t)f != 2147483647) cout << "f wrong" << endl;
- if ((uint64_t)g != 0xffff'ffff'ffffffffLL) cout << "g wrong" << endl;
- if ((int64_t)h != 0x7fff'ffff'ffffffffLL) cout << "h wrong" << endl;
- if ((uint8_t)i != 255) cout << "i wrong" << endl;
- addHash((uint8_t)a);
- addHash((int8_t)b);
- addHash((uint16_t)c);
- addHash((int16_t)d);
- addHash((uint32_t)e);
- addHash((int32_t)f);
- addHash((uint64_t)g);
- addHash((int64_t)h);
- addHash((uint8_t)i);
- });
- testHash(service, "after enumTestMax");
-}
-void scalarTestSmall(sp<ITypes> service)
-{
- service->echoScalar(34, 104, 234, 334, 434, 534, 634, 734, 43,
- [](uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i) {
- if (a != 34) cout << "a wrong" << endl;
- if (b != 104) cout << "b wrong" << endl;
- if (c != 234) cout << "c wrong" << endl;
- if (d != 334) cout << "d wrong" << endl;
- if (e != 434) cout << "e wrong" << endl;
- if (f != 534) cout << "f wrong" << endl;
- if (g != 634) cout << "g wrong" << endl;
- if (h != 734) cout << "h wrong" << endl;
- if (i != 43) cout << "i wrong" << endl;
- addHash(a);
- addHash(b);
- addHash(c);
- addHash(d);
- addHash(e);
- addHash(f);
- addHash(g);
- addHash(h);
- addHash(i);
- });
- testHash(service, "after scalarTestSmall");
-}
-void scalarTestMin(sp<ITypes> service)
-{
- service->echoScalar(0, -128, 0, -32768, 0, -2147483648,
- 0, -9223372036854775807LL, 0,
- [](uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i) {
- if (a != 0) cout << "a wrong" << endl;
- if (b != -128) cout << "b wrong" << endl;
- if (c != 0) cout << "c wrong" << endl;
- if (d != -32768) cout << "d wrong" << endl;
- if (e != 0) cout << "e wrong" << endl;
- if (f != -2147483648) cout << "f wrong" << endl;
- if (g != 0) cout << "g wrong" << endl;
- if (h != -9223372036854775807LL) cout << "h wrong" << endl;
- if (i != 0) cout << "i wrong" << endl;
- addHash(a);
- addHash(b);
- addHash(c);
- addHash(d);
- addHash(e);
- addHash(f);
- addHash(g);
- addHash(h);
- addHash(i);
- });
- testHash(service, "after scalarTestMin");
-}
-void scalarTestMax(sp<ITypes> service)
-{
- service->echoScalar(255, 127, 65535, 32767, 0xffffffff, 0x7fffffff,
- 0xffff'ffff'ffffffffLL, 0x7fff'ffff'ffffffffLL, 255,
- [](uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i) {
- if (a != 255) cout << "a wrong" << endl;
- if (b != 127) cout << "b wrong" << endl;
- if (c != 65535) cout << "c wrong" << endl;
- if (d != 32767) cout << "d wrong" << endl;
- if (e != 0xffffffff) cout << "e wrong" << endl;
- if (f != 2147483647) cout << "f wrong" << endl;
- if (g != 0xffff'ffff'ffffffffLL) cout << "g wrong" << endl;
- if (h != 0x7fff'ffff'ffffffffLL) cout << "h wrong" << endl;
- if (i != 255) cout << "i wrong" << endl;
- addHash(a);
- addHash(b);
- addHash(c);
- addHash(d);
- addHash(e);
- addHash(f);
- addHash(g);
- addHash(h);
- addHash(i);
- });
- testHash(service, "after scalarTestMax");
-}
-
-using disc = ::android::hardware::tests::ITypes::disc;
-
-void nestedTest(sp<ITypes> service)
-{
- char cs1[]{"HiWorld"};
- char cs2[]{"JiWorldFoo"};
- char cs3[]{"QiWorld"};
- char cs4[]{"FiWorld"};
- char cs5[]{"WiWorld"};
- ITypes::s0 v0;
- ITypes::s1s v1[2];
- v0.s1v2.count = 2;
- v0.s1v2.buffer = v1;
- v0.s1m1.str1.buffer = cs1;
- v0.s1m1.str1.length = -1;
- v1[0].str1.buffer = cs3;
- v1[0].str1.length = -1;
- v1[1].str1.buffer = cs4;
- v1[1].str1.length = 5;
-
- // v0.s1m1.dm1 = disc::US;
- // v0.s1m1.u1m1.s.buffer = cs1;
- // v0.s1m1.u1m1.s.length = -1;
- // v1[0].dm1 = disc::UF;
- /* int32_t *data_ptr;
- int fd = -1;
- gen_ref(&fd, &data_ptr);
- *data_ptr = 0xbeefcafe;
- if (fd >= 0) {
- v1[0].u1m1.fd = fd;
- } else {
- cout << "Couldn't get fd in nestedTest" << endl;
- }*/
- // v1[1].dm1 = disc::UI;
- // v1[1].u1m1.i = 0xada;
- // v0.s1m3.dm1 = disc::UC;
- // v0.s1m3.u1m1.s2m.i = 0xabcdef;
- cout << "Client: About to call echoStruct" << endl;
- printf("C: &v0 %p v0.s1m1.str1.buf %p v0.s1v2.buf %p v0.s1v2.buf[0].str1.buf %p [1] %p\n",
- &v0, v0.s1m1.str1.buffer, v0.s1v2.buffer, v0.s1v2.buffer[0].str1.buffer, v0.s1v2.buffer[1].str1.buffer);
- service->echoStruct(v0, [](const /*android::hardware::tests::ITypes::s0 */ auto & s){
- cout << "Client: in callback, s is " << &s << endl;
- printf("C: s %p s.s1m1.str1.buf %p s.s1v2.buf %p s.s1v2.buf[0].str1.buf %p [1] %p\n",
- &s, s.s1m1.str1.buffer, s.s1v2.buffer, s.s1v2.buffer[0].str1.buffer, s.s1v2.buffer[1].str1.buffer);
- int i = s.s1v2.count;
- cout << "Client: vec count(2?): " << i << endl;
- printf("s1m1 len is %ld\n", s.s1m1.str1.length);
- printf("s1m1 str is %s\n", s.s1m1.str1.buffer);
- printf("s1v2[0] len is %ld\n", s.s1v2.buffer[0].str1.length);
- printf("s1v2[0] str is %s\n", s.s1v2.buffer[0].str1.buffer);
- printf("s1v2[1] len is %ld\n", s.s1v2.buffer[0].str1.length);
- printf("s1v2[1] bytes is %c%c%c%c%c\n", s.s1v2.buffer[0].str1.buffer[0],
- s.s1v2.buffer[0].str1.buffer[1],s.s1v2.buffer[0].str1.buffer[2],
- s.s1v2.buffer[0].str1.buffer[3],s.s1v2.buffer[0].str1.buffer[4]);
- });
-}
-
-// This implementation of BnSmallTest is used to verify that interfaces
-// can be passed around as parameters.
-class CallbackTester : public android::hardware::tests::BnSmallTest {
- public:
- CallbackTester() {}
- virtual ~CallbackTester() = default;
-
- virtual android::hardware::Status echoNumber(
- uint32_t some_number,
- ISmallTest::echoNumber_cb the_callback) {
- // Simply echo the given number back to the caller.
- the_callback(some_number);
- return android::hardware::Status::ok();
- }
-};
-
-// Passes a CallbackTester object to the server, gets it back,
-// and verifies that it works.
-void RunCallbackTest(sp<ITypes> service)
-{
- android::sp<CallbackTester> call_server = new CallbackTester;
-
- bool all_is_happy = false;
- service->echoInterface(
- call_server,
- [&](android::sp<android::hardware::tests::ISmallTest> cb) {
- // cb should be a working CallbackTester object. Here we
- // verify that it works, echoing the given integer.
- cb->echoNumber(42, [&](const uint32_t should_be_42) {
- if (should_be_42 == 42) {
- all_is_happy = true;
- } else {
- // TODO(cphoenix): Printf's aren't the right way to deal with errors
- printf("Bad value %d received in client callback test\n",
- should_be_42);
- }
- });
- });
- if (!all_is_happy) {
- printf("Error in callbackTest (check if callback was called)\n");
- }
-}
-
-
-int main(int /* argc */, char * argv []) {
- cout << " Running tests" << endl;
- android::base::InitLogging(argv, android::base::StderrLogger);
- sp<ITypes> service;
- namespace client_tests = android::hardware::tests::client;
-
- hidl_version version = make_hidl_version(4,0);
- if (!client_tests::GetService(&service, version)) {
- cout << " * * Client couldn't find server * * " << endl;
- return 1;
- }
-
- ITypes::simple_t sts;
- sts.int1 = sts.int2 = 17;
- service->echoInteger(42, sts, [](int ret){
- if (ret != 42) cout << "Client: echoInteger returned " << ret << " instead of 42" << endl;});
- addHash(42);
- addHash(sts.int1);
- addHash(sts.int2);
- enumTestSmall(service);
- enumTestMin(service);
- enumTestMax(service);
- scalarTestSmall(service);
- scalarTestMin(service);
- scalarTestMax(service);
- nestedTest(service);
- RunCallbackTest(service);
- service->quit();
- cout << " Tests completed" << endl;
- return 0;
-}
diff --git a/types/IMsg.hal b/types/IMsg.hal
deleted file mode 100644
index 136b4c1..0000000
--- a/types/IMsg.hal
+++ /dev/null
@@ -1,37 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-interface IMsg {
-
- struct simple_t {
- uint32_t int1;
- uint32_t int2;
- };
-
- struct lots_of_data {
- uint8_t[4096] buffer;
- };
- struct shm_t {
- uint32_t fdIndex;
- uint32_t offset;
- uint32_t extent;
- };
- struct GrantorDescriptor {
- uint32_t flags;
- shm_t shm;
- };
-
- struct MQDescriptor {
- vec<GrantorDescriptor> grantors;
- handle mq_handles;
- uint32_t quantum;
- uint32_t nQuanta;
- uint32_t flags;
- };
-
-
- configure() generates ( MQDescriptor mqdescIn, MQDescriptor mqdescOut );
- requestWrite (int32_t count) generates (int32_t ret);
- requestRead(int32_t count) generates (int32_t ret);
-
-};
diff --git a/types/ISmallTest.hal b/types/ISmallTest.hal
deleted file mode 100644
index 0794fae..0000000
--- a/types/ISmallTest.hal
+++ /dev/null
@@ -1,9 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-// Interface contains one function that echoes an integer.
-// Useful only for testing.
-
-interface ISmallTest {
- echoNumber(uint32_t i) generates (uint32_t i);
-};
diff --git a/types/ITypes.hal b/types/ITypes.hal
deleted file mode 100644
index cf2125d..0000000
--- a/types/ITypes.hal
+++ /dev/null
@@ -1,87 +0,0 @@
-version 1.0;
-package android.hardware.tests;
-
-import ISmallTest;
-
-interface ITypes {
-
- struct simple_t {
- uint32_t int1;
- uint32_t int2;
- };
-
- enum eu8 : uint8_t { U8F = 34, max = 255, min = 0};
- enum es8 : int8_t { S8F = 104, max = 127, min = -128 };
- enum eu16 : uint16_t { U16F = 234, max = 65535, min = 0 };
- enum es16 : int16_t { S16F = 334, max = 32767, min = -32768 };
- enum eu32 : uint32_t { U32F = 434, max = 0xffff'f'fff, min = 0};
- enum es32 : int32_t { S32F = 534, max = 0x7fff'f'fff, min = -2147483648 };
- enum eu64 : uint64_t { U64F = 634, max = 0xffff'ffff'ffff'f'fffuLL, min = 0 };
- enum es64 : int64_t { S64F = 734, max=9223372036854775807LL, min=-9223372036854775807LL };
- enum ec : char { CF = 43, min=0, max=255 };
-
- struct lots_of_data {
- uint8_t[4096] buffer;
- };
-
- enum disc : uint32_t { US, UF, UI, UC };
-
- struct s2 {
- int32_t i;
- };
-
- union u1 : disc {
- string s on(US);
- ref<uint8_t> fd on(UF);
- int64_t i on(UI);
- s2 s2m on(UC);
- };
-
- struct s1s {
- string str1;
- };
-
- struct s1u {
- disc dm1;
- u1 u1m1;
- };
-
- struct s0 {
- s1s s1m1;
- vec<s1s> s1v2;
- };
-
- struct shm_t {
- uint32_t fdIndex;
- uint32_t offset;
- uint32_t extent;
- };
- struct GrantorDescriptor {
- uint32_t flags;
- shm_t shm;
- };
-
- struct MQDescriptor {
- vec<GrantorDescriptor> grantors;
- handle mq_handles;
- uint32_t quantum;
- uint32_t nQuanta;
- uint32_t flags;
- };
-
- echoInteger(int32_t echo_me, simple_t my_struct) generates (int32_t ret);
- echoEnum(eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i)
- generates(eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i);
- echoScalar(uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i)
- generates(uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i);
- echoStruct(s0 s) generates (s0 s);
-
- // EchoInterface passes an ISmalltest to the server and back,
- // and verifies that its functions can be called on the server side.
- echoInterface(ISmallTest cb_t) generates (ISmallTest cb_t);
-
- // Use of ref<T> is deprecated.
- shareBufferWithRef(ref<lots_of_data> buffer) generates (int32_t ret);
- getHash() generates (uint64_t hash);
- quit();
-};
diff --git a/types/Server.cpp b/types/Server.cpp
deleted file mode 100644
index 5692635..0000000
--- a/types/Server.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-#include "hasher.h"
-
-#include <iostream>
-#include <map>
-
-#include <unistd.h>
-
-#include <hwbinder/IInterface.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/IServiceManager.h>
-#include <hwbinder/ProcessState.h>
-#include <hwbinder/Status.h>
-#include <utils/Errors.h>
-#include <utils/Log.h>
-#include <utils/Looper.h>
-#include <utils/StrongPointer.h>
-
-#include <BnTypes.h>
-#include <ISmallTest.h>
-// libutils:
-using android::Looper;
-using android::LooperCallback;
-using android::OK;
-using android::sp;
-using android::String16;
-
-// libhwbinder:
-using android::hardware::BnInterface;
-using android::hardware::defaultServiceManager;
-using android::hardware::IInterface;
-using android::hardware::IPCThreadState;
-using android::hardware::Parcel;
-using android::hardware::ProcessState;
-using android::hardware::Status;
-using android::hardware::hidl_version;
-using android::hardware::make_hidl_version;
-using android::hardware::from_ref;
-
-// Standard library
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::map;
-using std::string;
-using std::unique_ptr;
-using std::vector;
-
-// Generated HIDL files
-using android::hardware::tests::BnTypes;
-
-namespace {
-
-class BinderCallback : public LooperCallback {
- public:
- BinderCallback() {}
- ~BinderCallback() override {}
-
- int handleEvent(int /* fd */, int /* events */, void* /* data */) override {
- IPCThreadState::self()->handlePolledCommands();
- return 1; // Continue receiving callbacks.
- }
-};
-
-class Types : public BnTypes {
- public:
- Types() {}
- virtual ~Types() = default;
-
- virtual Status echoInteger(int32_t echo_me, const ITypes::simple_t& my_struct, ITypes::echoInteger_cb callback) {
- //std::cout << "struct at addr " << (void *)&my_struct << std::endl;
- //std::cout << "int1 " << my_struct.int1 << " int 2 " << my_struct.int2 << std::endl;
- addHash(echo_me);
- addHash(my_struct.int1);
- addHash(my_struct.int2);
- callback(echo_me);
- return Status::ok();
- }
-
- // Proves we can receive an interface through HwBinder from the client,
- // call one of its functions successfully, and echo the interface back
- // to the client.
- virtual Status echoInterface(sp<android::hardware::tests::ISmallTest> cb_t,
- ITypes::echoInterface_cb callback) {
- // cb_t should be a viable HwBinder object implementing IC
- bool all_is_happy = false;
- cb_t->echoNumber(42, [&](const uint32_t should_be_42) {
- if (should_be_42 == 42) {
- all_is_happy = true;
- } else {
- // TODO(cphoenix): Printf's aren't the right way to deal with errors
- printf("Bad value %d received in server-side callback test\n",
- should_be_42);
- }
- });
- if (!all_is_happy) {
- printf("Error in server-side callbackTest (check if callback was called)\n");
- }
- callback(cb_t);
- return Status::ok();
- }
-
- virtual Status shareBufferWithRef(int buffer, ITypes::shareBufferWithRef_cb callback) {
- // Map back to struct lots_of_data
- ITypes::lots_of_data* dataPtr;
- if (from_ref(buffer, &dataPtr)) {
- // Failed
- callback(-1);
- } else {
- // cout << "Data element at position 1481 is " << unsigned(dataPtr->buffer[1481]) << endl;
- addHash(dataPtr->buffer[1481]);
- callback(int32_t(dataPtr->buffer[1481]));
- }
- return Status::ok();
- }
- virtual Status echoEnum(eu8 a, es8 b, eu16 c, es16 d, eu32 e, es32 f, eu64 g, es64 h, ec i, ITypes::echoEnum_cb cb) {
- addHash((uint8_t)a);
- addHash((int8_t)b);
- addHash((uint16_t)c);
- addHash((int16_t)d);
- addHash((uint32_t)e);
- addHash((int32_t)f);
- addHash((uint64_t)g);
- addHash((int64_t)h);
- addHash((uint8_t)i);
- cb(a, b, c, d, e, f, g, h, i);
- return Status::ok();
- }
-
- virtual Status echoScalar(uint8_t a, int8_t b, uint16_t c, int16_t d, uint32_t e, int32_t f, uint64_t g, int64_t h, char i, ITypes::echoScalar_cb cb) {
- addHash(a);
- addHash(b);
- addHash(c);
- addHash(d);
- addHash(e);
- addHash(f);
- addHash(g);
- addHash(h);
- addHash(i);
- cb(a, b, c, d, e, f, g, h, i);
- return Status::ok();
- }
-
- virtual Status echoStruct(const ITypes::s0 &s, ITypes::echoStruct_cb cb) {
- cout << "Server: echoStruct called" << endl;
- cout << "Server: in echoStruct, s is " << &s << endl;
- int i = s.s1v2.count;
- cout << "S: vec count(2?): " << i << endl;
- printf("S: s1m1 len is %ld\n", s.s1m1.str1.length);
- printf("S: s %p s.s1m1.str1.buf %p s.s1v2.buf %p\n",
- &s, s.s1m1.str1.buffer, s.s1v2.buffer);
- printf("S: * s.s1v2.buf[0].str1.buf %p [1] %p\n", s.s1v2.buffer[0].str1.buffer, s.s1v2.buffer[1].str1.buffer);
- printf("S: s1m1 str is %s\n", s.s1m1.str1.buffer);
- printf("S: s1v2[0] len is %ld\n", s.s1v2.buffer[0].str1.length);
- printf("S: s1v2[0] str is %s\n", s.s1v2.buffer[0].str1.buffer);
- printf("S: s1v2[1] len is %ld\n", s.s1v2.buffer[1].str1.length);
- printf("S: s1v2[1] bytes is %c%c%c%c%c\n", s.s1v2.buffer[1].str1.buffer[0],
- s.s1v2.buffer[1].str1.buffer[1],s.s1v2.buffer[1].str1.buffer[2],
- s.s1v2.buffer[1].str1.buffer[3],s.s1v2.buffer[1].str1.buffer[4]);
- cb(s);
- cout << "Server: echoStruct survived cb(s)" << endl;
- return Status::ok();
- }
-
- virtual Status getHash(ITypes::getHash_cb cb) {
- cb(::getHash());
- return Status::ok();
- }
-
- virtual Status quit() {
- //cout << "Service: quitting" << endl;
- fflush(stdout);
- exit(0);
- }
- private:
-};
-
-int Run() {
- android::sp<Types::Types> service = new Types::Types;
- //cout << "Service started." << endl;
- //fflush(stdout);
-
- sp<Looper> looper(Looper::prepare(0 /* opts */));
-
- int binder_fd = -1;
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- IPCThreadState::self()->disableBackgroundScheduling(true);
- IPCThreadState::self()->setupPolling(&binder_fd);
- ALOGI("Got binder FD %d", binder_fd);
- if (binder_fd < 0) return -1;
-
- sp<BinderCallback> cb(new BinderCallback);
- if (looper->addFd(binder_fd, Looper::POLL_CALLBACK, Looper::EVENT_INPUT, cb,
- nullptr) != 1) {
- ALOGE("Failed to add binder FD to Looper");
- return -1;
- }
- hidl_version version = android::hardware::make_hidl_version(4,1);
- defaultServiceManager()->addService(service->getInterfaceDescriptor(),
- service, version);
-
- ALOGI("Entering loop");
- while (true) {
- const int result = looper->pollAll(-1 /* timeoutMillis */);
- ALOGI("Looper returned %d", result);
- }
- return 0;
-
-}
-
-} // namespace
-
-int main(int /* argc */, char* /* argv */ []) {
- return Run();
-}
diff --git a/types/go.sh b/types/go.sh
deleted file mode 100755
index 2a745ed..0000000
--- a/types/go.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-my=$PWD
-top=$(cd ../../../..;pwd)
-cd $top
-. build/envsetup.sh
-lunch angler-userdebug
-make -j44 hidl-types-service hidl-types-client
-if [ $? -ne 0 ];
-then exit 1
-else
-adb sync system
-adb shell hidl-types-service &
-sleep 0.2
-adb shell hidl-types-client
-sleep 0.2
-exit 0
-fi
-
diff --git a/types/hasher.cpp b/types/hasher.cpp
deleted file mode 100644
index 79b0d34..0000000
--- a/types/hasher.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-#include "hasher.h"
-#include <iostream>
-using std::cout;
-using std::endl;
-
-static uint64_t the_hash = 0xdeadbeef;
-
-uint64_t getHash()
-{
- return the_hash;
-}
-
-static int calls = 0;
-void addHash(uint64_t n)
-{
- the_hash *= 65;
- the_hash += n;
- // cout << calls++ << ":U64 " << n << " h " << the_hash << endl;
-}
-void addHash(int64_t n)
-{
- the_hash *= 65;
- the_hash += uint64_t(n);
- // cout << calls++ << ":S64 " << n << " h " << the_hash << endl;
-}
-void addHash(uint32_t n)
-{
- the_hash *= 65;
- the_hash += n;
- // cout << calls++ << ":U32 " << n << " h " << the_hash << endl;
-}
-void addHash(int32_t n)
-{
- the_hash *= 65;
- the_hash += uint32_t(n);
- // cout << calls++ << ":S32 " << n << " h " << the_hash << endl;
-}
-void addHash(uint16_t n)
-{
- the_hash *= 65;
- the_hash += n;
- // cout << calls++ << ":U64 " << n << " h " << the_hash << endl;
-}
-void addHash(int16_t n)
-{
- the_hash *= 65;
- the_hash += uint16_t(n);
- // cout << calls++ << ":S64 " << n << " h " << the_hash << endl;
-}
-void addHash(uint8_t n)
-{
- the_hash *= 65;
- the_hash += n;
- // cout << calls++ << ":U32 " << n << " h " << the_hash << endl;
-}
-void addHash(int8_t n)
-{
- the_hash *= 65;
- the_hash += uint8_t(n);
- // cout << calls++ << ":S32 " << n << " h " << the_hash << endl;
-}
diff --git a/types/hasher.h b/types/hasher.h
deleted file mode 100644
index 77f9fbe..0000000
--- a/types/hasher.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef ANDROID_SYSTEM_TOOLS_HIDL_HASHER
-#define ANDROID_SYSTEM_TOOLS_HIDL_HASHER
-#include <cstdint>
-
-uint64_t getHash();
-void addHash(uint64_t n);
-void addHash(int64_t n);
-void addHash(uint32_t n);
-void addHash(int32_t n);
-void addHash(uint16_t n);
-void addHash(int16_t n);
-void addHash(uint8_t n);
-void addHash(int8_t n);
-#endif // ANDROID_SYSTEM_TOOLS_HIDL_HASHER