core/smn_protobuf.cpp
changeset 3747 cb3f97a59d55
parent 3743 a98686a77974
child 3813 bf1faf4a16c9
     1.1 --- a/core/smn_protobuf.cpp	Tue Jan 22 22:23:40 2013 -0500
     1.2 +++ b/core/smn_protobuf.cpp	Tue Jan 22 22:36:38 2013 -0500
     1.3 @@ -71,7 +71,7 @@
     1.4  	int ret;
     1.5  	if (!msg->GetInt32OrUnsigned(strField, &ret))
     1.6  	{
     1.7 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
     1.8 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
     1.9  	}
    1.10  
    1.11  	return ret;
    1.12 @@ -85,7 +85,7 @@
    1.13  	float ret;
    1.14  	if (!msg->GetFloatOrDouble(strField, &ret))
    1.15  	{
    1.16 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
    1.17 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
    1.18  	}
    1.19  
    1.20  	return sp_ftoc(ret);
    1.21 @@ -99,7 +99,7 @@
    1.22  	bool ret;
    1.23  	if (!msg->GetBool(strField, &ret))
    1.24  	{
    1.25 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
    1.26 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
    1.27  	}
    1.28  
    1.29  	return ret ? 1 : 0;
    1.30 @@ -115,7 +115,7 @@
    1.31  
    1.32  	if (!msg->GetString(strField, buf, params[4]))
    1.33  	{
    1.34 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
    1.35 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
    1.36  	}
    1.37  
    1.38  	return 1;
    1.39 @@ -132,7 +132,7 @@
    1.40  	Color clr;
    1.41  	if (!msg->GetColor(strField, &clr))
    1.42  	{
    1.43 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
    1.44 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
    1.45  	}
    1.46  
    1.47  	out[0] = clr.r();
    1.48 @@ -154,7 +154,7 @@
    1.49  	QAngle ang;
    1.50  	if (!msg->GetQAngle(strField, &ang))
    1.51  	{
    1.52 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
    1.53 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
    1.54  	}
    1.55  
    1.56  	out[0] = sp_ftoc(ang.x);
    1.57 @@ -175,7 +175,7 @@
    1.58  	Vector vec;
    1.59  	if (!msg->GetVector(strField, &vec))
    1.60  	{
    1.61 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
    1.62 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
    1.63  	}
    1.64  
    1.65  	out[0] = sp_ftoc(vec.x);
    1.66 @@ -196,7 +196,7 @@
    1.67  	Vector2D vec;
    1.68  	if (!msg->GetVector2D(strField, &vec))
    1.69  	{
    1.70 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
    1.71 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
    1.72  	}
    1.73  
    1.74  	out[0] = sp_ftoc(vec.x);
    1.75 @@ -213,7 +213,7 @@
    1.76  	int cnt = msg->GetRepeatedFieldCount(strField);
    1.77  	if (cnt == -1)
    1.78  	{
    1.79 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
    1.80 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
    1.81  	}
    1.82  
    1.83  	return cnt;
    1.84 @@ -227,7 +227,7 @@
    1.85  	int ret;
    1.86  	if (!msg->GetRepeatedInt32OrUnsigned(strField, params[3], &ret))
    1.87  	{
    1.88 -		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName());
    1.89 +		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName().c_str());
    1.90  	}
    1.91  
    1.92  	return ret;
    1.93 @@ -241,7 +241,7 @@
    1.94  	float ret;
    1.95  	if (!msg->GetRepeatedFloatOrDouble(strField, params[3], &ret))
    1.96  	{
    1.97 -		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName());
    1.98 +		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName().c_str());
    1.99  	}
   1.100  
   1.101  	return sp_ftoc(ret);
   1.102 @@ -255,7 +255,7 @@
   1.103  	bool ret;
   1.104  	if (!msg->GetRepeatedBool(strField, params[3], &ret))
   1.105  	{
   1.106 -		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName());
   1.107 +		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName().c_str());
   1.108  	}
   1.109  
   1.110  	return ret ? 1 : 0;
   1.111 @@ -271,7 +271,7 @@
   1.112  
   1.113  	if (!msg->GetRepeatedString(strField, params[3], buf, params[5]))
   1.114  	{
   1.115 -		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName());
   1.116 +		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName().c_str());
   1.117  	}
   1.118  
   1.119  	return 1;
   1.120 @@ -288,7 +288,7 @@
   1.121  	Color clr;
   1.122  	if (!msg->GetRepeatedColor(strField, params[3], &clr))
   1.123  	{
   1.124 -		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName());
   1.125 +		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName().c_str());
   1.126  	}
   1.127  
   1.128  	out[0] = clr.r();
   1.129 @@ -310,7 +310,7 @@
   1.130  	QAngle ang;
   1.131  	if (!msg->GetRepeatedQAngle(strField, params[3], &ang))
   1.132  	{
   1.133 -		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName());
   1.134 +		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName().c_str());
   1.135  	}
   1.136  
   1.137  	out[0] = sp_ftoc(ang.x);
   1.138 @@ -331,7 +331,7 @@
   1.139  	Vector vec;
   1.140  	if (!msg->GetRepeatedVector(strField, params[3], &vec))
   1.141  	{
   1.142 -		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName());
   1.143 +		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName().c_str());
   1.144  	}
   1.145  
   1.146  	out[0] = sp_ftoc(vec.x);
   1.147 @@ -352,7 +352,7 @@
   1.148  	Vector2D vec;
   1.149  	if (!msg->GetRepeatedVector2D(strField, params[3], &vec))
   1.150  	{
   1.151 -		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName());
   1.152 +		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName().c_str());
   1.153  	}
   1.154  
   1.155  	out[0] = sp_ftoc(vec.x);
   1.156 @@ -368,7 +368,7 @@
   1.157  
   1.158  	if (!msg->SetInt32OrUnsigned(strField, params[3]))
   1.159  	{
   1.160 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.161 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.162  	}
   1.163  
   1.164  	return 1;
   1.165 @@ -381,7 +381,7 @@
   1.166  
   1.167  	if (!msg->SetFloatOrDouble(strField, sp_ctof(params[3])))
   1.168  	{
   1.169 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.170 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.171  	}
   1.172  
   1.173  	return 1;
   1.174 @@ -395,7 +395,7 @@
   1.175  	bool value = (params[3] == 0 ? false : true);
   1.176  	if (!msg->SetBool(strField, value))
   1.177  	{
   1.178 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.179 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.180  	}
   1.181  
   1.182  	return 1;
   1.183 @@ -415,7 +415,7 @@
   1.184  
   1.185  	if (!msg->SetString(strField, strValue))
   1.186  	{
   1.187 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.188 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.189  	}
   1.190  
   1.191  	return 1;
   1.192 @@ -441,7 +441,7 @@
   1.193  
   1.194  	if (!msg->SetColor(strField, clr))
   1.195  	{
   1.196 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.197 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.198  	}
   1.199  
   1.200  	return 1;
   1.201 @@ -466,7 +466,7 @@
   1.202  
   1.203  	if (!msg->SetQAngle(strField, ang))
   1.204  	{
   1.205 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.206 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.207  	}
   1.208  
   1.209  	return 1;
   1.210 @@ -491,7 +491,7 @@
   1.211  
   1.212  	if (!msg->SetVector(strField, vec))
   1.213  	{
   1.214 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.215 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.216  	}
   1.217  
   1.218  	return 1;
   1.219 @@ -515,7 +515,7 @@
   1.220  
   1.221  	if (!msg->SetVector2D(strField, vec))
   1.222  	{
   1.223 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.224 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.225  	}
   1.226  
   1.227  	return 1;
   1.228 @@ -528,7 +528,7 @@
   1.229  
   1.230  	if (!msg->AddInt32OrUnsigned(strField, params[3]))
   1.231  	{
   1.232 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.233 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.234  	}
   1.235  
   1.236  	return 1;
   1.237 @@ -541,7 +541,7 @@
   1.238  
   1.239  	if (!msg->AddFloatOrDouble(strField, sp_ctof(params[3])))
   1.240  	{
   1.241 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.242 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.243  	}
   1.244  
   1.245  	return 1;
   1.246 @@ -555,7 +555,7 @@
   1.247  	bool value = (params[3] == 0 ? false : true);
   1.248  	if (!msg->AddBool(strField, value))
   1.249  	{
   1.250 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.251 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.252  	}
   1.253  
   1.254  	return 1;
   1.255 @@ -575,7 +575,7 @@
   1.256  
   1.257  	if (!msg->AddString(strField, strValue))
   1.258  	{
   1.259 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.260 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.261  	}
   1.262  
   1.263  	return 1;
   1.264 @@ -601,7 +601,7 @@
   1.265  
   1.266  	if (!msg->AddColor(strField, clr))
   1.267  	{
   1.268 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.269 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.270  	}
   1.271  
   1.272  	return 1;
   1.273 @@ -626,7 +626,7 @@
   1.274  
   1.275  	if (!msg->AddQAngle(strField, ang))
   1.276  	{
   1.277 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.278 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.279  	}
   1.280  
   1.281  	return 1;
   1.282 @@ -651,7 +651,7 @@
   1.283  
   1.284  	if (!msg->AddVector(strField, vec))
   1.285  	{
   1.286 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.287 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.288  	}
   1.289  
   1.290  	return 1;
   1.291 @@ -675,7 +675,7 @@
   1.292  
   1.293  	if (!msg->AddVector2D(strField, vec))
   1.294  	{
   1.295 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.296 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.297  	}
   1.298  
   1.299  	return 1;
   1.300 @@ -689,7 +689,7 @@
   1.301  	protobuf::Message *innerMsg;
   1.302  	if (!msg->GetMessage(strField, &innerMsg))
   1.303  	{
   1.304 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.305 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.306  	}
   1.307  
   1.308  	Handle_t outHndl = g_HandleSys.CreateHandle(g_ProtobufType, new SMProtobufMessage(innerMsg), NULL, g_pCoreIdent, NULL);
   1.309 @@ -706,7 +706,7 @@
   1.310  	const protobuf::Message *innerMsg;
   1.311  	if (!msg->GetRepeatedMessage(strField, params[3], &innerMsg))
   1.312  	{
   1.313 -		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName());
   1.314 +		return pCtx->ThrowNativeError("Invalid field \"%s\"[%d] for message \"%s\"", strField, params[3], msg->GetProtobufMessage()->GetTypeName().c_str());
   1.315  	}
   1.316  
   1.317  	Handle_t outHndl = g_HandleSys.CreateHandle(g_ProtobufType, new SMProtobufMessage(const_cast<protobuf::Message *>(innerMsg)), NULL, g_pCoreIdent, NULL);
   1.318 @@ -723,7 +723,7 @@
   1.319  	protobuf::Message *innerMsg;
   1.320  	if (!msg->AddMessage(strField, &innerMsg))
   1.321  	{
   1.322 -		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName());
   1.323 +		return pCtx->ThrowNativeError("Invalid field \"%s\" for message \"%s\"", strField, msg->GetProtobufMessage()->GetTypeName().c_str());
   1.324  	}
   1.325  
   1.326  	Handle_t outHndl = g_HandleSys.CreateHandle(g_ProtobufType, new SMProtobufMessage(innerMsg), NULL, g_pCoreIdent, NULL);