OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #define V8_AS_STRING_IMPL(x) #x | 42 #define V8_AS_STRING_IMPL(x) #x |
43 | 43 |
44 #define V8_HIDDEN_PROPERTY_PREFIX "WebCore::HiddenProperty::" | 44 #define V8_HIDDEN_PROPERTY_PREFIX "WebCore::HiddenProperty::" |
45 | 45 |
46 #define V8_DEFINE_HIDDEN_PROPERTY(name) \ | 46 #define V8_DEFINE_HIDDEN_PROPERTY(name) \ |
47 v8::Handle<v8::String> V8HiddenPropertyName::name() \ | 47 v8::Handle<v8::String> V8HiddenPropertyName::name() \ |
48 { \ | 48 { \ |
49 v8::Isolate* isolate = v8::Isolate::GetCurrent(); \ | 49 v8::Isolate* isolate = v8::Isolate::GetCurrent(); \ |
50 V8HiddenPropertyName* hiddenPropertyName = V8PerIsolateData::from(isolate)->
hiddenPropertyName(); \ | 50 V8HiddenPropertyName* hiddenPropertyName = V8PerIsolateData::from(isolate)->
hiddenPropertyName(); \ |
51 if (hiddenPropertyName->m_##name.IsEmpty()) { \ | 51 if (hiddenPropertyName->m_##name.IsEmpty()) { \ |
52 createString(V8_HIDDEN_PROPERTY_PREFIX V8_AS_STRING(name), &(hiddenPrope
rtyName->m_##name)); \ | 52 createString(V8_HIDDEN_PROPERTY_PREFIX V8_AS_STRING(name), &(hiddenPrope
rtyName->m_##name), isolate); \ |
53 } \ | 53 } \ |
54 return v8::Local<v8::String>::New(isolate, hiddenPropertyName->m_##name); \ | 54 return v8::Local<v8::String>::New(isolate, hiddenPropertyName->m_##name); \ |
55 } | 55 } |
56 | 56 |
57 V8_HIDDEN_PROPERTIES(V8_DEFINE_HIDDEN_PROPERTY); | 57 V8_HIDDEN_PROPERTIES(V8_DEFINE_HIDDEN_PROPERTY); |
58 | 58 |
59 static v8::Handle<v8::String> hiddenReferenceName(const char* name, unsigned len
gth) | 59 static v8::Handle<v8::String> hiddenReferenceName(const char* name, unsigned len
gth) |
60 { | 60 { |
61 ASSERT(length); | 61 ASSERT(length); |
62 Vector<char, 64> prefixedName; | 62 Vector<char, 64> prefixedName; |
63 prefixedName.append(V8_HIDDEN_PROPERTY_PREFIX, sizeof(V8_HIDDEN_PROPERTY_PRE
FIX) - 1); | 63 prefixedName.append(V8_HIDDEN_PROPERTY_PREFIX, sizeof(V8_HIDDEN_PROPERTY_PRE
FIX) - 1); |
64 prefixedName.append(name, length); | 64 prefixedName.append(name, length); |
65 return v8::String::NewSymbol(prefixedName.data(), static_cast<int>(prefixedN
ame.size())); | 65 return v8::String::NewSymbol(prefixedName.data(), static_cast<int>(prefixedN
ame.size())); |
66 } | 66 } |
67 | 67 |
68 void V8HiddenPropertyName::setNamedHiddenReference(v8::Handle<v8::Object> parent
, const char* name, v8::Handle<v8::Value> child) | 68 void V8HiddenPropertyName::setNamedHiddenReference(v8::Handle<v8::Object> parent
, const char* name, v8::Handle<v8::Value> child) |
69 { | 69 { |
70 ASSERT(name); | 70 ASSERT(name); |
71 parent->SetHiddenValue(hiddenReferenceName(name, strlen(name)), child); | 71 parent->SetHiddenValue(hiddenReferenceName(name, strlen(name)), child); |
72 } | 72 } |
73 | 73 |
74 void V8HiddenPropertyName::createString(const char* key, v8::Persistent<v8::Stri
ng>* handle) | 74 void V8HiddenPropertyName::createString(const char* key, v8::Persistent<v8::Stri
ng>* handle, v8::Isolate* isolate) |
75 { | 75 { |
76 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
77 v8::HandleScope scope(isolate); | 76 v8::HandleScope scope(isolate); |
78 handle->Reset(isolate, v8::String::NewSymbol(key)); | 77 handle->Reset(isolate, v8::String::NewSymbol(key)); |
79 } | 78 } |
80 | 79 |
81 } // namespace WebCore | 80 } // namespace WebCore |
OLD | NEW |