2018-07-18 09:40:26 +00:00
|
|
|
//* Copyright 2017 The Dawn Authors
|
2017-04-20 18:38:20 +00: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.
|
|
|
|
|
2018-12-08 10:35:53 +00:00
|
|
|
#include "mock_dawn.h"
|
2017-04-20 18:38:20 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
{% for type in by_category["object"] %}
|
2017-05-09 14:56:10 +00:00
|
|
|
{% for method in native_methods(type) if len(method.arguments) < 10 %}
|
2017-04-20 18:38:20 +00:00
|
|
|
{{as_cType(method.return_type.name)}} Forward{{as_MethodSuffix(type.name, method.name)}}(
|
|
|
|
{{-as_cType(type.name)}} self
|
|
|
|
{%- for arg in method.arguments -%}
|
|
|
|
, {{as_annotated_cType(arg)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
) {
|
2017-05-16 20:05:51 +00:00
|
|
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
|
|
|
return object->procs->{{as_MethodSuffix(type.name, method.name)}}(self
|
2017-04-20 18:38:20 +00:00
|
|
|
{%- for arg in method.arguments -%}
|
|
|
|
, {{as_varName(arg.name)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% endfor %}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcTableAsClass::~ProcTableAsClass() {
|
|
|
|
}
|
|
|
|
|
2019-03-11 16:52:42 +00:00
|
|
|
void ProcTableAsClass::GetProcTableAndDevice(DawnProcTable* table, DawnDevice* device) {
|
2017-04-20 18:38:20 +00:00
|
|
|
*device = GetNewDevice();
|
|
|
|
|
|
|
|
{% for type in by_category["object"] %}
|
2017-05-09 14:56:10 +00:00
|
|
|
{% for method in native_methods(type) if len(method.arguments) < 10 %}
|
2017-04-20 18:38:20 +00:00
|
|
|
table->{{as_varName(type.name, method.name)}} = reinterpret_cast<{{as_cProc(type.name, method.name)}}>(Forward{{as_MethodSuffix(type.name, method.name)}});
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
}
|
|
|
|
|
2019-03-11 16:52:42 +00:00
|
|
|
void ProcTableAsClass::DeviceSetErrorCallback(DawnDevice self, DawnDeviceErrorCallback callback, DawnCallbackUserdata userdata) {
|
2017-05-16 20:05:51 +00:00
|
|
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
|
|
|
object->deviceErrorCallback = callback;
|
|
|
|
object->userdata1 = userdata;
|
|
|
|
|
2017-11-23 21:04:26 +00:00
|
|
|
OnDeviceSetErrorCallback(self, callback, userdata);
|
2017-05-16 20:05:51 +00:00
|
|
|
}
|
|
|
|
|
2019-03-11 16:52:42 +00:00
|
|
|
void ProcTableAsClass::BufferMapReadAsync(DawnBuffer self, DawnBufferMapReadCallback callback, DawnCallbackUserdata userdata) {
|
2017-06-09 14:51:29 +00:00
|
|
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
|
|
|
object->mapReadCallback = callback;
|
|
|
|
object->userdata1 = userdata;
|
|
|
|
|
2019-02-14 19:31:17 +00:00
|
|
|
OnBufferMapReadAsyncCallback(self, callback, userdata);
|
2017-06-09 14:51:29 +00:00
|
|
|
}
|
|
|
|
|
2019-03-11 16:52:42 +00:00
|
|
|
void ProcTableAsClass::BufferMapWriteAsync(DawnBuffer self, DawnBufferMapWriteCallback callback, DawnCallbackUserdata userdata) {
|
2018-03-21 00:56:39 +00:00
|
|
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
|
|
|
object->mapWriteCallback = callback;
|
|
|
|
object->userdata1 = userdata;
|
|
|
|
|
2019-02-14 19:31:17 +00:00
|
|
|
OnBufferMapWriteAsyncCallback(self, callback, userdata);
|
2018-03-21 00:56:39 +00:00
|
|
|
}
|
|
|
|
|
2019-03-11 16:52:42 +00:00
|
|
|
void ProcTableAsClass::FenceOnCompletion(DawnFence self,
|
2018-12-03 16:57:34 +00:00
|
|
|
uint64_t value,
|
2019-03-11 16:52:42 +00:00
|
|
|
DawnFenceOnCompletionCallback callback,
|
|
|
|
DawnCallbackUserdata userdata) {
|
2018-12-03 16:57:34 +00:00
|
|
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
|
|
|
object->fenceOnCompletionCallback = callback;
|
|
|
|
object->userdata1 = userdata;
|
|
|
|
|
|
|
|
OnFenceOnCompletionCallback(self, value, callback, userdata);
|
|
|
|
}
|
|
|
|
|
2019-03-11 16:52:42 +00:00
|
|
|
void ProcTableAsClass::CallDeviceErrorCallback(DawnDevice device, const char* message) {
|
2017-05-17 15:16:00 +00:00
|
|
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(device);
|
|
|
|
object->deviceErrorCallback(message, object->userdata1);
|
|
|
|
}
|
2019-03-11 16:52:42 +00:00
|
|
|
void ProcTableAsClass::CallBuilderErrorCallback(void* builder , DawnBuilderErrorStatus status, const char* message) {
|
2017-05-17 15:16:00 +00:00
|
|
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(builder);
|
|
|
|
object->builderErrorCallback(status, message, object->userdata1, object->userdata2);
|
|
|
|
}
|
2019-03-11 16:52:42 +00:00
|
|
|
void ProcTableAsClass::CallMapReadCallback(DawnBuffer buffer, DawnBufferMapAsyncStatus status, const void* data, uint32_t dataLength) {
|
2017-06-09 14:51:29 +00:00
|
|
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
2019-02-14 19:31:17 +00:00
|
|
|
object->mapReadCallback(status, data, dataLength, object->userdata1);
|
2017-06-09 14:51:29 +00:00
|
|
|
}
|
2017-05-17 15:16:00 +00:00
|
|
|
|
2019-03-11 16:52:42 +00:00
|
|
|
void ProcTableAsClass::CallMapWriteCallback(DawnBuffer buffer, DawnBufferMapAsyncStatus status, void* data, uint32_t dataLength) {
|
2018-03-21 00:56:39 +00:00
|
|
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
|
2019-02-14 19:31:17 +00:00
|
|
|
object->mapWriteCallback(status, data, dataLength, object->userdata1);
|
2018-03-21 00:56:39 +00:00
|
|
|
}
|
|
|
|
|
2019-03-11 16:52:42 +00:00
|
|
|
void ProcTableAsClass::CallFenceOnCompletionCallback(DawnFence fence,
|
|
|
|
DawnFenceCompletionStatus status) {
|
2018-12-03 16:57:34 +00:00
|
|
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(fence);
|
|
|
|
object->fenceOnCompletionCallback(status, object->userdata1);
|
|
|
|
}
|
|
|
|
|
2017-05-16 20:05:51 +00:00
|
|
|
{% for type in by_category["object"] if type.is_builder %}
|
2019-03-11 16:52:42 +00:00
|
|
|
void ProcTableAsClass::{{as_MethodSuffix(type.name, Name("set error callback"))}}({{as_cType(type.name)}} self, DawnBuilderErrorCallback callback, DawnCallbackUserdata userdata1, DawnCallbackUserdata userdata2) {
|
2017-05-16 20:05:51 +00:00
|
|
|
auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
|
|
|
|
object->builderErrorCallback = callback;
|
|
|
|
object->userdata1 = userdata1;
|
|
|
|
object->userdata2 = userdata2;
|
|
|
|
|
2019-03-11 16:52:42 +00:00
|
|
|
OnBuilderSetErrorCallback(reinterpret_cast<DawnBufferBuilder>(self), callback, userdata1, userdata2);
|
2017-05-16 20:05:51 +00:00
|
|
|
}
|
|
|
|
{% endfor %}
|
|
|
|
|
2017-04-20 18:38:20 +00:00
|
|
|
{% for type in by_category["object"] %}
|
|
|
|
{{as_cType(type.name)}} ProcTableAsClass::GetNew{{type.name.CamelCase()}}() {
|
2017-11-23 21:04:26 +00:00
|
|
|
mObjects.emplace_back(new Object);
|
|
|
|
mObjects.back()->procs = this;
|
|
|
|
return reinterpret_cast<{{as_cType(type.name)}}>(mObjects.back().get());
|
2017-04-20 18:38:20 +00:00
|
|
|
}
|
|
|
|
{% endfor %}
|
2018-08-22 13:37:29 +00:00
|
|
|
|
|
|
|
MockProcTable::MockProcTable() {
|
|
|
|
}
|