Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 4172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4183 | 4183 |
| 4184 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) { | 4184 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function) { |
| 4185 Dart::set_perf_events_writer(function); | 4185 Dart::set_perf_events_writer(function); |
| 4186 } | 4186 } |
| 4187 | 4187 |
| 4188 | 4188 |
| 4189 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) { | 4189 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function) { |
| 4190 Dart::set_flow_graph_writer(function); | 4190 Dart::set_flow_graph_writer(function); |
| 4191 } | 4191 } |
| 4192 | 4192 |
| 4193 | |
| 4194 // --- Peer support --- | |
| 4195 | |
| 4196 | |
| 4197 DART_EXPORT Dart_Handle Dart_GetPeer(Dart_Handle object, void** peer) { | |
| 4198 if (peer == NULL) { | |
| 4199 RETURN_NULL_ERROR(peer); | |
| 4200 } | |
| 4201 Isolate* isolate = Isolate::Current(); | |
| 4202 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); | |
| 4203 if (obj.IsNull()) { | |
| 4204 RETURN_TYPE_ERROR(isolate, object, Object); | |
| 4205 } | |
| 4206 if (obj.IsSmi()) { | |
|
Anton Muhin
2012/09/13 06:27:07
that's up to you, but this dependence on internal
cshapiro
2012/09/15 01:23:41
I think your suggestion to prohibit the bool type
| |
| 4207 const char* msg = "%s expects argument 'object' to be heap allocated."; | |
| 4208 return Api::NewError(msg, CURRENT_FUNC); | |
| 4209 } | |
| 4210 { | |
| 4211 NoGCScope no_gc; | |
| 4212 RawObject* raw_obj = obj.raw(); | |
| 4213 *peer = isolate->heap()->GetPeer(raw_obj); | |
| 4214 } | |
| 4215 if (*peer == NULL) { | |
| 4216 const char* msg = "%s: expects 'object' to have its peer value set"; | |
| 4217 return Api::NewError(msg, CURRENT_FUNC); | |
| 4218 } | |
| 4219 return Api::Success(isolate); | |
| 4220 } | |
| 4221 | |
| 4222 | |
| 4223 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer) { | |
| 4224 Isolate* isolate = Isolate::Current(); | |
| 4225 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); | |
| 4226 if (obj.IsNull()) { | |
| 4227 RETURN_TYPE_ERROR(isolate, object, Object); | |
| 4228 } | |
| 4229 if (obj.IsSmi()) { | |
| 4230 const char* msg = "%s expects argument 'object' to be heap allocated."; | |
| 4231 return Api::NewError(msg, CURRENT_FUNC); | |
| 4232 } | |
| 4233 { | |
| 4234 NoGCScope no_gc; | |
| 4235 RawObject* raw_obj = obj.raw(); | |
| 4236 isolate->heap()->SetPeer(raw_obj, peer); | |
| 4237 } | |
| 4238 return Api::Success(isolate); | |
| 4239 } | |
| 4240 | |
| 4241 | |
| 4242 DART_EXPORT bool Dart_HasPeer(Dart_Handle object) { | |
| 4243 Isolate* isolate = Isolate::Current(); | |
| 4244 NoGCScope no_gc; | |
| 4245 RawObject* raw_obj = Api::UnwrapHandle(object); | |
| 4246 return raw_obj->IsHeapObject() && (isolate->heap()->GetPeer(raw_obj) != NULL); | |
| 4247 } | |
| 4248 | |
| 4193 } // namespace dart | 4249 } // namespace dart |
| OLD | NEW |