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 { \ |
99 return; | 125 v8::TryCatch block; \ |
| 126 var.prepare(); \ |
| 127 if (UNLIKELY(block.HasCaught())) { \ |
| 128 block.ReThrow(); \ |
| 129 return; \ |
| 130 } \ |
| 131 } |
100 | 132 |
101 #define TOSTRING_BOOL(type, var, value, retVal) \ | 133 #define TOSTRING_BOOL(type, var, value, retVal) \ |
102 type var(value); \ | 134 type var(value); \ |
103 if (UNLIKELY(!var.prepare())) \ | 135 { \ |
104 return retVal; | 136 v8::TryCatch block; \ |
| 137 var.prepare(); \ |
| 138 if (UNLIKELY(block.HasCaught())) { \ |
| 139 block.ReThrow(); \ |
| 140 return retVal; \ |
| 141 } \ |
| 142 } |
| 143 |
| 144 #define TOSTRING_VOID_ASYNC(type, var, value, info)
\ |
| 145 type var(value);
\ |
| 146 {
\ |
| 147 v8::TryCatch block;
\ |
| 148 var.prepare();
\ |
| 149 if (UNLIKELY(block.HasCaught())) {
\ |
| 150 v8::Isolate* isolate = info.GetIsolate();
\ |
| 151 ScriptPromise promise = ScriptPromise::reject(block.Exception(), iso
late); \ |
| 152 v8SetReturnValue(info, promise.v8Value());
\ |
| 153 return;
\ |
| 154 }
\ |
| 155 } |
105 | 156 |
106 } // namespace WebCore | 157 } // namespace WebCore |
107 | 158 |
108 #endif // V8BindingMacros_h | 159 #endif // V8BindingMacros_h |
OLD | NEW |