OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 # Built-in types | 583 # Built-in types |
584 'Date': 'v8DateOrNull({cpp_value}, {isolate})', | 584 'Date': 'v8DateOrNull({cpp_value}, {isolate})', |
585 'DOMString': 'v8String({isolate}, {cpp_value})', | 585 'DOMString': 'v8String({isolate}, {cpp_value})', |
586 'boolean': 'v8Boolean({cpp_value}, {isolate})', | 586 'boolean': 'v8Boolean({cpp_value}, {isolate})', |
587 'int': 'v8::Integer::New({isolate}, {cpp_value})', | 587 'int': 'v8::Integer::New({isolate}, {cpp_value})', |
588 'unsigned': 'v8::Integer::NewFromUnsigned({isolate}, {cpp_value})', | 588 'unsigned': 'v8::Integer::NewFromUnsigned({isolate}, {cpp_value})', |
589 'float': 'v8::Number::New({isolate}, {cpp_value})', | 589 'float': 'v8::Number::New({isolate}, {cpp_value})', |
590 'double': 'v8::Number::New({isolate}, {cpp_value})', | 590 'double': 'v8::Number::New({isolate}, {cpp_value})', |
591 'void': 'v8Undefined()', | 591 'void': 'v8Undefined()', |
592 # Special cases | 592 # Special cases |
593 'EventHandler': '{cpp_value} ? v8::Handle<v8::Value>(V8AbstractEventListener
::cast({cpp_value})->getListenerObject(imp->executionContext())) : v8::Handle<v8
::Value>(v8::Null({isolate}))', | 593 'EventHandler': '{cpp_value} ? v8::Handle<v8::Value>(V8AbstractEventListener
::cast({cpp_value})->getListenerObject(impl->executionContext())) : v8::Handle<v
8::Value>(v8::Null({isolate}))', |
594 'ScriptValue': '{cpp_value}.v8Value()', | 594 'ScriptValue': '{cpp_value}.v8Value()', |
595 'SerializedScriptValue': '{cpp_value} ? {cpp_value}->deserialize() : v8::Han
dle<v8::Value>(v8::Null({isolate}))', | 595 'SerializedScriptValue': '{cpp_value} ? {cpp_value}->deserialize() : v8::Han
dle<v8::Value>(v8::Null({isolate}))', |
596 # General | 596 # General |
597 'array': 'v8Array({cpp_value}, {isolate})', | 597 'array': 'v8Array({cpp_value}, {isolate})', |
598 'DOMWrapper': 'toV8({cpp_value}, {creation_context}, {isolate})', | 598 'DOMWrapper': 'toV8({cpp_value}, {creation_context}, {isolate})', |
599 } | 599 } |
600 | 600 |
601 | 601 |
602 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='', extended_attributes=None): | 602 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='', extended_attributes=None): |
603 """Returns an expression that converts a C++ value to a V8 value.""" | 603 """Returns an expression that converts a C++ value to a V8 value.""" |
604 # the isolate parameter is needed for callback interfaces | 604 # the isolate parameter is needed for callback interfaces |
605 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) | 605 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) |
606 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) | 606 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) |
607 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] | 607 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] |
608 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) | 608 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) |
609 return statement | 609 return statement |
610 | 610 |
611 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value | 611 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value |
OLD | NEW |