Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Side by Side Diff: include/v8.h

Issue 9298049: Improvements to v8::Value comments to make a little easier for new users to Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « AUTHORS ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 * constructor via "new". 847 * constructor via "new".
848 */ 848 */
849 bool IsConstructor() const; 849 bool IsConstructor() const;
850 }; 850 };
851 851
852 852
853 // --- Value --- 853 // --- Value ---
854 854
855 855
856 /** 856 /**
857 * The superclass of all JavaScript values and objects. 857 * The superclass of all JavaScript values.
858 *
859 * ECMA-262 defines six types, undefined, null, boolean, string, number and
860 * object. The Value class provides a mechanism for accessing internal data
861 * held in values of these types, it does not store the data but instead
862 * operates as a Value reference or Value accessor.
863 *
864 * There are a number of built-in object types for functions, arrays, strings
865 * booleans, numbers, dates and regular expressions. Values of these types
866 * can also be accessed via this class. The value class also supports External
867 * and NativeError objects types which are outside ECMA-262 scope.
868 *
869 * Types are defined in secion 8 of ECMA-262, built in objects are described in
870 * section 15.
858 */ 871 */
859 class Value : public Data { 872 class Value : public Data {
860 public: 873 public:
861 /** 874 /**
862 * Returns true if this value is the undefined value. See ECMA-262 875 * Returns true if this value is of undefined type.
863 * 4.3.10. 876 * See ECMA-262 8.1
864 */ 877 */
865 V8EXPORT bool IsUndefined() const; 878 V8EXPORT bool IsUndefined() const;
866 879
867 /** 880 /**
868 * Returns true if this value is the null value. See ECMA-262 881 * Returns true if this value is of null type.
869 * 4.3.11. 882 * See ECMA-262 8.2
870 */ 883 */
871 V8EXPORT bool IsNull() const; 884 V8EXPORT bool IsNull() const;
872 885
873 /** 886 /**
874 * Returns true if this value is true. 887 * Returns true if this value is boolean. This does not test for
888 * Boolean objects, only values of boolean type.
889 * See ECMA-262 8.3
890 */
891 V8EXPORT bool IsBoolean() const;
892
893 /**
894 * Returns true if this value is of boolean type and is true. For a Boolean
895 * object value this will always return false.
875 */ 896 */
876 V8EXPORT bool IsTrue() const; 897 V8EXPORT bool IsTrue() const;
877 898
878 /** 899 /**
879 * Returns true if this value is false. 900 * Returns true if this value is of boolean type and is false. For a Boolean
901 * object value this will always return false.
880 */ 902 */
881 V8EXPORT bool IsFalse() const; 903 V8EXPORT bool IsFalse() const;
882 904
883 /** 905 /**
884 * Returns true if this value is an instance of the String type. 906 * Returns true if this value is of string type. For a String object value
907 * this will always return false.
885 * See ECMA-262 8.4. 908 * See ECMA-262 8.4.
886 */ 909 */
887 inline bool IsString() const; 910 inline bool IsString() const;
888 911
889 /** 912 /**
890 * Returns true if this value is a function. 913 * Returns true if this value is of number type. For a Number object value
914 * this will always return false.
915 * See ECMA-262 8.5.
916 */
917 V8EXPORT bool IsNumber() const;
918
919 /**
920 * Returns true if this value is a object type.
921 * See ECMA-262 15.2
922 */
923 V8EXPORT bool IsObject() const;
924
925 /**
926 * Returns true if this value is a function object.
927 * See ECMA-262 15.3.
891 */ 928 */
892 V8EXPORT bool IsFunction() const; 929 V8EXPORT bool IsFunction() const;
893 930
894 /** 931 /**
895 * Returns true if this value is an array. 932 * Returns true if this value is an array object.
933 * See ECMA-262 15.4.
896 */ 934 */
897 V8EXPORT bool IsArray() const; 935 V8EXPORT bool IsArray() const;
898 936
899 /** 937 /**
900 * Returns true if this value is an object. 938 * Returns true if this value is a String object.
901 */ 939 * See ECMA-262 15.5.
902 V8EXPORT bool IsObject() const; 940 */
903 941 V8EXPORT bool IsStringObject() const;
904 /** 942
905 * Returns true if this value is boolean. 943 /**
906 */ 944 * Returns true if this value is a Boolean object.
907 V8EXPORT bool IsBoolean() const; 945 * See ECMA-262 15.6.
908 946 */
909 /** 947 V8EXPORT bool IsBooleanObject() const;
910 * Returns true if this value is a number. 948
911 */ 949 /**
912 V8EXPORT bool IsNumber() const; 950 * Returns true if this value is a Number object.
913 951 * See ECMA-262 15.7.
914 /** 952 */
915 * Returns true if this value is external. 953 V8EXPORT bool IsNumberObject() const;
954
955 /**
956 * Returns true if this value is a Date object.
957 * See ECMA-262 15.9.
958 */
959 V8EXPORT bool IsDate() const;
960
961 /**
962 * Returns true if this value is a regular expression object.
963 * See ECMA-262 15.10.
964 */
965 V8EXPORT bool IsRegExp() const;
966
967 /**
968 * Returns true if this value is an external object.
916 */ 969 */
917 V8EXPORT bool IsExternal() const; 970 V8EXPORT bool IsExternal() const;
918 971
919 /** 972 /**
920 * Returns true if this value is a 32-bit signed integer. 973 * Returns true if this value is a NativeError object.
974 */
975 V8EXPORT bool IsNativeError() const;
976
977 /**
978 * Returns true if this value is either a number type or a Number object
979 * and its value can be stored in a signed 32-bit integer without error.
921 */ 980 */
922 V8EXPORT bool IsInt32() const; 981 V8EXPORT bool IsInt32() const;
923 982
924 /** 983 /**
925 * Returns true if this value is a 32-bit unsigned integer. 984 * Returns true if this value is either a number type or a Number object
985 * and its value can be stored in a unsigned 32-bit integer without error.
926 */ 986 */
927 V8EXPORT bool IsUint32() const; 987 V8EXPORT bool IsUint32() const;
928 988
929 /** 989 /**
930 * Returns true if this value is a Date. 990 * These functions convert the value to a number according to ECAMA-262 9.1.
931 */ 991 * The result is either returned directly or as a value.
932 V8EXPORT bool IsDate() const; 992 */
933 993 V8EXPORT Local<Number> ToNumber() const;
934 /** 994 V8EXPORT double NumberValue() const;
935 * Returns true if this value is a Boolean object. 995
936 */ 996 /**
937 V8EXPORT bool IsBooleanObject() const; 997 * These functions convert the value to a signed 64-bit integer by first
938 998 * converting to a number according to ECAMA-262 9.3 and then converting that
939 /** 999 * number to an integer as per section 9.6. The result is either returned
940 * Returns true if this value is a Number object. 1000 * directly or via an internally managed value.
941 */ 1001 */
942 V8EXPORT bool IsNumberObject() const; 1002 V8EXPORT int64_t IntegerValue() const;
943 1003 V8EXPORT Local<Integer> ToInteger() const;
944 /** 1004
945 * Returns true if this value is a String object. 1005 /**
946 */ 1006 * These functions convert the value to a boolean according to ECAMA-262 9.1.
947 V8EXPORT bool IsStringObject() const; 1007 * The result is either returned directly or as an value.
948 1008 */
949 /**
950 * Returns true if this value is a NativeError.
951 */
952 V8EXPORT bool IsNativeError() const;
953
954 /**
955 * Returns true if this value is a RegExp.
956 */
957 V8EXPORT bool IsRegExp() const;
958
959 V8EXPORT Local<Boolean> ToBoolean() const; 1009 V8EXPORT Local<Boolean> ToBoolean() const;
960 V8EXPORT Local<Number> ToNumber() const; 1010 V8EXPORT bool BooleanValue() const;
1011
1012 /**
1013 * These functions convert the value to a unsigned 32-bit integer by first
1014 * converting to a number according to ECAMA-262 9.3 and then converting that
1015 * number to an integer as per section 9.6. The result is either returned
1016 * directly or via an internally managed value.
1017 */
1018 V8EXPORT Local<Uint32> ToUint32() const;
1019 V8EXPORT int32_t Int32Value() const;
1020
1021 /**
1022 * These functions convert the value to a signed 32-bit integer by first
1023 * converting to a number according to ECAMA-262 9.3 and then converting that
1024 * number to an integer as per section 9.5. The result is either returned
1025 * directly or via an internally managed value.
1026 */
1027 V8EXPORT Local<Int32> ToInt32() const;
1028 V8EXPORT uint32_t Uint32Value() const;
1029
1030 /**
1031 * This function converts the value to a String according to ECMA-262 9.8 and
1032 * then if possible to a unsigned 32-bit value that could possibly be used
1033 * to access an array. It returns an empty handle if the value is not
1034 * suitable for use as an index.
1035 */
1036 V8EXPORT Local<Uint32> ToArrayIndex() const;
1037
1038 /**
1039 * This functions convert the value to a string according to
1040 * ECMA-262 9.8.
1041 */
961 V8EXPORT Local<String> ToString() const; 1042 V8EXPORT Local<String> ToString() const;
1043
1044 /**
1045 * This function returns a string for an object similarly to ToString() with
1046 * the exceptions that for NativeError objects a formatted message is
1047 * returned.
1048 */
962 V8EXPORT Local<String> ToDetailString() const; 1049 V8EXPORT Local<String> ToDetailString() const;
1050
1051 /**
1052 * This functions convert the value to an object according to ECAMA-262 9.9.
1053 * Undefined, Null and undetectable objects will result in a empty value
1054 * being returned.
1055 */
963 V8EXPORT Local<Object> ToObject() const; 1056 V8EXPORT Local<Object> ToObject() const;
964 V8EXPORT Local<Integer> ToInteger() const; 1057
965 V8EXPORT Local<Uint32> ToUint32() const; 1058 /**
966 V8EXPORT Local<Int32> ToInt32() const; 1059 * These functions compare values for equality according to ECMA-262 11.9.3
967 1060 * & 11.9.4.
968 /** 1061 */
969 * Attempts to convert a string to an array index.
970 * Returns an empty handle if the conversion fails.
971 */
972 V8EXPORT Local<Uint32> ToArrayIndex() const;
973
974 V8EXPORT bool BooleanValue() const;
975 V8EXPORT double NumberValue() const;
976 V8EXPORT int64_t IntegerValue() const;
977 V8EXPORT uint32_t Uint32Value() const;
978 V8EXPORT int32_t Int32Value() const;
979
980 /** JS == */
981 V8EXPORT bool Equals(Handle<Value> that) const; 1062 V8EXPORT bool Equals(Handle<Value> that) const;
982 V8EXPORT bool StrictEquals(Handle<Value> that) const; 1063 V8EXPORT bool StrictEquals(Handle<Value> that) const;
983 1064
984 private: 1065 private:
985 inline bool QuickIsString() const; 1066 inline bool QuickIsString() const;
986 V8EXPORT bool FullIsString() const; 1067 V8EXPORT bool FullIsString() const;
987 }; 1068 };
988 1069
989 1070
990 /** 1071 /**
(...skipping 3285 matching lines...) Expand 10 before | Expand all | Expand 10 after
4276 4357
4277 4358
4278 } // namespace v8 4359 } // namespace v8
4279 4360
4280 4361
4281 #undef V8EXPORT 4362 #undef V8EXPORT
4282 #undef TYPE_CHECK 4363 #undef TYPE_CHECK
4283 4364
4284 4365
4285 #endif // V8_H_ 4366 #endif // V8_H_
OLDNEW
« no previous file with comments | « AUTHORS ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698