public void WriteArg(FuncModel func) { var args = new List<string>(); // 引数. foreach (var arg in func.args) { // 文字列. if (arg.type == "string") { args.Add("const char*" + arg.name); continue; } args.Add("const " + GetType(arg) + ' ' + arg.name); } writer_.Write(String.Join(",", args)); }
void WriteCallFunc(FuncModel func) { writer_.Write(func.name + "_("); List<string> args = new List<string>(); foreach (var arg in func.args) args.Add(arg.name); writer_.Write(String.Join(",", args)); writer_.WriteLine(");"); }
void WriteGetArg(FuncModel func) { foreach (var arg in func.args) { writer_.Write("auto " + arg.name + '='); // 文字列. if (arg.type == "string") { writer_.WriteLine("(char*)&buf[cnt];"); writer_.WriteLine("cnt+=strlen(" + arg.name + ")+1;"); continue; } else if (arg.type.Contains("byte")) { writer_.WriteLine("*(" + GetType(arg) + "*)&buf[cnt];"); } else if (arg.type.Contains("short")) { writer_.WriteLine('(' + GetType(arg) + ")ntohs(*(int16_t*)&buf[cnt]);"); } else if (arg.type.Contains("int")) { writer_.WriteLine('(' + GetType(arg) + ")ntohl(*(int32_t*)&buf[cnt]);"); } else if (arg.type.Contains("float")) { writer_.WriteLine("[&]()->float{auto work = ntohl(*(int32_t*)&buf[cnt]);return *(float*)&work;}();"); } writer_.WriteLine("cnt+=sizeof(" + arg.name + ");"); } }
void WriteArg(FuncModel func) { List<string> args = new List<string>(); foreach (var arg in func.args) { args.Add(arg.type + ' ' + arg.name); } writer_.Write(String.Join(",", args)); }