def getter_expression(interface, attribute, context): arguments = [] this_getter_base_name = getter_base_name(interface, attribute, arguments) getter_name = scoped_name(interface, attribute, this_getter_base_name) if 'ImplementedInPrivateScript' in attribute.extended_attributes: arguments.append( 'toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())') arguments.append('impl') arguments.append('&result') arguments.extend( ext_utilities.call_with_arguments( attribute.extended_attributes.get('CallWith'))) # Members of IDL partial interface definitions are implemented in C++ as # static member functions, which for instance members (non-static members) # take *impl as their first argument if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and not 'ImplementedInPrivateScript' in attribute.extended_attributes and not attribute.is_static): arguments.append('*impl') if attribute.idl_type.is_explicit_nullable: arguments.append('isNull') if context['is_getter_raises_exception']: arguments.append('exceptionState') return '%s(%s)' % (getter_name, ', '.join(arguments))
def cpp_value(interface, method, number_of_arguments): def cpp_argument(argument): idl_type = argument.idl_type if idl_type.name == 'EventListener': return argument.name if (idl_type.is_callback_interface or idl_type.name in ['NodeFilter', 'NodeFilterOrNull', 'XPathNSResolver', 'XPathNSResolverOrNull']): # FIXME: remove this special case return '%s.release()' % argument.name return argument.name # Truncate omitted optional arguments arguments = method.arguments[:number_of_arguments] cpp_arguments = [] if 'ImplementedInPrivateScript' in method.extended_attributes: cpp_arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())') cpp_arguments.append('impl') if method.is_constructor: call_with_values = interface.extended_attributes.get('ConstructorCallWith') else: call_with_values = method.extended_attributes.get('CallWith') cpp_arguments.extend(ext_utilities.call_with_arguments(call_with_values)) # Members of IDL partial interface definitions are implemented in C++ as # static member functions, which for instance members (non-static members) # take *impl as their first argument if ('PartialInterfaceImplementedAs' in method.extended_attributes and not 'ImplementedInPrivateScript' in method.extended_attributes and not method.is_static): cpp_arguments.append('*impl') cpp_arguments.extend(cpp_argument(argument) for argument in arguments) this_union_arguments = method.idl_type and method.idl_type.union_arguments if this_union_arguments: cpp_arguments.extend([member_argument['cpp_value'] for member_argument in this_union_arguments]) if 'ImplementedInPrivateScript' in method.extended_attributes: if method.idl_type.name != 'void': cpp_arguments.append('&result') elif ('RaisesException' in method.extended_attributes or (method.is_constructor and has_extended_attribute_value(interface, 'RaisesException', 'Constructor'))): cpp_arguments.append('exceptionState') if method.name == 'Constructor': base_name = 'create' elif method.name == 'NamedConstructor': base_name = 'createForJSConstructor' elif 'ImplementedInPrivateScript' in method.extended_attributes: base_name = '%sMethod' % method.name else: base_name = ext_utilities.cpp_name(method) cpp_method_name = ext_utilities.scoped_name(interface, method, base_name) return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
def setter_expression(interface, attribute, context): extended_attributes = attribute.extended_attributes arguments = ext_utilities.call_with_arguments( extended_attributes.get('SetterCallWith') or extended_attributes.get('CallWith')) this_setter_base_name = setter_base_name(interface, attribute, arguments) setter_name = scoped_name(interface, attribute, this_setter_base_name) # Members of IDL partial interface definitions are implemented in C++ as # static member functions, which for instance members (non-static members) # take *impl as their first argument if ('PartialInterfaceImplementedAs' in extended_attributes and not 'ImplementedInPrivateScript' in extended_attributes and not attribute.is_static): arguments.append('*impl') idl_type = attribute.idl_type if 'ImplementedInPrivateScript' in extended_attributes: arguments.append( 'toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())') arguments.append('impl') arguments.append('cppValue') elif idl_type.base_type == 'EventHandler': getter_name = scoped_name(interface, attribute, cpp_name(attribute)) context['event_handler_getter_expression'] = '%s(%s)' % ( getter_name, ', '.join(arguments)) if (interface.name in ['Window', 'WorkerGlobalScope'] and attribute.name == 'onerror'): includes.add('bindings/core/v8/V8ErrorHandler.h') arguments.append( 'V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(v8Value, true, ScriptState::current(info.GetIsolate()))' ) else: arguments.append( 'V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate)' ) elif idl_type.is_interface_type: # FIXME: should be able to eliminate WTF::getPtr in most or all cases arguments.append('WTF::getPtr(cppValue)') else: arguments.append('cppValue') if context['is_setter_raises_exception']: arguments.append('exceptionState') return '%s(%s)' % (setter_name, ', '.join(arguments))
def setter_expression(interface, attribute, context): extended_attributes = attribute.extended_attributes arguments = ext_utilities.call_with_arguments( extended_attributes.get('SetterCallWith') or extended_attributes.get('CallWith')) this_setter_base_name = setter_base_name(interface, attribute, arguments) setter_name = scoped_name(interface, attribute, this_setter_base_name) # Members of IDL partial interface definitions are implemented in C++ as # static member functions, which for instance members (non-static members) # take *impl as their first argument if ('PartialInterfaceImplementedAs' in extended_attributes and not 'ImplementedInPrivateScript' in extended_attributes and not attribute.is_static): arguments.append('*impl') idl_type = attribute.idl_type if 'ImplementedInPrivateScript' in extended_attributes: arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())') arguments.append('impl') arguments.append('cppValue') elif idl_type.base_type == 'EventHandler': getter_name = scoped_name(interface, attribute, cpp_name(attribute)) context['event_handler_getter_expression'] = '%s(%s)' % ( getter_name, ', '.join(arguments)) if (interface.name in ['Window', 'WorkerGlobalScope'] and attribute.name == 'onerror'): includes.add('bindings/core/v8/V8ErrorHandler.h') arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(v8Value, true, ScriptState::current(info.GetIsolate()))') else: arguments.append('V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate)') elif idl_type.is_interface_type: # FIXME: should be able to eliminate WTF::getPtr in most or all cases arguments.append('WTF::getPtr(cppValue)') else: arguments.append('cppValue') if context['is_setter_raises_exception']: arguments.append('exceptionState') return '%s(%s)' % (setter_name, ', '.join(arguments))
def getter_expression(interface, attribute, context): arguments = [] this_getter_base_name = getter_base_name(interface, attribute, arguments) getter_name = scoped_name(interface, attribute, this_getter_base_name) if 'ImplementedInPrivateScript' in attribute.extended_attributes: arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())') arguments.append('impl') arguments.append('&result') arguments.extend(ext_utilities.call_with_arguments( attribute.extended_attributes.get('CallWith'))) # Members of IDL partial interface definitions are implemented in C++ as # static member functions, which for instance members (non-static members) # take *impl as their first argument if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and not 'ImplementedInPrivateScript' in attribute.extended_attributes and not attribute.is_static): arguments.append('*impl') if attribute.idl_type.is_explicit_nullable: arguments.append('isNull') if context['is_getter_raises_exception']: arguments.append('exceptionState') return '%s(%s)' % (getter_name, ', '.join(arguments))
def cpp_value(interface, method, number_of_arguments): def cpp_argument(argument): idl_type = argument.idl_type if idl_type.name == 'EventListener': return argument.name if (idl_type.is_callback_interface or idl_type.name in [ 'NodeFilter', 'NodeFilterOrNull', 'XPathNSResolver', 'XPathNSResolverOrNull' ]): # FIXME: remove this special case return '%s.release()' % argument.name return argument.name # Truncate omitted optional arguments arguments = method.arguments[:number_of_arguments] cpp_arguments = [] if 'ImplementedInPrivateScript' in method.extended_attributes: cpp_arguments.append( 'toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())') cpp_arguments.append('impl') if method.is_constructor: call_with_values = interface.extended_attributes.get( 'ConstructorCallWith') else: call_with_values = method.extended_attributes.get('CallWith') cpp_arguments.extend(ext_utilities.call_with_arguments(call_with_values)) # Members of IDL partial interface definitions are implemented in C++ as # static member functions, which for instance members (non-static members) # take *impl as their first argument if ('PartialInterfaceImplementedAs' in method.extended_attributes and not 'ImplementedInPrivateScript' in method.extended_attributes and not method.is_static): cpp_arguments.append('*impl') cpp_arguments.extend(cpp_argument(argument) for argument in arguments) this_union_arguments = method.idl_type and method.idl_type.union_arguments if this_union_arguments: cpp_arguments.extend([ member_argument['cpp_value'] for member_argument in this_union_arguments ]) if 'ImplementedInPrivateScript' in method.extended_attributes: if method.idl_type.name != 'void': cpp_arguments.append('&result') elif ('RaisesException' in method.extended_attributes or (method.is_constructor and has_extended_attribute_value( interface, 'RaisesException', 'Constructor'))): cpp_arguments.append('exceptionState') if method.name == 'Constructor': base_name = 'create' elif method.name == 'NamedConstructor': base_name = 'createForJSConstructor' elif 'ImplementedInPrivateScript' in method.extended_attributes: base_name = '%sMethod' % method.name else: base_name = ext_utilities.cpp_name(method) cpp_method_name = ext_utilities.scoped_name(interface, method, base_name) return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))