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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 22632010: Added following dart API changes to enable more efficient access based (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 26045)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -26,6 +26,7 @@
#include "vm/object_store.h"
#include "vm/port.h"
#include "vm/resolver.h"
+#include "vm/reusable_handles.h"
#include "vm/stack_frame.h"
#include "vm/symbols.h"
#include "vm/timer.h"
@@ -262,6 +263,13 @@
}
+void Api::SetWeakHandleReturnValue(NativeArguments* args,
+ Dart_WeakPersistentHandle retval) {
+ args->SetReturnUnsafe(
+ reinterpret_cast<FinalizablePersistentHandle*>(retval)->raw());
+}
+
+
// --- Handles ---
DART_EXPORT bool Dart_IsError(Dart_Handle handle) {
@@ -1132,7 +1140,7 @@
DART_EXPORT bool Dart_IsNull(Dart_Handle object) {
- return Api::ClassId(object) == kNullCid;
+ return Api::UnwrapHandle(object) == Object::null();
}
@@ -1842,6 +1850,28 @@
}
+DART_EXPORT Dart_Handle Dart_StringGetProperties(Dart_Handle object,
+ intptr_t* char_size,
+ intptr_t* str_len,
+ void** peer) {
+ Isolate* isolate = Isolate::Current();
+ DARTSCOPE(isolate);
+ const String& str = Api::UnwrapStringHandle(isolate, object);
+ if (str.IsNull()) {
+ RETURN_TYPE_ERROR(isolate, object, String);
+ }
+ if (str.IsExternal()) {
+ *peer = str.GetPeer();
+ ASSERT(*peer != NULL);
+ } else {
+ *peer = NULL;
+ }
+ *char_size = str.CharSize();
+ *str_len = str.Length();
+ return Api::Success();
+}
+
+
// --- Lists ---
DART_EXPORT Dart_Handle Dart_NewList(intptr_t length) {
@@ -3623,12 +3653,15 @@
return Api::Success();
}
+
DART_EXPORT Dart_Handle Dart_GetNativeReceiver(Dart_NativeArguments args,
intptr_t* value) {
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
Isolate* isolate = arguments->isolate();
- DARTSCOPE(isolate);
- const Object& obj = Object::Handle(isolate, arguments->NativeArgAt(0));
+ CHECK_ISOLATE(isolate);
+ ReusableObjectHandleScope reused_obj_handle(isolate);
+ Object& obj = reused_obj_handle.Handle();
+ obj = arguments->NativeArgAt(0);
intptr_t cid = obj.GetClassId();
if (cid <= kNumPredefinedCids) {
if (cid == kNullCid) {
@@ -3648,6 +3681,31 @@
}
+DART_EXPORT Dart_Handle Dart_GetNativeStringArgument(Dart_NativeArguments args,
+ int arg_index,
+ void** peer) {
+ NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
+ Isolate* isolate = arguments->isolate();
+ CHECK_ISOLATE(isolate);
+ ReusableObjectHandleScope reused_obj_handle(isolate);
+ Object& obj = reused_obj_handle.Handle();
+ obj = arguments->NativeArgAt(arg_index);
+ intptr_t cid = obj.GetClassId();
+ if (RawObject::IsExternalStringClassId(cid)) {
+ const String& str = String::Cast(obj);
+ *peer = str.GetPeer();
+ ASSERT(*peer != NULL);
+ return Api::Success();
+ }
+ *peer = NULL;
+ if (RawObject::IsStringClassId(cid)) {
+ return Api::NewHandle(isolate, obj.raw());
+ }
+ return Api::NewError("%s expects argument to be of"
+ " type String.", CURRENT_FUNC);
+}
+
+
DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
Dart_Handle retval) {
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
@@ -3663,6 +3721,18 @@
}
+DART_EXPORT void Dart_SetWeakHandleReturnValue(Dart_NativeArguments args,
+ Dart_WeakPersistentHandle rval) {
+ NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
+ Isolate* isolate = arguments->isolate();
+ CHECK_ISOLATE(isolate);
+ ASSERT(isolate->api_state() != NULL &&
+ (isolate->api_state()->IsValidWeakPersistentHandle(rval) ||
+ isolate->api_state()->IsValidPrologueWeakPersistentHandle(rval)));
+ Api::SetWeakHandleReturnValue(arguments, rval);
+}
+
+
DART_EXPORT void Dart_SetBooleanReturnValue(Dart_NativeArguments args,
bool retval) {
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698