Create parcelable_utils.h for helper macros

This creates a new file parceable_utils.h for helper macros used in
C++ binder parcelable classes.

Currently this only includes macro RETURN_IF_FAILED.

Bug: None
Change-Id: I02b1e7feecb9c3879961f1bf6ac50458332c1a91
Test: compile, unit tests
This commit is contained in:
Ningyuan Wang 2016-11-30 15:20:04 -08:00
parent c2b0dce5c3
commit fa1a494f56
2 changed files with 41 additions and 10 deletions

39
parcelable_utils.h Normal file
View File

@ -0,0 +1,39 @@
/*
* 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 WIFICOND_PARCELABLE_UTILS_H_
#define WIFICOND_PARCELABLE_UTILS_H_
namespace android {
namespace wificond {
namespace parcelable_utils {
#define RETURN_IF_FAILED(expression_to_evaluate) \
{ \
status_t return_status = expression_to_evaluate; \
if (return_status) { \
LOG(ERROR) << "Failed to parse binder parcelable object at " \
<< __FILE__ << ":" << __LINE__; \
return return_status; \
} \
}
} // namespace parcelable_utils
} // namespace wificond
} // namespace android
#endif // WIFICOND_PARCELABLE_UTILS_H_

View File

@ -21,6 +21,8 @@
#include <android-base/logging.h>
#include "wificond/parcelable_utils.h"
using android::status_t;
using android::OK;
using std::string;
@ -32,16 +34,6 @@ namespace server {
namespace wifi {
namespace wificond {
#define RETURN_IF_FAILED(calledOnce) \
{ \
status_t returnStatus = calledOnce; \
if (returnStatus) { \
LOG(ERROR) << "Failed to parse binder parcelable object at " \
<< __FILE__ << ":" << __LINE__; \
return returnStatus; \
} \
}
NativeScanResult::NativeScanResult(std::vector<uint8_t>& ssid_,
std::vector<uint8_t>& bssid_,
std::vector<uint8_t>& info_element_,