| OLD | NEW |
| 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 #ifndef VM_DART_API_IMPL_H_ | 5 #ifndef VM_DART_API_IMPL_H_ |
| 6 #define VM_DART_API_IMPL_H_ | 6 #define VM_DART_API_IMPL_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 | 9 |
| 10 #define RETURN_FAILURE(msg) return Dart_ErrorResult(msg) | |
| 11 #define RETURN_CINT(retval) return Dart_ResultAsCIntptr(retval) | |
| 12 #define RETURN_CBOOLEAN(retval) return Dart_ResultAsCBoolean(retval) | |
| 13 #define RETURN_CSTRING(retval) return Dart_ResultAsCString(retval) | |
| 14 #define RETURN_OBJECT(obj) return Dart_ResultAsObject(Api::NewLocalHandle(obj)) | |
| 15 #define RETURN_CINT64(retval) return Dart_ResultAsCInt64(retval) | |
| 16 #define RETURN_CDOUBLE(retval) return Dart_ResultAsCDouble(retval) | |
| 17 | |
| 18 namespace dart { | 10 namespace dart { |
| 19 | 11 |
| 20 // Forward declarations. | 12 class ApiState; |
| 13 class LocalHandle; |
| 21 class Object; | 14 class Object; |
| 15 class PersistentHandle; |
| 22 class RawObject; | 16 class RawObject; |
| 23 class LocalHandle; | |
| 24 class PersistentHandle; | |
| 25 class ApiState; | |
| 26 | 17 |
| 27 class Api : AllStatic { | 18 class Api : AllStatic { |
| 28 public: | 19 public: |
| 29 // Create new local handles. | 20 // Create new local handles. |
| 30 static Dart_Handle NewLocalHandle(const Object& object); | 21 static Dart_Handle NewLocalHandle(const Object& object); |
| 31 | 22 |
| 32 // Unwrap the raw object from the handle. | 23 // Unwrap the raw object from the handle. |
| 33 static RawObject* UnwrapHandle(Dart_Handle object); | 24 static RawObject* UnwrapHandle(Dart_Handle object); |
| 34 | 25 |
| 35 // Validate and convert the passed in handle as a local handle. | 26 // Validate and convert the passed in handle as a local handle. |
| 36 static LocalHandle* UnwrapAsLocalHandle(const ApiState& state, | 27 static LocalHandle* UnwrapAsLocalHandle(const ApiState& state, |
| 37 Dart_Handle object); | 28 Dart_Handle object); |
| 38 | 29 |
| 39 // Validate and convert the passed in handle as a persistent handle. | 30 // Validate and convert the passed in handle as a persistent handle. |
| 40 static PersistentHandle* UnwrapAsPersistentHandle(const ApiState& state, | 31 static PersistentHandle* UnwrapAsPersistentHandle(const ApiState& state, |
| 41 Dart_Handle object); | 32 Dart_Handle object); |
| 42 | 33 |
| 34 // Get the handle used to designate successful return. |
| 35 static Dart_Handle Success(); |
| 36 |
| 37 // Generate a handle used to designate an error return. |
| 38 static Dart_Handle Error(const char* msg); |
| 39 |
| 43 // Allocate space in the local zone. | 40 // Allocate space in the local zone. |
| 44 static uword Allocate(intptr_t size); | 41 static uword Allocate(intptr_t size); |
| 45 | 42 |
| 46 // Reallocate space in the local zone. | 43 // Reallocate space in the local zone. |
| 47 static uword Reallocate(uword ptr, intptr_t old_size, intptr_t new_size); | 44 static uword Reallocate(uword ptr, intptr_t old_size, intptr_t new_size); |
| 48 }; | 45 }; |
| 49 | 46 |
| 50 } // namespace dart. | 47 } // namespace dart. |
| 51 | 48 |
| 52 #endif // VM_DART_API_IMPL_H_ | 49 #endif // VM_DART_API_IMPL_H_ |
| OLD | NEW |