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

Side by Side Diff: include/v8.h

Issue 199043: Const Correctness for String::Value (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 3 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') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 * Converts an object to a utf8-encoded character array. Useful if 972 * Converts an object to a utf8-encoded character array. Useful if
973 * you want to print the object. If conversion to a string fails 973 * you want to print the object. If conversion to a string fails
974 * (eg. due to an exception in the toString() method of the object) 974 * (eg. due to an exception in the toString() method of the object)
975 * then the length() method returns 0 and the * operator returns 975 * then the length() method returns 0 and the * operator returns
976 * NULL. 976 * NULL.
977 */ 977 */
978 class V8EXPORT Utf8Value { 978 class V8EXPORT Utf8Value {
979 public: 979 public:
980 explicit Utf8Value(Handle<v8::Value> obj); 980 explicit Utf8Value(Handle<v8::Value> obj);
981 ~Utf8Value(); 981 ~Utf8Value();
982 char* operator*() const { return str_; } 982 char* operator*() { return str_; }
983 int length() { return length_; } 983 const char* operator*() const { return str_; }
984 int length() const { return length_; }
984 private: 985 private:
985 char* str_; 986 char* str_;
986 int length_; 987 int length_;
987 988
988 // Disallow copying and assigning. 989 // Disallow copying and assigning.
989 Utf8Value(const Utf8Value&); 990 Utf8Value(const Utf8Value&);
990 void operator=(const Utf8Value&); 991 void operator=(const Utf8Value&);
991 }; 992 };
992 993
993 /** 994 /**
994 * Converts an object to an ascii string. 995 * Converts an object to an ascii string.
995 * Useful if you want to print the object. 996 * Useful if you want to print the object.
996 * If conversion to a string fails (eg. due to an exception in the toString() 997 * If conversion to a string fails (eg. due to an exception in the toString()
997 * method of the object) then the length() method returns 0 and the * operator 998 * method of the object) then the length() method returns 0 and the * operator
998 * returns NULL. 999 * returns NULL.
999 */ 1000 */
1000 class V8EXPORT AsciiValue { 1001 class V8EXPORT AsciiValue {
1001 public: 1002 public:
1002 explicit AsciiValue(Handle<v8::Value> obj); 1003 explicit AsciiValue(Handle<v8::Value> obj);
1003 ~AsciiValue(); 1004 ~AsciiValue();
1004 char* operator*() const { return str_; } 1005 char* operator*() { return str_; }
1005 int length() { return length_; } 1006 const char* operator*() const { return str_; }
1007 int length() const { return length_; }
1006 private: 1008 private:
1007 char* str_; 1009 char* str_;
1008 int length_; 1010 int length_;
1009 1011
1010 // Disallow copying and assigning. 1012 // Disallow copying and assigning.
1011 AsciiValue(const AsciiValue&); 1013 AsciiValue(const AsciiValue&);
1012 void operator=(const AsciiValue&); 1014 void operator=(const AsciiValue&);
1013 }; 1015 };
1014 1016
1015 /** 1017 /**
1016 * Converts an object to a two-byte string. 1018 * Converts an object to a two-byte string.
1017 * If conversion to a string fails (eg. due to an exception in the toString() 1019 * If conversion to a string fails (eg. due to an exception in the toString()
1018 * method of the object) then the length() method returns 0 and the * operator 1020 * method of the object) then the length() method returns 0 and the * operator
1019 * returns NULL. 1021 * returns NULL.
1020 */ 1022 */
1021 class V8EXPORT Value { 1023 class V8EXPORT Value {
1022 public: 1024 public:
1023 explicit Value(Handle<v8::Value> obj); 1025 explicit Value(Handle<v8::Value> obj);
1024 ~Value(); 1026 ~Value();
1025 uint16_t* operator*() const { return str_; } 1027 uint16_t* operator*() { return str_; }
1026 int length() { return length_; } 1028 const uint16_t* operator*() const { return str_; }
1029 int length() const { return length_; }
1027 private: 1030 private:
1028 uint16_t* str_; 1031 uint16_t* str_;
1029 int length_; 1032 int length_;
1030 1033
1031 // Disallow copying and assigning. 1034 // Disallow copying and assigning.
1032 Value(const Value&); 1035 Value(const Value&);
1033 void operator=(const Value&); 1036 void operator=(const Value&);
1034 }; 1037 };
1035 1038
1036 private: 1039 private:
(...skipping 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after
3077 3080
3078 } // namespace v8 3081 } // namespace v8
3079 3082
3080 3083
3081 #undef V8EXPORT 3084 #undef V8EXPORT
3082 #undef V8EXPORT_INLINE 3085 #undef V8EXPORT_INLINE
3083 #undef TYPE_CHECK 3086 #undef TYPE_CHECK
3084 3087
3085 3088
3086 #endif // V8_H_ 3089 #endif // V8_H_
OLDNEW
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698