OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 /** | 604 /** |
605 * Returns true if the source code could not be parsed. | 605 * Returns true if the source code could not be parsed. |
606 */ | 606 */ |
607 virtual bool HasError() = 0; | 607 virtual bool HasError() = 0; |
608 }; | 608 }; |
609 | 609 |
610 | 610 |
611 /** | 611 /** |
612 * The origin, within a file, of a script. | 612 * The origin, within a file, of a script. |
613 */ | 613 */ |
614 class V8EXPORT ScriptOrigin { | 614 class ScriptOrigin { |
615 public: | 615 public: |
616 V8_INLINE(ScriptOrigin( | 616 V8_INLINE(ScriptOrigin( |
617 Handle<Value> resource_name, | 617 Handle<Value> resource_name, |
618 Handle<Integer> resource_line_offset = Handle<Integer>(), | 618 Handle<Integer> resource_line_offset = Handle<Integer>(), |
619 Handle<Integer> resource_column_offset = Handle<Integer>())) | 619 Handle<Integer> resource_column_offset = Handle<Integer>())) |
620 : resource_name_(resource_name), | 620 : resource_name_(resource_name), |
621 resource_line_offset_(resource_line_offset), | 621 resource_line_offset_(resource_line_offset), |
622 resource_column_offset_(resource_column_offset) { } | 622 resource_column_offset_(resource_column_offset) { } |
623 V8_INLINE(Handle<Value> ResourceName() const); | 623 V8_INLINE(Handle<Value> ResourceName() const); |
624 V8_INLINE(Handle<Integer> ResourceLineOffset() const); | 624 V8_INLINE(Handle<Integer> ResourceLineOffset() const); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 bool IsConstructor() const; | 897 bool IsConstructor() const; |
898 }; | 898 }; |
899 | 899 |
900 | 900 |
901 // --- Value --- | 901 // --- Value --- |
902 | 902 |
903 | 903 |
904 /** | 904 /** |
905 * The superclass of all JavaScript values and objects. | 905 * The superclass of all JavaScript values and objects. |
906 */ | 906 */ |
907 class V8EXPORT Value : public Data { | 907 class Value : public Data { |
908 public: | 908 public: |
909 /** | 909 /** |
910 * Returns true if this value is the undefined value. See ECMA-262 | 910 * Returns true if this value is the undefined value. See ECMA-262 |
911 * 4.3.10. | 911 * 4.3.10. |
912 */ | 912 */ |
913 V8_INLINE(bool IsUndefined() const); | 913 V8_INLINE(bool IsUndefined() const); |
914 | 914 |
915 /** | 915 /** |
916 * Returns true if this value is the null value. See ECMA-262 | 916 * Returns true if this value is the null value. See ECMA-262 |
917 * 4.3.11. | 917 * 4.3.11. |
918 */ | 918 */ |
919 V8_INLINE(bool IsNull() const); | 919 V8_INLINE(bool IsNull() const); |
920 | 920 |
921 /** | 921 /** |
922 * Returns true if this value is true. | 922 * Returns true if this value is true. |
923 */ | 923 */ |
924 bool IsTrue() const; | 924 V8EXPORT bool IsTrue() const; |
925 | 925 |
926 /** | 926 /** |
927 * Returns true if this value is false. | 927 * Returns true if this value is false. |
928 */ | 928 */ |
929 bool IsFalse() const; | 929 V8EXPORT bool IsFalse() const; |
930 | 930 |
931 /** | 931 /** |
932 * Returns true if this value is an instance of the String type. | 932 * Returns true if this value is an instance of the String type. |
933 * See ECMA-262 8.4. | 933 * See ECMA-262 8.4. |
934 */ | 934 */ |
935 V8_INLINE(bool IsString() const); | 935 V8_INLINE(bool IsString() const); |
936 | 936 |
937 /** | 937 /** |
938 * Returns true if this value is a function. | 938 * Returns true if this value is a function. |
939 */ | 939 */ |
940 bool IsFunction() const; | 940 V8EXPORT bool IsFunction() const; |
941 | 941 |
942 /** | 942 /** |
943 * Returns true if this value is an array. | 943 * Returns true if this value is an array. |
944 */ | 944 */ |
945 bool IsArray() const; | 945 V8EXPORT bool IsArray() const; |
946 | 946 |
947 /** | 947 /** |
948 * Returns true if this value is an object. | 948 * Returns true if this value is an object. |
949 */ | 949 */ |
950 bool IsObject() const; | 950 V8EXPORT bool IsObject() const; |
951 | 951 |
952 /** | 952 /** |
953 * Returns true if this value is boolean. | 953 * Returns true if this value is boolean. |
954 */ | 954 */ |
955 bool IsBoolean() const; | 955 V8EXPORT bool IsBoolean() const; |
956 | 956 |
957 /** | 957 /** |
958 * Returns true if this value is a number. | 958 * Returns true if this value is a number. |
959 */ | 959 */ |
960 bool IsNumber() const; | 960 V8EXPORT bool IsNumber() const; |
961 | 961 |
962 /** | 962 /** |
963 * Returns true if this value is external. | 963 * Returns true if this value is external. |
964 */ | 964 */ |
965 bool IsExternal() const; | 965 V8EXPORT bool IsExternal() const; |
966 | 966 |
967 /** | 967 /** |
968 * Returns true if this value is a 32-bit signed integer. | 968 * Returns true if this value is a 32-bit signed integer. |
969 */ | 969 */ |
970 bool IsInt32() const; | 970 V8EXPORT bool IsInt32() const; |
971 | 971 |
972 /** | 972 /** |
973 * Returns true if this value is a 32-bit unsigned integer. | 973 * Returns true if this value is a 32-bit unsigned integer. |
974 */ | 974 */ |
975 bool IsUint32() const; | 975 V8EXPORT bool IsUint32() const; |
976 | 976 |
977 /** | 977 /** |
978 * Returns true if this value is a Date. | 978 * Returns true if this value is a Date. |
979 */ | 979 */ |
980 bool IsDate() const; | 980 V8EXPORT bool IsDate() const; |
981 | 981 |
982 /** | 982 /** |
983 * Returns true if this value is a Boolean object. | 983 * Returns true if this value is a Boolean object. |
984 */ | 984 */ |
985 bool IsBooleanObject() const; | 985 V8EXPORT bool IsBooleanObject() const; |
986 | 986 |
987 /** | 987 /** |
988 * Returns true if this value is a Number object. | 988 * Returns true if this value is a Number object. |
989 */ | 989 */ |
990 bool IsNumberObject() const; | 990 V8EXPORT bool IsNumberObject() const; |
991 | 991 |
992 /** | 992 /** |
993 * Returns true if this value is a String object. | 993 * Returns true if this value is a String object. |
994 */ | 994 */ |
995 bool IsStringObject() const; | 995 V8EXPORT bool IsStringObject() const; |
996 | 996 |
997 /** | 997 /** |
998 * Returns true if this value is a NativeError. | 998 * Returns true if this value is a NativeError. |
999 */ | 999 */ |
1000 bool IsNativeError() const; | 1000 V8EXPORT bool IsNativeError() const; |
1001 | 1001 |
1002 /** | 1002 /** |
1003 * Returns true if this value is a RegExp. | 1003 * Returns true if this value is a RegExp. |
1004 */ | 1004 */ |
1005 bool IsRegExp() const; | 1005 V8EXPORT bool IsRegExp() const; |
1006 | 1006 |
1007 Local<Boolean> ToBoolean() const; | 1007 V8EXPORT Local<Boolean> ToBoolean() const; |
1008 Local<Number> ToNumber() const; | 1008 V8EXPORT Local<Number> ToNumber() const; |
1009 Local<String> ToString() const; | 1009 V8EXPORT Local<String> ToString() const; |
1010 Local<String> ToDetailString() const; | 1010 V8EXPORT Local<String> ToDetailString() const; |
1011 Local<Object> ToObject() const; | 1011 V8EXPORT Local<Object> ToObject() const; |
1012 Local<Integer> ToInteger() const; | 1012 V8EXPORT Local<Integer> ToInteger() const; |
1013 Local<Uint32> ToUint32() const; | 1013 V8EXPORT Local<Uint32> ToUint32() const; |
1014 Local<Int32> ToInt32() const; | 1014 V8EXPORT Local<Int32> ToInt32() const; |
1015 | 1015 |
1016 /** | 1016 /** |
1017 * Attempts to convert a string to an array index. | 1017 * Attempts to convert a string to an array index. |
1018 * Returns an empty handle if the conversion fails. | 1018 * Returns an empty handle if the conversion fails. |
1019 */ | 1019 */ |
1020 Local<Uint32> ToArrayIndex() const; | 1020 V8EXPORT Local<Uint32> ToArrayIndex() const; |
1021 | 1021 |
1022 bool BooleanValue() const; | 1022 V8EXPORT bool BooleanValue() const; |
1023 double NumberValue() const; | 1023 V8EXPORT double NumberValue() const; |
1024 int64_t IntegerValue() const; | 1024 V8EXPORT int64_t IntegerValue() const; |
1025 uint32_t Uint32Value() const; | 1025 V8EXPORT uint32_t Uint32Value() const; |
1026 int32_t Int32Value() const; | 1026 V8EXPORT int32_t Int32Value() const; |
1027 | 1027 |
1028 /** JS == */ | 1028 /** JS == */ |
1029 bool Equals(Handle<Value> that) const; | 1029 V8EXPORT bool Equals(Handle<Value> that) const; |
1030 bool StrictEquals(Handle<Value> that) const; | 1030 V8EXPORT bool StrictEquals(Handle<Value> that) const; |
1031 | 1031 |
1032 private: | 1032 private: |
1033 V8_INLINE(bool QuickIsUndefined() const); | 1033 V8_INLINE(bool QuickIsUndefined() const); |
1034 V8_INLINE(bool QuickIsNull() const); | 1034 V8_INLINE(bool QuickIsNull() const); |
1035 V8_INLINE(bool QuickIsString() const); | 1035 V8_INLINE(bool QuickIsString() const); |
1036 bool FullIsUndefined() const; | 1036 V8EXPORT bool FullIsUndefined() const; |
1037 bool FullIsNull() const; | 1037 V8EXPORT bool FullIsNull() const; |
1038 bool FullIsString() const; | 1038 V8EXPORT bool FullIsString() const; |
1039 }; | 1039 }; |
1040 | 1040 |
1041 | 1041 |
1042 /** | 1042 /** |
1043 * The superclass of primitive values. See ECMA-262 4.3.2. | 1043 * The superclass of primitive values. See ECMA-262 4.3.2. |
1044 */ | 1044 */ |
1045 class V8EXPORT Primitive : public Value { }; | 1045 class Primitive : public Value { }; |
1046 | 1046 |
1047 | 1047 |
1048 /** | 1048 /** |
1049 * A primitive boolean value (ECMA-262, 4.3.14). Either the true | 1049 * A primitive boolean value (ECMA-262, 4.3.14). Either the true |
1050 * or false value. | 1050 * or false value. |
1051 */ | 1051 */ |
1052 class V8EXPORT Boolean : public Primitive { | 1052 class Boolean : public Primitive { |
1053 public: | 1053 public: |
1054 bool Value() const; | 1054 V8EXPORT bool Value() const; |
1055 V8_INLINE(static Handle<Boolean> New(bool value)); | 1055 V8_INLINE(static Handle<Boolean> New(bool value)); |
1056 }; | 1056 }; |
1057 | 1057 |
1058 | 1058 |
1059 /** | 1059 /** |
1060 * A JavaScript string value (ECMA-262, 4.3.17). | 1060 * A JavaScript string value (ECMA-262, 4.3.17). |
1061 */ | 1061 */ |
1062 class V8EXPORT String : public Primitive { | 1062 class String : public Primitive { |
1063 public: | 1063 public: |
1064 enum Encoding { | 1064 enum Encoding { |
1065 UNKNOWN_ENCODING = 0x1, | 1065 UNKNOWN_ENCODING = 0x1, |
1066 TWO_BYTE_ENCODING = 0x0, | 1066 TWO_BYTE_ENCODING = 0x0, |
1067 ASCII_ENCODING = 0x4, | 1067 ASCII_ENCODING = 0x4 |
1068 ONE_BYTE_ENCODING = 0x4 | |
1069 }; | 1068 }; |
1070 /** | 1069 /** |
1071 * Returns the number of characters in this string. | 1070 * Returns the number of characters in this string. |
1072 */ | 1071 */ |
1073 int Length() const; | 1072 V8EXPORT int Length() const; |
1074 | 1073 |
1075 /** | 1074 /** |
1076 * Returns the number of bytes in the UTF-8 encoded | 1075 * Returns the number of bytes in the UTF-8 encoded |
1077 * representation of this string. | 1076 * representation of this string. |
1078 */ | 1077 */ |
1079 int Utf8Length() const; | 1078 V8EXPORT int Utf8Length() const; |
1080 | 1079 |
1081 /** | 1080 /** |
1082 * A fast conservative check for non-ASCII characters. May | 1081 * A fast conservative check for non-ASCII characters. May |
1083 * return true even for ASCII strings, but if it returns | 1082 * return true even for ASCII strings, but if it returns |
1084 * false you can be sure that all characters are in the range | 1083 * false you can be sure that all characters are in the range |
1085 * 0-127. | 1084 * 0-127. |
1086 */ | 1085 */ |
1087 bool MayContainNonAscii() const; | 1086 V8EXPORT bool MayContainNonAscii() const; |
1088 | |
1089 /** | |
1090 * Returns whether this string contains only one byte data. | |
1091 */ | |
1092 bool IsOneByte() const; | |
1093 | 1087 |
1094 /** | 1088 /** |
1095 * Write the contents of the string to an external buffer. | 1089 * Write the contents of the string to an external buffer. |
1096 * If no arguments are given, expects the buffer to be large | 1090 * If no arguments are given, expects the buffer to be large |
1097 * enough to hold the entire string and NULL terminator. Copies | 1091 * enough to hold the entire string and NULL terminator. Copies |
1098 * the contents of the string and the NULL terminator into the | 1092 * the contents of the string and the NULL terminator into the |
1099 * buffer. | 1093 * buffer. |
1100 * | 1094 * |
1101 * WriteUtf8 will not write partial UTF-8 sequences, preferring to stop | 1095 * WriteUtf8 will not write partial UTF-8 sequences, preferring to stop |
1102 * before the end of the buffer. | 1096 * before the end of the buffer. |
(...skipping 14 matching lines...) Expand all Loading... |
1117 * including the null terminator (if written). | 1111 * including the null terminator (if written). |
1118 */ | 1112 */ |
1119 enum WriteOptions { | 1113 enum WriteOptions { |
1120 NO_OPTIONS = 0, | 1114 NO_OPTIONS = 0, |
1121 HINT_MANY_WRITES_EXPECTED = 1, | 1115 HINT_MANY_WRITES_EXPECTED = 1, |
1122 NO_NULL_TERMINATION = 2, | 1116 NO_NULL_TERMINATION = 2, |
1123 PRESERVE_ASCII_NULL = 4 | 1117 PRESERVE_ASCII_NULL = 4 |
1124 }; | 1118 }; |
1125 | 1119 |
1126 // 16-bit character codes. | 1120 // 16-bit character codes. |
1127 int Write(uint16_t* buffer, | 1121 V8EXPORT int Write(uint16_t* buffer, |
1128 int start = 0, | 1122 int start = 0, |
1129 int length = -1, | 1123 int length = -1, |
1130 int options = NO_OPTIONS) const; | 1124 int options = NO_OPTIONS) const; |
1131 // ASCII characters. | 1125 // ASCII characters. |
1132 int WriteAscii(char* buffer, | 1126 V8EXPORT int WriteAscii(char* buffer, |
1133 int start = 0, | 1127 int start = 0, |
1134 int length = -1, | 1128 int length = -1, |
1135 int options = NO_OPTIONS) const; | 1129 int options = NO_OPTIONS) const; |
1136 // One byte characters. | |
1137 int WriteOneByte(uint8_t* buffer, | |
1138 int start = 0, | |
1139 int length = -1, | |
1140 int options = NO_OPTIONS) const; | |
1141 // UTF-8 encoded characters. | 1130 // UTF-8 encoded characters. |
1142 int WriteUtf8(char* buffer, | 1131 V8EXPORT int WriteUtf8(char* buffer, |
1143 int length = -1, | 1132 int length = -1, |
1144 int* nchars_ref = NULL, | 1133 int* nchars_ref = NULL, |
1145 int options = NO_OPTIONS) const; | 1134 int options = NO_OPTIONS) const; |
1146 | 1135 |
1147 /** | 1136 /** |
1148 * A zero length string. | 1137 * A zero length string. |
1149 */ | 1138 */ |
1150 static v8::Local<v8::String> Empty(); | 1139 V8EXPORT static v8::Local<v8::String> Empty(); |
1151 V8_INLINE(static v8::Local<v8::String> Empty(Isolate* isolate)); | 1140 V8_INLINE(static v8::Local<v8::String> Empty(Isolate* isolate)); |
1152 | 1141 |
1153 /** | 1142 /** |
1154 * Returns true if the string is external | 1143 * Returns true if the string is external |
1155 */ | 1144 */ |
1156 bool IsExternal() const; | 1145 V8EXPORT bool IsExternal() const; |
1157 | 1146 |
1158 /** | 1147 /** |
1159 * Returns true if the string is both external and ASCII | 1148 * Returns true if the string is both external and ASCII |
1160 */ | 1149 */ |
1161 bool IsExternalAscii() const; | 1150 V8EXPORT bool IsExternalAscii() const; |
1162 | 1151 |
1163 class V8EXPORT ExternalStringResourceBase { // NOLINT | 1152 class V8EXPORT ExternalStringResourceBase { // NOLINT |
1164 public: | 1153 public: |
1165 virtual ~ExternalStringResourceBase() {} | 1154 virtual ~ExternalStringResourceBase() {} |
1166 | 1155 |
1167 protected: | 1156 protected: |
1168 ExternalStringResourceBase() {} | 1157 ExternalStringResourceBase() {} |
1169 | 1158 |
1170 /** | 1159 /** |
1171 * Internally V8 will call this Dispose method when the external string | 1160 * Internally V8 will call this Dispose method when the external string |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 */ | 1221 */ |
1233 virtual ~ExternalAsciiStringResource() {} | 1222 virtual ~ExternalAsciiStringResource() {} |
1234 /** The string data from the underlying buffer.*/ | 1223 /** The string data from the underlying buffer.*/ |
1235 virtual const char* data() const = 0; | 1224 virtual const char* data() const = 0; |
1236 /** The number of ASCII characters in the string.*/ | 1225 /** The number of ASCII characters in the string.*/ |
1237 virtual size_t length() const = 0; | 1226 virtual size_t length() const = 0; |
1238 protected: | 1227 protected: |
1239 ExternalAsciiStringResource() {} | 1228 ExternalAsciiStringResource() {} |
1240 }; | 1229 }; |
1241 | 1230 |
1242 typedef ExternalAsciiStringResource ExternalOneByteStringResource; | |
1243 | |
1244 /** | 1231 /** |
1245 * If the string is an external string, return the ExternalStringResourceBase | 1232 * If the string is an external string, return the ExternalStringResourceBase |
1246 * regardless of the encoding, otherwise return NULL. The encoding of the | 1233 * regardless of the encoding, otherwise return NULL. The encoding of the |
1247 * string is returned in encoding_out. | 1234 * string is returned in encoding_out. |
1248 */ | 1235 */ |
1249 V8_INLINE(ExternalStringResourceBase* GetExternalStringResourceBase( | 1236 V8_INLINE(ExternalStringResourceBase* GetExternalStringResourceBase( |
1250 Encoding* encoding_out) const); | 1237 Encoding* encoding_out) const); |
1251 | 1238 |
1252 /** | 1239 /** |
1253 * Get the ExternalStringResource for an external string. Returns | 1240 * Get the ExternalStringResource for an external string. Returns |
1254 * NULL if IsExternal() doesn't return true. | 1241 * NULL if IsExternal() doesn't return true. |
1255 */ | 1242 */ |
1256 V8_INLINE(ExternalStringResource* GetExternalStringResource() const); | 1243 V8_INLINE(ExternalStringResource* GetExternalStringResource() const); |
1257 | 1244 |
1258 /** | 1245 /** |
1259 * Get the ExternalAsciiStringResource for an external ASCII string. | 1246 * Get the ExternalAsciiStringResource for an external ASCII string. |
1260 * Returns NULL if IsExternalAscii() doesn't return true. | 1247 * Returns NULL if IsExternalAscii() doesn't return true. |
1261 */ | 1248 */ |
1262 const ExternalAsciiStringResource* GetExternalAsciiStringResource() const; | 1249 V8EXPORT const ExternalAsciiStringResource* GetExternalAsciiStringResource() |
| 1250 const; |
1263 | 1251 |
1264 V8_INLINE(static String* Cast(v8::Value* obj)); | 1252 V8_INLINE(static String* Cast(v8::Value* obj)); |
1265 | 1253 |
1266 /** | 1254 /** |
1267 * Allocates a new string from either UTF-8 encoded or ASCII data. | 1255 * Allocates a new string from either UTF-8 encoded or ASCII data. |
1268 * The second parameter 'length' gives the buffer length. If omitted, | 1256 * The second parameter 'length' gives the buffer length. If omitted, |
1269 * the function calls 'strlen' to determine the buffer length. | 1257 * the function calls 'strlen' to determine the buffer length. |
1270 */ | 1258 */ |
1271 static Local<String> New(const char* data, int length = -1); | 1259 V8EXPORT static Local<String> New(const char* data, int length = -1); |
1272 | 1260 |
1273 /** Allocates a new string from 16-bit character codes.*/ | 1261 /** Allocates a new string from 16-bit character codes.*/ |
1274 static Local<String> New(const uint16_t* data, int length = -1); | 1262 V8EXPORT static Local<String> New(const uint16_t* data, int length = -1); |
1275 | 1263 |
1276 /** Creates a symbol. Returns one if it exists already.*/ | 1264 /** Creates a symbol. Returns one if it exists already.*/ |
1277 static Local<String> NewSymbol(const char* data, int length = -1); | 1265 V8EXPORT static Local<String> NewSymbol(const char* data, int length = -1); |
1278 | 1266 |
1279 /** | 1267 /** |
1280 * Creates a new string by concatenating the left and the right strings | 1268 * Creates a new string by concatenating the left and the right strings |
1281 * passed in as parameters. | 1269 * passed in as parameters. |
1282 */ | 1270 */ |
1283 static Local<String> Concat(Handle<String> left, Handle<String> right); | 1271 V8EXPORT static Local<String> Concat(Handle<String> left, |
| 1272 Handle<String> right); |
1284 | 1273 |
1285 /** | 1274 /** |
1286 * Creates a new external string using the data defined in the given | 1275 * Creates a new external string using the data defined in the given |
1287 * resource. When the external string is no longer live on V8's heap the | 1276 * resource. When the external string is no longer live on V8's heap the |
1288 * resource will be disposed by calling its Dispose method. The caller of | 1277 * resource will be disposed by calling its Dispose method. The caller of |
1289 * this function should not otherwise delete or modify the resource. Neither | 1278 * this function should not otherwise delete or modify the resource. Neither |
1290 * should the underlying buffer be deallocated or modified except through the | 1279 * should the underlying buffer be deallocated or modified except through the |
1291 * destructor of the external string resource. | 1280 * destructor of the external string resource. |
1292 */ | 1281 */ |
1293 static Local<String> NewExternal(ExternalStringResource* resource); | 1282 V8EXPORT static Local<String> NewExternal(ExternalStringResource* resource); |
1294 | 1283 |
1295 /** | 1284 /** |
1296 * Associate an external string resource with this string by transforming it | 1285 * Associate an external string resource with this string by transforming it |
1297 * in place so that existing references to this string in the JavaScript heap | 1286 * in place so that existing references to this string in the JavaScript heap |
1298 * will use the external string resource. The external string resource's | 1287 * will use the external string resource. The external string resource's |
1299 * character contents need to be equivalent to this string. | 1288 * character contents need to be equivalent to this string. |
1300 * Returns true if the string has been changed to be an external string. | 1289 * Returns true if the string has been changed to be an external string. |
1301 * The string is not modified if the operation fails. See NewExternal for | 1290 * The string is not modified if the operation fails. See NewExternal for |
1302 * information on the lifetime of the resource. | 1291 * information on the lifetime of the resource. |
1303 */ | 1292 */ |
1304 bool MakeExternal(ExternalStringResource* resource); | 1293 V8EXPORT bool MakeExternal(ExternalStringResource* resource); |
1305 | 1294 |
1306 /** | 1295 /** |
1307 * Creates a new external string using the ASCII data defined in the given | 1296 * Creates a new external string using the ASCII data defined in the given |
1308 * resource. When the external string is no longer live on V8's heap the | 1297 * resource. When the external string is no longer live on V8's heap the |
1309 * resource will be disposed by calling its Dispose method. The caller of | 1298 * resource will be disposed by calling its Dispose method. The caller of |
1310 * this function should not otherwise delete or modify the resource. Neither | 1299 * this function should not otherwise delete or modify the resource. Neither |
1311 * should the underlying buffer be deallocated or modified except through the | 1300 * should the underlying buffer be deallocated or modified except through the |
1312 * destructor of the external string resource. | 1301 * destructor of the external string resource. |
1313 */ | 1302 */ V8EXPORT static Local<String> NewExternal( |
1314 static Local<String> NewExternal(ExternalAsciiStringResource* resource); | 1303 ExternalAsciiStringResource* resource); |
1315 | 1304 |
1316 /** | 1305 /** |
1317 * Associate an external string resource with this string by transforming it | 1306 * Associate an external string resource with this string by transforming it |
1318 * in place so that existing references to this string in the JavaScript heap | 1307 * in place so that existing references to this string in the JavaScript heap |
1319 * will use the external string resource. The external string resource's | 1308 * will use the external string resource. The external string resource's |
1320 * character contents need to be equivalent to this string. | 1309 * character contents need to be equivalent to this string. |
1321 * Returns true if the string has been changed to be an external string. | 1310 * Returns true if the string has been changed to be an external string. |
1322 * The string is not modified if the operation fails. See NewExternal for | 1311 * The string is not modified if the operation fails. See NewExternal for |
1323 * information on the lifetime of the resource. | 1312 * information on the lifetime of the resource. |
1324 */ | 1313 */ |
1325 bool MakeExternal(ExternalAsciiStringResource* resource); | 1314 V8EXPORT bool MakeExternal(ExternalAsciiStringResource* resource); |
1326 | 1315 |
1327 /** | 1316 /** |
1328 * Returns true if this string can be made external. | 1317 * Returns true if this string can be made external. |
1329 */ | 1318 */ |
1330 bool CanMakeExternal(); | 1319 V8EXPORT bool CanMakeExternal(); |
1331 | 1320 |
1332 /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/ | 1321 /** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/ |
1333 static Local<String> NewUndetectable(const char* data, int length = -1); | 1322 V8EXPORT static Local<String> NewUndetectable(const char* data, |
| 1323 int length = -1); |
1334 | 1324 |
1335 /** Creates an undetectable string from the supplied 16-bit character codes.*/ | 1325 /** Creates an undetectable string from the supplied 16-bit character codes.*/ |
1336 static Local<String> NewUndetectable(const uint16_t* data, int length = -1); | 1326 V8EXPORT static Local<String> NewUndetectable(const uint16_t* data, |
| 1327 int length = -1); |
1337 | 1328 |
1338 /** | 1329 /** |
1339 * Converts an object to a UTF-8-encoded character array. Useful if | 1330 * Converts an object to a UTF-8-encoded character array. Useful if |
1340 * you want to print the object. If conversion to a string fails | 1331 * you want to print the object. If conversion to a string fails |
1341 * (e.g. due to an exception in the toString() method of the object) | 1332 * (e.g. due to an exception in the toString() method of the object) |
1342 * then the length() method returns 0 and the * operator returns | 1333 * then the length() method returns 0 and the * operator returns |
1343 * NULL. | 1334 * NULL. |
1344 */ | 1335 */ |
1345 class V8EXPORT Utf8Value { | 1336 class V8EXPORT Utf8Value { |
1346 public: | 1337 public: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 private: | 1388 private: |
1398 uint16_t* str_; | 1389 uint16_t* str_; |
1399 int length_; | 1390 int length_; |
1400 | 1391 |
1401 // Disallow copying and assigning. | 1392 // Disallow copying and assigning. |
1402 Value(const Value&); | 1393 Value(const Value&); |
1403 void operator=(const Value&); | 1394 void operator=(const Value&); |
1404 }; | 1395 }; |
1405 | 1396 |
1406 private: | 1397 private: |
1407 void VerifyExternalStringResourceBase(ExternalStringResourceBase* v, | 1398 V8EXPORT void VerifyExternalStringResourceBase(ExternalStringResourceBase* v, |
1408 Encoding encoding) const; | 1399 Encoding encoding) const; |
1409 void VerifyExternalStringResource(ExternalStringResource* val) const; | 1400 V8EXPORT void VerifyExternalStringResource(ExternalStringResource* val) const; |
1410 static void CheckCast(v8::Value* obj); | 1401 V8EXPORT static void CheckCast(v8::Value* obj); |
1411 }; | 1402 }; |
1412 | 1403 |
1413 | 1404 |
1414 /** | 1405 /** |
1415 * A JavaScript number value (ECMA-262, 4.3.20) | 1406 * A JavaScript number value (ECMA-262, 4.3.20) |
1416 */ | 1407 */ |
1417 class V8EXPORT Number : public Primitive { | 1408 class Number : public Primitive { |
1418 public: | 1409 public: |
1419 double Value() const; | 1410 V8EXPORT double Value() const; |
1420 static Local<Number> New(double value); | 1411 V8EXPORT static Local<Number> New(double value); |
1421 V8_INLINE(static Number* Cast(v8::Value* obj)); | 1412 V8_INLINE(static Number* Cast(v8::Value* obj)); |
1422 private: | 1413 private: |
1423 Number(); | 1414 V8EXPORT Number(); |
1424 static void CheckCast(v8::Value* obj); | 1415 V8EXPORT static void CheckCast(v8::Value* obj); |
1425 }; | 1416 }; |
1426 | 1417 |
1427 | 1418 |
1428 /** | 1419 /** |
1429 * A JavaScript value representing a signed integer. | 1420 * A JavaScript value representing a signed integer. |
1430 */ | 1421 */ |
1431 class V8EXPORT Integer : public Number { | 1422 class Integer : public Number { |
1432 public: | 1423 public: |
1433 static Local<Integer> New(int32_t value); | 1424 V8EXPORT static Local<Integer> New(int32_t value); |
1434 static Local<Integer> NewFromUnsigned(uint32_t value); | 1425 V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value); |
1435 static Local<Integer> New(int32_t value, Isolate*); | 1426 V8EXPORT static Local<Integer> New(int32_t value, Isolate*); |
1436 static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); | 1427 V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); |
1437 int64_t Value() const; | 1428 V8EXPORT int64_t Value() const; |
1438 V8_INLINE(static Integer* Cast(v8::Value* obj)); | 1429 V8_INLINE(static Integer* Cast(v8::Value* obj)); |
1439 private: | 1430 private: |
1440 Integer(); | 1431 V8EXPORT Integer(); |
1441 static void CheckCast(v8::Value* obj); | 1432 V8EXPORT static void CheckCast(v8::Value* obj); |
1442 }; | 1433 }; |
1443 | 1434 |
1444 | 1435 |
1445 /** | 1436 /** |
1446 * A JavaScript value representing a 32-bit signed integer. | 1437 * A JavaScript value representing a 32-bit signed integer. |
1447 */ | 1438 */ |
1448 class V8EXPORT Int32 : public Integer { | 1439 class Int32 : public Integer { |
1449 public: | 1440 public: |
1450 int32_t Value() const; | 1441 V8EXPORT int32_t Value() const; |
1451 private: | 1442 private: |
1452 Int32(); | 1443 V8EXPORT Int32(); |
1453 }; | 1444 }; |
1454 | 1445 |
1455 | 1446 |
1456 /** | 1447 /** |
1457 * A JavaScript value representing a 32-bit unsigned integer. | 1448 * A JavaScript value representing a 32-bit unsigned integer. |
1458 */ | 1449 */ |
1459 class V8EXPORT Uint32 : public Integer { | 1450 class Uint32 : public Integer { |
1460 public: | 1451 public: |
1461 uint32_t Value() const; | 1452 V8EXPORT uint32_t Value() const; |
1462 private: | 1453 private: |
1463 Uint32(); | 1454 V8EXPORT Uint32(); |
1464 }; | 1455 }; |
1465 | 1456 |
1466 | 1457 |
1467 enum PropertyAttribute { | 1458 enum PropertyAttribute { |
1468 None = 0, | 1459 None = 0, |
1469 ReadOnly = 1 << 0, | 1460 ReadOnly = 1 << 0, |
1470 DontEnum = 1 << 1, | 1461 DontEnum = 1 << 1, |
1471 DontDelete = 1 << 2 | 1462 DontDelete = 1 << 2 |
1472 }; | 1463 }; |
1473 | 1464 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 DEFAULT = 0, | 1505 DEFAULT = 0, |
1515 ALL_CAN_READ = 1, | 1506 ALL_CAN_READ = 1, |
1516 ALL_CAN_WRITE = 1 << 1, | 1507 ALL_CAN_WRITE = 1 << 1, |
1517 PROHIBITS_OVERWRITING = 1 << 2 | 1508 PROHIBITS_OVERWRITING = 1 << 2 |
1518 }; | 1509 }; |
1519 | 1510 |
1520 | 1511 |
1521 /** | 1512 /** |
1522 * A JavaScript object (ECMA-262, 4.3.3) | 1513 * A JavaScript object (ECMA-262, 4.3.3) |
1523 */ | 1514 */ |
1524 class V8EXPORT Object : public Value { | 1515 class Object : public Value { |
1525 public: | 1516 public: |
1526 bool Set(Handle<Value> key, | 1517 V8EXPORT bool Set(Handle<Value> key, |
1527 Handle<Value> value, | 1518 Handle<Value> value, |
1528 PropertyAttribute attribs = None); | 1519 PropertyAttribute attribs = None); |
1529 | 1520 |
1530 bool Set(uint32_t index, Handle<Value> value); | 1521 V8EXPORT bool Set(uint32_t index, |
| 1522 Handle<Value> value); |
1531 | 1523 |
1532 // Sets a local property on this object bypassing interceptors and | 1524 // Sets a local property on this object bypassing interceptors and |
1533 // overriding accessors or read-only properties. | 1525 // overriding accessors or read-only properties. |
1534 // | 1526 // |
1535 // Note that if the object has an interceptor the property will be set | 1527 // Note that if the object has an interceptor the property will be set |
1536 // locally, but since the interceptor takes precedence the local property | 1528 // locally, but since the interceptor takes precedence the local property |
1537 // will only be returned if the interceptor doesn't return a value. | 1529 // will only be returned if the interceptor doesn't return a value. |
1538 // | 1530 // |
1539 // Note also that this only works for named properties. | 1531 // Note also that this only works for named properties. |
1540 bool ForceSet(Handle<Value> key, | 1532 V8EXPORT bool ForceSet(Handle<Value> key, |
1541 Handle<Value> value, | 1533 Handle<Value> value, |
1542 PropertyAttribute attribs = None); | 1534 PropertyAttribute attribs = None); |
1543 | 1535 |
1544 Local<Value> Get(Handle<Value> key); | 1536 V8EXPORT Local<Value> Get(Handle<Value> key); |
1545 | 1537 |
1546 Local<Value> Get(uint32_t index); | 1538 V8EXPORT Local<Value> Get(uint32_t index); |
1547 | 1539 |
1548 /** | 1540 /** |
1549 * Gets the property attributes of a property which can be None or | 1541 * Gets the property attributes of a property which can be None or |
1550 * any combination of ReadOnly, DontEnum and DontDelete. Returns | 1542 * any combination of ReadOnly, DontEnum and DontDelete. Returns |
1551 * None when the property doesn't exist. | 1543 * None when the property doesn't exist. |
1552 */ | 1544 */ |
1553 PropertyAttribute GetPropertyAttributes(Handle<Value> key); | 1545 V8EXPORT PropertyAttribute GetPropertyAttributes(Handle<Value> key); |
1554 | 1546 |
1555 // TODO(1245389): Replace the type-specific versions of these | 1547 // TODO(1245389): Replace the type-specific versions of these |
1556 // functions with generic ones that accept a Handle<Value> key. | 1548 // functions with generic ones that accept a Handle<Value> key. |
1557 bool Has(Handle<String> key); | 1549 V8EXPORT bool Has(Handle<String> key); |
1558 | 1550 |
1559 bool Delete(Handle<String> key); | 1551 V8EXPORT bool Delete(Handle<String> key); |
1560 | 1552 |
1561 // Delete a property on this object bypassing interceptors and | 1553 // Delete a property on this object bypassing interceptors and |
1562 // ignoring dont-delete attributes. | 1554 // ignoring dont-delete attributes. |
1563 bool ForceDelete(Handle<Value> key); | 1555 V8EXPORT bool ForceDelete(Handle<Value> key); |
1564 | 1556 |
1565 bool Has(uint32_t index); | 1557 V8EXPORT bool Has(uint32_t index); |
1566 | 1558 |
1567 bool Delete(uint32_t index); | 1559 V8EXPORT bool Delete(uint32_t index); |
1568 | 1560 |
1569 bool SetAccessor(Handle<String> name, | 1561 V8EXPORT bool SetAccessor(Handle<String> name, |
1570 AccessorGetter getter, | 1562 AccessorGetter getter, |
1571 AccessorSetter setter = 0, | 1563 AccessorSetter setter = 0, |
1572 Handle<Value> data = Handle<Value>(), | 1564 Handle<Value> data = Handle<Value>(), |
1573 AccessControl settings = DEFAULT, | 1565 AccessControl settings = DEFAULT, |
1574 PropertyAttribute attribute = None); | 1566 PropertyAttribute attribute = None); |
1575 | 1567 |
1576 /** | 1568 /** |
1577 * Returns an array containing the names of the enumerable properties | 1569 * Returns an array containing the names of the enumerable properties |
1578 * of this object, including properties from prototype objects. The | 1570 * of this object, including properties from prototype objects. The |
1579 * array returned by this method contains the same values as would | 1571 * array returned by this method contains the same values as would |
1580 * be enumerated by a for-in statement over this object. | 1572 * be enumerated by a for-in statement over this object. |
1581 */ | 1573 */ |
1582 Local<Array> GetPropertyNames(); | 1574 V8EXPORT Local<Array> GetPropertyNames(); |
1583 | 1575 |
1584 /** | 1576 /** |
1585 * This function has the same functionality as GetPropertyNames but | 1577 * This function has the same functionality as GetPropertyNames but |
1586 * the returned array doesn't contain the names of properties from | 1578 * the returned array doesn't contain the names of properties from |
1587 * prototype objects. | 1579 * prototype objects. |
1588 */ | 1580 */ |
1589 Local<Array> GetOwnPropertyNames(); | 1581 V8EXPORT Local<Array> GetOwnPropertyNames(); |
1590 | 1582 |
1591 /** | 1583 /** |
1592 * Get the prototype object. This does not skip objects marked to | 1584 * Get the prototype object. This does not skip objects marked to |
1593 * be skipped by __proto__ and it does not consult the security | 1585 * be skipped by __proto__ and it does not consult the security |
1594 * handler. | 1586 * handler. |
1595 */ | 1587 */ |
1596 Local<Value> GetPrototype(); | 1588 V8EXPORT Local<Value> GetPrototype(); |
1597 | 1589 |
1598 /** | 1590 /** |
1599 * Set the prototype object. This does not skip objects marked to | 1591 * Set the prototype object. This does not skip objects marked to |
1600 * be skipped by __proto__ and it does not consult the security | 1592 * be skipped by __proto__ and it does not consult the security |
1601 * handler. | 1593 * handler. |
1602 */ | 1594 */ |
1603 bool SetPrototype(Handle<Value> prototype); | 1595 V8EXPORT bool SetPrototype(Handle<Value> prototype); |
1604 | 1596 |
1605 /** | 1597 /** |
1606 * Finds an instance of the given function template in the prototype | 1598 * Finds an instance of the given function template in the prototype |
1607 * chain. | 1599 * chain. |
1608 */ | 1600 */ |
1609 Local<Object> FindInstanceInPrototypeChain(Handle<FunctionTemplate> tmpl); | 1601 V8EXPORT Local<Object> FindInstanceInPrototypeChain( |
| 1602 Handle<FunctionTemplate> tmpl); |
1610 | 1603 |
1611 /** | 1604 /** |
1612 * Call builtin Object.prototype.toString on this object. | 1605 * Call builtin Object.prototype.toString on this object. |
1613 * This is different from Value::ToString() that may call | 1606 * This is different from Value::ToString() that may call |
1614 * user-defined toString function. This one does not. | 1607 * user-defined toString function. This one does not. |
1615 */ | 1608 */ |
1616 Local<String> ObjectProtoToString(); | 1609 V8EXPORT Local<String> ObjectProtoToString(); |
1617 | 1610 |
1618 /** | 1611 /** |
1619 * Returns the function invoked as a constructor for this object. | 1612 * Returns the function invoked as a constructor for this object. |
1620 * May be the null value. | 1613 * May be the null value. |
1621 */ | 1614 */ |
1622 Local<Value> GetConstructor(); | 1615 V8EXPORT Local<Value> GetConstructor(); |
1623 | 1616 |
1624 /** | 1617 /** |
1625 * Returns the name of the function invoked as a constructor for this object. | 1618 * Returns the name of the function invoked as a constructor for this object. |
1626 */ | 1619 */ |
1627 Local<String> GetConstructorName(); | 1620 V8EXPORT Local<String> GetConstructorName(); |
1628 | 1621 |
1629 /** Gets the number of internal fields for this Object. */ | 1622 /** Gets the number of internal fields for this Object. */ |
1630 int InternalFieldCount(); | 1623 V8EXPORT int InternalFieldCount(); |
1631 | 1624 |
1632 /** Gets the value from an internal field. */ | 1625 /** Gets the value from an internal field. */ |
1633 V8_INLINE(Local<Value> GetInternalField(int index)); | 1626 V8_INLINE(Local<Value> GetInternalField(int index)); |
1634 | 1627 |
1635 /** Sets the value in an internal field. */ | 1628 /** Sets the value in an internal field. */ |
1636 void SetInternalField(int index, Handle<Value> value); | 1629 V8EXPORT void SetInternalField(int index, Handle<Value> value); |
| 1630 |
| 1631 /** |
| 1632 * Gets a native pointer from an internal field. Deprecated. If the pointer is |
| 1633 * always 2-byte-aligned, use GetAlignedPointerFromInternalField instead, |
| 1634 * otherwise use a combination of GetInternalField, External::Cast and |
| 1635 * External::Value. |
| 1636 */ |
| 1637 V8EXPORT V8_DEPRECATED(void* GetPointerFromInternalField(int index)); |
| 1638 |
| 1639 /** |
| 1640 * Sets a native pointer in an internal field. Deprecated. If the pointer is |
| 1641 * always 2-byte aligned, use SetAlignedPointerInInternalField instead, |
| 1642 * otherwise use a combination of External::New and SetInternalField. |
| 1643 */ |
| 1644 V8_DEPRECATED(V8_INLINE(void SetPointerInInternalField(int index, |
| 1645 void* value))); |
1637 | 1646 |
1638 /** | 1647 /** |
1639 * Gets a 2-byte-aligned native pointer from an internal field. This field | 1648 * Gets a 2-byte-aligned native pointer from an internal field. This field |
1640 * must have been set by SetAlignedPointerInInternalField, everything else | 1649 * must have been set by SetAlignedPointerInInternalField, everything else |
1641 * leads to undefined behavior. | 1650 * leads to undefined behavior. |
1642 */ | 1651 */ |
1643 V8_INLINE(void* GetAlignedPointerFromInternalField(int index)); | 1652 V8_INLINE(void* GetAlignedPointerFromInternalField(int index)); |
1644 | 1653 |
1645 /** | 1654 /** |
1646 * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such | 1655 * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such |
1647 * a field, GetAlignedPointerFromInternalField must be used, everything else | 1656 * a field, GetAlignedPointerFromInternalField must be used, everything else |
1648 * leads to undefined behavior. | 1657 * leads to undefined behavior. |
1649 */ | 1658 */ |
1650 void SetAlignedPointerInInternalField(int index, void* value); | 1659 V8EXPORT void SetAlignedPointerInInternalField(int index, void* value); |
1651 | 1660 |
1652 // Testers for local properties. | 1661 // Testers for local properties. |
1653 bool HasOwnProperty(Handle<String> key); | 1662 V8EXPORT bool HasOwnProperty(Handle<String> key); |
1654 bool HasRealNamedProperty(Handle<String> key); | 1663 V8EXPORT bool HasRealNamedProperty(Handle<String> key); |
1655 bool HasRealIndexedProperty(uint32_t index); | 1664 V8EXPORT bool HasRealIndexedProperty(uint32_t index); |
1656 bool HasRealNamedCallbackProperty(Handle<String> key); | 1665 V8EXPORT bool HasRealNamedCallbackProperty(Handle<String> key); |
1657 | 1666 |
1658 /** | 1667 /** |
1659 * If result.IsEmpty() no real property was located in the prototype chain. | 1668 * If result.IsEmpty() no real property was located in the prototype chain. |
1660 * This means interceptors in the prototype chain are not called. | 1669 * This means interceptors in the prototype chain are not called. |
1661 */ | 1670 */ |
1662 Local<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key); | 1671 V8EXPORT Local<Value> GetRealNamedPropertyInPrototypeChain( |
| 1672 Handle<String> key); |
1663 | 1673 |
1664 /** | 1674 /** |
1665 * If result.IsEmpty() no real property was located on the object or | 1675 * If result.IsEmpty() no real property was located on the object or |
1666 * in the prototype chain. | 1676 * in the prototype chain. |
1667 * This means interceptors in the prototype chain are not called. | 1677 * This means interceptors in the prototype chain are not called. |
1668 */ | 1678 */ |
1669 Local<Value> GetRealNamedProperty(Handle<String> key); | 1679 V8EXPORT Local<Value> GetRealNamedProperty(Handle<String> key); |
1670 | 1680 |
1671 /** Tests for a named lookup interceptor.*/ | 1681 /** Tests for a named lookup interceptor.*/ |
1672 bool HasNamedLookupInterceptor(); | 1682 V8EXPORT bool HasNamedLookupInterceptor(); |
1673 | 1683 |
1674 /** Tests for an index lookup interceptor.*/ | 1684 /** Tests for an index lookup interceptor.*/ |
1675 bool HasIndexedLookupInterceptor(); | 1685 V8EXPORT bool HasIndexedLookupInterceptor(); |
1676 | 1686 |
1677 /** | 1687 /** |
1678 * Turns on access check on the object if the object is an instance of | 1688 * Turns on access check on the object if the object is an instance of |
1679 * a template that has access check callbacks. If an object has no | 1689 * a template that has access check callbacks. If an object has no |
1680 * access check info, the object cannot be accessed by anyone. | 1690 * access check info, the object cannot be accessed by anyone. |
1681 */ | 1691 */ |
1682 void TurnOnAccessCheck(); | 1692 V8EXPORT void TurnOnAccessCheck(); |
1683 | 1693 |
1684 /** | 1694 /** |
1685 * Returns the identity hash for this object. The current implementation | 1695 * Returns the identity hash for this object. The current implementation |
1686 * uses a hidden property on the object to store the identity hash. | 1696 * uses a hidden property on the object to store the identity hash. |
1687 * | 1697 * |
1688 * The return value will never be 0. Also, it is not guaranteed to be | 1698 * The return value will never be 0. Also, it is not guaranteed to be |
1689 * unique. | 1699 * unique. |
1690 */ | 1700 */ |
1691 int GetIdentityHash(); | 1701 V8EXPORT int GetIdentityHash(); |
1692 | 1702 |
1693 /** | 1703 /** |
1694 * Access hidden properties on JavaScript objects. These properties are | 1704 * Access hidden properties on JavaScript objects. These properties are |
1695 * hidden from the executing JavaScript and only accessible through the V8 | 1705 * hidden from the executing JavaScript and only accessible through the V8 |
1696 * C++ API. Hidden properties introduced by V8 internally (for example the | 1706 * C++ API. Hidden properties introduced by V8 internally (for example the |
1697 * identity hash) are prefixed with "v8::". | 1707 * identity hash) are prefixed with "v8::". |
1698 */ | 1708 */ |
1699 bool SetHiddenValue(Handle<String> key, Handle<Value> value); | 1709 V8EXPORT bool SetHiddenValue(Handle<String> key, Handle<Value> value); |
1700 Local<Value> GetHiddenValue(Handle<String> key); | 1710 V8EXPORT Local<Value> GetHiddenValue(Handle<String> key); |
1701 bool DeleteHiddenValue(Handle<String> key); | 1711 V8EXPORT bool DeleteHiddenValue(Handle<String> key); |
1702 | 1712 |
1703 /** | 1713 /** |
1704 * Returns true if this is an instance of an api function (one | 1714 * Returns true if this is an instance of an api function (one |
1705 * created from a function created from a function template) and has | 1715 * created from a function created from a function template) and has |
1706 * been modified since it was created. Note that this method is | 1716 * been modified since it was created. Note that this method is |
1707 * conservative and may return true for objects that haven't actually | 1717 * conservative and may return true for objects that haven't actually |
1708 * been modified. | 1718 * been modified. |
1709 */ | 1719 */ |
1710 bool IsDirty(); | 1720 V8EXPORT bool IsDirty(); |
1711 | 1721 |
1712 /** | 1722 /** |
1713 * Clone this object with a fast but shallow copy. Values will point | 1723 * Clone this object with a fast but shallow copy. Values will point |
1714 * to the same values as the original object. | 1724 * to the same values as the original object. |
1715 */ | 1725 */ |
1716 Local<Object> Clone(); | 1726 V8EXPORT Local<Object> Clone(); |
1717 | 1727 |
1718 /** | 1728 /** |
1719 * Returns the context in which the object was created. | 1729 * Returns the context in which the object was created. |
1720 */ | 1730 */ |
1721 Local<Context> CreationContext(); | 1731 V8EXPORT Local<Context> CreationContext(); |
1722 | 1732 |
1723 /** | 1733 /** |
1724 * Set the backing store of the indexed properties to be managed by the | 1734 * Set the backing store of the indexed properties to be managed by the |
1725 * embedding layer. Access to the indexed properties will follow the rules | 1735 * embedding layer. Access to the indexed properties will follow the rules |
1726 * spelled out in CanvasPixelArray. | 1736 * spelled out in CanvasPixelArray. |
1727 * Note: The embedding program still owns the data and needs to ensure that | 1737 * Note: The embedding program still owns the data and needs to ensure that |
1728 * the backing store is preserved while V8 has a reference. | 1738 * the backing store is preserved while V8 has a reference. |
1729 */ | 1739 */ |
1730 void SetIndexedPropertiesToPixelData(uint8_t* data, int length); | 1740 V8EXPORT void SetIndexedPropertiesToPixelData(uint8_t* data, int length); |
1731 bool HasIndexedPropertiesInPixelData(); | 1741 V8EXPORT bool HasIndexedPropertiesInPixelData(); |
1732 uint8_t* GetIndexedPropertiesPixelData(); | 1742 V8EXPORT uint8_t* GetIndexedPropertiesPixelData(); |
1733 int GetIndexedPropertiesPixelDataLength(); | 1743 V8EXPORT int GetIndexedPropertiesPixelDataLength(); |
1734 | 1744 |
1735 /** | 1745 /** |
1736 * Set the backing store of the indexed properties to be managed by the | 1746 * Set the backing store of the indexed properties to be managed by the |
1737 * embedding layer. Access to the indexed properties will follow the rules | 1747 * embedding layer. Access to the indexed properties will follow the rules |
1738 * spelled out for the CanvasArray subtypes in the WebGL specification. | 1748 * spelled out for the CanvasArray subtypes in the WebGL specification. |
1739 * Note: The embedding program still owns the data and needs to ensure that | 1749 * Note: The embedding program still owns the data and needs to ensure that |
1740 * the backing store is preserved while V8 has a reference. | 1750 * the backing store is preserved while V8 has a reference. |
1741 */ | 1751 */ |
1742 void SetIndexedPropertiesToExternalArrayData(void* data, | 1752 V8EXPORT void SetIndexedPropertiesToExternalArrayData( |
1743 ExternalArrayType array_type, | 1753 void* data, |
1744 int number_of_elements); | 1754 ExternalArrayType array_type, |
1745 bool HasIndexedPropertiesInExternalArrayData(); | 1755 int number_of_elements); |
1746 void* GetIndexedPropertiesExternalArrayData(); | 1756 V8EXPORT bool HasIndexedPropertiesInExternalArrayData(); |
1747 ExternalArrayType GetIndexedPropertiesExternalArrayDataType(); | 1757 V8EXPORT void* GetIndexedPropertiesExternalArrayData(); |
1748 int GetIndexedPropertiesExternalArrayDataLength(); | 1758 V8EXPORT ExternalArrayType GetIndexedPropertiesExternalArrayDataType(); |
| 1759 V8EXPORT int GetIndexedPropertiesExternalArrayDataLength(); |
1749 | 1760 |
1750 /** | 1761 /** |
1751 * Checks whether a callback is set by the | 1762 * Checks whether a callback is set by the |
1752 * ObjectTemplate::SetCallAsFunctionHandler method. | 1763 * ObjectTemplate::SetCallAsFunctionHandler method. |
1753 * When an Object is callable this method returns true. | 1764 * When an Object is callable this method returns true. |
1754 */ | 1765 */ |
1755 bool IsCallable(); | 1766 V8EXPORT bool IsCallable(); |
1756 | 1767 |
1757 /** | 1768 /** |
1758 * Call an Object as a function if a callback is set by the | 1769 * Call an Object as a function if a callback is set by the |
1759 * ObjectTemplate::SetCallAsFunctionHandler method. | 1770 * ObjectTemplate::SetCallAsFunctionHandler method. |
1760 */ | 1771 */ |
1761 Local<Value> CallAsFunction(Handle<Object> recv, | 1772 V8EXPORT Local<Value> CallAsFunction(Handle<Object> recv, |
1762 int argc, | 1773 int argc, |
1763 Handle<Value> argv[]); | 1774 Handle<Value> argv[]); |
1764 | 1775 |
1765 /** | 1776 /** |
1766 * Call an Object as a constructor if a callback is set by the | 1777 * Call an Object as a constructor if a callback is set by the |
1767 * ObjectTemplate::SetCallAsFunctionHandler method. | 1778 * ObjectTemplate::SetCallAsFunctionHandler method. |
1768 * Note: This method behaves like the Function::NewInstance method. | 1779 * Note: This method behaves like the Function::NewInstance method. |
1769 */ | 1780 */ |
1770 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]); | 1781 V8EXPORT Local<Value> CallAsConstructor(int argc, |
| 1782 Handle<Value> argv[]); |
1771 | 1783 |
1772 static Local<Object> New(); | 1784 V8EXPORT static Local<Object> New(); |
1773 V8_INLINE(static Object* Cast(Value* obj)); | 1785 V8_INLINE(static Object* Cast(Value* obj)); |
1774 | 1786 |
1775 private: | 1787 private: |
1776 Object(); | 1788 V8EXPORT Object(); |
1777 static void CheckCast(Value* obj); | 1789 V8EXPORT static void CheckCast(Value* obj); |
1778 Local<Value> SlowGetInternalField(int index); | 1790 V8EXPORT Local<Value> SlowGetInternalField(int index); |
1779 void* SlowGetAlignedPointerFromInternalField(int index); | 1791 V8EXPORT void* SlowGetAlignedPointerFromInternalField(int index); |
1780 }; | 1792 }; |
1781 | 1793 |
1782 | 1794 |
1783 /** | 1795 /** |
1784 * An instance of the built-in array constructor (ECMA-262, 15.4.2). | 1796 * An instance of the built-in array constructor (ECMA-262, 15.4.2). |
1785 */ | 1797 */ |
1786 class V8EXPORT Array : public Object { | 1798 class Array : public Object { |
1787 public: | 1799 public: |
1788 uint32_t Length() const; | 1800 V8EXPORT uint32_t Length() const; |
1789 | 1801 |
1790 /** | 1802 /** |
1791 * Clones an element at index |index|. Returns an empty | 1803 * Clones an element at index |index|. Returns an empty |
1792 * handle if cloning fails (for any reason). | 1804 * handle if cloning fails (for any reason). |
1793 */ | 1805 */ |
1794 Local<Object> CloneElementAt(uint32_t index); | 1806 V8EXPORT Local<Object> CloneElementAt(uint32_t index); |
1795 | 1807 |
1796 /** | 1808 /** |
1797 * Creates a JavaScript array with the given length. If the length | 1809 * Creates a JavaScript array with the given length. If the length |
1798 * is negative the returned array will have length 0. | 1810 * is negative the returned array will have length 0. |
1799 */ | 1811 */ |
1800 static Local<Array> New(int length = 0); | 1812 V8EXPORT static Local<Array> New(int length = 0); |
1801 | 1813 |
1802 V8_INLINE(static Array* Cast(Value* obj)); | 1814 V8_INLINE(static Array* Cast(Value* obj)); |
1803 private: | 1815 private: |
1804 Array(); | 1816 V8EXPORT Array(); |
1805 static void CheckCast(Value* obj); | 1817 V8EXPORT static void CheckCast(Value* obj); |
1806 }; | 1818 }; |
1807 | 1819 |
1808 | 1820 |
1809 /** | 1821 /** |
1810 * A JavaScript function object (ECMA-262, 15.3). | 1822 * A JavaScript function object (ECMA-262, 15.3). |
1811 */ | 1823 */ |
1812 class V8EXPORT Function : public Object { | 1824 class Function : public Object { |
1813 public: | 1825 public: |
1814 Local<Object> NewInstance() const; | 1826 V8EXPORT Local<Object> NewInstance() const; |
1815 Local<Object> NewInstance(int argc, Handle<Value> argv[]) const; | 1827 V8EXPORT Local<Object> NewInstance(int argc, Handle<Value> argv[]) const; |
1816 Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]); | 1828 V8EXPORT Local<Value> Call(Handle<Object> recv, |
1817 void SetName(Handle<String> name); | 1829 int argc, |
1818 Handle<Value> GetName() const; | 1830 Handle<Value> argv[]); |
| 1831 V8EXPORT void SetName(Handle<String> name); |
| 1832 V8EXPORT Handle<Value> GetName() const; |
1819 | 1833 |
1820 /** | 1834 /** |
1821 * Name inferred from variable or property assignment of this function. | 1835 * Name inferred from variable or property assignment of this function. |
1822 * Used to facilitate debugging and profiling of JavaScript code written | 1836 * Used to facilitate debugging and profiling of JavaScript code written |
1823 * in an OO style, where many functions are anonymous but are assigned | 1837 * in an OO style, where many functions are anonymous but are assigned |
1824 * to object properties. | 1838 * to object properties. |
1825 */ | 1839 */ |
1826 Handle<Value> GetInferredName() const; | 1840 V8EXPORT Handle<Value> GetInferredName() const; |
1827 | 1841 |
1828 /** | 1842 /** |
1829 * Returns zero based line number of function body and | 1843 * Returns zero based line number of function body and |
1830 * kLineOffsetNotFound if no information available. | 1844 * kLineOffsetNotFound if no information available. |
1831 */ | 1845 */ |
1832 int GetScriptLineNumber() const; | 1846 V8EXPORT int GetScriptLineNumber() const; |
1833 /** | 1847 /** |
1834 * Returns zero based column number of function body and | 1848 * Returns zero based column number of function body and |
1835 * kLineOffsetNotFound if no information available. | 1849 * kLineOffsetNotFound if no information available. |
1836 */ | 1850 */ |
1837 int GetScriptColumnNumber() const; | 1851 V8EXPORT int GetScriptColumnNumber() const; |
1838 Handle<Value> GetScriptId() const; | 1852 V8EXPORT Handle<Value> GetScriptId() const; |
1839 ScriptOrigin GetScriptOrigin() const; | 1853 V8EXPORT ScriptOrigin GetScriptOrigin() const; |
1840 V8_INLINE(static Function* Cast(Value* obj)); | 1854 V8_INLINE(static Function* Cast(Value* obj)); |
1841 static const int kLineOffsetNotFound; | 1855 V8EXPORT static const int kLineOffsetNotFound; |
1842 | 1856 |
1843 private: | 1857 private: |
1844 Function(); | 1858 V8EXPORT Function(); |
1845 static void CheckCast(Value* obj); | 1859 V8EXPORT static void CheckCast(Value* obj); |
1846 }; | 1860 }; |
1847 | 1861 |
1848 | 1862 |
1849 /** | 1863 /** |
1850 * An instance of the built-in Date constructor (ECMA-262, 15.9). | 1864 * An instance of the built-in Date constructor (ECMA-262, 15.9). |
1851 */ | 1865 */ |
1852 class V8EXPORT Date : public Object { | 1866 class Date : public Object { |
1853 public: | 1867 public: |
1854 static Local<Value> New(double time); | 1868 V8EXPORT static Local<Value> New(double time); |
1855 | 1869 |
1856 /** | 1870 /** |
1857 * A specialization of Value::NumberValue that is more efficient | 1871 * A specialization of Value::NumberValue that is more efficient |
1858 * because we know the structure of this object. | 1872 * because we know the structure of this object. |
1859 */ | 1873 */ |
1860 double NumberValue() const; | 1874 V8EXPORT double NumberValue() const; |
1861 | 1875 |
1862 V8_INLINE(static Date* Cast(v8::Value* obj)); | 1876 V8_INLINE(static Date* Cast(v8::Value* obj)); |
1863 | 1877 |
1864 /** | 1878 /** |
1865 * Notification that the embedder has changed the time zone, | 1879 * Notification that the embedder has changed the time zone, |
1866 * daylight savings time, or other date / time configuration | 1880 * daylight savings time, or other date / time configuration |
1867 * parameters. V8 keeps a cache of various values used for | 1881 * parameters. V8 keeps a cache of various values used for |
1868 * date / time computation. This notification will reset | 1882 * date / time computation. This notification will reset |
1869 * those cached values for the current context so that date / | 1883 * those cached values for the current context so that date / |
1870 * time configuration changes would be reflected in the Date | 1884 * time configuration changes would be reflected in the Date |
1871 * object. | 1885 * object. |
1872 * | 1886 * |
1873 * This API should not be called more than needed as it will | 1887 * This API should not be called more than needed as it will |
1874 * negatively impact the performance of date operations. | 1888 * negatively impact the performance of date operations. |
1875 */ | 1889 */ |
1876 static void DateTimeConfigurationChangeNotification(); | 1890 V8EXPORT static void DateTimeConfigurationChangeNotification(); |
1877 | 1891 |
1878 private: | 1892 private: |
1879 static void CheckCast(v8::Value* obj); | 1893 V8EXPORT static void CheckCast(v8::Value* obj); |
1880 }; | 1894 }; |
1881 | 1895 |
1882 | 1896 |
1883 /** | 1897 /** |
1884 * A Number object (ECMA-262, 4.3.21). | 1898 * A Number object (ECMA-262, 4.3.21). |
1885 */ | 1899 */ |
1886 class V8EXPORT NumberObject : public Object { | 1900 class NumberObject : public Object { |
1887 public: | 1901 public: |
1888 static Local<Value> New(double value); | 1902 V8EXPORT static Local<Value> New(double value); |
1889 | 1903 |
1890 /** | 1904 /** |
1891 * Returns the Number held by the object. | 1905 * Returns the Number held by the object. |
1892 */ | 1906 */ |
1893 double NumberValue() const; | 1907 V8EXPORT double NumberValue() const; |
1894 | 1908 |
1895 V8_INLINE(static NumberObject* Cast(v8::Value* obj)); | 1909 V8_INLINE(static NumberObject* Cast(v8::Value* obj)); |
1896 | 1910 |
1897 private: | 1911 private: |
1898 static void CheckCast(v8::Value* obj); | 1912 V8EXPORT static void CheckCast(v8::Value* obj); |
1899 }; | 1913 }; |
1900 | 1914 |
1901 | 1915 |
1902 /** | 1916 /** |
1903 * A Boolean object (ECMA-262, 4.3.15). | 1917 * A Boolean object (ECMA-262, 4.3.15). |
1904 */ | 1918 */ |
1905 class V8EXPORT BooleanObject : public Object { | 1919 class BooleanObject : public Object { |
1906 public: | 1920 public: |
1907 static Local<Value> New(bool value); | 1921 V8EXPORT static Local<Value> New(bool value); |
1908 | 1922 |
1909 /** | 1923 /** |
1910 * Returns the Boolean held by the object. | 1924 * Returns the Boolean held by the object. |
1911 */ | 1925 */ |
1912 bool BooleanValue() const; | 1926 V8EXPORT bool BooleanValue() const; |
1913 | 1927 |
1914 V8_INLINE(static BooleanObject* Cast(v8::Value* obj)); | 1928 V8_INLINE(static BooleanObject* Cast(v8::Value* obj)); |
1915 | 1929 |
1916 private: | 1930 private: |
1917 static void CheckCast(v8::Value* obj); | 1931 V8EXPORT static void CheckCast(v8::Value* obj); |
1918 }; | 1932 }; |
1919 | 1933 |
1920 | 1934 |
1921 /** | 1935 /** |
1922 * A String object (ECMA-262, 4.3.18). | 1936 * A String object (ECMA-262, 4.3.18). |
1923 */ | 1937 */ |
1924 class V8EXPORT StringObject : public Object { | 1938 class StringObject : public Object { |
1925 public: | 1939 public: |
1926 static Local<Value> New(Handle<String> value); | 1940 V8EXPORT static Local<Value> New(Handle<String> value); |
1927 | 1941 |
1928 /** | 1942 /** |
1929 * Returns the String held by the object. | 1943 * Returns the String held by the object. |
1930 */ | 1944 */ |
1931 Local<String> StringValue() const; | 1945 V8EXPORT Local<String> StringValue() const; |
1932 | 1946 |
1933 V8_INLINE(static StringObject* Cast(v8::Value* obj)); | 1947 V8_INLINE(static StringObject* Cast(v8::Value* obj)); |
1934 | 1948 |
1935 private: | 1949 private: |
1936 static void CheckCast(v8::Value* obj); | 1950 V8EXPORT static void CheckCast(v8::Value* obj); |
1937 }; | 1951 }; |
1938 | 1952 |
1939 | 1953 |
1940 /** | 1954 /** |
1941 * An instance of the built-in RegExp constructor (ECMA-262, 15.10). | 1955 * An instance of the built-in RegExp constructor (ECMA-262, 15.10). |
1942 */ | 1956 */ |
1943 class V8EXPORT RegExp : public Object { | 1957 class RegExp : public Object { |
1944 public: | 1958 public: |
1945 /** | 1959 /** |
1946 * Regular expression flag bits. They can be or'ed to enable a set | 1960 * Regular expression flag bits. They can be or'ed to enable a set |
1947 * of flags. | 1961 * of flags. |
1948 */ | 1962 */ |
1949 enum Flags { | 1963 enum Flags { |
1950 kNone = 0, | 1964 kNone = 0, |
1951 kGlobal = 1, | 1965 kGlobal = 1, |
1952 kIgnoreCase = 2, | 1966 kIgnoreCase = 2, |
1953 kMultiline = 4 | 1967 kMultiline = 4 |
1954 }; | 1968 }; |
1955 | 1969 |
1956 /** | 1970 /** |
1957 * Creates a regular expression from the given pattern string and | 1971 * Creates a regular expression from the given pattern string and |
1958 * the flags bit field. May throw a JavaScript exception as | 1972 * the flags bit field. May throw a JavaScript exception as |
1959 * described in ECMA-262, 15.10.4.1. | 1973 * described in ECMA-262, 15.10.4.1. |
1960 * | 1974 * |
1961 * For example, | 1975 * For example, |
1962 * RegExp::New(v8::String::New("foo"), | 1976 * RegExp::New(v8::String::New("foo"), |
1963 * static_cast<RegExp::Flags>(kGlobal | kMultiline)) | 1977 * static_cast<RegExp::Flags>(kGlobal | kMultiline)) |
1964 * is equivalent to evaluating "/foo/gm". | 1978 * is equivalent to evaluating "/foo/gm". |
1965 */ | 1979 */ |
1966 static Local<RegExp> New(Handle<String> pattern, Flags flags); | 1980 V8EXPORT static Local<RegExp> New(Handle<String> pattern, |
| 1981 Flags flags); |
1967 | 1982 |
1968 /** | 1983 /** |
1969 * Returns the value of the source property: a string representing | 1984 * Returns the value of the source property: a string representing |
1970 * the regular expression. | 1985 * the regular expression. |
1971 */ | 1986 */ |
1972 Local<String> GetSource() const; | 1987 V8EXPORT Local<String> GetSource() const; |
1973 | 1988 |
1974 /** | 1989 /** |
1975 * Returns the flags bit field. | 1990 * Returns the flags bit field. |
1976 */ | 1991 */ |
1977 Flags GetFlags() const; | 1992 V8EXPORT Flags GetFlags() const; |
1978 | 1993 |
1979 V8_INLINE(static RegExp* Cast(v8::Value* obj)); | 1994 V8_INLINE(static RegExp* Cast(v8::Value* obj)); |
1980 | 1995 |
1981 private: | 1996 private: |
1982 static void CheckCast(v8::Value* obj); | 1997 V8EXPORT static void CheckCast(v8::Value* obj); |
1983 }; | 1998 }; |
1984 | 1999 |
1985 | 2000 |
1986 /** | 2001 /** |
1987 * A JavaScript value that wraps a C++ void*. This type of value is mainly used | 2002 * A JavaScript value that wraps a C++ void*. This type of value is mainly used |
1988 * to associate C++ data structures with JavaScript objects. | 2003 * to associate C++ data structures with JavaScript objects. |
1989 */ | 2004 */ |
1990 class V8EXPORT External : public Value { | 2005 class External : public Value { |
1991 public: | 2006 public: |
1992 static Local<External> New(void* value); | 2007 /** Deprecated, use New instead. */ |
| 2008 V8_DEPRECATED(V8_INLINE(static Local<Value> Wrap(void* value))); |
| 2009 |
| 2010 /** Deprecated, use a combination of Cast and Value instead. */ |
| 2011 V8_DEPRECATED(V8_INLINE(static void* Unwrap(Handle<Value> obj))); |
| 2012 |
| 2013 V8EXPORT static Local<External> New(void* value); |
1993 V8_INLINE(static External* Cast(Value* obj)); | 2014 V8_INLINE(static External* Cast(Value* obj)); |
1994 void* Value() const; | 2015 V8EXPORT void* Value() const; |
1995 private: | 2016 private: |
1996 static void CheckCast(v8::Value* obj); | 2017 V8EXPORT static void CheckCast(v8::Value* obj); |
1997 }; | 2018 }; |
1998 | 2019 |
1999 | 2020 |
2000 // --- Templates --- | 2021 // --- Templates --- |
2001 | 2022 |
2002 | 2023 |
2003 /** | 2024 /** |
2004 * The superclass of object and function templates. | 2025 * The superclass of object and function templates. |
2005 */ | 2026 */ |
2006 class V8EXPORT Template : public Data { | 2027 class V8EXPORT Template : public Data { |
2007 public: | 2028 public: |
2008 /** Adds a property to each instance created by this template.*/ | 2029 /** Adds a property to each instance created by this template.*/ |
2009 void Set(Handle<String> name, Handle<Data> value, | 2030 void Set(Handle<String> name, Handle<Data> value, |
2010 PropertyAttribute attributes = None); | 2031 PropertyAttribute attributes = None); |
2011 V8_INLINE(void Set(const char* name, Handle<Data> value)); | 2032 V8_INLINE(void Set(const char* name, Handle<Data> value)); |
2012 private: | 2033 private: |
2013 Template(); | 2034 Template(); |
2014 | 2035 |
2015 friend class ObjectTemplate; | 2036 friend class ObjectTemplate; |
2016 friend class FunctionTemplate; | 2037 friend class FunctionTemplate; |
2017 }; | 2038 }; |
2018 | 2039 |
2019 | 2040 |
2020 /** | 2041 /** |
2021 * The argument information given to function call callbacks. This | 2042 * The argument information given to function call callbacks. This |
2022 * class provides access to information about the context of the call, | 2043 * class provides access to information about the context of the call, |
2023 * including the receiver, the number and values of arguments, and | 2044 * including the receiver, the number and values of arguments, and |
2024 * the holder of the function. | 2045 * the holder of the function. |
2025 */ | 2046 */ |
2026 class V8EXPORT Arguments { | 2047 class Arguments { |
2027 public: | 2048 public: |
2028 V8_INLINE(int Length() const); | 2049 V8_INLINE(int Length() const); |
2029 V8_INLINE(Local<Value> operator[](int i) const); | 2050 V8_INLINE(Local<Value> operator[](int i) const); |
2030 V8_INLINE(Local<Function> Callee() const); | 2051 V8_INLINE(Local<Function> Callee() const); |
2031 V8_INLINE(Local<Object> This() const); | 2052 V8_INLINE(Local<Object> This() const); |
2032 V8_INLINE(Local<Object> Holder() const); | 2053 V8_INLINE(Local<Object> Holder() const); |
2033 V8_INLINE(bool IsConstructCall() const); | 2054 V8_INLINE(bool IsConstructCall() const); |
2034 V8_INLINE(Local<Value> Data() const); | 2055 V8_INLINE(Local<Value> Data() const); |
2035 V8_INLINE(Isolate* GetIsolate() const); | 2056 V8_INLINE(Isolate* GetIsolate() const); |
2036 | 2057 |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2916 private: | 2937 private: |
2917 Isolate(); | 2938 Isolate(); |
2918 Isolate(const Isolate&); | 2939 Isolate(const Isolate&); |
2919 ~Isolate(); | 2940 ~Isolate(); |
2920 Isolate& operator=(const Isolate&); | 2941 Isolate& operator=(const Isolate&); |
2921 void* operator new(size_t size); | 2942 void* operator new(size_t size); |
2922 void operator delete(void*, size_t); | 2943 void operator delete(void*, size_t); |
2923 }; | 2944 }; |
2924 | 2945 |
2925 | 2946 |
2926 class V8EXPORT StartupData { | 2947 class StartupData { |
2927 public: | 2948 public: |
2928 enum CompressionAlgorithm { | 2949 enum CompressionAlgorithm { |
2929 kUncompressed, | 2950 kUncompressed, |
2930 kBZip2 | 2951 kBZip2 |
2931 }; | 2952 }; |
2932 | 2953 |
2933 const char* data; | 2954 const char* data; |
2934 int compressed_size; | 2955 int compressed_size; |
2935 int raw_size; | 2956 int raw_size; |
2936 }; | 2957 }; |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3790 */ | 3811 */ |
3791 void Exit(); | 3812 void Exit(); |
3792 | 3813 |
3793 /** Returns true if the context has experienced an out of memory situation. */ | 3814 /** Returns true if the context has experienced an out of memory situation. */ |
3794 bool HasOutOfMemoryException(); | 3815 bool HasOutOfMemoryException(); |
3795 | 3816 |
3796 /** Returns true if V8 has a current context. */ | 3817 /** Returns true if V8 has a current context. */ |
3797 static bool InContext(); | 3818 static bool InContext(); |
3798 | 3819 |
3799 /** | 3820 /** |
| 3821 * Gets embedder data with index 0. Deprecated, use GetEmbedderData with index |
| 3822 * 0 instead. |
| 3823 */ |
| 3824 V8_DEPRECATED(V8_INLINE(Local<Value> GetData())); |
| 3825 |
| 3826 /** |
| 3827 * Sets embedder data with index 0. Deprecated, use SetEmbedderData with index |
| 3828 * 0 instead. |
| 3829 */ |
| 3830 V8_DEPRECATED(V8_INLINE(void SetData(Handle<Value> value))); |
| 3831 |
| 3832 /** |
3800 * Gets the embedder data with the given index, which must have been set by a | 3833 * Gets the embedder data with the given index, which must have been set by a |
3801 * previous call to SetEmbedderData with the same index. Note that index 0 | 3834 * previous call to SetEmbedderData with the same index. Note that index 0 |
3802 * currently has a special meaning for Chrome's debugger. | 3835 * currently has a special meaning for Chrome's debugger. |
3803 */ | 3836 */ |
3804 V8_INLINE(Local<Value> GetEmbedderData(int index)); | 3837 V8_INLINE(Local<Value> GetEmbedderData(int index)); |
3805 | 3838 |
3806 /** | 3839 /** |
3807 * Sets the embedder data with the given index, growing the data as | 3840 * Sets the embedder data with the given index, growing the data as |
3808 * needed. Note that index 0 currently has a special meaning for Chrome's | 3841 * needed. Note that index 0 currently has a special meaning for Chrome's |
3809 * debugger. | 3842 * debugger. |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4483 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); | 4516 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); |
4484 O* value = I::ReadField<O*>(obj, offset); | 4517 O* value = I::ReadField<O*>(obj, offset); |
4485 O** result = HandleScope::CreateHandle(value); | 4518 O** result = HandleScope::CreateHandle(value); |
4486 return Local<Value>(reinterpret_cast<Value*>(result)); | 4519 return Local<Value>(reinterpret_cast<Value*>(result)); |
4487 } | 4520 } |
4488 #endif | 4521 #endif |
4489 return SlowGetInternalField(index); | 4522 return SlowGetInternalField(index); |
4490 } | 4523 } |
4491 | 4524 |
4492 | 4525 |
| 4526 void Object::SetPointerInInternalField(int index, void* value) { |
| 4527 SetInternalField(index, External::New(value)); |
| 4528 } |
| 4529 |
| 4530 |
4493 void* Object::GetAlignedPointerFromInternalField(int index) { | 4531 void* Object::GetAlignedPointerFromInternalField(int index) { |
4494 #ifndef V8_ENABLE_CHECKS | 4532 #ifndef V8_ENABLE_CHECKS |
4495 typedef internal::Object O; | 4533 typedef internal::Object O; |
4496 typedef internal::Internals I; | 4534 typedef internal::Internals I; |
4497 O* obj = *reinterpret_cast<O**>(this); | 4535 O* obj = *reinterpret_cast<O**>(this); |
4498 // Fast path: If the object is a plain JSObject, which is the common case, we | 4536 // Fast path: If the object is a plain JSObject, which is the common case, we |
4499 // know where to find the internal fields and can return the value directly. | 4537 // know where to find the internal fields and can return the value directly. |
4500 if (I::GetInstanceType(obj) == I::kJSObjectType) { | 4538 if (I::GetInstanceType(obj) == I::kJSObjectType) { |
4501 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); | 4539 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); |
4502 return I::ReadField<void*>(obj, offset); | 4540 return I::ReadField<void*>(obj, offset); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4687 | 4725 |
4688 | 4726 |
4689 Function* Function::Cast(v8::Value* value) { | 4727 Function* Function::Cast(v8::Value* value) { |
4690 #ifdef V8_ENABLE_CHECKS | 4728 #ifdef V8_ENABLE_CHECKS |
4691 CheckCast(value); | 4729 CheckCast(value); |
4692 #endif | 4730 #endif |
4693 return static_cast<Function*>(value); | 4731 return static_cast<Function*>(value); |
4694 } | 4732 } |
4695 | 4733 |
4696 | 4734 |
| 4735 Local<Value> External::Wrap(void* value) { |
| 4736 return External::New(value); |
| 4737 } |
| 4738 |
| 4739 |
| 4740 void* External::Unwrap(Handle<v8::Value> obj) { |
| 4741 return External::Cast(*obj)->Value(); |
| 4742 } |
| 4743 |
| 4744 |
4697 External* External::Cast(v8::Value* value) { | 4745 External* External::Cast(v8::Value* value) { |
4698 #ifdef V8_ENABLE_CHECKS | 4746 #ifdef V8_ENABLE_CHECKS |
4699 CheckCast(value); | 4747 CheckCast(value); |
4700 #endif | 4748 #endif |
4701 return static_cast<External*>(value); | 4749 return static_cast<External*>(value); |
4702 } | 4750 } |
4703 | 4751 |
4704 | 4752 |
4705 Isolate* AccessorInfo::GetIsolate() const { | 4753 Isolate* AccessorInfo::GetIsolate() const { |
4706 return *reinterpret_cast<Isolate**>(&args_[-3]); | 4754 return *reinterpret_cast<Isolate**>(&args_[-3]); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4763 I::SetEmbedderData(this, data); | 4811 I::SetEmbedderData(this, data); |
4764 } | 4812 } |
4765 | 4813 |
4766 | 4814 |
4767 void* Isolate::GetData() { | 4815 void* Isolate::GetData() { |
4768 typedef internal::Internals I; | 4816 typedef internal::Internals I; |
4769 return I::GetEmbedderData(this); | 4817 return I::GetEmbedderData(this); |
4770 } | 4818 } |
4771 | 4819 |
4772 | 4820 |
| 4821 Local<Value> Context::GetData() { |
| 4822 return GetEmbedderData(0); |
| 4823 } |
| 4824 |
| 4825 void Context::SetData(Handle<Value> data) { |
| 4826 SetEmbedderData(0, data); |
| 4827 } |
| 4828 |
| 4829 |
4773 Local<Value> Context::GetEmbedderData(int index) { | 4830 Local<Value> Context::GetEmbedderData(int index) { |
4774 #ifndef V8_ENABLE_CHECKS | 4831 #ifndef V8_ENABLE_CHECKS |
4775 typedef internal::Object O; | 4832 typedef internal::Object O; |
4776 typedef internal::Internals I; | 4833 typedef internal::Internals I; |
4777 O** result = HandleScope::CreateHandle(I::ReadEmbedderData<O*>(this, index)); | 4834 O** result = HandleScope::CreateHandle(I::ReadEmbedderData<O*>(this, index)); |
4778 return Local<Value>(reinterpret_cast<Value*>(result)); | 4835 return Local<Value>(reinterpret_cast<Value*>(result)); |
4779 #else | 4836 #else |
4780 return SlowGetEmbedderData(index); | 4837 return SlowGetEmbedderData(index); |
4781 #endif | 4838 #endif |
4782 } | 4839 } |
(...skipping 22 matching lines...) Expand all Loading... |
4805 | 4862 |
4806 | 4863 |
4807 } // namespace v8 | 4864 } // namespace v8 |
4808 | 4865 |
4809 | 4866 |
4810 #undef V8EXPORT | 4867 #undef V8EXPORT |
4811 #undef TYPE_CHECK | 4868 #undef TYPE_CHECK |
4812 | 4869 |
4813 | 4870 |
4814 #endif // V8_H_ | 4871 #endif // V8_H_ |
OLD | NEW |