OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
6 * | 6 * |
7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
8 * | 8 * |
9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 /** | 966 /** |
967 * The superclass of values and API object templates. | 967 * The superclass of values and API object templates. |
968 */ | 968 */ |
969 class V8_EXPORT Data { | 969 class V8_EXPORT Data { |
970 private: | 970 private: |
971 Data(); | 971 Data(); |
972 }; | 972 }; |
973 | 973 |
974 | 974 |
975 /** | 975 /** |
| 976 * The optional attributes of ScriptOrigin. |
| 977 */ |
| 978 class ScriptOriginOptions { |
| 979 public: |
| 980 V8_INLINE ScriptOriginOptions(bool is_embedder_debug_script = false, |
| 981 bool is_shared_cross_origin = false, |
| 982 bool is_opaque = false) |
| 983 : flags_((is_embedder_debug_script ? kIsEmbedderDebugScript : 0) | |
| 984 (is_shared_cross_origin ? kIsSharedCrossOrigin : 0) | |
| 985 (is_opaque ? kIsOpaque : 0)) {} |
| 986 V8_INLINE ScriptOriginOptions(int flags) |
| 987 : flags_(flags & |
| 988 (kIsEmbedderDebugScript | kIsSharedCrossOrigin | kIsOpaque)) {} |
| 989 bool IsEmbedderDebugScript() const { return flags_ & kIsEmbedderDebugScript; } |
| 990 bool IsSharedCrossOrigin() const { return flags_ & kIsSharedCrossOrigin; } |
| 991 bool IsOpaque() const { return flags_ & kIsOpaque; } |
| 992 int Flags() const { return flags_; } |
| 993 |
| 994 private: |
| 995 enum { |
| 996 kIsEmbedderDebugScript = 1, |
| 997 kIsSharedCrossOrigin = 1 << 1, |
| 998 kIsOpaque = 1 << 2 |
| 999 }; |
| 1000 const int flags_; |
| 1001 }; |
| 1002 |
| 1003 /** |
976 * The origin, within a file, of a script. | 1004 * The origin, within a file, of a script. |
977 */ | 1005 */ |
978 class ScriptOrigin { | 1006 class ScriptOrigin { |
979 public: | 1007 public: |
980 V8_INLINE ScriptOrigin( | 1008 V8_INLINE ScriptOrigin( |
981 Handle<Value> resource_name, | 1009 Handle<Value> resource_name, |
982 Handle<Integer> resource_line_offset = Handle<Integer>(), | 1010 Handle<Integer> resource_line_offset = Handle<Integer>(), |
983 Handle<Integer> resource_column_offset = Handle<Integer>(), | 1011 Handle<Integer> resource_column_offset = Handle<Integer>(), |
984 Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>(), | 1012 Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>(), |
985 Handle<Integer> script_id = Handle<Integer>(), | 1013 Handle<Integer> script_id = Handle<Integer>(), |
986 Handle<Boolean> resource_is_embedder_debug_script = Handle<Boolean>(), | 1014 Handle<Boolean> resource_is_embedder_debug_script = Handle<Boolean>(), |
987 Handle<Value> source_map_url = Handle<Value>()) | 1015 Handle<Value> source_map_url = Handle<Value>(), |
988 : resource_name_(resource_name), | 1016 Handle<Boolean> resource_is_opaque = Handle<Boolean>()); |
989 resource_line_offset_(resource_line_offset), | |
990 resource_column_offset_(resource_column_offset), | |
991 resource_is_embedder_debug_script_(resource_is_embedder_debug_script), | |
992 resource_is_shared_cross_origin_(resource_is_shared_cross_origin), | |
993 script_id_(script_id), | |
994 source_map_url_(source_map_url) {} | |
995 V8_INLINE Handle<Value> ResourceName() const; | 1017 V8_INLINE Handle<Value> ResourceName() const; |
996 V8_INLINE Handle<Integer> ResourceLineOffset() const; | 1018 V8_INLINE Handle<Integer> ResourceLineOffset() const; |
997 V8_INLINE Handle<Integer> ResourceColumnOffset() const; | 1019 V8_INLINE Handle<Integer> ResourceColumnOffset() const; |
998 /** | 1020 /** |
999 * Returns true for embedder's debugger scripts | 1021 * Returns true for embedder's debugger scripts |
1000 */ | 1022 */ |
1001 V8_INLINE Handle<Boolean> ResourceIsEmbedderDebugScript() const; | |
1002 V8_INLINE Handle<Boolean> ResourceIsSharedCrossOrigin() const; | |
1003 V8_INLINE Handle<Integer> ScriptID() const; | 1023 V8_INLINE Handle<Integer> ScriptID() const; |
1004 V8_INLINE Handle<Value> SourceMapUrl() const; | 1024 V8_INLINE Handle<Value> SourceMapUrl() const; |
| 1025 V8_INLINE ScriptOriginOptions Options() const { return options_; } |
1005 | 1026 |
1006 private: | 1027 private: |
1007 Handle<Value> resource_name_; | 1028 Handle<Value> resource_name_; |
1008 Handle<Integer> resource_line_offset_; | 1029 Handle<Integer> resource_line_offset_; |
1009 Handle<Integer> resource_column_offset_; | 1030 Handle<Integer> resource_column_offset_; |
1010 Handle<Boolean> resource_is_embedder_debug_script_; | 1031 ScriptOriginOptions options_; |
1011 Handle<Boolean> resource_is_shared_cross_origin_; | |
1012 Handle<Integer> script_id_; | 1032 Handle<Integer> script_id_; |
1013 Handle<Value> source_map_url_; | 1033 Handle<Value> source_map_url_; |
1014 }; | 1034 }; |
1015 | 1035 |
1016 | 1036 |
1017 /** | 1037 /** |
1018 * A compiled JavaScript script, not yet tied to a Context. | 1038 * A compiled JavaScript script, not yet tied to a Context. |
1019 */ | 1039 */ |
1020 class V8_EXPORT UnboundScript { | 1040 class V8_EXPORT UnboundScript { |
1021 public: | 1041 public: |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 // Prevent copying. Not implemented. | 1173 // Prevent copying. Not implemented. |
1154 Source(const Source&); | 1174 Source(const Source&); |
1155 Source& operator=(const Source&); | 1175 Source& operator=(const Source&); |
1156 | 1176 |
1157 Local<String> source_string; | 1177 Local<String> source_string; |
1158 | 1178 |
1159 // Origin information | 1179 // Origin information |
1160 Handle<Value> resource_name; | 1180 Handle<Value> resource_name; |
1161 Handle<Integer> resource_line_offset; | 1181 Handle<Integer> resource_line_offset; |
1162 Handle<Integer> resource_column_offset; | 1182 Handle<Integer> resource_column_offset; |
1163 Handle<Boolean> resource_is_embedder_debug_script; | 1183 ScriptOriginOptions resource_options; |
1164 Handle<Boolean> resource_is_shared_cross_origin; | |
1165 Handle<Value> source_map_url; | 1184 Handle<Value> source_map_url; |
1166 | 1185 |
1167 // Cached data from previous compilation (if a kConsume*Cache flag is | 1186 // Cached data from previous compilation (if a kConsume*Cache flag is |
1168 // set), or hold newly generated cache data (kProduce*Cache flags) are | 1187 // set), or hold newly generated cache data (kProduce*Cache flags) are |
1169 // set when calling a compile method. | 1188 // set when calling a compile method. |
1170 CachedData* cached_data; | 1189 CachedData* cached_data; |
1171 }; | 1190 }; |
1172 | 1191 |
1173 /** | 1192 /** |
1174 * For streaming incomplete script data to V8. The embedder should implement a | 1193 * For streaming incomplete script data to V8. The embedder should implement a |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 * the error occurred. | 1462 * the error occurred. |
1444 */ | 1463 */ |
1445 V8_DEPRECATE_SOON("Use maybe version", int GetEndColumn() const); | 1464 V8_DEPRECATE_SOON("Use maybe version", int GetEndColumn() const); |
1446 V8_WARN_UNUSED_RESULT Maybe<int> GetEndColumn(Local<Context> context) const; | 1465 V8_WARN_UNUSED_RESULT Maybe<int> GetEndColumn(Local<Context> context) const; |
1447 | 1466 |
1448 /** | 1467 /** |
1449 * Passes on the value set by the embedder when it fed the script from which | 1468 * Passes on the value set by the embedder when it fed the script from which |
1450 * this Message was generated to V8. | 1469 * this Message was generated to V8. |
1451 */ | 1470 */ |
1452 bool IsSharedCrossOrigin() const; | 1471 bool IsSharedCrossOrigin() const; |
| 1472 bool IsOpaque() const; |
1453 | 1473 |
1454 // TODO(1245381): Print to a string instead of on a FILE. | 1474 // TODO(1245381): Print to a string instead of on a FILE. |
1455 static void PrintCurrentStackTrace(Isolate* isolate, FILE* out); | 1475 static void PrintCurrentStackTrace(Isolate* isolate, FILE* out); |
1456 | 1476 |
1457 static const int kNoLineNumberInfo = 0; | 1477 static const int kNoLineNumberInfo = 0; |
1458 static const int kNoColumnInfo = 0; | 1478 static const int kNoColumnInfo = 0; |
1459 static const int kNoScriptIdInfo = 0; | 1479 static const int kNoScriptIdInfo = 0; |
1460 }; | 1480 }; |
1461 | 1481 |
1462 | 1482 |
(...skipping 5756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7219 bool FunctionCallbackInfo<T>::IsConstructCall() const { | 7239 bool FunctionCallbackInfo<T>::IsConstructCall() const { |
7220 return is_construct_call_ & 0x1; | 7240 return is_construct_call_ & 0x1; |
7221 } | 7241 } |
7222 | 7242 |
7223 | 7243 |
7224 template<typename T> | 7244 template<typename T> |
7225 int FunctionCallbackInfo<T>::Length() const { | 7245 int FunctionCallbackInfo<T>::Length() const { |
7226 return length_; | 7246 return length_; |
7227 } | 7247 } |
7228 | 7248 |
| 7249 ScriptOrigin::ScriptOrigin(Handle<Value> resource_name, |
| 7250 Handle<Integer> resource_line_offset, |
| 7251 Handle<Integer> resource_column_offset, |
| 7252 Handle<Boolean> resource_is_shared_cross_origin, |
| 7253 Handle<Integer> script_id, |
| 7254 Handle<Boolean> resource_is_embedder_debug_script, |
| 7255 Handle<Value> source_map_url, |
| 7256 Handle<Boolean> resource_is_opaque) |
| 7257 : resource_name_(resource_name), |
| 7258 resource_line_offset_(resource_line_offset), |
| 7259 resource_column_offset_(resource_column_offset), |
| 7260 options_(!resource_is_embedder_debug_script.IsEmpty() && |
| 7261 resource_is_embedder_debug_script->IsTrue(), |
| 7262 !resource_is_shared_cross_origin.IsEmpty() && |
| 7263 resource_is_shared_cross_origin->IsTrue(), |
| 7264 !resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue()), |
| 7265 script_id_(script_id), |
| 7266 source_map_url_(source_map_url) {} |
7229 | 7267 |
7230 Handle<Value> ScriptOrigin::ResourceName() const { | 7268 Handle<Value> ScriptOrigin::ResourceName() const { |
7231 return resource_name_; | 7269 return resource_name_; |
7232 } | 7270 } |
7233 | 7271 |
7234 | 7272 |
7235 Handle<Integer> ScriptOrigin::ResourceLineOffset() const { | 7273 Handle<Integer> ScriptOrigin::ResourceLineOffset() const { |
7236 return resource_line_offset_; | 7274 return resource_line_offset_; |
7237 } | 7275 } |
7238 | 7276 |
7239 | 7277 |
7240 Handle<Integer> ScriptOrigin::ResourceColumnOffset() const { | 7278 Handle<Integer> ScriptOrigin::ResourceColumnOffset() const { |
7241 return resource_column_offset_; | 7279 return resource_column_offset_; |
7242 } | 7280 } |
7243 | 7281 |
7244 | 7282 |
7245 Handle<Boolean> ScriptOrigin::ResourceIsEmbedderDebugScript() const { | |
7246 return resource_is_embedder_debug_script_; | |
7247 } | |
7248 | |
7249 | |
7250 Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const { | |
7251 return resource_is_shared_cross_origin_; | |
7252 } | |
7253 | |
7254 | |
7255 Handle<Integer> ScriptOrigin::ScriptID() const { | 7283 Handle<Integer> ScriptOrigin::ScriptID() const { |
7256 return script_id_; | 7284 return script_id_; |
7257 } | 7285 } |
7258 | 7286 |
7259 | 7287 |
7260 Handle<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; } | 7288 Handle<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; } |
7261 | 7289 |
7262 | 7290 |
7263 ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin, | 7291 ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin, |
7264 CachedData* data) | 7292 CachedData* data) |
7265 : source_string(string), | 7293 : source_string(string), |
7266 resource_name(origin.ResourceName()), | 7294 resource_name(origin.ResourceName()), |
7267 resource_line_offset(origin.ResourceLineOffset()), | 7295 resource_line_offset(origin.ResourceLineOffset()), |
7268 resource_column_offset(origin.ResourceColumnOffset()), | 7296 resource_column_offset(origin.ResourceColumnOffset()), |
7269 resource_is_embedder_debug_script(origin.ResourceIsEmbedderDebugScript()), | 7297 resource_options(origin.Options()), |
7270 resource_is_shared_cross_origin(origin.ResourceIsSharedCrossOrigin()), | |
7271 source_map_url(origin.SourceMapUrl()), | 7298 source_map_url(origin.SourceMapUrl()), |
7272 cached_data(data) {} | 7299 cached_data(data) {} |
7273 | 7300 |
7274 | 7301 |
7275 ScriptCompiler::Source::Source(Local<String> string, | 7302 ScriptCompiler::Source::Source(Local<String> string, |
7276 CachedData* data) | 7303 CachedData* data) |
7277 : source_string(string), cached_data(data) {} | 7304 : source_string(string), cached_data(data) {} |
7278 | 7305 |
7279 | 7306 |
7280 ScriptCompiler::Source::~Source() { | 7307 ScriptCompiler::Source::~Source() { |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8024 */ | 8051 */ |
8025 | 8052 |
8026 | 8053 |
8027 } // namespace v8 | 8054 } // namespace v8 |
8028 | 8055 |
8029 | 8056 |
8030 #undef TYPE_CHECK | 8057 #undef TYPE_CHECK |
8031 | 8058 |
8032 | 8059 |
8033 #endif // V8_H_ | 8060 #endif // V8_H_ |
OLD | NEW |