| 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, Poin
terType<T>& value) | 35 bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, Poin
terType<T>& value) |
| 36 { | 36 { |
| 37 v8::Local<v8::Value> v8Value; | 37 v8::Local<v8::Value> v8Value; |
| 38 if (!dictionary.get(key, v8Value)) | 38 if (!dictionary.get(key, v8Value)) |
| 39 return false; | 39 return false; |
| 40 | 40 |
| 41 value = V8TypeOf<T>::Type::toImplWithTypeCheck(dictionary.isolate(), v8Value
); | 41 value = V8TypeOf<T>::Type::toImplWithTypeCheck(dictionary.isolate(), v8Value
); |
| 42 return true; | 42 return true; |
| 43 } | 43 } |
| 44 | 44 |
| 45 template <template <typename> class PointerType, typename T> | |
| 46 bool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::Convers
ionContext& context, const String& key, PointerType<T>& value) | |
| 47 { | |
| 48 Dictionary::ConversionContextScope scope(context); | |
| 49 | |
| 50 if (!DictionaryHelper::get(dictionary, key, value)) | |
| 51 return true; | |
| 52 | |
| 53 if (value) | |
| 54 return true; | |
| 55 | |
| 56 v8::Local<v8::Value> v8Value; | |
| 57 dictionary.get(key, v8Value); | |
| 58 if (context.isNullable() && blink::isUndefinedOrNull(v8Value)) | |
| 59 return true; | |
| 60 | |
| 61 context.throwTypeError(ExceptionMessages::incorrectPropertyType(key, "does n
ot have a " + context.typeName() + " type.")); | |
| 62 return false; | |
| 63 } | |
| 64 | |
| 65 } // namespace blink | 45 } // namespace blink |
| 66 | 46 |
| 67 #endif // DictionaryHelperForBindings_h | 47 #endif // DictionaryHelperForBindings_h |
| OLD | NEW |