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

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

Issue 9465004: Add native extensions for the Dart shell to mac and windows (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typos Created 8 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 | Annotate | Revision Log
OLDNEW
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
5 #include <string.h> 4 #include <string.h>
6 5
7 #include "../include/dart_api.h" 6 #include "include/dart_api.h"
8 7
9 #define EXPORT_SYMBOL __attribute__ ((visibility ("default"))) 8 DART_EXTERN_C Dart_NativeFunction ResolveName(Dart_Handle name, int argc);
10 9
11 extern "C" Dart_NativeFunction ResolveName(Dart_Handle name, int argc); 10 DART_EXPORT Dart_Handle test_extension_Init(
11 Dart_Handle parent_library) {
12 if (Dart_IsError(parent_library)) {
13 return parent_library;
Bill Hesse 2012/03/06 15:04:07 Reformat to longer lines.
14 }
12 15
13 extern "C" EXPORT_SYMBOL Dart_Handle test_extension_Init(Dart_Handle library) { 16 Dart_Handle check_return =
14 if (Dart_IsError(library)) return library; 17 Dart_SetNativeResolver(parent_library, ResolveName);
15 Dart_Handle check_return = Dart_SetNativeResolver(library, ResolveName);
16 if (Dart_IsError(check_return)) return check_return; 18 if (Dart_IsError(check_return)) return check_return;
17 return Dart_Null(); 19
20 return parent_library;
18 } 21 }
19 22
20 extern "C" void IfNull(Dart_NativeArguments arguments) { 23 DART_EXTERN_C void IfNull(Dart_NativeArguments arguments) {
Søren Gjesse 2012/03/07 06:58:31 Should we add an additional macro DART_NATIVE (or
21 Dart_Handle object = Dart_GetNativeArgument(arguments, 0); 24 Dart_Handle object = Dart_GetNativeArgument(arguments, 0);
25
22 if (Dart_IsNull(object)) { 26 if (Dart_IsNull(object)) {
23 Dart_SetReturnValue(arguments, Dart_GetNativeArgument(arguments, 1)); 27 Dart_SetReturnValue(arguments, Dart_GetNativeArgument(arguments, 1));
24 } else { 28 } else {
25 Dart_SetReturnValue(arguments, object); 29 Dart_SetReturnValue(arguments, object);
26 } 30 }
27 } 31 }
28 32
29 extern "C" Dart_NativeFunction ResolveName(Dart_Handle name, int argc) { 33 DART_EXTERN_C Dart_NativeFunction ResolveName(Dart_Handle name, int argc) {
Ivan Posva 2012/03/07 07:22:51 Can you please explain why these need to be 'exter
30 assert(Dart_IsString8(name)); 34 assert(Dart_IsString8(name));
31 const char* cname; 35 const char* cname;
32 Dart_Handle check_error; 36 Dart_Handle check_error;
33 37
34 check_error = Dart_StringToCString(name, &cname); 38 check_error = Dart_StringToCString(name, &cname);
35 if (Dart_IsError(check_error)) return NULL; 39 if (Dart_IsError(check_error)) return NULL;
36 if (!strcmp("Cat_IfNull", cname) && argc == 2) { 40 if (!strcmp("TestExtension_IfNull", cname) && argc == 2) {
37 return IfNull; 41 return IfNull;
38 } 42 }
39 return NULL; 43 return NULL;
40 } 44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698