struct_types_ada.mako: refactor prototype for public converter

TN: S401-014
This commit is contained in:
Pierre-Marie de Rodat
2019-04-16 14:44:16 +02:00
committed by Raphaël AMIARD
parent 03b2b1b996
commit 2b407dc49c

View File

@@ -5,21 +5,24 @@
<%def name="create_prototype(cls)">
function Create_${cls.api_name} (${'; '.join('{} : {}{}'.format(
f.name,
f.type.api_name,
"'Class" if f.type.is_entity_type or f.type.is_ast_node else ''
f.public_type.api_name,
"'Class" if f.public_type.is_entity_type else ''
) for f in cls.get_fields())}) return ${cls.api_name}
</%def>
<%def name="accessor_prototype(cls, f)">
function ${f.name}
(Self : ${cls.api_name})
return ${f.public_type.api_name}${(
"'Class" if f.public_type.is_entity_type else '')}
</%def>
<%def name="public_api_decl(cls)">
type ${cls.api_name} is private;
${ada_doc(cls, 3)}
% for f in cls.get_fields():
function ${f.name}
(Self : ${cls.api_name})
return ${f.type.api_name}${("'Class"
if f.type.is_entity_type or
f.type.is_ast_node else '')};
${accessor_prototype(cls, f)};
${ada_doc(f, 6)}
% endfor
@@ -68,12 +71,7 @@
<%def name="public_api_body(cls)">
% for f in cls.get_fields():
function ${f.name}
(Self : ${cls.api_name})
return ${f.type.api_name}${("'Class"
if f.type.is_entity_type or
f.type.is_ast_node else '')}
is
${accessor_prototype(cls, f)} is
Record_Ref : constant Boxed_${cls.api_name}.Element_Access :=
Internal_Access (Self);
begin