def cpp_argument(argument): idl_type = argument.idl_type if (v8_types.is_callback_interface(idl_type) or idl_type in ['NodeFilter', 'XPathNSResolver']): # FIXME: remove this special case return '%s.release()' % argument.name return argument.name
def overload_check_argument(index, argument): cpp_value = 'info[%s]' % index idl_type = argument['idl_type'] # FIXME: proper type checking, sharing code with attributes and methods if idl_type == 'DOMString' and argument['is_strict_type_checking']: return ' || '.join(['isUndefinedOrNull(%s)' % cpp_value, '%s->IsString()' % cpp_value, '%s->IsObject()' % cpp_value]) if v8_types.array_or_sequence_type(idl_type): return '%s->IsArray()' % cpp_value if v8_types.is_callback_interface(idl_type): return ' || '.join(['%s->IsNull()' % cpp_value, '%s->IsFunction()' % cpp_value]) if v8_types.is_wrapper_type(idl_type): type_check = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate())'.format(idl_type=idl_type, cpp_value=cpp_value) if argument['is_nullable']: type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check]) return type_check if v8_types.is_interface_type(idl_type): # Non-wrapper types are just objects: we don't distinguish type type_check = '%s->IsObject()' % cpp_value if argument['is_nullable']: type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check]) return type_check return None
def generate_argument(interface, method, argument, index): extended_attributes = argument.extended_attributes idl_type = argument.idl_type this_cpp_value = cpp_value(interface, method, index) return { 'cpp_type': v8_types.cpp_type(idl_type), 'cpp_value': this_cpp_value, 'enum_validation_expression': v8_utilities.enum_validation_expression(idl_type), 'has_default': 'Default' in extended_attributes, 'idl_type': idl_type, 'index': index, 'is_clamp': 'Clamp' in extended_attributes, 'is_callback_interface': v8_types.is_callback_interface(idl_type), 'is_nullable': argument.is_nullable, 'is_optional': argument.is_optional, 'is_strict_type_checking': 'StrictTypeChecking' in extended_attributes, 'is_variadic_wrapper_type': argument.is_variadic and v8_types.is_wrapper_type(idl_type), 'is_wrapper_type': v8_types.is_wrapper_type(idl_type), 'name': argument.name, 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name, method, this_cpp_value, for_main_world=True), 'v8_set_return_value': v8_set_return_value(interface.name, method, this_cpp_value), 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, index), }
def overload_check_argument(index, argument): def null_or_optional_check(): # If undefined is passed for an optional argument, the argument should # be treated as missing; otherwise undefined is not allowed. if argument['is_nullable']: if argument['is_optional']: return 'isUndefinedOrNull(%s)' return '%s->IsNull()' if argument['is_optional']: return '%s->IsUndefined()' return None cpp_value = 'info[%s]' % index idl_type = argument['idl_type'] # FIXME: proper type checking, sharing code with attributes and methods if idl_type == 'DOMString' and argument['is_strict_type_checking']: return ' || '.join(['isUndefinedOrNull(%s)' % cpp_value, '%s->IsString()' % cpp_value, '%s->IsObject()' % cpp_value]) if v8_types.array_or_sequence_type(idl_type): return '%s->IsArray()' % cpp_value if v8_types.is_callback_interface(idl_type): return ' || '.join(['%s->IsNull()' % cpp_value, '%s->IsFunction()' % cpp_value]) if v8_types.is_wrapper_type(idl_type): type_check = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate())'.format(idl_type=idl_type, cpp_value=cpp_value) if argument['is_nullable']: type_check = ' || '.join(['%s->IsNull()' % cpp_value, type_check]) return type_check if is_interface_type(idl_type): # Non-wrapper types are just objects: we don't distinguish type # We only allow undefined for non-wrapper types (notably Dictionary), # as we need it for optional Dictionary arguments, but we don't want to # change behavior of existing bindings for other types. type_check = '%s->IsObject()' % cpp_value added_check_template = null_or_optional_check() if added_check_template: type_check = ' || '.join([added_check_template % cpp_value, type_check]) return type_check return None
def generate_argument(interface, method, argument, index): extended_attributes = argument.extended_attributes idl_type = argument.idl_type this_cpp_value = cpp_value(interface, method, index) return { 'cpp_type': v8_types.cpp_type(idl_type), 'cpp_value': this_cpp_value, 'enum_validation_expression': v8_utilities.enum_validation_expression(idl_type), 'has_default': 'Default' in extended_attributes, 'idl_type': idl_type, 'index': index, 'is_clamp': 'Clamp' in extended_attributes, 'is_callback_interface': v8_types.is_callback_interface(idl_type), 'is_nullable': argument.is_nullable, 'is_optional': argument.is_optional, 'is_strict_type_checking': 'StrictTypeChecking' in extended_attributes, 'is_variadic_wrapper_type': argument.is_variadic and v8_types.is_wrapper_type(idl_type), 'is_wrapper_type': v8_types.is_wrapper_type(idl_type), 'name': argument.name, 'v8_set_return_value': v8_set_return_value(interface.name, method, this_cpp_value), 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, index), }