Exemplo n.º 1
0
        } // TranslateConstExpr()

        /// <summary> Constructs language specific representation of the given TPM structure field type
        /// for the currently active language. In particular, applies array and byte buffer conventions.
        /// </summary>
        /// <param name="f"> Structure field metadata extracted from the TPM spec </param>
        /// <returns> Language specific representation of the given TPM structure field type </returns>
        static string TranslateFieldType(StructField f)
        {
            string typeName = f.Type.Name;

            if (f.IsByteBuffer())
            {
                if (TargetLang.Cpp)
                {
                    typeName = "ByteVec";
                }
                else
                {
                    if (TargetLang.Node)
                    {
                        return("Buffer");
                    }
                    else if (TargetLang.Py)
                    {
                        return("bytes");
                    }
                    return(typeName + "[]");
                }
            }
            else if (f.IsArray())
            {
                if (TargetLang.Cpp)
                {
                    typeName = $"vector<{typeName}>";
                }
                else
                {
                    return(typeName + "[]");
                }
            }
            return(typeName);
        }