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

Side by Side Diff: include/v8.h

Issue 108783007: Reland r18383: More API cleanup. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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 | « no previous file | src/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 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 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 int options = NO_OPTIONS) const; 1661 int options = NO_OPTIONS) const;
1662 // UTF-8 encoded characters. 1662 // UTF-8 encoded characters.
1663 int WriteUtf8(char* buffer, 1663 int WriteUtf8(char* buffer,
1664 int length = -1, 1664 int length = -1,
1665 int* nchars_ref = NULL, 1665 int* nchars_ref = NULL,
1666 int options = NO_OPTIONS) const; 1666 int options = NO_OPTIONS) const;
1667 1667
1668 /** 1668 /**
1669 * A zero length string. 1669 * A zero length string.
1670 */ 1670 */
1671 static v8::Local<v8::String> Empty();
1672 V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate); 1671 V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate);
1673 1672
1674 /** 1673 /**
1675 * Returns true if the string is external 1674 * Returns true if the string is external
1676 */ 1675 */
1677 bool IsExternal() const; 1676 bool IsExternal() const;
1678 1677
1679 /** 1678 /**
1680 * Returns true if the string is both external and ASCII 1679 * Returns true if the string is both external and ASCII
1681 */ 1680 */
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 }; 1955 };
1957 1956
1958 1957
1959 /** 1958 /**
1960 * A JavaScript number value (ECMA-262, 4.3.20) 1959 * A JavaScript number value (ECMA-262, 4.3.20)
1961 */ 1960 */
1962 class V8_EXPORT Number : public Primitive { 1961 class V8_EXPORT Number : public Primitive {
1963 public: 1962 public:
1964 double Value() const; 1963 double Value() const;
1965 static Local<Number> New(Isolate* isolate, double value); 1964 static Local<Number> New(Isolate* isolate, double value);
1966 // Will be deprecated soon.
1967 static Local<Number> New(double value);
1968 V8_INLINE static Number* Cast(v8::Value* obj); 1965 V8_INLINE static Number* Cast(v8::Value* obj);
1969 private: 1966 private:
1970 Number(); 1967 Number();
1971 static void CheckCast(v8::Value* obj); 1968 static void CheckCast(v8::Value* obj);
1972 }; 1969 };
1973 1970
1974 1971
1975 /** 1972 /**
1976 * A JavaScript value representing a signed integer. 1973 * A JavaScript value representing a signed integer.
1977 */ 1974 */
1978 class V8_EXPORT Integer : public Number { 1975 class V8_EXPORT Integer : public Number {
1979 public: 1976 public:
1980 static Local<Integer> New(Isolate* isolate, int32_t value); 1977 static Local<Integer> New(Isolate* isolate, int32_t value);
1981 static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value); 1978 static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value);
1982 // Will be deprecated soon.
1983 static Local<Integer> New(int32_t value, Isolate*);
1984 static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*);
1985 static Local<Integer> New(int32_t value);
1986 static Local<Integer> NewFromUnsigned(uint32_t value);
1987 int64_t Value() const; 1979 int64_t Value() const;
1988 V8_INLINE static Integer* Cast(v8::Value* obj); 1980 V8_INLINE static Integer* Cast(v8::Value* obj);
1989 private: 1981 private:
1990 Integer(); 1982 Integer();
1991 static void CheckCast(v8::Value* obj); 1983 static void CheckCast(v8::Value* obj);
1992 }; 1984 };
1993 1985
1994 1986
1995 /** 1987 /**
1996 * A JavaScript value representing a 32-bit signed integer. 1988 * A JavaScript value representing a 32-bit signed integer.
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 Handle<Value> argv[]); 2322 Handle<Value> argv[]);
2331 2323
2332 /** 2324 /**
2333 * Call an Object as a constructor if a callback is set by the 2325 * Call an Object as a constructor if a callback is set by the
2334 * ObjectTemplate::SetCallAsFunctionHandler method. 2326 * ObjectTemplate::SetCallAsFunctionHandler method.
2335 * Note: This method behaves like the Function::NewInstance method. 2327 * Note: This method behaves like the Function::NewInstance method.
2336 */ 2328 */
2337 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]); 2329 Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]);
2338 2330
2339 static Local<Object> New(Isolate* isolate); 2331 static Local<Object> New(Isolate* isolate);
2340 // Will be deprecated soon. 2332
2341 static Local<Object> New();
2342 V8_INLINE static Object* Cast(Value* obj); 2333 V8_INLINE static Object* Cast(Value* obj);
2343 2334
2344 private: 2335 private:
2345 Object(); 2336 Object();
2346 static void CheckCast(Value* obj); 2337 static void CheckCast(Value* obj);
2347 Local<Value> SlowGetInternalField(int index); 2338 Local<Value> SlowGetInternalField(int index);
2348 void* SlowGetAlignedPointerFromInternalField(int index); 2339 void* SlowGetAlignedPointerFromInternalField(int index);
2349 }; 2340 };
2350 2341
2351 2342
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
3340 */ 3331 */
3341 class V8_EXPORT FunctionTemplate : public Template { 3332 class V8_EXPORT FunctionTemplate : public Template {
3342 public: 3333 public:
3343 /** Creates a function template.*/ 3334 /** Creates a function template.*/
3344 static Local<FunctionTemplate> New( 3335 static Local<FunctionTemplate> New(
3345 Isolate* isolate, 3336 Isolate* isolate,
3346 FunctionCallback callback = 0, 3337 FunctionCallback callback = 0,
3347 Handle<Value> data = Handle<Value>(), 3338 Handle<Value> data = Handle<Value>(),
3348 Handle<Signature> signature = Handle<Signature>(), 3339 Handle<Signature> signature = Handle<Signature>(),
3349 int length = 0); 3340 int length = 0);
3350 // Will be deprecated soon.
3351 static Local<FunctionTemplate> New(
3352 FunctionCallback callback = 0,
3353 Handle<Value> data = Handle<Value>(),
3354 Handle<Signature> signature = Handle<Signature>(),
3355 int length = 0);
3356 3341
3357 /** Returns the unique function instance in the current execution context.*/ 3342 /** Returns the unique function instance in the current execution context.*/
3358 Local<Function> GetFunction(); 3343 Local<Function> GetFunction();
3359 3344
3360 /** 3345 /**
3361 * Set the call-handler callback for a FunctionTemplate. This 3346 * Set the call-handler callback for a FunctionTemplate. This
3362 * callback is called whenever the function created from this 3347 * callback is called whenever the function created from this
3363 * FunctionTemplate is called. 3348 * FunctionTemplate is called.
3364 */ 3349 */
3365 void SetCallHandler(FunctionCallback callback, 3350 void SetCallHandler(FunctionCallback callback,
(...skipping 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after
5785 } 5770 }
5786 5771
5787 template<typename T> 5772 template<typename T>
5788 void ReturnValue<T>::Set(int32_t i) { 5773 void ReturnValue<T>::Set(int32_t i) {
5789 TYPE_CHECK(T, Integer); 5774 TYPE_CHECK(T, Integer);
5790 typedef internal::Internals I; 5775 typedef internal::Internals I;
5791 if (V8_LIKELY(I::IsValidSmi(i))) { 5776 if (V8_LIKELY(I::IsValidSmi(i))) {
5792 *value_ = I::IntToSmi(i); 5777 *value_ = I::IntToSmi(i);
5793 return; 5778 return;
5794 } 5779 }
5795 Set(Integer::New(i, GetIsolate())); 5780 Set(Integer::New(GetIsolate(), i));
5796 } 5781 }
5797 5782
5798 template<typename T> 5783 template<typename T>
5799 void ReturnValue<T>::Set(uint32_t i) { 5784 void ReturnValue<T>::Set(uint32_t i) {
5800 TYPE_CHECK(T, Integer); 5785 TYPE_CHECK(T, Integer);
5801 // Can't simply use INT32_MAX here for whatever reason. 5786 // Can't simply use INT32_MAX here for whatever reason.
5802 bool fits_into_int32_t = (i & (1U << 31)) == 0; 5787 bool fits_into_int32_t = (i & (1U << 31)) == 0;
5803 if (V8_LIKELY(fits_into_int32_t)) { 5788 if (V8_LIKELY(fits_into_int32_t)) {
5804 Set(static_cast<int32_t>(i)); 5789 Set(static_cast<int32_t>(i));
5805 return; 5790 return;
5806 } 5791 }
5807 Set(Integer::NewFromUnsigned(i, GetIsolate())); 5792 Set(Integer::NewFromUnsigned(GetIsolate(), i));
5808 } 5793 }
5809 5794
5810 template<typename T> 5795 template<typename T>
5811 void ReturnValue<T>::Set(bool value) { 5796 void ReturnValue<T>::Set(bool value) {
5812 TYPE_CHECK(T, Boolean); 5797 TYPE_CHECK(T, Boolean);
5813 typedef internal::Internals I; 5798 typedef internal::Internals I;
5814 int root_index; 5799 int root_index;
5815 if (value) { 5800 if (value) {
5816 root_index = I::kTrueValueRootIndex; 5801 root_index = I::kTrueValueRootIndex;
5817 } else { 5802 } else {
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
6455 */ 6440 */
6456 6441
6457 6442
6458 } // namespace v8 6443 } // namespace v8
6459 6444
6460 6445
6461 #undef TYPE_CHECK 6446 #undef TYPE_CHECK
6462 6447
6463 6448
6464 #endif // V8_H_ 6449 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698