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

Side by Side Diff: runtime/bin/dartutils.cc

Issue 9642003: Start using Dart_SetField and Dart_GetField in the vm. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/directory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "bin/file.h" 7 #include "bin/file.h"
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/globals.h" 10 #include "platform/globals.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 62
63 bool DartUtils::GetBooleanValue(Dart_Handle bool_obj) { 63 bool DartUtils::GetBooleanValue(Dart_Handle bool_obj) {
64 bool value = false; 64 bool value = false;
65 Dart_Handle result = Dart_BooleanValue(bool_obj, &value); 65 Dart_Handle result = Dart_BooleanValue(bool_obj, &value);
66 ASSERT(!Dart_IsError(result)); 66 ASSERT(!Dart_IsError(result));
67 return value; 67 return value;
68 } 68 }
69 69
70 70
71 void DartUtils::SetIntegerInstanceField(Dart_Handle handle, 71 void DartUtils::SetIntegerField(Dart_Handle handle,
72 const char* name, 72 const char* name,
73 intptr_t val) { 73 intptr_t val) {
74 Dart_Handle result = Dart_SetInstanceField(handle, 74 Dart_Handle result = Dart_SetField(handle,
75 Dart_NewString(name), 75 Dart_NewString(name),
76 Dart_NewInteger(val)); 76 Dart_NewInteger(val));
77 ASSERT(!Dart_IsError(result)); 77 ASSERT(!Dart_IsError(result));
78 } 78 }
79 79
80 80
81 intptr_t DartUtils::GetIntegerInstanceField(Dart_Handle handle, 81 intptr_t DartUtils::GetIntegerField(Dart_Handle handle,
82 const char* name) { 82 const char* name) {
83 Dart_Handle result = 83 Dart_Handle result = Dart_GetField(handle, Dart_NewString(name));
84 Dart_GetInstanceField(handle, Dart_NewString(name));
85 ASSERT(!Dart_IsError(result)); 84 ASSERT(!Dart_IsError(result));
86 intptr_t value = DartUtils::GetIntegerValue(result); 85 intptr_t value = DartUtils::GetIntegerValue(result);
87 return value; 86 return value;
88 } 87 }
89 88
90 89
91 void DartUtils::SetStringInstanceField(Dart_Handle handle, 90 void DartUtils::SetStringField(Dart_Handle handle,
92 const char* name, 91 const char* name,
93 const char* val) { 92 const char* val) {
94 Dart_Handle result = Dart_SetInstanceField(handle, 93 Dart_Handle result = Dart_SetField(handle,
95 Dart_NewString(name), 94 Dart_NewString(name),
96 Dart_NewString(val)); 95 Dart_NewString(val));
97 ASSERT(!Dart_IsError(result)); 96 ASSERT(!Dart_IsError(result));
98 } 97 }
99 98
100 99
101 bool DartUtils::IsDartSchemeURL(const char* url_name) { 100 bool DartUtils::IsDartSchemeURL(const char* url_name) {
102 static const intptr_t kDartSchemeLen = strlen(kDartScheme); 101 static const intptr_t kDartSchemeLen = strlen(kDartScheme);
103 // If the URL starts with "dart:" then it is considered as a special 102 // If the URL starts with "dart:" then it is considered as a special
104 // library URL which is handled differently from other URLs. 103 // library URL which is handled differently from other URLs.
105 return (strncmp(url_name, kDartScheme, kDartSchemeLen) == 0); 104 return (strncmp(url_name, kDartScheme, kDartSchemeLen) == 0);
106 } 105 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 return cobject; 371 return cobject;
373 } 372 }
374 373
375 374
376 Dart_CObject* CObject::NewByteArray(int length) { 375 Dart_CObject* CObject::NewByteArray(int length) {
377 Dart_CObject* cobject = New(Dart_CObject::kByteArray, length); 376 Dart_CObject* cobject = New(Dart_CObject::kByteArray, length);
378 cobject->value.as_byte_array.length = length; 377 cobject->value.as_byte_array.length = length;
379 cobject->value.as_byte_array.values = reinterpret_cast<uint8_t*>(cobject + 1); 378 cobject->value.as_byte_array.values = reinterpret_cast<uint8_t*>(cobject + 1);
380 return cobject; 379 return cobject;
381 } 380 }
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/directory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698