OLD | NEW |
---|---|
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1509 return Utils::OpenHandle(this)->IsBoolean(); | 1509 return Utils::OpenHandle(this)->IsBoolean(); |
1510 } | 1510 } |
1511 | 1511 |
1512 | 1512 |
1513 bool Value::IsExternal() const { | 1513 bool Value::IsExternal() const { |
1514 if (IsDeadCheck("v8::Value::IsExternal()")) return false; | 1514 if (IsDeadCheck("v8::Value::IsExternal()")) return false; |
1515 return Utils::OpenHandle(this)->IsProxy(); | 1515 return Utils::OpenHandle(this)->IsProxy(); |
1516 } | 1516 } |
1517 | 1517 |
1518 | 1518 |
1519 bool Value::IsBlob() const { | |
1520 if (IsDeadCheck("v8::Value::IsBlob()")) return false; | |
1521 return Utils::OpenHandle(this)->IsByteArray(); | |
1522 } | |
1523 | |
1524 | |
1519 bool Value::IsInt32() const { | 1525 bool Value::IsInt32() const { |
1520 if (IsDeadCheck("v8::Value::IsInt32()")) return false; | 1526 if (IsDeadCheck("v8::Value::IsInt32()")) return false; |
1521 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1527 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1522 if (obj->IsSmi()) return true; | 1528 if (obj->IsSmi()) return true; |
1523 if (obj->IsNumber()) { | 1529 if (obj->IsNumber()) { |
1524 double value = obj->Number(); | 1530 double value = obj->Number(); |
1525 return i::FastI2D(i::FastD2I(value)) == value; | 1531 return i::FastI2D(i::FastD2I(value)) == value; |
1526 } | 1532 } |
1527 return false; | 1533 return false; |
1528 } | 1534 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1636 | 1642 |
1637 void External::CheckCast(v8::Value* that) { | 1643 void External::CheckCast(v8::Value* that) { |
1638 if (IsDeadCheck("v8::External::Cast()")) return; | 1644 if (IsDeadCheck("v8::External::Cast()")) return; |
1639 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 1645 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
1640 ApiCheck(obj->IsProxy(), | 1646 ApiCheck(obj->IsProxy(), |
1641 "v8::External::Cast()", | 1647 "v8::External::Cast()", |
1642 "Could not convert to external"); | 1648 "Could not convert to external"); |
1643 } | 1649 } |
1644 | 1650 |
1645 | 1651 |
1652 void Blob::CheckCast(v8::Value* that) { | |
1653 if (IsDeadCheck("v8::Blob::Cast()")) return; | |
1654 i::Handle<i::Object> obj = Utils::OpenHandle(that); | |
1655 ApiCheck(obj->IsByteArray(), | |
1656 "v8::Blob::Cast()", | |
1657 "Could not convert to external"); | |
Christian Plesner Hansen
2009/11/16 12:12:22
I expect you mean "...to blob".
| |
1658 } | |
1659 | |
1660 | |
1646 void v8::Object::CheckCast(Value* that) { | 1661 void v8::Object::CheckCast(Value* that) { |
1647 if (IsDeadCheck("v8::Object::Cast()")) return; | 1662 if (IsDeadCheck("v8::Object::Cast()")) return; |
1648 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 1663 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
1649 ApiCheck(obj->IsJSObject(), | 1664 ApiCheck(obj->IsJSObject(), |
1650 "v8::Object::Cast()", | 1665 "v8::Object::Cast()", |
1651 "Could not convert to object"); | 1666 "Could not convert to object"); |
1652 } | 1667 } |
1653 | 1668 |
1654 | 1669 |
1655 void v8::Function::CheckCast(Value* that) { | 1670 void v8::Function::CheckCast(Value* that) { |
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2947 } | 2962 } |
2948 | 2963 |
2949 | 2964 |
2950 void* External::Value() const { | 2965 void* External::Value() const { |
2951 if (IsDeadCheck("v8::External::Value()")) return 0; | 2966 if (IsDeadCheck("v8::External::Value()")) return 0; |
2952 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2967 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2953 return ExternalValueImpl(obj); | 2968 return ExternalValueImpl(obj); |
2954 } | 2969 } |
2955 | 2970 |
2956 | 2971 |
2972 Local<Blob> v8::Blob::New(int length) { | |
2973 LOG_API("Blob::New"); | |
2974 EnsureInitialized("v8::Blob::New()"); | |
2975 ENTER_V8; | |
2976 return Utils::ToLocal(i::Factory::NewByteArray(length)); | |
2977 } | |
2978 | |
2979 | |
2980 int Blob::ByteCount() { | |
2981 if (IsDeadCheck("v8::Blob::ByteCount()")) return 0; | |
2982 i::Handle<i::Object> obj = Utils::OpenHandle(this); | |
Christian Plesner Hansen
2009/11/16 12:12:22
Doesn't OpenHandle give you back a ByteArray that
| |
2983 return i::ByteArray::cast(*obj)->length(); | |
2984 } | |
2985 | |
2986 | |
2987 uint8_t Blob::GetByte(int index) { | |
2988 if (IsDeadCheck("v8::Blob::GetByte()")) return 0; | |
2989 i::Handle<i::Object> obj = Utils::OpenHandle(this); | |
2990 return i::ByteArray::cast(*obj)->get(index); | |
2991 } | |
2992 | |
2993 | |
2994 void Blob::SetByte(int index, uint8_t value) { | |
2995 if (IsDeadCheck("v8::Blob::SetByte()")) return; | |
2996 i::Handle<i::Object> obj = Utils::OpenHandle(this); | |
2997 i::ByteArray::cast(*obj)->set(index, value); | |
2998 } | |
2999 | |
3000 | |
3001 uint8_t* Blob::GetAddress() { | |
3002 if (IsDeadCheck("v8::Blob::GetAddress()")) return NULL; | |
3003 i::Handle<i::Object> obj = Utils::OpenHandle(this); | |
3004 return i::ByteArray::cast(*obj)->GetDataStartAddress(); | |
Christian Plesner Hansen
2009/11/16 12:12:22
Danger danger! This will give you a derived point
| |
3005 } | |
3006 | |
3007 | |
2957 Local<String> v8::String::Empty() { | 3008 Local<String> v8::String::Empty() { |
2958 EnsureInitialized("v8::String::Empty()"); | 3009 EnsureInitialized("v8::String::Empty()"); |
2959 LOG_API("String::Empty()"); | 3010 LOG_API("String::Empty()"); |
2960 return Utils::ToLocal(i::Factory::empty_symbol()); | 3011 return Utils::ToLocal(i::Factory::empty_symbol()); |
2961 } | 3012 } |
2962 | 3013 |
2963 | 3014 |
2964 Local<String> v8::String::New(const char* data, int length) { | 3015 Local<String> v8::String::New(const char* data, int length) { |
2965 EnsureInitialized("v8::String::New()"); | 3016 EnsureInitialized("v8::String::New()"); |
2966 LOG_API("String::New(char)"); | 3017 LOG_API("String::New(char)"); |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3862 | 3913 |
3863 | 3914 |
3864 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 3915 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
3865 HandleScopeImplementer* thread_local = | 3916 HandleScopeImplementer* thread_local = |
3866 reinterpret_cast<HandleScopeImplementer*>(storage); | 3917 reinterpret_cast<HandleScopeImplementer*>(storage); |
3867 thread_local->IterateThis(v); | 3918 thread_local->IterateThis(v); |
3868 return storage + ArchiveSpacePerThread(); | 3919 return storage + ArchiveSpacePerThread(); |
3869 } | 3920 } |
3870 | 3921 |
3871 } } // namespace v8::internal | 3922 } } // namespace v8::internal |
OLD | NEW |