mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 13:38:00 +00:00
Wire: Add support for nullptr objects as arguments
BUG=dawn:5 Change-Id: I84c80796e9bdfbcf59fafdd38d33ab2101a1d795 Reviewed-on: https://dawn-review.googlesource.com/1541 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
82fbccbd78
commit
386b8889bd
@@ -215,6 +215,9 @@ namespace dawn_wire {
|
||||
// Implementation of the ObjectIdProvider interface
|
||||
{% for type in by_category["object"] %}
|
||||
ObjectId GetId({{as_cType(type.name)}} object) const override {
|
||||
if (object == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return reinterpret_cast<{{as_wireType(type)}}>(object)->id;
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
@@ -358,6 +358,11 @@ namespace dawn_wire {
|
||||
// Implementation of the ObjectIdResolver interface
|
||||
{% for type in by_category["object"] %}
|
||||
DeserializeResult GetFromId(ObjectId id, {{as_cType(type.name)}}* out) const override {
|
||||
if (id == 0) {
|
||||
*out = nullptr;
|
||||
return DeserializeResult::Success;
|
||||
}
|
||||
|
||||
auto data = mKnown{{type.name.CamelCase()}}.Get(id);
|
||||
if (data == nullptr) {
|
||||
return DeserializeResult::FatalError;
|
||||
|
||||
Reference in New Issue
Block a user