Skip to content

Commit

Permalink
bind-gen: Implements NVT<IDLNullable<new IDL unions>>
Browse files Browse the repository at this point in the history
Implements NativeValueTraits for new nullable IDL unions.

Bug: 839389
Change-Id: Ib206f7e1d27c0e0f1c9847bbd7b3188851592586
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2726013
Reviewed-by: Hitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#858456}
  • Loading branch information
yuki3 authored and Chromium LUCI CQ committed Mar 1, 2021
1 parent e0b2d82 commit e2122c2
Showing 1 changed file with 14 additions and 0 deletions.
Expand Up @@ -1330,6 +1330,20 @@ struct NativeValueTraits<
}
};

template <typename T>
struct NativeValueTraits<
IDLNullable<T>,
typename std::enable_if_t<std::is_base_of<bindings::UnionBase, T>::value>>
: public NativeValueTraitsBase<T*> {
static T* NativeValue(v8::Isolate* isolate,
v8::Local<v8::Value> value,
ExceptionState& exception_state) {
if (value->IsNullOrUndefined())
return nullptr;
return T::Create(isolate, value, exception_state);
}
};

// Migration Adapters: union types generated by the old bindings generator.
template <typename T>
struct NativeValueTraits<IDLUnionNotINT<T>> : public NativeValueTraitsBase<T> {
Expand Down

0 comments on commit e2122c2

Please sign in to comment.