| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 25 matching lines...) Expand all Loading... |
| 36 #include "bindings/tests/idls/TestInterfaceNamedConstructor.h" | 36 #include "bindings/tests/idls/TestInterfaceNamedConstructor.h" |
| 37 #include "bindings/v8/V8Binding.h" | 37 #include "bindings/v8/V8Binding.h" |
| 38 #include "bindings/v8/V8DOMWrapper.h" | 38 #include "bindings/v8/V8DOMWrapper.h" |
| 39 #include "bindings/v8/WrapperTypeInfo.h" | 39 #include "bindings/v8/WrapperTypeInfo.h" |
| 40 #include "heap/Handle.h" | 40 #include "heap/Handle.h" |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 class V8TestInterfaceNamedConstructorConstructor { | 44 class V8TestInterfaceNamedConstructorConstructor { |
| 45 public: | 45 public: |
| 46 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*, WrapperWor
ldType); | 46 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*); |
| 47 static const WrapperTypeInfo wrapperTypeInfo; | 47 static const WrapperTypeInfo wrapperTypeInfo; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class V8TestInterfaceNamedConstructor { | 50 class V8TestInterfaceNamedConstructor { |
| 51 public: | 51 public: |
| 52 static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*); | 52 static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*); |
| 53 static v8::Handle<v8::Object> findInstanceInPrototypeChain(v8::Handle<v8::Va
lue>, v8::Isolate*); | 53 static v8::Handle<v8::Object> findInstanceInPrototypeChain(v8::Handle<v8::Va
lue>, v8::Isolate*); |
| 54 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*, WrapperWor
ldType); | 54 static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*); |
| 55 static TestInterfaceNamedConstructor* toNative(v8::Handle<v8::Object> object
) | 55 static TestInterfaceNamedConstructor* toNative(v8::Handle<v8::Object> object
) |
| 56 { | 56 { |
| 57 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8
DOMWrapperObjectIndex)); | 57 return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8
DOMWrapperObjectIndex)); |
| 58 } | 58 } |
| 59 static TestInterfaceNamedConstructor* toNativeWithTypeCheck(v8::Isolate*, v8
::Handle<v8::Value>); | 59 static TestInterfaceNamedConstructor* toNativeWithTypeCheck(v8::Isolate*, v8
::Handle<v8::Value>); |
| 60 static const WrapperTypeInfo wrapperTypeInfo; | 60 static const WrapperTypeInfo wrapperTypeInfo; |
| 61 static void derefObject(void*); | 61 static void derefObject(void*); |
| 62 static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>); | 62 static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>); |
| 63 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0
; | 63 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0
; |
| 64 static inline void* toInternalPointer(TestInterfaceNamedConstructor* impl) | 64 static inline void* toInternalPointer(TestInterfaceNamedConstructor* impl) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 if (DOMDataStore::setReturnValueFromWrapper<V8TestInterfaceNamedConstructor>
(callbackInfo.GetReturnValue(), impl)) | 105 if (DOMDataStore::setReturnValueFromWrapper<V8TestInterfaceNamedConstructor>
(callbackInfo.GetReturnValue(), impl)) |
| 106 return; | 106 return; |
| 107 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackI
nfo.GetIsolate()); | 107 v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackI
nfo.GetIsolate()); |
| 108 v8SetReturnValue(callbackInfo, wrapper); | 108 v8SetReturnValue(callbackInfo, wrapper); |
| 109 } | 109 } |
| 110 | 110 |
| 111 template<typename CallbackInfo> | 111 template<typename CallbackInfo> |
| 112 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, TestI
nterfaceNamedConstructor* impl) | 112 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, TestI
nterfaceNamedConstructor* impl) |
| 113 { | 113 { |
| 114 ASSERT(worldType(callbackInfo.GetIsolate()) == MainWorld); | 114 ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate())->isMainWorld()); |
| 115 if (UNLIKELY(!impl)) { | 115 if (UNLIKELY(!impl)) { |
| 116 v8SetReturnValueNull(callbackInfo); | 116 v8SetReturnValueNull(callbackInfo); |
| 117 return; | 117 return; |
| 118 } | 118 } |
| 119 if (DOMDataStore::setReturnValueFromWrapperForMainWorld<V8TestInterfaceNamed
Constructor>(callbackInfo.GetReturnValue(), impl)) | 119 if (DOMDataStore::setReturnValueFromWrapperForMainWorld<V8TestInterfaceNamed
Constructor>(callbackInfo.GetReturnValue(), impl)) |
| 120 return; | 120 return; |
| 121 v8::Handle<v8::Value> wrapper = wrap(impl, callbackInfo.Holder(), callbackIn
fo.GetIsolate()); | 121 v8::Handle<v8::Value> wrapper = wrap(impl, callbackInfo.Holder(), callbackIn
fo.GetIsolate()); |
| 122 v8SetReturnValue(callbackInfo, wrapper); | 122 v8SetReturnValue(callbackInfo, wrapper); |
| 123 } | 123 } |
| 124 | 124 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 153 } | 153 } |
| 154 | 154 |
| 155 template<class CallbackInfo, class Wrappable> | 155 template<class CallbackInfo, class Wrappable> |
| 156 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<Te
stInterfaceNamedConstructor> impl, Wrappable* wrappable) | 156 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<Te
stInterfaceNamedConstructor> impl, Wrappable* wrappable) |
| 157 { | 157 { |
| 158 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); | 158 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); |
| 159 } | 159 } |
| 160 | 160 |
| 161 } | 161 } |
| 162 #endif // V8TestInterfaceNamedConstructor_h | 162 #endif // V8TestInterfaceNamedConstructor_h |
| OLD | NEW |