| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 type var; \ | 50 type var; \ |
| 51 { \ | 51 { \ |
| 52 v8::TryCatch block; \ | 52 v8::TryCatch block; \ |
| 53 var = (value); \ | 53 var = (value); \ |
| 54 if (UNLIKELY(block.HasCaught())) { \ | 54 if (UNLIKELY(block.HasCaught())) { \ |
| 55 block.ReThrow(); \ | 55 block.ReThrow(); \ |
| 56 return; \ | 56 return; \ |
| 57 } \ | 57 } \ |
| 58 } | 58 } |
| 59 | 59 |
| 60 #define TONATIVE_VOID_ASYNC(type, var, value, info)
\ |
| 61 type var;
\ |
| 62 {
\ |
| 63 v8::TryCatch block;
\ |
| 64 var = (value);
\ |
| 65 if (UNLIKELY(block.HasCaught())) {
\ |
| 66 v8::Isolate* isolate = info.GetIsolate();
\ |
| 67 ScriptPromise promise = ScriptPromise::reject(block.Exception(), iso
late); \ |
| 68 v8SetReturnValue(info, promise.v8Value());
\ |
| 69 return;
\ |
| 70 }
\ |
| 71 } |
| 72 |
| 60 #define TONATIVE_BOOL(type, var, value, retVal) \ | 73 #define TONATIVE_BOOL(type, var, value, retVal) \ |
| 61 type var; \ | 74 type var; \ |
| 62 { \ | 75 { \ |
| 63 v8::TryCatch block; \ | 76 v8::TryCatch block; \ |
| 64 var = (value); \ | 77 var = (value); \ |
| 65 if (UNLIKELY(block.HasCaught())) { \ | 78 if (UNLIKELY(block.HasCaught())) { \ |
| 66 block.ReThrow(); \ | 79 block.ReThrow(); \ |
| 67 return retVal; \ | 80 return retVal; \ |
| 68 } \ | 81 } \ |
| 69 } | 82 } |
| 70 | 83 |
| 71 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ | 84 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ |
| 72 type var; \ | 85 type var; \ |
| 73 { \ | 86 { \ |
| 74 v8::TryCatch block; \ | 87 v8::TryCatch block; \ |
| 75 var = (value); \ | 88 var = (value); \ |
| 76 if (UNLIKELY(block.HasCaught())) \ | 89 if (UNLIKELY(block.HasCaught())) \ |
| 77 exceptionState.rethrowV8Exception(block.Exception()); \ | 90 exceptionState.rethrowV8Exception(block.Exception()); \ |
| 78 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | 91 if (UNLIKELY(exceptionState.throwIfNeeded())) \ |
| 79 return; \ | 92 return; \ |
| 80 } | 93 } |
| 81 | 94 |
| 95 #define TONATIVE_VOID_EXCEPTIONSTATE_ASYNC(type, var, value, exceptionState, inf
o) \ |
| 96 type var;
\ |
| 97 {
\ |
| 98 v8::TryCatch block;
\ |
| 99 var = (value);
\ |
| 100 if (UNLIKELY(block.HasCaught()))
\ |
| 101 exceptionState.rethrowV8Exception(block.Exception());
\ |
| 102 if (UNLIKELY(exceptionState.hadException())) {
\ |
| 103 v8SetReturnValue(info, exceptionState.reject().v8Value());
\ |
| 104 return;
\ |
| 105 }
\ |
| 106 } |
| 107 |
| 82 #define TONATIVE_BOOL_EXCEPTIONSTATE(type, var, value, exceptionState, retVal) \ | 108 #define TONATIVE_BOOL_EXCEPTIONSTATE(type, var, value, exceptionState, retVal) \ |
| 83 type var; \ | 109 type var; \ |
| 84 { \ | 110 { \ |
| 85 v8::TryCatch block; \ | 111 v8::TryCatch block; \ |
| 86 var = (value); \ | 112 var = (value); \ |
| 87 if (UNLIKELY(block.HasCaught())) \ | 113 if (UNLIKELY(block.HasCaught())) \ |
| 88 exceptionState.rethrowV8Exception(block.Exception()); \ | 114 exceptionState.rethrowV8Exception(block.Exception()); \ |
| 89 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | 115 if (UNLIKELY(exceptionState.throwIfNeeded())) \ |
| 90 return retVal; \ | 116 return retVal; \ |
| 91 } | 117 } |
| 92 | 118 |
| 93 // type is an instance of class template V8StringResource<>, | 119 // type is an instance of class template V8StringResource<>, |
| 94 // but Mode argument varies; using type (not Mode) for consistency | 120 // but Mode argument varies; using type (not Mode) for consistency |
| 95 // with other macros and ease of code generation | 121 // with other macros and ease of code generation |
| 96 #define TOSTRING_VOID(type, var, value) \ | 122 #define TOSTRING_VOID(type, var, value) \ |
| 97 type var(value); \ | 123 type var(value); \ |
| 98 if (UNLIKELY(!var.prepare())) \ | 124 if (UNLIKELY(!var.prepare())) \ |
| 99 return; | 125 return; |
| 100 | 126 |
| 101 #define TOSTRING_BOOL(type, var, value, retVal) \ | 127 #define TOSTRING_BOOL(type, var, value, retVal) \ |
| 102 type var(value); \ | 128 type var(value); \ |
| 103 if (UNLIKELY(!var.prepare())) \ | 129 if (UNLIKELY(!var.prepare())) \ |
| 104 return retVal; | 130 return retVal; |
| 105 | 131 |
| 132 #define TOSTRING_VOID_ASYNC(type, var, value, info)
\ |
| 133 type var(value);
\ |
| 134 {
\ |
| 135 v8::TryCatch block;
\ |
| 136 var.prepare();
\ |
| 137 if (UNLIKELY(block.HasCaught())) {
\ |
| 138 v8::Isolate* isolate = info.GetIsolate();
\ |
| 139 ScriptPromise promise = ScriptPromise::reject(block.Exception(), iso
late); \ |
| 140 v8SetReturnValue(info, promise.v8Value());
\ |
| 141 return;
\ |
| 142 }
\ |
| 143 } |
| 144 |
| 106 } // namespace WebCore | 145 } // namespace WebCore |
| 107 | 146 |
| 108 #endif // V8BindingMacros_h | 147 #endif // V8BindingMacros_h |
| OLD | NEW |