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

Side by Side Diff: runtime/vm/dart_api_impl.h

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
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 #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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698