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

Side by Side Diff: src/api.h

Issue 2396353002: Revert "Add Smi::Zero and replace all Smi::FromInt(0) calls" (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « src/accessors.cc ('k') | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_API_H_ 5 #ifndef V8_API_H_
6 #define V8_API_H_ 6 #define V8_API_H_
7 7
8 #include "include/v8-testing.h" 8 #include "include/v8-testing.h"
9 #include "src/contexts.h" 9 #include "src/contexts.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 10 matching lines...) Expand all
21 class Consts { 21 class Consts {
22 public: 22 public:
23 enum TemplateType { 23 enum TemplateType {
24 FUNCTION_TEMPLATE = 0, 24 FUNCTION_TEMPLATE = 0,
25 OBJECT_TEMPLATE = 1 25 OBJECT_TEMPLATE = 1
26 }; 26 };
27 }; 27 };
28 28
29 template <typename T> inline T ToCData(v8::internal::Object* obj) { 29 template <typename T> inline T ToCData(v8::internal::Object* obj) {
30 STATIC_ASSERT(sizeof(T) == sizeof(v8::internal::Address)); 30 STATIC_ASSERT(sizeof(T) == sizeof(v8::internal::Address));
31 if (obj == v8::internal::Smi::kZero) return nullptr; 31 if (obj == v8::internal::Smi::FromInt(0)) return nullptr;
32 return reinterpret_cast<T>( 32 return reinterpret_cast<T>(
33 reinterpret_cast<intptr_t>( 33 reinterpret_cast<intptr_t>(
34 v8::internal::Foreign::cast(obj)->foreign_address())); 34 v8::internal::Foreign::cast(obj)->foreign_address()));
35 } 35 }
36 36
37 37
38 template <typename T> 38 template <typename T>
39 inline v8::internal::Handle<v8::internal::Object> FromCData( 39 inline v8::internal::Handle<v8::internal::Object> FromCData(
40 v8::internal::Isolate* isolate, T obj) { 40 v8::internal::Isolate* isolate, T obj) {
41 STATIC_ASSERT(sizeof(T) == sizeof(v8::internal::Address)); 41 STATIC_ASSERT(sizeof(T) == sizeof(v8::internal::Address));
42 if (obj == nullptr) return handle(v8::internal::Smi::kZero, isolate); 42 if (obj == nullptr) return handle(v8::internal::Smi::FromInt(0), isolate);
43 return isolate->factory()->NewForeign( 43 return isolate->factory()->NewForeign(
44 reinterpret_cast<v8::internal::Address>(reinterpret_cast<intptr_t>(obj))); 44 reinterpret_cast<v8::internal::Address>(reinterpret_cast<intptr_t>(obj)));
45 } 45 }
46 46
47 47
48 class ApiFunction { 48 class ApiFunction {
49 public: 49 public:
50 explicit ApiFunction(v8::internal::Address addr) : addr_(addr) { } 50 explicit ApiFunction(v8::internal::Address addr) : addr_(addr) { }
51 v8::internal::Address address() { return addr_; } 51 v8::internal::Address address() { return addr_; }
52 private: 52 private:
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 } 662 }
663 663
664 private: 664 private:
665 static v8::Testing::StressType stress_type_; 665 static v8::Testing::StressType stress_type_;
666 }; 666 };
667 667
668 } // namespace internal 668 } // namespace internal
669 } // namespace v8 669 } // namespace v8
670 670
671 #endif // V8_API_H_ 671 #endif // V8_API_H_
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698