2019-01-30 02:31:37 +00:00
|
|
|
//* Copyright 2019 The Dawn Authors
|
|
|
|
//*
|
|
|
|
//* 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 DAWNWIRE_CLIENT_CLIENTBASE_AUTOGEN_H_
|
|
|
|
#define DAWNWIRE_CLIENT_CLIENTBASE_AUTOGEN_H_
|
|
|
|
|
2022-02-04 12:51:25 +00:00
|
|
|
#include "dawn/wire/ChunkedCommandHandler.h"
|
|
|
|
#include "dawn/wire/WireCmd_autogen.h"
|
|
|
|
#include "dawn/wire/client/ApiObjects.h"
|
2019-01-30 02:31:37 +00:00
|
|
|
|
2022-01-11 09:57:33 +00:00
|
|
|
namespace dawn::wire::client {
|
2019-01-30 02:31:37 +00:00
|
|
|
|
2020-10-13 22:35:34 +00:00
|
|
|
class ClientBase : public ChunkedCommandHandler, public ObjectIdProvider {
|
2019-01-30 02:31:37 +00:00
|
|
|
public:
|
2020-11-11 19:46:18 +00:00
|
|
|
ClientBase() = default;
|
2022-05-10 18:44:34 +00:00
|
|
|
~ClientBase() override = default;
|
2019-01-30 02:31:37 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Implementation of the ObjectIdProvider interface
|
|
|
|
{% for type in by_category["object"] %}
|
2021-09-10 20:36:20 +00:00
|
|
|
WireResult GetId({{as_cType(type.name)}} object, ObjectId* out) const final {
|
|
|
|
ASSERT(out != nullptr);
|
2019-01-30 02:31:37 +00:00
|
|
|
if (object == nullptr) {
|
2021-09-10 20:36:20 +00:00
|
|
|
return WireResult::FatalError;
|
2019-01-30 02:31:37 +00:00
|
|
|
}
|
2022-06-14 14:55:46 +00:00
|
|
|
*out = reinterpret_cast<{{as_wireType(type)}}>(object)->GetWireId();
|
2021-09-10 20:36:20 +00:00
|
|
|
return WireResult::Success;
|
|
|
|
}
|
|
|
|
WireResult GetOptionalId({{as_cType(type.name)}} object, ObjectId* out) const final {
|
|
|
|
ASSERT(out != nullptr);
|
2022-06-14 14:55:46 +00:00
|
|
|
*out = (object == nullptr ? 0 : reinterpret_cast<{{as_wireType(type)}}>(object)->GetWireId());
|
2021-09-10 20:36:20 +00:00
|
|
|
return WireResult::Success;
|
2019-01-30 02:31:37 +00:00
|
|
|
}
|
|
|
|
{% endfor %}
|
|
|
|
};
|
|
|
|
|
2022-01-11 09:57:33 +00:00
|
|
|
} // namespace dawn::wire::client
|
2019-01-30 02:31:37 +00:00
|
|
|
|
|
|
|
#endif // DAWNWIRE_CLIENT_CLIENTBASE_AUTOGEN_H_
|