Index: Source/bindings/scripts/v8_methods.py |
diff --git a/Source/bindings/scripts/v8_methods.py b/Source/bindings/scripts/v8_methods.py |
index b50ba604efeda5d30d6904c14ab2371aec03b82c..33ed1e32662551eaa1136074727f2b8deaaa4350 100644 |
--- a/Source/bindings/scripts/v8_methods.py |
+++ b/Source/bindings/scripts/v8_methods.py |
@@ -168,6 +168,7 @@ def generate_argument(interface, method, argument, index): |
used_as_argument=True, |
used_as_variadic_argument=argument.is_variadic), |
'cpp_value': this_cpp_value, |
+ 'default_value': default_value_to_cpp_value(argument), |
Nils Barth (inactive)
2014/06/04 05:22:24
Using a property this is more cleanly:
argument.de
Jens Widell
2014/06/04 06:12:18
I'm using the argument's type to generate differen
Nils Barth (inactive)
2014/06/04 06:33:35
Ow, good point. (>.<)
2 possible approaches:
1. M
Jens Widell
2014/06/04 09:49:16
I ended up tentatively going for a third option:
|
'enum_validation_expression': idl_type.enum_validation_expression, |
'has_default': 'Default' in extended_attributes, |
'has_event_listener_argument': any( |
@@ -285,16 +286,30 @@ def v8_value_to_local_cpp_value(argument, index): |
name = argument.name |
if argument.is_variadic: |
return v8_value_to_local_cpp_variadic_value(argument, index) |
- # [Default=NullString] |
- if (argument.is_optional and idl_type.name == 'String' and |
- extended_attributes.get('Default') == 'NullString'): |
- v8_value = 'argumentOrNull(info, %s)' % index |
Nils Barth (inactive)
2014/06/04 06:33:36
You can get rid of argumentOrNull from V8Binding.h
|
- else: |
- v8_value = 'info[%s]' % index |
- return idl_type.v8_value_to_local_cpp_value(extended_attributes, v8_value, |
+ return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]' % index, |
name, index=index, declare_variable=False) |
+def default_value_to_cpp_value(argument): |
Nils Barth (inactive)
2014/06/04 05:22:24
Could you make this a property?
(For slickness and
|
+ default_value = argument.default_value |
Nils Barth (inactive)
2014/06/04 05:22:24
Might be clearer to also have:
value_type = defaul
|
+ if default_value is None: |
Nils Barth (inactive)
2014/06/04 05:22:24
if not default_value:
...per:
Use the "implicit" f
|
+ return None |
+ if default_value.value_type == 'DOMString': |
+ if '"' in default_value.value or '\\' in default_value.value: |
+ raise ValueError('Unsupported string value: %r' % default_value.value) |
+ return 'String("%s")' % default_value.value |
+ if default_value.value_type == 'integer': |
+ return '%d' % default_value.value |
Nils Barth (inactive)
2014/06/04 05:22:24
Could you put all this "string representation" log
|
+ if default_value.value_type == 'float': |
+ return '%g' % default_value.value |
+ if default_value.value_type == 'boolean': |
+ return 'true' if default_value.value else 'false' |
+ if default_value.value_type == 'NULL': |
+ if argument.idl_type.name in ('String', 'StringOrNull'): |
+ return 'String()' |
+ return 'nullptr' |
+ |
Nils Barth (inactive)
2014/06/04 05:22:24
...do you mean to implicitly return None here?
(..
Jens Widell
2014/06/04 06:12:18
Not really, no. I am handling all value types that
|
+ |
################################################################################ |
# Auxiliary functions |
################################################################################ |