Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h

Issue 2836093004: Remove V8Call and replace with v8::Maybe<T>::To and v8::MaybeLocal<T>::ToLocal. (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // Checks for a given v8::Value (value) whether it is an ArrayBufferView and 52 // Checks for a given v8::Value (value) whether it is an ArrayBufferView and
53 // below a certain size limit. If below the limit, memory is allocated on the 53 // below a certain size limit. If below the limit, memory is allocated on the
54 // stack to hold the actual payload. Keep the limit in sync with V8's 54 // stack to hold the actual payload. Keep the limit in sync with V8's
55 // typed_array_max_size. 55 // typed_array_max_size.
56 #define allocateFlexibleArrayBufferViewStorage(value) \ 56 #define allocateFlexibleArrayBufferViewStorage(value) \
57 (value->IsArrayBufferView() && \ 57 (value->IsArrayBufferView() && \
58 (value.As<v8::ArrayBufferView>()->ByteLength() <= 64) \ 58 (value.As<v8::ArrayBufferView>()->ByteLength() <= 64) \
59 ? alloca(value.As<v8::ArrayBufferView>()->ByteLength()) \ 59 ? alloca(value.As<v8::ArrayBufferView>()->ByteLength()) \
60 : nullptr) 60 : nullptr)
61 61
62 // DEPRECATED: These v8Call macros are deprecated.
63 // Use To/ToLocal/ToChecked/ToLocalChecked instead.
64 // TODO(haraken): Remove these macros.
65 template <typename T>
66 inline bool V8Call(v8::Maybe<T> maybe, T& out_variable) {
67 if (maybe.IsNothing())
68 return false;
69 out_variable = maybe.FromJust();
70 return true;
71 }
72
73 // DEPRECATED 62 // DEPRECATED
74 inline bool V8CallBoolean(v8::Maybe<bool> maybe) { 63 inline bool V8CallBoolean(v8::Maybe<bool> maybe) {
75 bool result; 64 bool result;
76 return V8Call(maybe, result) && result; 65 return maybe.To(&result) && result;
77 }
78
79 // DEPRECATED
80 template <typename T>
81 inline bool V8Call(v8::Maybe<T> maybe,
82 T& out_variable,
83 v8::TryCatch& try_catch) {
84 bool success = V8Call(maybe, out_variable);
85 DCHECK(success || try_catch.HasCaught());
86 return success;
87 }
88
89 // DEPRECATED
90 template <typename T>
91 inline bool V8Call(v8::MaybeLocal<T> maybe_local, v8::Local<T>& out_variable) {
92 return maybe_local.ToLocal(&out_variable);
93 }
94
95 // DEPRECATED
96 template <typename T>
97 inline bool V8Call(v8::MaybeLocal<T> maybe_local,
98 v8::Local<T>& out_variable,
99 v8::TryCatch& try_catch) {
100 bool success = maybe_local.ToLocal(&out_variable);
101 DCHECK(success || try_catch.HasCaught());
102 return success;
103 } 66 }
104 67
105 } // namespace blink 68 } // namespace blink
106 69
107 #endif // V8BindingMacros_h 70 #endif // V8BindingMacros_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698