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

Side by Side Diff: Source/bindings/core/v8/V8Binding.h

Issue 1051753003: bindings: Add toBoolean() to V8Binding.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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 | « no previous file | Source/bindings/scripts/v8_types.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Ericsson AB. All rights reserved. 3 * Copyright (C) 2012 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return v8::Handle<v8::Value>(); 380 return v8::Handle<v8::Value>();
381 } 381 }
382 382
383 // Conversion flags, used in toIntXX/toUIntXX. 383 // Conversion flags, used in toIntXX/toUIntXX.
384 enum IntegerConversionConfiguration { 384 enum IntegerConversionConfiguration {
385 NormalConversion, 385 NormalConversion,
386 EnforceRange, 386 EnforceRange,
387 Clamp 387 Clamp
388 }; 388 };
389 389
390 // Convert a value to a boolean.
391 inline bool toBoolean(v8::Isolate* isolate, v8::Local<v8::Value> value, Exceptio nState& exceptionState)
392 {
393 if (value->IsBoolean())
vivekg 2015/04/10 05:43:47 Shall we split this into fast (inline toBoolean) a
vivekg 2015/04/10 05:47:36 Or may be wrap it using inline bool toBoolean(v8
haraken 2015/04/10 05:48:01 Yeah, it's good to minimize the inlined part. We c
bashi 2015/04/10 06:39:54 Done.
394 return value.As<v8::Boolean>()->Value();
395 v8::TryCatch block;
396 bool result = false;
397 if (!v8Call(value->BooleanValue(isolate->GetCurrentContext()), result, block ))
398 exceptionState.rethrowV8Exception(block.Exception());
399 return result;
400 }
401
390 // Convert a value to a 8-bit signed integer. The conversion fails if the 402 // Convert a value to a 8-bit signed integer. The conversion fails if the
391 // value cannot be converted to a number or the range violated per WebIDL: 403 // value cannot be converted to a number or the range violated per WebIDL:
392 // http://www.w3.org/TR/WebIDL/#es-byte 404 // http://www.w3.org/TR/WebIDL/#es-byte
393 int8_t toInt8(v8::Isolate*, v8::Handle<v8::Value>, IntegerConversionConfiguratio n, ExceptionState&); 405 int8_t toInt8(v8::Isolate*, v8::Handle<v8::Value>, IntegerConversionConfiguratio n, ExceptionState&);
394 406
395 // Convert a value to a 8-bit unsigned integer. The conversion fails if the 407 // Convert a value to a 8-bit unsigned integer. The conversion fails if the
396 // value cannot be converted to a number or the range violated per WebIDL: 408 // value cannot be converted to a number or the range violated per WebIDL:
397 // http://www.w3.org/TR/WebIDL/#es-octet 409 // http://www.w3.org/TR/WebIDL/#es-octet
398 uint8_t toUInt8(v8::Isolate*, v8::Handle<v8::Value>, IntegerConversionConfigurat ion, ExceptionState&); 410 uint8_t toUInt8(v8::Isolate*, v8::Handle<v8::Value>, IntegerConversionConfigurat ion, ExceptionState&);
399 411
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol ate*, ExecutionContext*, v8::Handle<v8::Function>); 1002 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol ate*, ExecutionContext*, v8::Handle<v8::Function>);
991 1003
992 // Callback functions used by generated code. 1004 // Callback functions used by generated code.
993 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName, const v8::PropertyCallbackInfo<v8::Value>&); 1005 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName, const v8::PropertyCallbackInfo<v8::Value>&);
994 1006
995 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso late*); 1007 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso late*);
996 1008
997 } // namespace blink 1009 } // namespace blink
998 1010
999 #endif // V8Binding_h 1011 #endif // V8Binding_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_types.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698