diff options
author | UbitUmarov | 2018-11-29 21:07:46 +0000 |
---|---|---|
committer | UbitUmarov | 2018-11-29 21:07:46 +0000 |
commit | cc7a241cbc262b91362736201c1727cdcf35c542 (patch) | |
tree | 60435912bef34ef73880b76b925e1734a67b8963 /OpenSim/Region/ScriptEngine/YEngine | |
parent | fix CopyInventoryFromNotecard error handling (diff) | |
download | opensim-SC-cc7a241cbc262b91362736201c1727cdcf35c542.zip opensim-SC-cc7a241cbc262b91362736201c1727cdcf35c542.tar.gz opensim-SC-cc7a241cbc262b91362736201c1727cdcf35c542.tar.bz2 opensim-SC-cc7a241cbc262b91362736201c1727cdcf35c542.tar.xz |
remove xmr json functions that where a fix for ossl ones now removed
Diffstat (limited to 'OpenSim/Region/ScriptEngine/YEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs | 259 |
1 files changed, 0 insertions, 259 deletions
diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs index 092d9c2..a440cf3 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs | |||
@@ -1163,265 +1163,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | /** | 1165 | /** |
1166 | * @brief Implement osParseJSON() so we return an array to the script. | ||
1167 | * No coherent example of its use in scripts on web found. | ||
1168 | * see http://www.json.org/ for more details on JSON | ||
1169 | */ | ||
1170 | private static LSL_List nullList = new LSL_List(new object[0]); | ||
1171 | public new XMR_Array osParseJSON(string json) | ||
1172 | { | ||
1173 | XMR_Array dict = new XMR_Array(this); | ||
1174 | int idx = ParseJSON(dict, nullList, json, 0); | ||
1175 | while(idx < json.Length) | ||
1176 | { | ||
1177 | if(json[idx] > ' ') | ||
1178 | throw new Exception("left-over json " + json); | ||
1179 | idx++; | ||
1180 | } | ||
1181 | return dict; | ||
1182 | } | ||
1183 | |||
1184 | private static int ParseJSON(XMR_Array dict, LSL_List keys, string json, int idx) | ||
1185 | { | ||
1186 | char c; | ||
1187 | |||
1188 | while((c = json[idx++]) <= ' ') | ||
1189 | { | ||
1190 | } | ||
1191 | switch(c) | ||
1192 | { | ||
1193 | |||
1194 | // '{' <keystring> ':' <value> [ ',' <keystring> ':' <value> ... ] '}' | ||
1195 | case '{': | ||
1196 | do | ||
1197 | { | ||
1198 | string key = ParseJSONString(json, ref idx); | ||
1199 | while((c = json[idx++]) <= ' ') | ||
1200 | { | ||
1201 | } | ||
1202 | if(c != ':') | ||
1203 | throw new Exception("missing : after key"); | ||
1204 | idx = ParseJSON(dict, ParseJSONKeyAdd(keys, key), json, idx); | ||
1205 | while((c = json[idx++]) <= ' ') | ||
1206 | { | ||
1207 | } | ||
1208 | } while(c == ','); | ||
1209 | if(c != '}') | ||
1210 | throw new Exception("missing , or } after value"); | ||
1211 | break; | ||
1212 | |||
1213 | |||
1214 | // '[' <value> [ ',' <value> ... ] ']' | ||
1215 | case '[': | ||
1216 | int index = 0; | ||
1217 | do | ||
1218 | { | ||
1219 | object key = index++; | ||
1220 | idx = ParseJSON(dict, ParseJSONKeyAdd(keys, key), json, idx); | ||
1221 | while((c = json[idx++]) <= ' ') | ||
1222 | { | ||
1223 | } | ||
1224 | } while(c == ','); | ||
1225 | if(c != ']') | ||
1226 | throw new Exception("missing , or ] after value"); | ||
1227 | break; | ||
1228 | |||
1229 | |||
1230 | // '"'<string>'"' | ||
1231 | case '"': | ||
1232 | { | ||
1233 | --idx; | ||
1234 | string val = ParseJSONString(json, ref idx); | ||
1235 | dict.SetByKey(keys, val); | ||
1236 | break; | ||
1237 | } | ||
1238 | // true false null | ||
1239 | case 't': | ||
1240 | if(json.Substring(idx, 3) != "rue") | ||
1241 | throw new Exception("bad true in json"); | ||
1242 | idx += 3; | ||
1243 | dict.SetByKey(keys, 1); | ||
1244 | break; | ||
1245 | |||
1246 | case 'f': | ||
1247 | if(json.Substring(idx, 4) != "alse") | ||
1248 | throw new Exception("bad false in json"); | ||
1249 | idx += 4; | ||
1250 | dict.SetByKey(keys, 0); | ||
1251 | break; | ||
1252 | |||
1253 | case 'n': | ||
1254 | if(json.Substring(idx, 3) != "ull") | ||
1255 | throw new Exception("bad null in json"); | ||
1256 | idx += 3; | ||
1257 | dict.SetByKey(keys, null); | ||
1258 | break; | ||
1259 | |||
1260 | // otherwise assume it's a number | ||
1261 | default: | ||
1262 | { | ||
1263 | --idx; | ||
1264 | object val = ParseJSONNumber(json, ref idx); | ||
1265 | dict.SetByKey(keys, val); | ||
1266 | break; | ||
1267 | } | ||
1268 | } | ||
1269 | return idx; | ||
1270 | } | ||
1271 | |||
1272 | // Given the key for a whole array, create a key for a given element of the array | ||
1273 | private static LSL_List ParseJSONKeyAdd(LSL_List oldkeys, object key) | ||
1274 | { | ||
1275 | int oldkeyslen = oldkeys.Length; | ||
1276 | object[] array = oldkeys.Data; | ||
1277 | Array.Resize<object>(ref array, oldkeyslen + 1); | ||
1278 | array[oldkeyslen] = key; | ||
1279 | return new LSL_List(array); | ||
1280 | } | ||
1281 | |||
1282 | // Parse out a JSON string | ||
1283 | private static string ParseJSONString(string json, ref int idx) | ||
1284 | { | ||
1285 | char c; | ||
1286 | |||
1287 | while((c = json[idx++]) <= ' ') | ||
1288 | { | ||
1289 | } | ||
1290 | if(c != '"') | ||
1291 | throw new Exception("bad start of json string"); | ||
1292 | |||
1293 | StringBuilder sb = new StringBuilder(); | ||
1294 | while((c = json[idx++]) != '"') | ||
1295 | { | ||
1296 | if(c == '\\') | ||
1297 | { | ||
1298 | c = json[idx++]; | ||
1299 | switch(c) | ||
1300 | { | ||
1301 | case 'b': | ||
1302 | c = '\b'; | ||
1303 | break; | ||
1304 | |||
1305 | case 'f': | ||
1306 | c = '\f'; | ||
1307 | break; | ||
1308 | |||
1309 | case 'n': | ||
1310 | c = '\n'; | ||
1311 | break; | ||
1312 | |||
1313 | case 'r': | ||
1314 | c = '\r'; | ||
1315 | break; | ||
1316 | |||
1317 | case 't': | ||
1318 | c = '\t'; | ||
1319 | break; | ||
1320 | |||
1321 | case 'u': | ||
1322 | c = (char)Int32.Parse(json.Substring(idx, 4), | ||
1323 | System.Globalization.NumberStyles.HexNumber); | ||
1324 | idx += 4; | ||
1325 | break; | ||
1326 | |||
1327 | default: | ||
1328 | break; | ||
1329 | } | ||
1330 | } | ||
1331 | sb.Append(c); | ||
1332 | } | ||
1333 | return sb.ToString(); | ||
1334 | } | ||
1335 | |||
1336 | // Parse out a JSON number | ||
1337 | private static object ParseJSONNumber(string json, ref int idx) | ||
1338 | { | ||
1339 | char c; | ||
1340 | |||
1341 | while((c = json[idx++]) <= ' ') | ||
1342 | { | ||
1343 | } | ||
1344 | |||
1345 | bool expneg = false; | ||
1346 | bool isneg = false; | ||
1347 | int decpt = -1; | ||
1348 | int expon = 0; | ||
1349 | int ival = 0; | ||
1350 | double dval = 0; | ||
1351 | |||
1352 | if(c == '-') | ||
1353 | { | ||
1354 | isneg = true; | ||
1355 | c = json[idx++]; | ||
1356 | } | ||
1357 | if((c < '0') || (c > '9')) | ||
1358 | throw new Exception("bad json number"); | ||
1359 | |||
1360 | while((c >= '0') && (c <= '9')) | ||
1361 | { | ||
1362 | dval *= 10; | ||
1363 | ival *= 10; | ||
1364 | dval += c - '0'; | ||
1365 | ival += c - '0'; | ||
1366 | c = '\0'; | ||
1367 | if(idx < json.Length) | ||
1368 | c = json[idx++]; | ||
1369 | } | ||
1370 | if(c == '.') | ||
1371 | { | ||
1372 | decpt = 0; | ||
1373 | c = '\0'; | ||
1374 | if(idx < json.Length) | ||
1375 | c = json[idx++]; | ||
1376 | while((c >= '0') && (c <= '9')) | ||
1377 | { | ||
1378 | dval *= 10; | ||
1379 | dval += c - '0'; | ||
1380 | decpt++; | ||
1381 | c = '\0'; | ||
1382 | if(idx < json.Length) | ||
1383 | c = json[idx++]; | ||
1384 | } | ||
1385 | } | ||
1386 | if((c == 'e') || (c == 'E')) | ||
1387 | { | ||
1388 | if(decpt < 0) | ||
1389 | decpt = 0; | ||
1390 | c = json[idx++]; | ||
1391 | if(c == '-') | ||
1392 | expneg = true; | ||
1393 | if((c == '-') || (c == '+')) | ||
1394 | c = json[idx++]; | ||
1395 | while((c >= '0') && (c <= '9')) | ||
1396 | { | ||
1397 | expon *= 10; | ||
1398 | expon += c - '0'; | ||
1399 | c = '\0'; | ||
1400 | if(idx < json.Length) | ||
1401 | c = json[idx++]; | ||
1402 | } | ||
1403 | if(expneg) | ||
1404 | expon = -expon; | ||
1405 | } | ||
1406 | |||
1407 | if(c != 0) | ||
1408 | --idx; | ||
1409 | if(decpt < 0) | ||
1410 | { | ||
1411 | if(isneg) | ||
1412 | ival = -ival; | ||
1413 | return ival; | ||
1414 | } | ||
1415 | else | ||
1416 | { | ||
1417 | if(isneg) | ||
1418 | dval = -dval; | ||
1419 | dval *= Math.Pow(10, expon - decpt); | ||
1420 | return dval; | ||
1421 | } | ||
1422 | } | ||
1423 | |||
1424 | /** | ||
1425 | * @brief Exception-related runtime calls. | 1166 | * @brief Exception-related runtime calls. |
1426 | */ | 1167 | */ |
1427 | // Return exception message (no type information just the message) | 1168 | // Return exception message (no type information just the message) |