2020-01-17 21:05:03 +08:00
|
|
|
# Copyright 2019 Google LLC
|
2019-03-19 00:21:48 +08:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
"""Contains golden outputs for tests."""
|
|
|
|
|
|
|
|
|
|
|
|
CODE_GOLD = """// AUTO-GENERATED by the Sandboxed API generator.
|
|
|
|
// Edits will be discarded when regenerating this file.
|
|
|
|
|
2021-01-05 23:18:13 +08:00
|
|
|
#include "absl/status/status.h"
|
|
|
|
#include "absl/status/statusor.h"
|
2019-03-19 00:21:48 +08:00
|
|
|
#include "sandboxed_api/sandbox.h"
|
2021-01-05 23:18:13 +08:00
|
|
|
#include "sandboxed_api/util/status_macros.h"
|
2019-03-19 00:21:48 +08:00
|
|
|
#include "sandboxed_api/vars.h"
|
|
|
|
|
|
|
|
namespace sapi {
|
|
|
|
namespace Tests {
|
|
|
|
|
|
|
|
class TestApi {
|
|
|
|
public:
|
|
|
|
explicit TestApi(::sapi::Sandbox* sandbox) : sandbox_(sandbox) {}
|
2019-07-26 22:46:43 +08:00
|
|
|
// Deprecated
|
|
|
|
::sapi::Sandbox* GetSandbox() const { return sandbox(); }
|
|
|
|
::sapi::Sandbox* sandbox() const { return sandbox_; }
|
2019-03-19 00:21:48 +08:00
|
|
|
|
|
|
|
// int function_a(int, int)
|
2020-09-02 23:46:48 +08:00
|
|
|
absl::StatusOr<int> function_a(int x, int y) {
|
2019-03-19 00:21:48 +08:00
|
|
|
::sapi::v::Int ret;
|
|
|
|
::sapi::v::Int x_((x));
|
|
|
|
::sapi::v::Int y_((y));
|
|
|
|
|
|
|
|
SAPI_RETURN_IF_ERROR(sandbox_->Call("function_a", &ret, &x_, &y_));
|
|
|
|
return ret.GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// int types_1(bool, unsigned char, char, unsigned short, short)
|
2020-09-02 23:46:48 +08:00
|
|
|
absl::StatusOr<int> types_1(bool a0, unsigned char a1, char a2, unsigned short a3, short a4) {
|
2019-03-19 00:21:48 +08:00
|
|
|
::sapi::v::Int ret;
|
|
|
|
::sapi::v::Bool a0_((a0));
|
|
|
|
::sapi::v::UChar a1_((a1));
|
|
|
|
::sapi::v::Char a2_((a2));
|
|
|
|
::sapi::v::UShort a3_((a3));
|
|
|
|
::sapi::v::Short a4_((a4));
|
|
|
|
|
|
|
|
SAPI_RETURN_IF_ERROR(sandbox_->Call("types_1", &ret, &a0_, &a1_, &a2_, &a3_, &a4_));
|
|
|
|
return ret.GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// int types_2(int, unsigned int, long, unsigned long)
|
2020-09-02 23:46:48 +08:00
|
|
|
absl::StatusOr<int> types_2(int a0, unsigned int a1, long a2, unsigned long a3) {
|
2019-03-19 00:21:48 +08:00
|
|
|
::sapi::v::Int ret;
|
|
|
|
::sapi::v::Int a0_((a0));
|
|
|
|
::sapi::v::UInt a1_((a1));
|
|
|
|
::sapi::v::Long a2_((a2));
|
|
|
|
::sapi::v::ULong a3_((a3));
|
|
|
|
|
|
|
|
SAPI_RETURN_IF_ERROR(sandbox_->Call("types_2", &ret, &a0_, &a1_, &a2_, &a3_));
|
|
|
|
return ret.GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// int types_3(long long, unsigned long long, float, double)
|
2020-09-02 23:46:48 +08:00
|
|
|
absl::StatusOr<int> types_3(long long a0, unsigned long long a1, float a2, double a3) {
|
2019-03-19 00:21:48 +08:00
|
|
|
::sapi::v::Int ret;
|
|
|
|
::sapi::v::LLong a0_((a0));
|
|
|
|
::sapi::v::ULLong a1_((a1));
|
|
|
|
::sapi::v::Reg<float> a2_((a2));
|
|
|
|
::sapi::v::Reg<double> a3_((a3));
|
|
|
|
|
|
|
|
SAPI_RETURN_IF_ERROR(sandbox_->Call("types_3", &ret, &a0_, &a1_, &a2_, &a3_));
|
|
|
|
return ret.GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// int types_4(signed char, short, int, long)
|
2020-09-02 23:46:48 +08:00
|
|
|
absl::StatusOr<int> types_4(signed char a0, short a1, int a2, long a3) {
|
2019-03-19 00:21:48 +08:00
|
|
|
::sapi::v::Int ret;
|
|
|
|
::sapi::v::SChar a0_((a0));
|
|
|
|
::sapi::v::Short a1_((a1));
|
|
|
|
::sapi::v::Int a2_((a2));
|
|
|
|
::sapi::v::Long a3_((a3));
|
|
|
|
|
|
|
|
SAPI_RETURN_IF_ERROR(sandbox_->Call("types_4", &ret, &a0_, &a1_, &a2_, &a3_));
|
|
|
|
return ret.GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// int types_5(long long, long double)
|
2020-09-02 23:46:48 +08:00
|
|
|
absl::StatusOr<int> types_5(long long a0, long double a1) {
|
2019-03-19 00:21:48 +08:00
|
|
|
::sapi::v::Int ret;
|
|
|
|
::sapi::v::LLong a0_((a0));
|
|
|
|
::sapi::v::Reg<long double> a1_((a1));
|
|
|
|
|
|
|
|
SAPI_RETURN_IF_ERROR(sandbox_->Call("types_5", &ret, &a0_, &a1_));
|
|
|
|
return ret.GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
// void types_6(char *)
|
2020-02-28 01:23:44 +08:00
|
|
|
absl::Status types_6(::sapi::v::Ptr* a0) {
|
2019-03-19 00:21:48 +08:00
|
|
|
::sapi::v::Void ret;
|
|
|
|
|
|
|
|
SAPI_RETURN_IF_ERROR(sandbox_->Call("types_6", &ret, a0));
|
2020-02-28 01:23:44 +08:00
|
|
|
return absl::OkStatus();
|
2019-03-19 00:21:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
::sapi::Sandbox* sandbox_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Tests
|
|
|
|
} // namespace sapi
|
|
|
|
"""
|
|
|
|
|
|
|
|
CODE_GOLD_MAPPED = """// AUTO-GENERATED by the Sandboxed API generator.
|
|
|
|
// Edits will be discarded when regenerating this file.
|
|
|
|
|
2021-01-05 23:18:13 +08:00
|
|
|
#include "absl/status/status.h"
|
|
|
|
#include "absl/status/statusor.h"
|
2019-03-19 00:21:48 +08:00
|
|
|
#include "sandboxed_api/sandbox.h"
|
2021-01-05 23:18:13 +08:00
|
|
|
#include "sandboxed_api/util/status_macros.h"
|
2019-03-19 00:21:48 +08:00
|
|
|
#include "sandboxed_api/vars.h"
|
|
|
|
|
|
|
|
namespace sapi {
|
|
|
|
namespace Tests {
|
|
|
|
|
|
|
|
typedef unsigned int uint;
|
|
|
|
typedef uint * uintp;
|
|
|
|
|
|
|
|
class TestApi {
|
|
|
|
public:
|
|
|
|
explicit TestApi(::sapi::Sandbox* sandbox) : sandbox_(sandbox) {}
|
2019-07-26 22:46:43 +08:00
|
|
|
// Deprecated
|
|
|
|
::sapi::Sandbox* GetSandbox() const { return sandbox(); }
|
|
|
|
::sapi::Sandbox* sandbox() const { return sandbox_; }
|
2019-03-19 00:21:48 +08:00
|
|
|
|
|
|
|
// uint function(uintp)
|
2020-09-02 23:46:48 +08:00
|
|
|
absl::StatusOr<uint> function(::sapi::v::Ptr* a) {
|
2019-03-19 00:21:48 +08:00
|
|
|
::sapi::v::UInt ret;
|
|
|
|
|
|
|
|
SAPI_RETURN_IF_ERROR(sandbox_->Call("function", &ret, a));
|
|
|
|
return ret.GetValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
::sapi::Sandbox* sandbox_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Tests
|
|
|
|
} // namespace sapi
|
|
|
|
"""
|
|
|
|
|
|
|
|
CODE_ENUM_GOLD = """// AUTO-GENERATED by the Sandboxed API generator.
|
|
|
|
// Edits will be discarded when regenerating this file.
|
|
|
|
|
2021-01-05 23:18:13 +08:00
|
|
|
#include "absl/status/status.h"
|
|
|
|
#include "absl/status/statusor.h"
|
2019-03-19 00:21:48 +08:00
|
|
|
#include "sandboxed_api/sandbox.h"
|
2021-01-05 23:18:13 +08:00
|
|
|
#include "sandboxed_api/util/status_macros.h"
|
2019-03-19 00:21:48 +08:00
|
|
|
#include "sandboxed_api/vars.h"
|
|
|
|
|
|
|
|
namespace sapi {
|
|
|
|
namespace Tests {
|
|
|
|
|
|
|
|
enum ProcessStatus {
|
|
|
|
\tOK = 0 ,
|
|
|
|
\tERROR = 1 ,
|
|
|
|
};
|
|
|
|
|
|
|
|
class TestApi {
|
|
|
|
public:
|
|
|
|
explicit TestApi(::sapi::Sandbox* sandbox) : sandbox_(sandbox) {}
|
2019-07-26 22:46:43 +08:00
|
|
|
// Deprecated
|
|
|
|
::sapi::Sandbox* GetSandbox() const { return sandbox(); }
|
|
|
|
::sapi::Sandbox* sandbox() const { return sandbox_; }
|
2019-03-19 00:21:48 +08:00
|
|
|
|
|
|
|
// ProcessStatus ProcessDatapoint(ProcessStatus)
|
2020-09-02 23:46:48 +08:00
|
|
|
absl::StatusOr<ProcessStatus> ProcessDatapoint(ProcessStatus status) {
|
2019-03-19 00:21:48 +08:00
|
|
|
::sapi::v::IntBase<ProcessStatus> ret;
|
|
|
|
::sapi::v::IntBase<ProcessStatus> status_((status));
|
|
|
|
|
|
|
|
SAPI_RETURN_IF_ERROR(sandbox_->Call("ProcessDatapoint", &ret, &status_));
|
|
|
|
return static_cast<ProcessStatus>(ret.GetValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
::sapi::Sandbox* sandbox_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Tests
|
|
|
|
} // namespace sapi
|
|
|
|
"""
|