| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #ifndef V8BindingMacros_h | 31 #ifndef V8BindingMacros_h |
| 32 #define V8BindingMacros_h | 32 #define V8BindingMacros_h |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 // Naming scheme: | 36 // Naming scheme: |
| 37 // TO*_RETURNTYPE[_ARGTYPE]... | 37 // TO*_RETURNTYPE[_ARGTYPE]... |
| 38 // ...using _DEFAULT instead of _ANY..._ANY when returing a default value. | 38 // ...using _DEFAULT instead of _ANY..._ANY when returing a default value. |
| 39 | 39 |
| 40 #define TONATIVE_EXCEPTION(type, var, value) \ | |
| 41 type var; \ | |
| 42 { \ | |
| 43 v8::TryCatch block; \ | |
| 44 var = (value); \ | |
| 45 if (UNLIKELY(block.HasCaught())) \ | |
| 46 return block.ReThrow(); \ | |
| 47 } | |
| 48 | |
| 49 #define TONATIVE_VOID_INTERNAL(var, value) \ | |
| 50 var = (value); \ | |
| 51 if (UNLIKELY(block.HasCaught())) \ | |
| 52 return; | |
| 53 | |
| 54 #define TONATIVE_VOID(type, var, value) \ | 40 #define TONATIVE_VOID(type, var, value) \ |
| 55 type var; \ | 41 type var; \ |
| 56 { \ | 42 { \ |
| 57 v8::TryCatch block; \ | 43 v8::TryCatch block; \ |
| 58 V8RethrowTryCatchScope rethrow(block); \ | 44 var = (value); \ |
| 59 TONATIVE_VOID_INTERNAL(var, value); \ | 45 if (UNLIKELY(block.HasCaught())) { \ |
| 46 block.ReThrow(); \ |
| 47 return; \ |
| 48 } \ |
| 60 } | 49 } |
| 61 | 50 |
| 62 #define TONATIVE_DEFAULT(type, var, value, retVal) \ | 51 #define TONATIVE_DEFAULT(type, var, value, retVal) \ |
| 63 type var; \ | 52 type var; \ |
| 64 { \ | 53 { \ |
| 65 v8::TryCatch block; \ | 54 v8::TryCatch block; \ |
| 66 var = (value); \ | 55 var = (value); \ |
| 67 if (UNLIKELY(block.HasCaught())) { \ | 56 if (UNLIKELY(block.HasCaught())) { \ |
| 68 block.ReThrow(); \ | 57 block.ReThrow(); \ |
| 69 return retVal; \ | 58 return retVal; \ |
| 70 } \ | 59 } \ |
| 71 } | 60 } |
| 72 | 61 |
| 73 // We need to cancel the exception propergation when we return a rejected | |
| 74 // Promise. | |
| 75 #define TONATIVE_VOID_PROMISE_INTERNAL(var, value, info)
\ | |
| 76 var = (value);
\ | |
| 77 if (UNLIKELY(block.HasCaught())) {
\ | |
| 78 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), block
.Exception())); \ | |
| 79 block.Reset();
\ | |
| 80 return;
\ | |
| 81 } | |
| 82 | |
| 83 #define TONATIVE_VOID_PROMISE(type, var, value, info) \ | |
| 84 type var; \ | |
| 85 { \ | |
| 86 v8::TryCatch block; \ | |
| 87 TONATIVE_VOID_PROMISE_INTERNAL(var, value, info); \ | |
| 88 } | |
| 89 | |
| 90 | |
| 91 #define TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState) \ | |
| 92 var = (value); \ | |
| 93 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | |
| 94 return; \ | |
| 95 | |
| 96 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ | 62 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ |
| 97 type var; \ | 63 type var(value); \ |
| 98 var = (value); \ | |
| 99 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | 64 if (UNLIKELY(exceptionState.throwIfNeeded())) \ |
| 100 return; | 65 return; |
| 101 | 66 |
| 102 #define TONATIVE_VOID_EXCEPTIONSTATE_ARGINTERNAL(value, exceptionState) \ | |
| 103 (value); \ | |
| 104 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | |
| 105 return; | |
| 106 | |
| 107 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal
) \ | |
| 108 type var = (value);
\ | |
| 109 if (UNLIKELY(exceptionState.throwIfNeeded()))
\ | |
| 110 return retVal; | |
| 111 | |
| 112 // We need to cancel the exception propergation when we return a rejected | |
| 113 // Promise. | |
| 114 #define TONATIVE_VOID_EXCEPTIONSTATE_PROMISE_INTERNAL(var, value, exceptionState
, info, scriptState) \ | |
| 115 var = (value);
\ | |
| 116 if (UNLIKELY(exceptionState.hadException())) {
\ | |
| 117 v8SetReturnValue(info, exceptionState.reject(scriptState).v8Value());
\ | |
| 118 return;
\ | |
| 119 } | |
| 120 | |
| 121 #define TONATIVE_VOID_EXCEPTIONSTATE_PROMISE(type, var, value, exceptionState, i
nfo, scriptState) \ | |
| 122 type var;
\ | |
| 123 TONATIVE_VOID_EXCEPTIONSTATE_PROMISE_INTERNAL(var, value, exceptionState, in
fo, scriptState); | |
| 124 | |
| 125 // type is an instance of class template V8StringResource<>, | 67 // type is an instance of class template V8StringResource<>, |
| 126 // but Mode argument varies; using type (not Mode) for consistency | 68 // but Mode argument varies; using type (not Mode) for consistency |
| 127 // with other macros and ease of code generation | 69 // with other macros and ease of code generation |
| 128 #define TOSTRING_VOID(type, var, value) \ | 70 #define TOSTRING_VOID(type, var, value) \ |
| 129 type var(value); \ | 71 type var(value); \ |
| 130 if (UNLIKELY(!var.prepare())) \ | 72 if (UNLIKELY(!var.prepare())) \ |
| 131 return; | 73 return; |
| 132 | 74 |
| 133 #define TOSTRING_VOID_INTERNAL(var, value) \ | |
| 134 var = (value); \ | |
| 135 if (UNLIKELY(!var.prepare())) \ | |
| 136 return; | |
| 137 | |
| 138 #define TOSTRING_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ | |
| 139 type var(value); \ | |
| 140 if (UNLIKELY(!var.prepare(exceptionState))) \ | |
| 141 return; | |
| 142 | |
| 143 #define TOSTRING_DEFAULT(type, var, value, retVal) \ | 75 #define TOSTRING_DEFAULT(type, var, value, retVal) \ |
| 144 type var(value); \ | 76 type var(value); \ |
| 145 if (UNLIKELY(!var.prepare())) \ | 77 if (UNLIKELY(!var.prepare())) \ |
| 146 return retVal; | 78 return retVal; |
| 147 | 79 |
| 148 // We need to cancel the exception propagation when we return a rejected | |
| 149 // Promise. | |
| 150 #define TOSTRING_VOID_EXCEPTIONSTATE_PROMISE_INTERNAL(var, value, exceptionState
, info, scriptState) \ | |
| 151 var = (value);
\ | |
| 152 if (UNLIKELY(!var.prepare(exceptionState))) {
\ | |
| 153 v8SetReturnValue(info, exceptionState.reject(scriptState).v8Value());
\ | |
| 154 return;
\ | |
| 155 } | |
| 156 | |
| 157 } // namespace blink | 80 } // namespace blink |
| 158 | 81 |
| 159 #endif // V8BindingMacros_h | 82 #endif // V8BindingMacros_h |
| OLD | NEW |