| OLD | NEW |
| 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 | 4 |
| 5 #ifndef BIN_BUILTIN_H_ | 5 #ifndef BIN_BUILTIN_H_ |
| 6 #define BIN_BUILTIN_H_ | 6 #define BIN_BUILTIN_H_ |
| 7 | 7 |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 | 10 |
| 11 #include "include/dart_api.h" | 11 #include "include/dart_api.h" |
| 12 #include "platform/assert.h" | 12 #include "platform/assert.h" |
| 13 #include "platform/globals.h" | 13 #include "platform/globals.h" |
| 14 | 14 |
| 15 #define FUNCTION_NAME(name) Builtin_##name | 15 #define FUNCTION_NAME(name) Builtin_##name |
| 16 #define REGISTER_FUNCTION(name, count) \ | 16 #define REGISTER_FUNCTION(name, count) \ |
| 17 { ""#name, FUNCTION_NAME(name), count }, | 17 { ""#name, FUNCTION_NAME(name), count }, |
| 18 #define DECLARE_FUNCTION(name, count) \ | 18 #define DECLARE_FUNCTION(name, count) \ |
| 19 extern void FUNCTION_NAME(name)(Dart_NativeArguments args); | 19 extern void FUNCTION_NAME(name)(Dart_NativeArguments args); |
| 20 | 20 |
| 21 | 21 |
| 22 class Builtin { | 22 class Builtin { |
| 23 public: | 23 public: |
| 24 // Note: Changes to this enum should be accompanied with changes to | 24 // Note: Changes to this enum should be accompanied with changes to |
| 25 // the builtin_libraries_ array in builtin.cc and builtin_nolib.cc. | 25 // the builtin_libraries_ array in builtin.cc and builtin_nolib.cc. |
| 26 enum BuiltinLibraryId { | 26 enum BuiltinLibraryId { |
| 27 kBuiltinLibrary = 0, | 27 kBuiltinLibrary = 0, |
| 28 kJsonLibrary, | |
| 29 kUriLibrary, | |
| 30 kCryptoLibrary, | |
| 31 kIOLibrary, | 28 kIOLibrary, |
| 32 kUtfLibrary, | |
| 33 | 29 |
| 34 kInvalidLibrary, | 30 kInvalidLibrary, |
| 35 }; | 31 }; |
| 36 | 32 |
| 37 static Dart_Handle Source(BuiltinLibraryId id); | 33 static Dart_Handle Source(BuiltinLibraryId id); |
| 38 static void SetNativeResolver(BuiltinLibraryId id); | 34 static void SetNativeResolver(BuiltinLibraryId id); |
| 39 static Dart_Handle LoadAndCheckLibrary(BuiltinLibraryId id); | 35 static Dart_Handle LoadAndCheckLibrary(BuiltinLibraryId id); |
| 40 static void PrintString(FILE* out, Dart_Handle object); | 36 static void PrintString(FILE* out, Dart_Handle object); |
| 41 | 37 |
| 42 private: | 38 private: |
| 43 static Dart_NativeFunction NativeLookup(Dart_Handle name, | 39 static Dart_NativeFunction NativeLookup(Dart_Handle name, |
| 44 int argument_count); | 40 int argument_count); |
| 45 static Dart_NativeFunction BuiltinNativeLookup(Dart_Handle name, | 41 static Dart_NativeFunction BuiltinNativeLookup(Dart_Handle name, |
| 46 int argument_count); | 42 int argument_count); |
| 47 | 43 |
| 48 static const char async_source_[]; | |
| 49 static const char builtin_source_[]; | 44 static const char builtin_source_[]; |
| 50 static const char crypto_source_[]; | |
| 51 static const char io_source_[]; | 45 static const char io_source_[]; |
| 52 static const char io_patch_[]; | 46 static const char io_patch_[]; |
| 53 static const char json_source_[]; | |
| 54 static const char uri_source_[]; | |
| 55 static const char utf_source_[]; | |
| 56 static const char web_source_[]; | 47 static const char web_source_[]; |
| 57 | 48 |
| 58 typedef struct { | 49 typedef struct { |
| 59 const char* url_; | 50 const char* url_; |
| 60 const char* source_; | 51 const char* source_; |
| 61 const char* patch_url_; | 52 const char* patch_url_; |
| 62 const char* patch_source_; | 53 const char* patch_source_; |
| 63 bool has_natives_; | 54 bool has_natives_; |
| 64 } builtin_lib_props; | 55 } builtin_lib_props; |
| 65 static builtin_lib_props builtin_libraries_[]; | 56 static builtin_lib_props builtin_libraries_[]; |
| 66 | 57 |
| 67 DISALLOW_ALLOCATION(); | 58 DISALLOW_ALLOCATION(); |
| 68 DISALLOW_IMPLICIT_CONSTRUCTORS(Builtin); | 59 DISALLOW_IMPLICIT_CONSTRUCTORS(Builtin); |
| 69 }; | 60 }; |
| 70 | 61 |
| 71 | 62 |
| 72 #endif // BIN_BUILTIN_H_ | 63 #endif // BIN_BUILTIN_H_ |
| OLD | NEW |