OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |