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 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(['%s->IsNull()' % cpp_value, '%s->IsUndefined()' % 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_wrapper_type(idl_type): type_check = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate(), worldType(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 return None
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([ '%s->IsNull()' % cpp_value, '%s->IsUndefined()' % 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_wrapper_type(idl_type): type_check = 'V8{idl_type}::hasInstance({cpp_value}, info.GetIsolate(), worldType(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 return None
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