OLD | NEW |
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 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 env->Global()->Set(v8_str("ext"), ext); | 1335 env->Global()->Set(v8_str("ext"), ext); |
1336 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); | 1336 Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); |
1337 v8::Handle<v8::External> reext = v8::Handle<v8::External>::Cast(reext_obj); | 1337 v8::Handle<v8::External> reext = v8::Handle<v8::External>::Cast(reext_obj); |
1338 int* ptr = static_cast<int*>(reext->Value()); | 1338 int* ptr = static_cast<int*>(reext->Value()); |
1339 CHECK_EQ(x, 3); | 1339 CHECK_EQ(x, 3); |
1340 *ptr = 10; | 1340 *ptr = 10; |
1341 CHECK_EQ(x, 10); | 1341 CHECK_EQ(x, 10); |
1342 | 1342 |
1343 // Make sure unaligned pointers are wrapped properly. | 1343 // Make sure unaligned pointers are wrapped properly. |
1344 char* data = i::StrDup("0123456789"); | 1344 char* data = i::StrDup("0123456789"); |
1345 Local<v8::External> zero = v8::External::New(&data[0]); | 1345 Local<v8::Value> zero = v8::External::Wrap(&data[0]); |
1346 Local<v8::External> one = v8::External::New(&data[1]); | 1346 Local<v8::Value> one = v8::External::Wrap(&data[1]); |
1347 Local<v8::External> two = v8::External::New(&data[2]); | 1347 Local<v8::Value> two = v8::External::Wrap(&data[2]); |
1348 Local<v8::External> three = v8::External::New(&data[3]); | 1348 Local<v8::Value> three = v8::External::Wrap(&data[3]); |
1349 | 1349 |
1350 char* char_ptr = reinterpret_cast<char*>(zero->Value()); | 1350 char* char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(zero)); |
1351 CHECK_EQ('0', *char_ptr); | 1351 CHECK_EQ('0', *char_ptr); |
1352 char_ptr = reinterpret_cast<char*>(one->Value()); | 1352 char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(one)); |
1353 CHECK_EQ('1', *char_ptr); | 1353 CHECK_EQ('1', *char_ptr); |
1354 char_ptr = reinterpret_cast<char*>(two->Value()); | 1354 char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(two)); |
1355 CHECK_EQ('2', *char_ptr); | 1355 CHECK_EQ('2', *char_ptr); |
1356 char_ptr = reinterpret_cast<char*>(three->Value()); | 1356 char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(three)); |
1357 CHECK_EQ('3', *char_ptr); | 1357 CHECK_EQ('3', *char_ptr); |
1358 i::DeleteArray(data); | 1358 i::DeleteArray(data); |
1359 } | 1359 } |
1360 | 1360 |
1361 | 1361 |
1362 THREADED_TEST(GlobalHandle) { | 1362 THREADED_TEST(GlobalHandle) { |
1363 v8::Persistent<String> global; | 1363 v8::Persistent<String> global; |
1364 { | 1364 { |
1365 v8::HandleScope scope; | 1365 v8::HandleScope scope; |
1366 Local<String> str = v8_str("str"); | 1366 Local<String> str = v8_str("str"); |
(...skipping 4721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6088 | 6088 |
6089 // Local context should still be live. | 6089 // Local context should still be live. |
6090 CHECK(!local_env.IsEmpty()); | 6090 CHECK(!local_env.IsEmpty()); |
6091 local_env->Enter(); | 6091 local_env->Enter(); |
6092 | 6092 |
6093 // Should complete without problems. | 6093 // Should complete without problems. |
6094 RegExpStringModificationTest().RunTest(); | 6094 RegExpStringModificationTest().RunTest(); |
6095 | 6095 |
6096 local_env->Exit(); | 6096 local_env->Exit(); |
6097 } | 6097 } |
OLD | NEW |