Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 #include "wtf/text/AtomicString.h" | 39 #include "wtf/text/AtomicString.h" |
| 40 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 41 #include <v8.h> | 41 #include <v8.h> |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 // Dictionary class provides ways to retrieve property values as C++ objects | 45 // Dictionary class provides ways to retrieve property values as C++ objects |
| 46 // from a V8 object. Instances of this class must not outlive V8's handle scope | 46 // from a V8 object. Instances of this class must not outlive V8's handle scope |
| 47 // because they hold a V8 value without putting it on persistent handles. | 47 // because they hold a V8 value without putting it on persistent handles. |
| 48 class CORE_EXPORT Dictionary final { | 48 class CORE_EXPORT Dictionary final { |
| 49 ALLOW_ONLY_INLINE_ALLOCATION(); | |
| 49 public: | 50 public: |
| 50 Dictionary(); | 51 Dictionary(); |
| 51 Dictionary(const v8::Local<v8::Value>& options, v8::Isolate*, ExceptionState &); | 52 Dictionary(const v8::Local<v8::Value>& options, v8::Isolate*, ExceptionState &); |
| 52 ~Dictionary(); | 53 ~Dictionary(); |
| 53 | 54 |
| 54 Dictionary& operator=(const Dictionary&); | 55 Dictionary& operator=(const Dictionary&); |
| 55 | 56 |
| 56 bool isObject() const; | 57 bool isObject() const; |
| 57 bool isUndefinedOrNull() const; | 58 bool isUndefinedOrNull() const; |
| 58 | 59 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 template <typename T> | 104 template <typename T> |
| 104 static bool getWithUndefinedOrNullCheck(const Dictionary& dictionary, const String& key, T& value) | 105 static bool getWithUndefinedOrNullCheck(const Dictionary& dictionary, const String& key, T& value) |
| 105 { | 106 { |
| 106 v8::Local<v8::Value> v8Value; | 107 v8::Local<v8::Value> v8Value; |
| 107 if (!dictionary.getKey(key, v8Value) || isUndefinedOrNull(v8Value)) | 108 if (!dictionary.getKey(key, v8Value) || isUndefinedOrNull(v8Value)) |
| 108 return false; | 109 return false; |
| 109 return DictionaryHelper::get(dictionary, key, value); | 110 return DictionaryHelper::get(dictionary, key, value); |
| 110 } | 111 } |
| 111 template <template <typename> class PointerType, typename T> | 112 template <template <typename> class PointerType, typename T> |
| 112 static bool get(const Dictionary&, const String& key, PointerType<T>& value) ; | 113 static bool get(const Dictionary&, const String& key, PointerType<T>& value) ; |
| 114 STATIC_ONLY(DictionaryHelper); | |
|
haraken
2015/08/12 07:56:12
Can we move this to the top of the class/struct de
tasak
2015/08/12 09:13:26
Done.
| |
| 113 }; | 115 }; |
| 114 | 116 |
| 115 } | 117 } |
| 116 | 118 |
| 117 #endif // Dictionary_h | 119 #endif // Dictionary_h |
| OLD | NEW |