47 lines
1.9 KiB
C#
47 lines
1.9 KiB
C#
using System.Runtime.CompilerServices;
|
|
|
|
namespace CodeGenerator {
|
|
public static class StrExt {
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static string ParseFName(this string str) {
|
|
str = str.Replace("*", "");
|
|
return str;
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
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,
|
|
"ushort" => typeof(ushort).AssemblyQualifiedName,
|
|
"uchar" => typeof(byte).AssemblyQualifiedName,
|
|
"int64_t" => typeof(long).AssemblyQualifiedName,
|
|
"int8_t" => typeof(sbyte).AssemblyQualifiedName,
|
|
"uint64_t" => typeof(ulong).AssemblyQualifiedName,
|
|
_ => str
|
|
};
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static int ParseFSize(this string str) {
|
|
return str switch {
|
|
"char" => sizeof(char),
|
|
"short" => sizeof(short),
|
|
"int" => sizeof(int),
|
|
"float" => sizeof(float),
|
|
"double" => sizeof(double),
|
|
"ushort" => sizeof(ushort),
|
|
"uchar" => sizeof(byte),
|
|
"int64_t" => sizeof(long),
|
|
"int8_t" => sizeof(sbyte),
|
|
"uint64_t" => sizeof(ulong),
|
|
_ => throw new("Unknown type")
|
|
};
|
|
}
|
|
}
|
|
} |