Improving setting up of array-like native values for cases when they are null
Publish PHP Package / docker (push) Successful in 7s Details

This commit is contained in:
Pavel Shevaev 2024-07-04 16:35:05 +03:00
parent 5e870a3973
commit a8ebe821be
1 changed files with 13 additions and 2 deletions

View File

@ -407,11 +407,22 @@ Script_{{o.name|norm_name}}.Method_{{m.name}}.ReturnValue(frm, stack
{%- endif -%}
{%- if type is instanceof('\\mtgArrType') -%}
var _arr_type = (ArrayTypeSymbol){{value}}.type;
int _native_before_count = 0;
{%- if type == 'any[]'-%}
{{native}} = ValList.New(frm.vm);
{%~ else ~%}
try
{
_native_before_count = {{native}}.Count;
}
catch(NullReferenceException)
{
{{native}} = new();
}
{%~ endif -%}
var _arr_type = (ArrayTypeSymbol){{value}}.type;
int _native_before_count = {{native}}.Count;
for(int i=0;i<_arr_type.ArrCount({{value}});++i)
{
var _arr_item = _arr_type.ArrGetAt({{value}}, i);