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

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

Issue 15689013: - Modify dart_api.h to be a proper C API. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/test_extension.c ('k') | runtime/include/dart_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 #include <string.h>
5
6 #include "include/dart_api.h"
7
8
9 namespace dart {
10 namespace bin {
11
12 Dart_NativeFunction ResolveName(Dart_Handle name, int argc);
13
14 DART_EXPORT Dart_Handle test_extension_Init(Dart_Handle parent_library) {
15 if (Dart_IsError(parent_library)) { return parent_library; }
16
17 Dart_Handle result_code = Dart_SetNativeResolver(parent_library, ResolveName);
18 if (Dart_IsError(result_code)) return result_code;
19
20 return parent_library;
21 }
22
23
24 void IfNull(Dart_NativeArguments arguments) {
25 Dart_Handle object = Dart_GetNativeArgument(arguments, 0);
26 if (Dart_IsNull(object)) {
27 Dart_SetReturnValue(arguments, Dart_GetNativeArgument(arguments, 1));
28 } else {
29 Dart_SetReturnValue(arguments, object);
30 }
31 }
32
33
34 void ThrowMeTheBall(Dart_NativeArguments arguments) {
35 Dart_Handle object = Dart_GetNativeArgument(arguments, 0);
36 Dart_ThrowException(object);
37 }
38
39
40 Dart_NativeFunction ResolveName(Dart_Handle name, int argc) {
41 assert(Dart_IsString(name));
42 const char* cname;
43 Dart_Handle check_error;
44
45 check_error = Dart_StringToCString(name, &cname);
46 if (Dart_IsError(check_error)) {
47 Dart_PropagateError(check_error);
48 }
49 if ((strcmp("TestExtension_IfNull", cname) == 0) && (argc == 2)) {
50 return IfNull;
51 }
52 if ((strcmp("TestExtension_ThrowMeTheBall", cname) == 0) && (argc == 1)) {
53 return ThrowMeTheBall;
54 }
55 return NULL;
56 }
57
58 } // namespace bin
59 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/test_extension.c ('k') | runtime/include/dart_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698