1{% macro v8_value_to_local_cpp_value(thing) %}
2{# This indirection is just to avoid spurious white-space lines. #}
3{{generate_v8_value_to_local_cpp_value(thing) | trim}}
4{%- endmacro %}
5
6
7{% macro generate_v8_value_to_local_cpp_value(thing) %}
8{% set item = thing.v8_value_to_local_cpp_value or thing %}
9{% if item.error_message %}
10/* {{item.error_message}} */
11{% else %}
12{% if item.declare_variable %}
13{% if item.assign_expression %}
14{{item.cpp_type}} {{item.cpp_name}} = {{item.assign_expression}};
15{% else %}
16{{item.cpp_type}} {{item.cpp_name}};
17{% endif %}
18{% else %}{# item.declare_variable #}
19{% if item.assign_expression %}
20{{item.cpp_name}} = {{item.assign_expression}};
21{% endif %}
22{% endif %}{# item.declare_variable #}
23{% if item.set_expression %}
24{{item.set_expression}};
25{% endif %}
26{% if item.check_expression %}
27if ({{item.check_expression}})
28  return{% if item.return_expression %} {{item.return_expression}}{% endif %};
29{% endif %}{# item.check_expression #}
30{% endif %}{# item.error_message #}
31{% endmacro %}
32
33
34{% macro declare_enum_validation_variable(enum_values, enum_variable='kValidValues') %}
35const char* const {{enum_variable}}[] = {
36{% for enum_value in enum_values %}
37{% if enum_value is none %}
38    nullptr,
39{% else %}
40    "{{enum_value}}",
41{% endif %}
42{% endfor %}
43};
44{%-endmacro %}
45
46
47{% macro property_location(member) %}
48{% set property_location_list = [] %}
49{% if member.on_instance %}
50{% set property_location_list = property_location_list + ['V8DOMConfiguration::kOnInstance'] %}
51{% endif %}
52{% if member.on_prototype %}
53{% set property_location_list = property_location_list + ['V8DOMConfiguration::kOnPrototype'] %}
54{% endif %}
55{% if member.on_interface %}
56{% set property_location_list = property_location_list + ['V8DOMConfiguration::kOnInterface'] %}
57{% endif %}
58{{property_location_list | join(' | ')}}
59{%- endmacro %}
60