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

Side by Side Diff: test/cctest/test-api.cc

Issue 16102002: Add template parameter to ReturnValue::Set. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: rebased Created 7 years, 7 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 | « include/v8.h ('k') | no next file » | 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 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 void FastReturnValueCallback<void>( 1067 void FastReturnValueCallback<void>(
1068 const v8::FunctionCallbackInfo<v8::Value>& info) { 1068 const v8::FunctionCallbackInfo<v8::Value>& info) {
1069 CheckReturnValue(info); 1069 CheckReturnValue(info);
1070 if (fast_return_value_void_is_null) { 1070 if (fast_return_value_void_is_null) {
1071 info.GetReturnValue().SetNull(); 1071 info.GetReturnValue().SetNull();
1072 } else { 1072 } else {
1073 info.GetReturnValue().SetUndefined(); 1073 info.GetReturnValue().SetUndefined();
1074 } 1074 }
1075 } 1075 }
1076 1076
1077 template<>
1078 void FastReturnValueCallback<Object>(
1079 const v8::FunctionCallbackInfo<v8::Value>& info) {
1080 info.GetReturnValue().Set(Object::New());
1081 }
1082
1077 template<typename T> 1083 template<typename T>
1078 Handle<Value> TestFastReturnValues() { 1084 Handle<Value> TestFastReturnValues() {
1079 LocalContext env; 1085 LocalContext env;
1080 v8::HandleScope scope(env->GetIsolate()); 1086 v8::HandleScope scope(env->GetIsolate());
1081 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New(); 1087 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New();
1082 v8::FunctionCallback callback = &FastReturnValueCallback<T>; 1088 v8::FunctionCallback callback = &FastReturnValueCallback<T>;
1083 object_template->Set("callback", v8::FunctionTemplate::New(callback)); 1089 object_template->Set("callback", v8::FunctionTemplate::New(callback));
1084 v8::Local<v8::Object> object = object_template->NewInstance(); 1090 v8::Local<v8::Object> object = object_template->NewInstance();
1085 (*env)->Global()->Set(v8_str("callback_object"), object); 1091 (*env)->Global()->Set(v8_str("callback_object"), object);
1086 return scope.Close(CompileRun("callback_object.callback()")); 1092 return scope.Close(CompileRun("callback_object.callback()"));
(...skipping 24 matching lines...) Expand all
1111 // check oddballs 1117 // check oddballs
1112 for (int i = 0; i < 2; i++) { 1118 for (int i = 0; i < 2; i++) {
1113 fast_return_value_void_is_null = i == 0; 1119 fast_return_value_void_is_null = i == 0;
1114 value = TestFastReturnValues<void>(); 1120 value = TestFastReturnValues<void>();
1115 if (fast_return_value_void_is_null) { 1121 if (fast_return_value_void_is_null) {
1116 CHECK(value->IsNull()); 1122 CHECK(value->IsNull());
1117 } else { 1123 } else {
1118 CHECK(value->IsUndefined()); 1124 CHECK(value->IsUndefined());
1119 } 1125 }
1120 } 1126 }
1127 value = TestFastReturnValues<Object>();
1128 CHECK(value->IsObject());
1121 } 1129 }
1122 1130
1123 1131
1124 THREADED_TEST(FunctionTemplateSetLength) { 1132 THREADED_TEST(FunctionTemplateSetLength) {
1125 LocalContext env; 1133 LocalContext env;
1126 v8::HandleScope scope(env->GetIsolate()); 1134 v8::HandleScope scope(env->GetIsolate());
1127 { 1135 {
1128 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New( 1136 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(
1129 handle_call, Handle<v8::Value>(), Handle<v8::Signature>(), 23); 1137 handle_call, Handle<v8::Value>(), Handle<v8::Signature>(), 23);
1130 Local<Function> fun = fun_templ->GetFunction(); 1138 Local<Function> fun = fun_templ->GetFunction();
(...skipping 18189 matching lines...) Expand 10 before | Expand all | Expand 10 after
19320 i::Semaphore* sem_; 19328 i::Semaphore* sem_;
19321 volatile int sem_value_; 19329 volatile int sem_value_;
19322 }; 19330 };
19323 19331
19324 19332
19325 THREADED_TEST(SemaphoreInterruption) { 19333 THREADED_TEST(SemaphoreInterruption) {
19326 ThreadInterruptTest().RunTest(); 19334 ThreadInterruptTest().RunTest();
19327 } 19335 }
19328 19336
19329 #endif // WIN32 19337 #endif // WIN32
OLDNEW
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698