OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project 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 V8_NATIVES_H_ | 5 #ifndef V8_NATIVES_H_ |
6 #define V8_NATIVES_H_ | 6 #define V8_NATIVES_H_ |
7 | 7 |
8 #include "src/vector.h" | 8 #include "src/vector.h" |
9 | 9 |
10 namespace v8 { class StartupData; } // Forward declaration. | 10 namespace v8 { class StartupData; } // Forward declaration. |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 typedef bool (*NativeSourceCallback)(Vector<const char> name, | |
16 Vector<const char> source, | |
17 int index); | |
18 | |
19 enum NativeType { | 15 enum NativeType { |
20 CORE, EXPERIMENTAL, D8, TEST | 16 CORE, EXPERIMENTAL, D8, TEST |
21 }; | 17 }; |
22 | 18 |
23 template <NativeType type> | 19 template <NativeType type> |
24 class NativesCollection { | 20 class NativesCollection { |
25 public: | 21 public: |
26 // Number of built-in scripts. | 22 // Number of built-in scripts. |
27 static int GetBuiltinsCount(); | 23 static int GetBuiltinsCount(); |
28 // Number of debugger implementation scripts. | 24 // Number of debugger implementation scripts. |
29 static int GetDebuggerCount(); | 25 static int GetDebuggerCount(); |
30 | 26 |
31 // These are used to access built-in scripts. The debugger implementation | 27 // These are used to access built-in scripts. The debugger implementation |
32 // scripts have an index in the interval [0, GetDebuggerCount()). The | 28 // scripts have an index in the interval [0, GetDebuggerCount()). The |
33 // non-debugger scripts have an index in the interval [GetDebuggerCount(), | 29 // non-debugger scripts have an index in the interval [GetDebuggerCount(), |
34 // GetNativesCount()). | 30 // GetNativesCount()). |
35 static int GetIndex(const char* name); | 31 static int GetIndex(const char* name); |
36 static int GetRawScriptsSize(); | 32 static Vector<const char> GetScriptSource(int index); |
37 static Vector<const char> GetRawScriptSource(int index); | |
38 static Vector<const char> GetScriptName(int index); | 33 static Vector<const char> GetScriptName(int index); |
39 static Vector<const byte> GetScriptsSource(); | 34 static Vector<const char> GetScriptsSource(); |
40 static void SetRawScriptsSource(Vector<const char> raw_source); | |
41 }; | 35 }; |
42 | 36 |
43 typedef NativesCollection<CORE> Natives; | 37 typedef NativesCollection<CORE> Natives; |
44 typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives; | 38 typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives; |
45 | 39 |
46 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 40 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
47 // Used for reading the natives at runtime. Implementation in natives-empty.cc | 41 // Used for reading the natives at runtime. Implementation in natives-empty.cc |
48 void SetNativesFromFile(StartupData* natives_blob); | 42 void SetNativesFromFile(StartupData* natives_blob); |
49 #endif | 43 #endif |
50 | 44 |
51 } } // namespace v8::internal | 45 } } // namespace v8::internal |
52 | 46 |
53 #endif // V8_NATIVES_H_ | 47 #endif // V8_NATIVES_H_ |
OLD | NEW |