Commit 6807a950 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 9dac56e8
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
{# jref_of_shared returns original reference used to request shared instance. {# jref_of_shared returns original reference used to request shared instance.
it is extracted from slave_reference which is composed as `partition_id`+'_'+`reference` #} it is extracted from slave_reference which is composed as <partition_id>_<reference>. #}
{%- macro jref_of_shared(slave) %} {%- macro jref_of_shared(slave) %}
{%- set ref = slave['slave_reference'] %} {%- set ref = slave['slave_reference'] %}
{%- set partition_id %}{{partition_id}}{%- endset %} {%- set partition_id %}{{partition_id}}{%- endset %}
...@@ -44,16 +44,28 @@ ...@@ -44,16 +44,28 @@
{# jcell_ru_ref returns RU reference linked from a cell. {# jcell_ru_ref returns RU reference linked from a cell.
if the cell embeds RU definition, its reference comes as `_<cell_ref>_ru`. #} if the cell embeds RU definition, its reference comes as `_<cell_ref>_ru`. #}
# XXX cycle protection # XXX cycle protection
{%- macro jcell_ru_ref(cell) %} {%- macro jcell_ru_ref(cell) %}
{%- set ru = cell['ru'] %} {{ _jcell_ru_ref(cell, []) | tojson }}
{%- if ru['ru_type'] == 'ru_ref' %} {%- endmacro %}
{{ ru['ru_ref'] | tojson }} {%- macro _jcell_ru_ref(cell, seen) %}
{%- elif ru['ru_type'] == 'ruincell_ref' %} {%- set cell_ref = J(jref_of_shared(cell)) %}
{{ jcell_ru_ref(ru['ruincell_ref']) }} {%- if cell_ref in seen %}
{%- else %} {%- for x in seen %}
{# ru definition is embedded into cell #} {%- do error(x, "%s form a cycle via RU references" % seen) %}
{{ ('_%s_ru' % J(jref_of_shared(cell))) | tojson }} {%- endfor %}
{%- endif %} {# XXX what to return ? #}
{%- else %}
{%- seen.append(cell_ref) %}
{%- set ru = cell['ru'] %}
{%- if ru['ru_type'] == 'ru_ref' %}
{{ ru['ru_ref'] | tojson }}
{%- elif ru['ru_type'] == 'ruincell_ref' %}
{{ jcell_ru_ref(ru['ruincell_ref']) }}
{%- else %}
{# ru definition is embedded into cell #}
{{ ('_%s_ru' % J(jref_of_shared(cell))) | tojson }}
{%- endif %}
{%- endif %}
{%- endmacro %} {%- endmacro %}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment