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

Side by Side Diff: mojo/dart/embedder/common.h

Issue 1786473004: Rolls Dart runtime forward. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: whitespace Created 4 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
« no previous file with comments | « DEPS ('k') | mojo/dart/embedder/common.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_DART_EMBEDDER_COMMON_H_ 5 #ifndef MOJO_DART_EMBEDDER_COMMON_H_
6 #define MOJO_DART_EMBEDDER_COMMON_H_ 6 #define MOJO_DART_EMBEDDER_COMMON_H_
7 7
8 #include "dart/runtime/include/dart_api.h" 8 #include "dart/runtime/include/dart_api.h"
9 9
10 namespace mojo { 10 namespace mojo {
11 namespace dart { 11 namespace dart {
12 12
13 class DartEmbedder { 13 class DartEmbedder {
14 public: 14 public:
15 static Dart_Handle GetDartType(const char* library_url, 15 static Dart_Handle GetDartType(const char* library_url,
16 const char* class_name); 16 const char* class_name);
17 17
18 static Dart_Handle NewDartExceptionWithMessage(const char* library_url, 18 static Dart_Handle NewDartExceptionWithMessage(const char* library_url,
19 const char* error_type, 19 const char* error_type,
20 const char* message); 20 const char* message);
21 21
22 static Dart_Handle NewInternalError(const char* message); 22 static Dart_Handle NewInternalError(const char* message);
23 23
24 // Returns the integer value of a Dart object. If the object is not 24 // Returns the integer value of a Dart object. If the object is not
25 // an integer value an API error is propagated. 25 // an integer value an API error is propagated.
26 static int64_t GetIntegerValue(Dart_Handle value_obj); 26 static int64_t GetIntegerValue(Dart_Handle value_obj);
27
27 // Returns the integer value of a Dart object. If the object is not 28 // Returns the integer value of a Dart object. If the object is not
28 // an integer value or outside the requested range an API error is 29 // an integer value or outside the requested range, an API error is
29 // propagated. 30 // propagated.
30 static int64_t GetInt64ValueCheckRange( 31 static int64_t GetInt64ValueCheckRange(
31 Dart_Handle value_obj, int64_t lower, int64_t upper); 32 Dart_Handle value_obj, int64_t lower, int64_t upper);
33
32 // Returns the intptr_t value of a Dart object. If the object is not 34 // Returns the intptr_t value of a Dart object. If the object is not
33 // an integer value or the value is outside the intptr_t range an 35 // an integer value or the value is outside the intptr_t range, an
34 // API error is propagated. 36 // API error is propagated.
35 static intptr_t GetIntptrValue(Dart_Handle value_obj); 37 static intptr_t GetIntptrValue(Dart_Handle value_obj);
38
36 // Returns the string value of a Dart object. If the object is not 39 // Returns the string value of a Dart object. If the object is not
37 // a string value an API error is propagated. 40 // a string value, an API error is propagated.
38 static const char* GetStringValue(Dart_Handle str_obj); 41 static const char* GetStringValue(Dart_Handle str_obj);
42
39 // Returns the boolean value of a Dart object. If the object is not 43 // Returns the boolean value of a Dart object. If the object is not
40 // a boolean value an API error is propagated. 44 // a boolean value, an API error is propagated.
41 static bool GetBooleanValue(Dart_Handle bool_obj); 45 static bool GetBooleanValue(Dart_Handle bool_obj);
46
42 // Sets the field "name" in handle to val. Any error is propagated. 47 // Sets the field "name" in handle to val. Any error is propagated.
43 static void SetIntegerField(Dart_Handle handle, 48 static void SetIntegerField(Dart_Handle handle,
44 const char* name, 49 const char* name,
45 int64_t val); 50 int64_t val);
51
46 // Sets the field "name" in handle to val. Any error is propagated. 52 // Sets the field "name" in handle to val. Any error is propagated.
47 static void SetStringField(Dart_Handle handle, 53 static void SetStringField(Dart_Handle handle,
48 const char* name, 54 const char* name,
49 const char* val); 55 const char* val);
56
50 // Returns a new Dart string. Any error is propagated. 57 // Returns a new Dart string. Any error is propagated.
51 static Dart_Handle NewCString(const char* str); 58 static Dart_Handle NewCString(const char* str);
52 59
53 // Sets the return value in arguments to null. 60 // Sets the return value in arguments to null.
54 static void SetNullReturn(Dart_NativeArguments arguments); 61 static void SetNullReturn(Dart_NativeArguments arguments);
55 62
56 // Sets the return value in arguments to a string created from |str|. 63 // Sets the return value in arguments to a string created from |str|.
57 static void SetCStringReturn(Dart_NativeArguments arguments, const char* str); 64 static void SetCStringReturn(Dart_NativeArguments arguments, const char* str);
58 65
66 // Returns the boolean value from native arguments. If the object is not
67 // a boolean value, an API error is propagated.
68 static bool GetBooleanArgument(Dart_NativeArguments args, intptr_t index);
69
70 // Returns the integer value from native arguments. If the object is not
71 // an integer value, an API error is propagated.
72 static int64_t GetIntegerArgument(Dart_NativeArguments args, intptr_t index);
73 static intptr_t GetIntptrArgument(Dart_NativeArguments args, intptr_t index);
74
59 // Gets the string argument at index and returns a C string. 75 // Gets the string argument at index and returns a C string.
60 // Any error is propagated. 76 // Any error is propagated.
61 static const char* GetStringArgument(Dart_NativeArguments arguments, 77 static const char* GetStringArgument(Dart_NativeArguments arguments,
62 intptr_t index); 78 intptr_t index);
63 79
64 // Copies the bytes from a TypedDataList argument at |index| into a C array. 80 // Copies the bytes from a TypedDataList argument at |index| into a C array.
65 // Any error is propagated. Caller must call free on |out|. 81 // Any error is propagated. Caller must call free on |out|.
66 // NOTE: Only supports Uint8List now. 82 // NOTE: Only supports Uint8List now.
67 static void GetTypedDataListArgument(Dart_NativeArguments arguments, 83 static void GetTypedDataListArgument(Dart_NativeArguments arguments,
68 intptr_t index, 84 intptr_t index,
69 uint8_t** out, 85 uint8_t** out,
70 intptr_t* out_len); 86 intptr_t* out_len);
71 87
72 // Creates a Uint8List with a copy of bytes. 88 // Creates a Uint8List with a copy of bytes.
73 // Any error is propagated. 89 // Any error is propagated.
74 static Dart_Handle MakeUint8TypedData(uint8_t* bytes, intptr_t length); 90 static Dart_Handle MakeUint8TypedData(uint8_t* bytes, intptr_t length);
75 }; 91 };
76 92
77 } // namespace dart 93 } // namespace dart
78 } // namespace mojo 94 } // namespace mojo
79 95
80 96
81 #endif // MOJO_DART_EMBEDDER_COMMON_H_ 97 #endif // MOJO_DART_EMBEDDER_COMMON_H_
OLDNEW
« no previous file with comments | « DEPS ('k') | mojo/dart/embedder/common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698