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

Unified Diff: sky/engine/bindings-dart/core/dart/custom/DartDOMStringMapCustom.cpp

Issue 875013003: Import Dart bindings as of Blink r188698. This merely copies the files over and does not attach any… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: sky/engine/bindings-dart/core/dart/custom/DartDOMStringMapCustom.cpp
diff --git a/sky/engine/bindings-dart/core/dart/custom/DartDOMStringMapCustom.cpp b/sky/engine/bindings-dart/core/dart/custom/DartDOMStringMapCustom.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..89373fbf14985b6e98f82641f2a079d0f990d973
--- /dev/null
+++ b/sky/engine/bindings-dart/core/dart/custom/DartDOMStringMapCustom.cpp
@@ -0,0 +1,166 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#include "config.h"
+#include "bindings/core/dart/DartDOMStringMap.h"
+
+namespace blink {
+
+namespace DartDOMStringMapInternal {
+
+static void containsKeyCallback(Dart_NativeArguments args)
+{
+ Dart_Handle exception = 0;
+ {
+ DOMStringMap* receiver = DartDOMWrapper::receiver<DOMStringMap>(args);
+
+ DartStringAdapter key = DartUtilities::dartToString(args, 1, exception);
+ if (exception)
+ goto fail;
+
+ Dart_SetReturnValue(args, DartUtilities::boolToDart(receiver->contains(key)));
+ return;
+ }
+
+fail:
+ Dart_ThrowException(exception);
+ ASSERT_NOT_REACHED();
+}
+
+static void itemCallback(Dart_NativeArguments args)
+{
+ Dart_Handle exception = 0;
+ {
+ DOMStringMap* receiver = DartDOMWrapper::receiver<DOMStringMap>(args);
+
+ DartStringAdapter key = DartUtilities::dartToString(args, 1, exception);
+ if (exception)
+ goto fail;
+
+ Dart_SetReturnValue(args, DartUtilities::stringToDart(receiver->item(key)));
+ return;
+ }
+
+fail:
+ Dart_ThrowException(exception);
+ ASSERT_NOT_REACHED();
+}
+
+static void setItemCallback(Dart_NativeArguments args)
+{
+ Dart_Handle exception = 0;
+ {
+ DOMStringMap* receiver = DartDOMWrapper::receiver<DOMStringMap>(args);
+
+ DartStringAdapter key = DartUtilities::dartToString(args, 1, exception);
+ if (exception)
+ goto fail;
+
+ DartStringAdapter value = DartUtilities::dartToString(args, 2, exception);
+ if (exception)
+ goto fail;
+
+ DartExceptionState es;
+ receiver->setItem(key, value, es);
+ if (es.hadException()) {
+ exception = es.toDart(args);
+ goto fail;
+ }
+
+ return;
+ }
+
+fail:
+ Dart_ThrowException(exception);
+ ASSERT_NOT_REACHED();
+}
+
+static void removeCallback(Dart_NativeArguments args)
+{
+ Dart_Handle exception = 0;
+ {
+ DOMStringMap* receiver = DartDOMWrapper::receiver<DOMStringMap>(args);
+
+ DartStringAdapter key = DartUtilities::dartToString(args, 1, exception);
+ if (exception)
+ goto fail;
+
+ String value = receiver->item(key);
+
+ // FIXMEDART: is the signature for removeCallback now incorrect? Should
+ // we instead just return the boolean return value of
+ // receiver->deleteItem(key)?
+ receiver->deleteItem(key);
+ Dart_SetReturnValue(args, DartUtilities::stringToDartWithNullCheck(value));
+ return;
+ }
+
+fail:
+ Dart_ThrowException(exception);
+ ASSERT_NOT_REACHED();
+}
+
+static void getKeysCallback(Dart_NativeArguments args)
+{
+ Dart_Handle exception = 0;
+ {
+ DOMStringMap* receiver = DartDOMWrapper::receiver<DOMStringMap>(args);
+
+ Vector<String> names;
+ receiver->getNames(names);
+
+ Dart_Handle result = Dart_NewList(names.size());
+ if (!DartUtilities::checkResult(result, exception))
+ goto fail;
+
+ for (size_t i = 0; i < names.size(); ++i)
+ Dart_ListSetAt(result, i, DartUtilities::stringToDartString(names[i]));
+
+ Dart_SetReturnValue(args, result);
+ return;
+ }
+
+fail:
+ Dart_ThrowException(exception);
+ ASSERT_NOT_REACHED();
+}
+
+}
+
+static DartNativeEntry nativeEntries[] = {
+ { DartDOMStringMapInternal::containsKeyCallback, 2, "DOMStringMap_containsKey_Callback" },
+ { DartDOMStringMapInternal::itemCallback, 2, "DOMStringMap_item_Callback" },
+ { DartDOMStringMapInternal::setItemCallback, 3, "DOMStringMap_setItem_Callback" },
+ { DartDOMStringMapInternal::removeCallback, 2, "DOMStringMap_remove_Callback" },
+ { DartDOMStringMapInternal::getKeysCallback, 1, "DOMStringMap_getKeys_Callback" },
+ { 0, 0, 0 }
+};
+
+Dart_NativeFunction customDartDOMStringMapResolver(Dart_Handle nameHandle, int argumentCount, bool* autoSetupScope)
+{
+ ASSERT(autoSetupScope);
+ *autoSetupScope = true;
+ String name = DartUtilities::toString(nameHandle);
+
+ for (intptr_t i = 0; nativeEntries[i].nativeFunction != 0; i++) {
+ if (argumentCount == nativeEntries[i].argumentCount && name == nativeEntries[i].name) {
+ return nativeEntries[i].nativeFunction;
+ }
+ }
+
+ return 0;
+}
+
+const uint8_t* customDartDOMStringMapSymbolizer(Dart_NativeFunction nf)
+{
+ for (intptr_t i = 0; nativeEntries[i].nativeFunction != 0; i++) {
+ if (nf == nativeEntries[i].nativeFunction) {
+ return reinterpret_cast<const uint8_t*>(nativeEntries[i].name);
+ }
+ }
+
+ return 0;
+}
+
+}

Powered by Google App Engine
This is Rietveld 408576698