Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvements in AXL generation #1773

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions axlstar/Arcane.Axl.T4/Arcane.Axl/T4.StrongOptions/CaseOptionsT.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:6.0.28
// Runtime Version:6.0.35
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
Expand All @@ -23,8 +23,11 @@ public virtual string TransformText() {
Action<OptionHandler, String, String> getterSection = (OptionHandler _xml, String beginLineSpace, String redirectionPrefix) => {
foreach(var simple in _xml.Simple) {
string return_type = simple.type.QualifiedName();
if (simple.IsSingle == false) {
string call_type = "()";
// Use view() for array type because 'operator()' is deprecated for these types.
if (!simple.IsSingle) {
return_type = return_type.ToArrayType();
call_type = ".view()";
}
this.Write(this.ToStringHelper.ToStringWithCulture(beginLineSpace));
this.Write(this.ToStringHelper.ToStringWithCulture( return_type ));
Expand All @@ -37,13 +40,14 @@ public virtual string TransformText() {
this.Write(" return ");
this.Write(this.ToStringHelper.ToStringWithCulture( redirectionPrefix ));
this.Write(this.ToStringHelper.ToStringWithCulture( simple.Name.ToFuncName() ));
this.Write("() ;\n");
this.Write(this.ToStringHelper.ToStringWithCulture( call_type ));
this.Write(";\n");
this.Write(this.ToStringHelper.ToStringWithCulture(beginLineSpace));
this.Write("}\n");
}
foreach(var enumerator in _xml.Enumeration) {
string return_type = enumerator.type;
if (enumerator.IsSingle == true) {
if (enumerator.IsSingle) {
this.Write(this.ToStringHelper.ToStringWithCulture(beginLineSpace));
this.Write(this.ToStringHelper.ToStringWithCulture( return_type ));
this.Write(" ");
Expand All @@ -64,7 +68,7 @@ public virtual string TransformText() {
this.Write(this.ToStringHelper.ToStringWithCulture( return_type.ToArrayType() ));
this.Write(" ");
this.Write(this.ToStringHelper.ToStringWithCulture( enumerator.Name.ToFuncName() ));
this.Write("() const\n");
this.Write(" const\n");
this.Write(this.ToStringHelper.ToStringWithCulture(beginLineSpace));
this.Write("{\n");
this.Write(this.ToStringHelper.ToStringWithCulture(beginLineSpace));
Expand Down Expand Up @@ -225,10 +229,11 @@ public virtual string TransformText() {
this.Write(" = false;\n\t}\n");
}
};
this.Write("/*---------------------------------------------------------------------------*/\n/" +
"*---------------------------------------------------------------------------*/\n/" +
"/ #WARNING#: This file has been generated automatically. Do not edit.\n// Arcane " +
"version ");
this.Write(@"/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
// #WARNING#: This file has been generated automatically. Do not edit.
// Generated from 'CaseOptionsT.tt' (version 2024.11.17)
// Arcane version ");
this.Write(this.ToStringHelper.ToStringWithCulture( Version ));
this.Write(" : ");
this.Write(this.ToStringHelper.ToStringWithCulture( DateTime.Now ));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,27 @@
<# Action<OptionHandler, String, String> getterSection = (OptionHandler _xml, String beginLineSpace, String redirectionPrefix) => { #>
<# foreach(var simple in _xml.Simple) {
string return_type = simple.type.QualifiedName();
if (simple.IsSingle == false) {
string call_type = "()";
// Use view() for array type because 'operator()' is deprecated for these types.
if (!simple.IsSingle) {
return_type = return_type.ToArrayType();
call_type = ".view()";
}#>
<#=beginLineSpace#><#= return_type #> <#= simple.Name.ToFuncName() #>() const
<#=beginLineSpace#>{
<#=beginLineSpace#> return <#= redirectionPrefix #><#= simple.Name.ToFuncName() #>() ;
<#=beginLineSpace#> return <#= redirectionPrefix #><#= simple.Name.ToFuncName() #><#= call_type #>;
<#=beginLineSpace#>}
<# } #>
<# foreach(var enumerator in _xml.Enumeration) {
string return_type = enumerator.type;
if (enumerator.IsSingle == true) { #>
if (enumerator.IsSingle) { #>
<#=beginLineSpace#><#= return_type #> <#= enumerator.Name.ToFuncName() #>() const
<#=beginLineSpace#>{
<#=beginLineSpace#> return <#= redirectionPrefix #><#= enumerator.Name.ToFuncName() #>();
<#=beginLineSpace#>}
<# }
else{ #>
<#=beginLineSpace#><#= return_type.ToArrayType() #> <#= enumerator.Name.ToFuncName() #>() const
<#=beginLineSpace#><#= return_type.ToArrayType() #> <#= enumerator.Name.ToFuncName() #> const
<#=beginLineSpace#>{
<#=beginLineSpace#> return <#= redirectionPrefix #><#= enumerator.Name.ToFuncName() #>;
<#=beginLineSpace#>}
Expand Down Expand Up @@ -88,6 +91,7 @@
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
// #WARNING#: This file has been generated automatically. Do not edit.
// Generated from 'CaseOptionsT.tt' (version 2024.11.17)
// Arcane version <#= Version #> : <#= DateTime.Now #>
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:6.0.28
// Runtime Version:6.0.32
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
Expand Down Expand Up @@ -178,7 +178,7 @@ public virtual string TransformText() {
this.Write(this.ToStringHelper.ToStringWithCulture( _option.Name.ToFuncName() ));
this.Write("_, Args...>(m_");
this.Write(this.ToStringHelper.ToStringWithCulture( _option.Name.DashToUnderscore() ));
this.Write(", std::move(args)...);\n");
this.Write(", std::forward<Args>(args)...);\n");
}
else {
if(problemStdArray) {
Expand All @@ -188,7 +188,8 @@ public virtual string TransformText() {
this.Write(this.ToStringHelper.ToStringWithCulture( _option.Name.ToFuncName() ));
this.Write("_, Args...>(m_");
this.Write(this.ToStringHelper.ToStringWithCulture( _option.Name.DashToUnderscore() ));
this.Write(", std::move(args)...);\n // todo replace by static assert\t\n if(!exist_");
this.Write(", std::forward<Args>(args)...);\n // todo replace by static assert\t\n if(!exi" +
"st_");
this.Write(this.ToStringHelper.ToStringWithCulture( _option.Name.DashToUnderscore() ));
this.Write(")\n throw ");
this.Write(this.ToStringHelper.ToStringWithCulture(SimpleTypeExtensions.Namespace()));
Expand All @@ -201,7 +202,7 @@ public virtual string TransformText() {
this.Write(this.ToStringHelper.ToStringWithCulture( _option.Name.DashToUnderscore() ));
this.Write(" = OptionTools::requiredFixedArray<");
this.Write(this.ToStringHelper.ToStringWithCulture( _option.Name.ToFuncName() ));
this.Write("_, 1, Args...>(std::move(args)...)[0];\n");
this.Write("_, 1, Args...>(std::forward<Args>(args)...)[0];\n");
}
}
}
Expand All @@ -215,7 +216,7 @@ public virtual string TransformText() {
this.Write(this.ToStringHelper.ToStringWithCulture( _option.Name.ToFuncName() ));
this.Write("_, ");
this.Write(this.ToStringHelper.ToStringWithCulture( _option.MinOccurs ));
this.Write(", -1, Args...>(std::move(args)...);\n");
this.Write(", -1, Args...>(std::forward<Args>(args)...);\n");
}
this.Write("\n");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,25 @@
<# if (_option.IsSingle == true) { #>
<# if (hasDefault) { #>
m_<#= _option.Name.DashToUnderscore() #> = <#= _option_default #>;
OptionTools::optionalSimple<<#= _option.Name.ToFuncName() #>_, Args...>(m_<#= _option.Name.DashToUnderscore() #>, std::move(args)...);
OptionTools::optionalSimple<<#= _option.Name.ToFuncName() #>_, Args...>(m_<#= _option.Name.DashToUnderscore() #>, std::forward<Args>(args)...);
<# }
else {
if(problemStdArray) { #>
static bool exist_<#= _option.Name.DashToUnderscore() #> = OptionTools::optionalSimple<<#= _option.Name.ToFuncName() #>_, Args...>(m_<#= _option.Name.DashToUnderscore() #>, std::move(args)...);
static bool exist_<#= _option.Name.DashToUnderscore() #> = OptionTools::optionalSimple<<#= _option.Name.ToFuncName() #>_, Args...>(m_<#= _option.Name.DashToUnderscore() #>, std::forward<Args>(args)...);
// todo replace by static assert
if(!exist_<#= _option.Name.DashToUnderscore() #>)
throw <#=SimpleTypeExtensions.Namespace()#>::FatalErrorException(A_FUNCINFO, "missing required option <#= _option.Name.ToFuncName() #>");
<# }
else { #>
m_<#= _option.Name.DashToUnderscore() #> = OptionTools::requiredFixedArray<<#= _option.Name.ToFuncName() #>_, 1, Args...>(std::move(args)...)[0];
m_<#= _option.Name.DashToUnderscore() #> = OptionTools::requiredFixedArray<<#= _option.Name.ToFuncName() #>_, 1, Args...>(std::forward<Args>(args)...)[0];
<# }
}
} #>
<# else { #>
<# if (hasDefault) { #>
//#warning "Default for multi options not used"
<# } #>
m_<#= _option.Name.DashToUnderscore() #> = OptionTools::requiredVariableArray<<#= _option.Name.ToFuncName() #>_, <#= _option.MinOccurs #>, -1, Args...>(std::move(args)...);
m_<#= _option.Name.DashToUnderscore() #> = OptionTools::requiredVariableArray<<#= _option.Name.ToFuncName() #>_, <#= _option.MinOccurs #>, -1, Args...>(std::forward<Args>(args)...);
<# } #>

<# }; #>
Expand Down
Loading