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

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

Issue 1269443002: Introduce FlexibleArrayBufferView and TypedFlexibleArrayBufferView (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed typo Created 5 years, 4 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
« no previous file with comments | « Source/bindings/core/v8/V8Binding.cpp ('k') | Source/bindings/scripts/v8_types.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 28 matching lines...) Expand all
39 #define TOSTRING_VOID(type, var, value) \ 39 #define TOSTRING_VOID(type, var, value) \
40 type var(value); \ 40 type var(value); \
41 if (UNLIKELY(!var.prepare())) \ 41 if (UNLIKELY(!var.prepare())) \
42 return; 42 return;
43 43
44 #define TOSTRING_DEFAULT(type, var, value, retVal) \ 44 #define TOSTRING_DEFAULT(type, var, value, retVal) \
45 type var(value); \ 45 type var(value); \
46 if (UNLIKELY(!var.prepare())) \ 46 if (UNLIKELY(!var.prepare())) \
47 return retVal; 47 return retVal;
48 48
49 // Checks for a given v8::Value (value) whether it is an ArrayBufferView and
50 // below a certain size limit. If below the limit, memory is allocated on the
51 // stack to hold the actual payload. Keep the limit in sync with V8's
52 // typed_array_max_size.
53 #define allocateFlexibleArrayBufferViewStorage(value) \
54 (value->IsArrayBufferView() && (value.As<v8::ArrayBufferView>()->ByteLength( ) <= 64) ? \
55 alloca(value.As<v8::ArrayBufferView>()->ByteLength()) : nullptr)
56
49 template <typename T> 57 template <typename T>
50 inline bool v8Call(v8::Maybe<T> maybe, T& outVariable) 58 inline bool v8Call(v8::Maybe<T> maybe, T& outVariable)
51 { 59 {
52 if (maybe.IsNothing()) 60 if (maybe.IsNothing())
53 return false; 61 return false;
54 outVariable = maybe.FromJust(); 62 outVariable = maybe.FromJust();
55 return true; 63 return true;
56 } 64 }
57 65
58 inline bool v8CallBoolean(v8::Maybe<bool> maybe) 66 inline bool v8CallBoolean(v8::Maybe<bool> maybe)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 99
92 // The last "else" is to avoid dangling else problem. 100 // The last "else" is to avoid dangling else problem.
93 #define V8_CALL(outVariable, handle, methodCall, failureExpression) \ 101 #define V8_CALL(outVariable, handle, methodCall, failureExpression) \
94 if (handle.IsEmpty() || !v8Call(handle->methodCall, outVariable)) { \ 102 if (handle.IsEmpty() || !v8Call(handle->methodCall, outVariable)) { \
95 failureExpression; \ 103 failureExpression; \
96 } else 104 } else
97 105
98 } // namespace blink 106 } // namespace blink
99 107
100 #endif // V8BindingMacros_h 108 #endif // V8BindingMacros_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8Binding.cpp ('k') | Source/bindings/scripts/v8_types.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698