From 83b207b7995d74cf0235505d4dd3d934a529dd44 Mon Sep 17 00:00:00 2001 From: Samuele Lorefice Date: Wed, 22 Jan 2025 02:23:16 +0100 Subject: [PATCH] Added string extension class --- CodeGenerator/StrExt.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 CodeGenerator/StrExt.cs diff --git a/CodeGenerator/StrExt.cs b/CodeGenerator/StrExt.cs new file mode 100644 index 0000000..6d43c0e --- /dev/null +++ b/CodeGenerator/StrExt.cs @@ -0,0 +1,21 @@ +namespace CodeGenerator { + public static class StrExt { + public static string ParseFName(this string str) { + str = str.Replace("*", "ptr_"); + return str; + } + + public static string ParseFType(this string str) { + return str switch { + "char" => typeof(char).AssemblyQualifiedName, + "short" => typeof(short).AssemblyQualifiedName, + "int" => typeof(int).AssemblyQualifiedName, + "float" => typeof(float).AssemblyQualifiedName, + "double" => typeof(double).AssemblyQualifiedName, + "string" => typeof(string).AssemblyQualifiedName, + "void" => typeof(object).AssemblyQualifiedName, + _ => str + }; + } + } +} \ No newline at end of file