Skip to content

Commit

Permalink
protobuf: WIP update to use interface node
Browse files Browse the repository at this point in the history
Signed-off-by: Gunnar Andersson <gunnar_dev@nospam@novaspring.eu>
  • Loading branch information
Gunnar Andersson committed Aug 23, 2023
1 parent 6c249a1 commit 9edcbaf
Showing 1 changed file with 70 additions and 64 deletions.
134 changes: 70 additions & 64 deletions ifex/templates/protobuf/AST_protobuf.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,73 +59,79 @@ message {{x.name}} {
}

{% endfor %}
{% for x in n.methods %}
// IFEX Method {{x.name}}
message {{ x.name }}_request {
{% for x in x.input %}
{% if x.datatype in typedefs %}
{% set type = typedefs[x.datatype] %}
{% else %}
{% set type = x.datatype %}
{% endif %}
{{type|replace(".", "_")}} {{ x.name }} = {{ loop.index }};
{% endfor %}
}

message {{ x.name }}_response {
{% for x in x.output %}
{% if x.datatype in typedefs %}
{% set type = typedefs[x.datatype] %}
{% else %}
{% set type = x.datatype %}
{% endif %}
{{type|replace(".", "_")}} {{ x.name }} = {{ loop.index }};
{% endfor %}
}

service {{ x.name }}_service {
rpc {{ x.name }}({{ x.name }}_request) returns ({{ x.name }}_response);
}
{% if item.interface != None %}
{% for x in n.methods %}
// IFEX: Method {{x.name}}
message {{ x.name }}_request {
{% for x in x.input %}
{% if x.datatype in typedefs %}
{% set type = typedefs[x.datatype] %}
{% else %}
{% set type = x.datatype %}
{% endif %}
{{type|replace(".", "_")}} {{ x.name }} = {{ loop.index }};
{% endfor %}
}

message {{ x.name }}_response {
{% for x in x.output %}
{% if x.datatype in typedefs %}
{% set type = typedefs[x.datatype] %}
{% else %}
{% set type = x.datatype %}
{% endif %}
{{type|replace(".", "_")}} {{ x.name }} = {{ loop.index }};
{% endfor %}
}

{% endfor %}
service {{ n.name }}_service {
{% for x in n.methods %}
rpc {{ x.name }}({{ x.name }}_request) returns ({{ x.name }}_response);
{% endfor %}
}

{% endfor %}

{% for x in n.events %}
// IFEX Event {{x.name}}
{# Limitation: for now just creating a message #}
message {{ x.name }} {
{% for x in x.input %}
{% if x.datatype in typedefs %}
{% set type = typedefs[x.datatype] %}
{% else %}
{% set type = x.datatype %}
{% endif %}
{{type|replace(".", "_")}} {{ x.name }} = {{ loop.index }};
{% endfor %}
}

{% endfor %}

{% for x in n.properties %}
// IFEX Property {{x.name}}
message {{ x.name }}_value {
{% if x.datatype in typedefs %}
{% set type = typedefs[x.datatype] %}
{% else %}
{% set type = x.datatype %}
{% endif %}
{{type|replace(".", "_")}} value = 1;
}

// To request value in read operation
message {{ x.name }}_request {}

{# With current specification all properties are read/write #}
service {{ x.name }} {
rpc {{ x.name }}_read({{ x.name }}_request) returns ({{ x.name }}_value);
rpc {{ x.name }}_write({{ x.name }}_value) returns (operation_result);
}

{% endfor %}
{% endfor %}
{% for x in n.events %}
// IFEX Event {{x.name}}
{# Limitation: for now just creating a message #}
message {{ x.name }} {
{% for x in x.input %}
{% if x.datatype in typedefs %}
{% set type = typedefs[x.datatype] %}
{% else %}
{% set type = x.datatype %}
{% endif %}
{{type|replace(".", "_")}} {{ x.name }} = {{ loop.index }};
{% endfor %}
}

{% endfor %}

{% for x in n.properties %}
// IFEX Property {{x.name}}
message {{ x.name }}_value {
{% if x.datatype in typedefs %}
{% set type = typedefs[x.datatype] %}
{% else %}
{% set type = x.datatype %}
{% endif %}
{{type|replace(".", "_")}} value = 1;
}

// To request value in read operation
message {{ x.name }}_request {}

{# With current specification all properties are read/write #}
service {{ x.name }} {
rpc {{ x.name }}_read({{ x.name }}_request) returns ({{ x.name }}_value);
rpc {{ x.name }}_write({{ x.name }}_value) returns (operation_result);
}

{% endfor %}
{% endif %}
{% endfor %}


0 comments on commit 9edcbaf

Please sign in to comment.