OLD | NEW |
1 // Copyright 2011, Google Inc. | 1 // Copyright 2011, Google Inc. |
2 // All rights reserved. | 2 // 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 DartApiScope scope; | 181 DartApiScope scope; |
182 Dart_Handle result = Dart_SetNativeInstanceField(wrapper, index, reinter
pret_cast<intptr_t>(pointer)); | 182 Dart_Handle result = Dart_SetNativeInstanceField(wrapper, index, reinter
pret_cast<intptr_t>(pointer)); |
183 UNUSED_PARAM(result); | 183 UNUSED_PARAM(result); |
184 ASSERT(!Dart_IsError(result)); | 184 ASSERT(!Dart_IsError(result)); |
185 } | 185 } |
186 | 186 |
187 static void* readNativePointer(Dart_Handle wrapper, int index) | 187 static void* readNativePointer(Dart_Handle wrapper, int index) |
188 { | 188 { |
189 intptr_t value; | 189 intptr_t value; |
190 Dart_Handle result = Dart_GetNativeInstanceField(wrapper, index, &value)
; | 190 Dart_Handle result = Dart_GetNativeInstanceField(wrapper, index, &value)
; |
191 ASSERT(!Dart_IsError(result)); | 191 // FIXME: the fact that we return 0 on error rather than asserting is |
192 UNUSED_PARAM(result); | 192 // somewhat of a hack. We currently make this method return 0 because |
| 193 // we reuse this method to verify that objects are actually native |
| 194 // Node objects rather than objects that implement the Node interface. |
| 195 if (Dart_IsError(result)) |
| 196 return 0; |
193 return reinterpret_cast<void*>(value); | 197 return reinterpret_cast<void*>(value); |
194 } | 198 } |
195 | 199 |
196 template <class BindingsClass> | 200 template <class BindingsClass> |
197 static void wrapperWeakCallback(Dart_WeakPersistentHandle, void* peer) | 201 static void wrapperWeakCallback(Dart_WeakPersistentHandle, void* peer) |
198 { | 202 { |
199 typedef DartDOMWrapperTraits<BindingsClass> Traits; | 203 typedef DartDOMWrapperTraits<BindingsClass> Traits; |
200 DartDOMData* domData = DartDOMData::current(); | 204 DartDOMData* domData = DartDOMData::current(); |
201 typename BindingsClass::NativeType* domObject = static_cast<typename Bin
dingsClass::NativeType*>(peer); | 205 typename BindingsClass::NativeType* domObject = static_cast<typename Bin
dingsClass::NativeType*>(peer); |
202 ASSERT(DartDOMWrapperTraits<BindingsClass>::MapTraits::domMap(domData)->
contains(domObject)); | 206 ASSERT(DartDOMWrapperTraits<BindingsClass>::MapTraits::domMap(domData)->
contains(domObject)); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 static DartMessagePortMap* domMap(DartDOMData* domData) { return domData
->messagePortMap(); } | 285 static DartMessagePortMap* domMap(DartDOMData* domData) { return domData
->messagePortMap(); } |
282 }; | 286 }; |
283 typedef MessagePortMapTraits MapTraits; | 287 typedef MessagePortMapTraits MapTraits; |
284 typedef DartDOMWrapperActiveTraits<DartMessagePort, false> ActiveTraits; | 288 typedef DartDOMWrapperActiveTraits<DartMessagePort, false> ActiveTraits; |
285 typedef DartDOMWrapperEventTargetTraits<DartMessagePort, true> EventTargetTr
aits; | 289 typedef DartDOMWrapperEventTargetTraits<DartMessagePort, true> EventTargetTr
aits; |
286 }; | 290 }; |
287 | 291 |
288 } | 292 } |
289 | 293 |
290 #endif // DartDOMWrapper_h | 294 #endif // DartDOMWrapper_h |
OLD | NEW |