Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: Source/bindings/dart/DartUtilities.cpp

Issue 27140002: Use Dart_InstanceIsSubtypeOf to check if instance is a direct subtype of specified type. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 335
336 double DartUtilities::dartToDate(Dart_NativeArguments args, int idx, Dart_Handle & exception) 336 double DartUtilities::dartToDate(Dart_NativeArguments args, int idx, Dart_Handle & exception)
337 { 337 {
338 Dart_Handle object = Dart_GetNativeArgument(args, idx); 338 Dart_Handle object = Dart_GetNativeArgument(args, idx);
339 return dartToDate(object, exception); 339 return dartToDate(object, exception);
340 } 340 }
341 341
342 bool DartUtilities::isHtmlElement(DartDOMData* domData, Dart_Handle handle) 342 bool DartUtilities::isHtmlElement(DartDOMData* domData, Dart_Handle handle)
343 { 343 {
344 ASSERT(domData); 344 ASSERT(domData);
345 return DartDOMWrapper::instanceOf<DartHTMLElement>(domData, handle); 345 return DartDOMWrapper::subtypeOf<DartHTMLElement>(domData, handle);
346 } 346 }
347 347
348 bool DartUtilities::isDateTime(DartDOMData* domData, Dart_Handle handle) 348 bool DartUtilities::isDateTime(DartDOMData* domData, Dart_Handle handle)
349 { 349 {
350 ASSERT(domData); 350 ASSERT(domData);
351 Dart_Handle type = DartDOMWrapper::dartClass( 351 Dart_Handle type = DartDOMWrapper::dartClass(
352 domData, "DateTime", DartCoreLibraryId, _DateTimeClassId); 352 domData, "DateTime", DartCoreLibraryId, _DateTimeClassId);
353 ASSERT(!Dart_IsError(type)); 353 ASSERT(!Dart_IsError(type));
354 return objectIsType(handle, type); 354 return objectIsType(handle, type);
rmacnak 2013/10/14 17:37:26 Should we be using the new test here too?
355 } 355 }
356 356
357 bool DartUtilities::isBlob(DartDOMData* domData, Dart_Handle handle) 357 bool DartUtilities::isBlob(DartDOMData* domData, Dart_Handle handle)
358 { 358 {
359 ASSERT(domData); 359 ASSERT(domData);
360 return DartDOMWrapper::instanceOf<DartBlob>(domData, handle); 360 return DartDOMWrapper::subtypeOf<DartBlob>(domData, handle);
361 } 361 }
362 362
363 bool DartUtilities::isImageData(DartDOMData* domData, Dart_Handle handle) 363 bool DartUtilities::isImageData(DartDOMData* domData, Dart_Handle handle)
364 { 364 {
365 ASSERT(domData); 365 ASSERT(domData);
366 return DartDOMWrapper::instanceOf<DartImageData>(domData, handle); 366 return DartDOMWrapper::subtypeOf<DartImageData>(domData, handle);
367 } 367 }
368 368
369 bool DartUtilities::isIDBKeyRange(DartDOMData* domData, Dart_Handle handle) 369 bool DartUtilities::isIDBKeyRange(DartDOMData* domData, Dart_Handle handle)
370 { 370 {
371 ASSERT(domData); 371 ASSERT(domData);
372 return DartDOMWrapper::instanceOf<DartIDBKeyRange>(domData, handle); 372 return DartDOMWrapper::subtypeOf<DartIDBKeyRange>(domData, handle);
373 } 373 }
374 374
375 bool DartUtilities::objectIsType(Dart_Handle handle, Dart_Handle type) 375 bool DartUtilities::objectIsType(Dart_Handle handle, Dart_Handle type)
376 { 376 {
377 bool isType = false; 377 bool isType = false;
378 Dart_Handle result = Dart_ObjectIsType(handle, type, &isType); 378 Dart_Handle result = Dart_ObjectIsType(handle, type, &isType);
379 if (Dart_IsError(result)) 379 if (Dart_IsError(result))
380 return false; 380 return false;
381 return isType; 381 return isType;
382 } 382 }
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 void DartUtilities::toMessagePortArray(Dart_Handle value, MessagePortArray& port s, ArrayBufferArray& arrayBuffers, Dart_Handle& exception) 796 void DartUtilities::toMessagePortArray(Dart_Handle value, MessagePortArray& port s, ArrayBufferArray& arrayBuffers, Dart_Handle& exception)
797 { 797 {
798 Vector<Dart_Handle> elements; 798 Vector<Dart_Handle> elements;
799 DartUtilities::extractListElements(value, exception, elements); 799 DartUtilities::extractListElements(value, exception, elements);
800 if (exception) 800 if (exception)
801 return; 801 return;
802 802
803 DartDOMData* domData = DartDOMData::current(); 803 DartDOMData* domData = DartDOMData::current();
804 for (size_t i = 0; i < elements.size(); i++) { 804 for (size_t i = 0; i < elements.size(); i++) {
805 Dart_Handle element = elements[i]; 805 Dart_Handle element = elements[i];
806 if (DartDOMWrapper::instanceOf<DartMessagePort>(domData, element)) { 806 if (DartDOMWrapper::subtypeOf<DartMessagePort>(domData, element)) {
807 MessagePort* messagePort = DartMessagePort::toNative(element, except ion); 807 MessagePort* messagePort = DartMessagePort::toNative(element, except ion);
808 ASSERT(!exception); 808 ASSERT(!exception);
809 ASSERT(messagePort); 809 ASSERT(messagePort);
810 ports.append(messagePort); 810 ports.append(messagePort);
811 continue; 811 continue;
812 } 812 }
813 813
814 // FIXME: We need better type testing functionality. Currently this is n ot 814 // FIXME: We need better type testing functionality. Currently this is n ot
815 // disallowing views and it should. 815 // disallowing views and it should.
816 if (DartUtilities::isTypedData(element)) { 816 if (DartUtilities::isTypedData(element)) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 Dart_PersistentHandle library = domData->htmlLibrary(); 1081 Dart_PersistentHandle library = domData->htmlLibrary();
1082 ASSERT(!Dart_IsError(library)); 1082 ASSERT(!Dart_IsError(library));
1083 1083
1084 Dart_Handle utilsClass = Dart_GetType(library, Dart_NewStringFromCString("_U tils"), 0, 0); 1084 Dart_Handle utilsClass = Dart_GetType(library, Dart_NewStringFromCString("_U tils"), 0, 0);
1085 ASSERT(!Dart_IsError(utilsClass)); 1085 ASSERT(!Dart_IsError(utilsClass));
1086 1086
1087 return Dart_Invoke(utilsClass, Dart_NewStringFromCString(methodName), argCou nt, args); 1087 return Dart_Invoke(utilsClass, Dart_NewStringFromCString(methodName), argCou nt, args);
1088 } 1088 }
1089 1089
1090 } 1090 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698