| 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 enum BuiltinLibraryId { | 24 enum BuiltinLibraryId { |
| 25 kBuiltinLibrary, | 25 // These libraries are included in the core snapshot. |
| 26 kBuiltinLibrary = 0, |
| 27 kJsonLibrary, |
| 28 kUriLibrary, |
| 29 |
| 30 // These libraries are not included in the core snapshot. |
| 26 kCryptoLibrary, | 31 kCryptoLibrary, |
| 27 kIOLibrary, | 32 kIOLibrary, |
| 28 kJsonLibrary, | |
| 29 kUriLibrary, | |
| 30 kUtfLibrary, | 33 kUtfLibrary, |
| 34 |
| 35 kInvalidLibrary, |
| 31 }; | 36 }; |
| 32 | 37 |
| 33 static Dart_Handle Source(BuiltinLibraryId id); | 38 static Dart_Handle Source(BuiltinLibraryId id); |
| 34 static void SetupLibrary(Dart_Handle library, BuiltinLibraryId id); | 39 static void SetupLibrary(Dart_Handle library, BuiltinLibraryId id); |
| 35 static Dart_Handle LoadLibrary(BuiltinLibraryId id); | 40 static Dart_Handle LoadLibrary(BuiltinLibraryId id); |
| 36 static void ImportLibrary(Dart_Handle library, BuiltinLibraryId id); | 41 static void ImportLibrary(Dart_Handle library, BuiltinLibraryId id); |
| 37 static void SetNativeResolver(BuiltinLibraryId id); | 42 static void SetNativeResolver(BuiltinLibraryId id); |
| 38 static void PrintString(FILE* out, Dart_Handle object); | 43 static void PrintString(FILE* out, Dart_Handle object); |
| 39 | 44 |
| 40 private: | 45 private: |
| 41 static Dart_NativeFunction NativeLookup(Dart_Handle name, | 46 static Dart_NativeFunction NativeLookup(Dart_Handle name, |
| 42 int argument_count); | 47 int argument_count); |
| 43 | 48 |
| 44 static const char builtin_source_[]; | 49 static const char builtin_source_[]; |
| 45 static const char crypto_source_[]; | 50 static const char crypto_source_[]; |
| 46 static const char io_source_[]; | 51 static const char io_source_[]; |
| 47 static const char json_source_[]; | 52 static const char json_source_[]; |
| 48 static const char uri_source_[]; | 53 static const char uri_source_[]; |
| 49 static const char utf_source_[]; | 54 static const char utf_source_[]; |
| 50 | 55 |
| 56 typedef struct { |
| 57 const char* url_; |
| 58 const char* source_; |
| 59 bool has_natives_; |
| 60 } builtin_lib_props; |
| 61 static builtin_lib_props builtin_libraries_[]; |
| 62 |
| 51 DISALLOW_ALLOCATION(); | 63 DISALLOW_ALLOCATION(); |
| 52 DISALLOW_IMPLICIT_CONSTRUCTORS(Builtin); | 64 DISALLOW_IMPLICIT_CONSTRUCTORS(Builtin); |
| 53 }; | 65 }; |
| 54 | 66 |
| 55 | 67 |
| 56 #endif // BIN_BUILTIN_H_ | 68 #endif // BIN_BUILTIN_H_ |
| OLD | NEW |