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

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

Issue 8380020: Refactor the dart api a bit: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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/builtin_in.cc ('k') | runtime/bin/eventhandler.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 const char* DartUtils::kBuiltinLibURL = "./dart:builtin-lib"; 7 const char* DartUtils::kBuiltinLibURL = "./dart:builtin-lib";
8 const char* DartUtils::kBuiltinLibSpec = "library { }"; 8 const char* DartUtils::kBuiltinLibSpec = "library { }";
9 const char* DartUtils::kIdFieldName = "_id"; 9 const char* DartUtils::kIdFieldName = "_id";
10 10
11 11
12 int64_t DartUtils::GetIntegerValue(Dart_Handle value_obj) { 12 int64_t DartUtils::GetIntegerValue(Dart_Handle value_obj) {
13 ASSERT(Dart_IsInteger(value_obj)); 13 ASSERT(Dart_IsInteger(value_obj));
14 Dart_Result result = Dart_IntegerValue(value_obj); 14 int64_t value = 0;
15 ASSERT(Dart_IsValidResult(result)); 15 Dart_Handle result = Dart_IntegerValue(value_obj, &value);
16 return Dart_GetResultAsCInt64(result); 16 ASSERT(Dart_IsValid(result));
17 return value;
17 } 18 }
18 19
19 const char* DartUtils::GetStringValue(Dart_Handle str_obj) { 20 const char* DartUtils::GetStringValue(Dart_Handle str_obj) {
20 Dart_Result result = Dart_StringToCString(str_obj); 21 const char* cstring = NULL;
21 ASSERT(Dart_IsValidResult(result)); 22 Dart_Handle result = Dart_StringToCString(str_obj, &cstring);
22 return Dart_GetResultAsCString(result); 23 ASSERT(Dart_IsValid(result));
24 return cstring;
23 } 25 }
24 26
25 27
26 bool DartUtils::GetBooleanValue(Dart_Handle bool_obj) { 28 bool DartUtils::GetBooleanValue(Dart_Handle bool_obj) {
27 Dart_Result result = Dart_BooleanValue(bool_obj); 29 bool value = false;
28 ASSERT(Dart_IsValidResult(result)); 30 Dart_Handle result = Dart_BooleanValue(bool_obj, &value);
29 return Dart_GetResultAsCBoolean(result); 31 ASSERT(Dart_IsValid(result));
32 return value;
30 } 33 }
31 34
32 void DartUtils::SetIntegerInstanceField(Dart_Handle handle, 35 void DartUtils::SetIntegerInstanceField(Dart_Handle handle,
33 const char* name, 36 const char* name,
34 intptr_t val) { 37 intptr_t val) {
35 Dart_Result result = Dart_SetInstanceField(handle, 38 Dart_Handle result = Dart_SetInstanceField(handle,
36 Dart_NewString(name), 39 Dart_NewString(name),
37 Dart_NewInteger(val)); 40 Dart_NewInteger(val));
38 ASSERT(Dart_IsValidResult(result)); 41 ASSERT(Dart_IsValid(result));
39 } 42 }
40 43
41 intptr_t DartUtils::GetIntegerInstanceField(Dart_Handle handle, 44 intptr_t DartUtils::GetIntegerInstanceField(Dart_Handle handle,
42 const char* name) { 45 const char* name) {
43 Dart_Result result = 46 Dart_Handle result =
44 Dart_GetInstanceField(handle, Dart_NewString(name)); 47 Dart_GetInstanceField(handle, Dart_NewString(name));
45 ASSERT(Dart_IsValidResult(result)); 48 ASSERT(Dart_IsValid(result));
46 intptr_t value = DartUtils::GetIntegerValue(Dart_GetResult(result)); 49 intptr_t value = DartUtils::GetIntegerValue(result);
47 return value; 50 return value;
48 } 51 }
49 52
50 void DartUtils::SetStringInstanceField(Dart_Handle handle, 53 void DartUtils::SetStringInstanceField(Dart_Handle handle,
51 const char* name, 54 const char* name,
52 const char* val) { 55 const char* val) {
53 Dart_Result result = Dart_SetInstanceField(handle, 56 Dart_Handle result = Dart_SetInstanceField(handle,
54 Dart_NewString(name), 57 Dart_NewString(name),
55 Dart_NewString(val)); 58 Dart_NewString(val));
56 ASSERT(Dart_IsValidResult(result)); 59 ASSERT(Dart_IsValid(result));
57 } 60 }
OLDNEW
« no previous file with comments | « runtime/bin/builtin_in.cc ('k') | runtime/bin/eventhandler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698