| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef V8BindingMacros_h | 31 #ifndef V8BindingMacros_h |
| 32 #define V8BindingMacros_h | 32 #define V8BindingMacros_h |
| 33 | 33 |
| 34 namespace WebCore { | 34 namespace WebCore { |
| 35 | 35 |
| 36 // Naming scheme: | 36 // Naming scheme: |
| 37 // TO*_RETURNTYPE[_ARGTYPE]... | 37 // TO*_RETURNTYPE[_ARGTYPE]... |
| 38 // ...removing RETURNTYPE/ARGTYPE duplicate if an argument is simply returned | 38 // ...using _DEFAULT instead of _ANY..._ANY when returing a default value. |
| 39 | 39 |
| 40 #define TONATIVE_EXCEPTION(type, var, value) \ | 40 #define TONATIVE_EXCEPTION(type, var, value) \ |
| 41 type var; \ | 41 type var; \ |
| 42 { \ | 42 { \ |
| 43 v8::TryCatch block; \ | 43 v8::TryCatch block; \ |
| 44 var = (value); \ | 44 var = (value); \ |
| 45 if (UNLIKELY(block.HasCaught())) \ | 45 if (UNLIKELY(block.HasCaught())) \ |
| 46 return block.ReThrow(); \ | 46 return block.ReThrow(); \ |
| 47 } | 47 } |
| 48 | 48 |
| 49 #define TONATIVE_VOID(type, var, value) \ | 49 #define TONATIVE_VOID(type, var, value) \ |
| 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_BOOL(type, var, value, retVal) \ | 60 #define TONATIVE_DEFAULT(type, var, value, retVal) \ |
| 61 type var; \ | 61 type var; \ |
| 62 { \ | 62 { \ |
| 63 v8::TryCatch block; \ | 63 v8::TryCatch block; \ |
| 64 var = (value); \ | 64 var = (value); \ |
| 65 if (UNLIKELY(block.HasCaught())) { \ | 65 if (UNLIKELY(block.HasCaught())) { \ |
| 66 block.ReThrow(); \ | 66 block.ReThrow(); \ |
| 67 return retVal; \ | 67 return retVal; \ |
| 68 } \ | 68 } \ |
| 69 } | 69 } |
| 70 | 70 |
| 71 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ | 71 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ |
| 72 type var; \ | 72 type var; \ |
| 73 { \ | 73 { \ |
| 74 v8::TryCatch block; \ | 74 v8::TryCatch block; \ |
| 75 var = (value); \ | 75 var = (value); \ |
| 76 if (UNLIKELY(block.HasCaught())) \ | 76 if (UNLIKELY(block.HasCaught())) \ |
| 77 exceptionState.rethrowV8Exception(block.Exception()); \ | 77 exceptionState.rethrowV8Exception(block.Exception()); \ |
| 78 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | 78 if (UNLIKELY(exceptionState.throwIfNeeded())) \ |
| 79 return; \ | 79 return; \ |
| 80 } | 80 } |
| 81 | 81 |
| 82 #define TONATIVE_BOOL_EXCEPTIONSTATE(type, var, value, exceptionState, retVal) \ | 82 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal
) \ |
| 83 type var; \ | 83 type var; \ |
| 84 { \ | 84 { \ |
| 85 v8::TryCatch block; \ | 85 v8::TryCatch block; \ |
| 86 var = (value); \ | 86 var = (value); \ |
| 87 if (UNLIKELY(block.HasCaught())) \ | 87 if (UNLIKELY(block.HasCaught())) \ |
| 88 exceptionState.rethrowV8Exception(block.Exception()); \ | 88 exceptionState.rethrowV8Exception(block.Exception()); \ |
| 89 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | 89 if (UNLIKELY(exceptionState.throwIfNeeded())) \ |
| 90 return retVal; \ | 90 return retVal; \ |
| 91 } | 91 } |
| 92 | 92 |
| 93 // type is an instance of class template V8StringResource<>, | 93 // type is an instance of class template V8StringResource<>, |
| 94 // but Mode argument varies; using type (not Mode) for consistency | 94 // but Mode argument varies; using type (not Mode) for consistency |
| 95 // with other macros and ease of code generation | 95 // with other macros and ease of code generation |
| 96 #define TOSTRING_VOID(type, var, value) \ | 96 #define TOSTRING_VOID(type, var, value) \ |
| 97 type var(value); \ | 97 type var(value); \ |
| 98 if (UNLIKELY(!var.prepare())) \ | 98 if (UNLIKELY(!var.prepare())) \ |
| 99 return; | 99 return; |
| 100 | 100 |
| 101 #define TOSTRING_BOOL(type, var, value, retVal) \ | 101 #define TOSTRING_DEFAULT(type, var, value, retVal) \ |
| 102 type var(value); \ | 102 type var(value); \ |
| 103 if (UNLIKELY(!var.prepare())) \ | 103 if (UNLIKELY(!var.prepare())) \ |
| 104 return retVal; | 104 return retVal; |
| 105 | 105 |
| 106 } // namespace WebCore | 106 } // namespace WebCore |
| 107 | 107 |
| 108 #endif // V8BindingMacros_h | 108 #endif // V8BindingMacros_h |
| OLD | NEW |