Chromium Code Reviews| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 | 50 |
| 51 Dart_Handle type = Dart_GetType(library, Dart_NewStringFromCString(className ), 0, 0); | 51 Dart_Handle type = Dart_GetType(library, Dart_NewStringFromCString(className ), 0, 0); |
| 52 ASSERT(!Dart_IsError(type)); | 52 ASSERT(!Dart_IsError(type)); |
| 53 | 53 |
| 54 Dart_Handle instance = Dart_Allocate(type); | 54 Dart_Handle instance = Dart_Allocate(type); |
| 55 ASSERT(!Dart_IsError(instance)); | 55 ASSERT(!Dart_IsError(instance)); |
| 56 | 56 |
| 57 return instance; | 57 return instance; |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool DartDOMWrapper::instanceOf(const char* className, const char* libraryName, Dart_Handle wrapper) | 60 Dart_Handle DartDOMWrapper::dartClass(const char* className, const char* library Name, intptr_t index) |
| 61 { | 61 { |
| 62 // FIXME(rmacnak): Cache classes in the corresponding bindings class. Requir es persistent handles. | 62 Vector<Dart_PersistentHandle> *map = DartDOMData::current()->classHandleCach e(); |
| 63 Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryName); | |
| 64 ASSERT(!Dart_IsError(library)); | |
| 65 | 63 |
| 66 Dart_Handle type = Dart_GetType(library, Dart_NewStringFromCString(className ), 0, 0); | 64 Dart_Handle type; |
| 67 ASSERT(!Dart_IsError(type)); | 65 Dart_PersistentHandle persistentType; |
| 68 if (Dart_IsError(type)) | |
| 69 return false; | |
| 70 | 66 |
| 71 bool isInstanceOf = false; | 67 while (map->size() <= index) { |
| 72 Dart_Handle result = Dart_ObjectIsType(wrapper, type, &isInstanceOf); | 68 map->append(reinterpret_cast<Dart_PersistentHandle>(0)); |
|
siva
2013/09/10 00:18:50
Might be more efficient to do:
if (map->size() <=
rmacnak
2013/09/10 20:09:51
expandCapacity is private, but grow works
| |
| 73 ASSERT(!Dart_IsError(result)); | 69 } |
| 74 if (Dart_IsError(result)) | 70 |
| 75 return false; | 71 if (map->at(index)) { |
| 76 return isInstanceOf; | 72 persistentType = map->at(index); |
| 73 type = Dart_HandleFromPersistent(persistentType); | |
| 74 } else { | |
| 75 Dart_Handle library = DartUtilities::libraryForCurrentIsolate(libraryNam e); | |
| 76 ASSERT(!Dart_IsError(library)); | |
| 77 | |
| 78 type = Dart_GetType(library, Dart_NewStringFromCString(className), 0, 0) ; | |
| 79 ASSERT(!Dart_IsError(type)); | |
| 80 | |
| 81 persistentType = Dart_NewPersistentHandle(type); | |
| 82 map->insert(index, persistentType); | |
|
siva
2013/09/10 00:18:50
insert here in the implementation of Vector seems
rmacnak
2013/09/10 20:09:51
map->data()[index] = persistentType seems to do th
| |
| 83 } | |
| 84 | |
| 85 return type; | |
| 77 } | 86 } |
| 78 | 87 |
| 79 Dart_Handle DartDOMWrapper::exceptionCodeToDartException(ExceptionCode exception Code) | 88 Dart_Handle DartDOMWrapper::exceptionCodeToDartException(ExceptionCode exception Code) |
| 80 { | 89 { |
| 81 ASSERT(exceptionCode > 0); | 90 ASSERT(exceptionCode > 0); |
| 82 | 91 |
| 83 // FIXME: Get a better exception message here. | 92 // FIXME: Get a better exception message here. |
| 84 RefPtr<DOMException> domException = DOMException::create(exceptionCode, "Int ernal Dartium Exception"); | 93 RefPtr<DOMException> domException = DOMException::create(exceptionCode, "Int ernal Dartium Exception"); |
| 85 | 94 |
| 86 return DartDOMException::toDart(domException); | 95 return DartDOMException::toDart(domException); |
| 87 } | 96 } |
| 88 | 97 |
| 89 Dart_Handle DartDOMWrapper::exceptionCodeToDartException(DartExceptionState& exc eptionState) | 98 Dart_Handle DartDOMWrapper::exceptionCodeToDartException(DartExceptionState& exc eptionState) |
| 90 { | 99 { |
| 91 return exceptionCodeToDartException(exceptionState.code()); | 100 return exceptionCodeToDartException(exceptionState.code()); |
| 92 } | 101 } |
| 93 | 102 |
| 94 } | 103 } |
| OLD | NEW |