Skip to content

Commit a4b3348

Browse files
authored
Deprecate the LSL JSON functions (#70)
1 parent abd0a20 commit a4b3348

File tree

5 files changed

+83
-6
lines changed

5 files changed

+83
-6
lines changed

generated/slua_default.d.luau

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,10 +698,10 @@ declare ll: {
698698
IntegerToBase64: (Value: number) -> string,
699699
IsFriend: (agent_id: uuid) -> boolean,
700700
IsLinkGLTFMaterial: (link: number, face: number) -> boolean,
701-
Json2List: (JSON: string) -> {any},
702-
JsonGetValue: (JSON: string, Specifiers: list) -> string,
703-
JsonSetValue: (JSON: string, Specifiers: list, Value: string) -> string,
704-
JsonValueType: (JSON: string, Specifiers: list) -> string,
701+
Json2List: @[deprecated {use='lljson.decode'}](JSON: string) -> {any},
702+
JsonGetValue: @[deprecated {use='lljson.decode', reason='Also, the indices are zero-based.'}](JSON: string, Specifiers: list) -> string,
703+
JsonSetValue: @[deprecated {use='lljson.encode', reason='Also, the indices are zero-based.'}](JSON: string, Specifiers: list, Value: string) -> string,
704+
JsonValueType: @[deprecated {reason="Use 'lljson.decode' and 'typeof' instead. Also, the indices are zero-based."}](JSON: string, Specifiers: list) -> string,
705705
Key2Name: (ID: uuid) -> string,
706706
KeyCountKeyValue: () -> uuid,
707707
KeysKeyValue: (First: number, Count: number) -> uuid,
@@ -729,7 +729,7 @@ declare ll: {
729729
List2CSV: (ListVariable: list) -> string,
730730
List2Float: (ListVariable: list, Index: number) -> number,
731731
List2Integer: (ListVariable: list, Index: number) -> number,
732-
List2Json: (JsonType: string, Values: list) -> string,
732+
List2Json: @[deprecated {use='lljson.encode'}](JsonType: string, Values: list) -> string,
733733
List2Key: (ListVariable: list, Index: number) -> uuid,
734734
List2List: <T>(ListVariable: {T}, Start: number, End: number) -> {T},
735735
List2ListSlice: <T>(ListVariable: {T}, Start: number, End: number, Stride: number, slice_index: number) -> {T},

generated/slua_keywords_pretty.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2991,6 +2991,8 @@ export type rotation = quaternion</string>
29912991
</map>
29922992
<key>JSON_APPEND</key>
29932993
<map>
2994+
<key>deprecated</key>
2995+
<boolean>true</boolean>
29942996
<key>tooltip</key>
29952997
<string></string>
29962998
<key>type</key>
@@ -3000,6 +3002,8 @@ export type rotation = quaternion</string>
30003002
</map>
30013003
<key>JSON_ARRAY</key>
30023004
<map>
3005+
<key>deprecated</key>
3006+
<boolean>true</boolean>
30033007
<key>tooltip</key>
30043008
<string></string>
30053009
<key>type</key>
@@ -3009,6 +3013,8 @@ export type rotation = quaternion</string>
30093013
</map>
30103014
<key>JSON_DELETE</key>
30113015
<map>
3016+
<key>deprecated</key>
3017+
<boolean>true</boolean>
30123018
<key>tooltip</key>
30133019
<string></string>
30143020
<key>type</key>
@@ -3018,6 +3024,8 @@ export type rotation = quaternion</string>
30183024
</map>
30193025
<key>JSON_FALSE</key>
30203026
<map>
3027+
<key>deprecated</key>
3028+
<boolean>true</boolean>
30213029
<key>tooltip</key>
30223030
<string></string>
30233031
<key>type</key>
@@ -3027,6 +3035,8 @@ export type rotation = quaternion</string>
30273035
</map>
30283036
<key>JSON_INVALID</key>
30293037
<map>
3038+
<key>deprecated</key>
3039+
<boolean>true</boolean>
30303040
<key>tooltip</key>
30313041
<string></string>
30323042
<key>type</key>
@@ -3036,6 +3046,8 @@ export type rotation = quaternion</string>
30363046
</map>
30373047
<key>JSON_NULL</key>
30383048
<map>
3049+
<key>deprecated</key>
3050+
<boolean>true</boolean>
30393051
<key>tooltip</key>
30403052
<string></string>
30413053
<key>type</key>
@@ -3045,6 +3057,8 @@ export type rotation = quaternion</string>
30453057
</map>
30463058
<key>JSON_NUMBER</key>
30473059
<map>
3060+
<key>deprecated</key>
3061+
<boolean>true</boolean>
30483062
<key>tooltip</key>
30493063
<string></string>
30503064
<key>type</key>
@@ -3054,6 +3068,8 @@ export type rotation = quaternion</string>
30543068
</map>
30553069
<key>JSON_OBJECT</key>
30563070
<map>
3071+
<key>deprecated</key>
3072+
<boolean>true</boolean>
30573073
<key>tooltip</key>
30583074
<string></string>
30593075
<key>type</key>
@@ -3063,6 +3079,8 @@ export type rotation = quaternion</string>
30633079
</map>
30643080
<key>JSON_STRING</key>
30653081
<map>
3082+
<key>deprecated</key>
3083+
<boolean>true</boolean>
30663084
<key>tooltip</key>
30673085
<string></string>
30683086
<key>type</key>
@@ -3072,6 +3090,8 @@ export type rotation = quaternion</string>
30723090
</map>
30733091
<key>JSON_TRUE</key>
30743092
<map>
3093+
<key>deprecated</key>
3094+
<boolean>true</boolean>
30753095
<key>tooltip</key>
30763096
<string></string>
30773097
<key>type</key>
@@ -22350,6 +22370,8 @@ Returns true if result is non-zero.</string>
2235022370
</map>
2235122371
</map>
2235222372
</array>
22373+
<key>deprecated</key>
22374+
<boolean>true</boolean>
2235322375
<key>energy</key>
2235422376
<real>10.0</real>
2235522377
<key>return</key>
@@ -22382,6 +22404,8 @@ Returns true if result is non-zero.</string>
2238222404
</map>
2238322405
</map>
2238422406
</array>
22407+
<key>deprecated</key>
22408+
<boolean>true</boolean>
2238522409
<key>energy</key>
2238622410
<real>10.0</real>
2238722411
<key>return</key>
@@ -22423,6 +22447,8 @@ Returns true if result is non-zero.</string>
2242322447
</map>
2242422448
</map>
2242522449
</array>
22450+
<key>deprecated</key>
22451+
<boolean>true</boolean>
2242622452
<key>energy</key>
2242722453
<real>10.0</real>
2242822454
<key>return</key>
@@ -22455,6 +22481,8 @@ Returns true if result is non-zero.</string>
2245522481
</map>
2245622482
</map>
2245722483
</array>
22484+
<key>deprecated</key>
22485+
<boolean>true</boolean>
2245822486
<key>energy</key>
2245922487
<real>10.0</real>
2246022488
<key>return</key>
@@ -23265,6 +23293,8 @@ Returns true if result is non-zero.</string>
2326523293
</map>
2326623294
</map>
2326723295
</array>
23296+
<key>deprecated</key>
23297+
<boolean>true</boolean>
2326823298
<key>energy</key>
2326923299
<real>10.0</real>
2327023300
<key>return</key>

generated/slua_selene.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6879,17 +6879,23 @@ globals:
68796879
must_use: true
68806880
description: Checks the face for a PBR render material.
68816881
ll.Json2List:
6882+
deprecated:
6883+
message: Use 'lljson.decode' instead.
68826884
args:
68836885
- type: string
68846886
must_use: true
68856887
description: Converts the top level of the JSON string to a list.
68866888
ll.JsonGetValue:
6889+
deprecated:
6890+
message: Use 'lljson.decode' instead. Also, the indices are zero-based.
68876891
args:
68886892
- type: string
68896893
- type: table
68906894
must_use: true
68916895
description: Gets the value indicated by Specifiers from the JSON string.
68926896
ll.JsonSetValue:
6897+
deprecated:
6898+
message: Use 'lljson.encode' instead. Also, the indices are zero-based.
68936899
args:
68946900
- type: string
68956901
- type: table
@@ -6898,6 +6904,8 @@ globals:
68986904
description: Returns a new JSON string that is the JSON given with the Value indicated
68996905
by Specifiers set to Value.
69006906
ll.JsonValueType:
6907+
deprecated:
6908+
message: Use 'lljson.decode' and 'typeof' instead. Also, the indices are zero-based.
69016909
args:
69026910
- type: string
69036911
- type: table
@@ -7089,6 +7097,10 @@ globals:
70897097
in the specified list. If Index describes a location not in the list, or the
70907098
value cannot be type-cast to an integer, then zero is returned.
70917099
ll.List2Json:
7100+
deprecated:
7101+
message: Use 'lljson.encode' instead.
7102+
replace:
7103+
- lljson.encode(%2)
70927104
args:
70937105
- type: string
70947106
- type: table

lsl_definitions.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,42 +1258,62 @@ constants:
12581258
type: integer
12591259
value: 0
12601260
JSON_APPEND:
1261+
slua-deprecated:
1262+
reason: Use 'lljson.decode' and 'table.insert' instead.
12611263
tooltip: ''
12621264
type: integer
12631265
value: -1
12641266
JSON_ARRAY:
1267+
slua-deprecated:
1268+
use: lljson.array_mt
12651269
tooltip: ''
12661270
type: string
12671271
value: '\u{FDD2}'
12681272
JSON_DELETE:
1273+
slua-deprecated:
1274+
use: nil
12691275
tooltip: ''
12701276
type: string
12711277
value: '\u{FDD8}'
12721278
JSON_FALSE:
1279+
slua-deprecated:
1280+
use: "false"
12731281
tooltip: ''
12741282
type: string
12751283
value: '\u{FDD7}'
12761284
JSON_INVALID:
1285+
slua-deprecated:
1286+
use: pcall
12771287
tooltip: ''
12781288
type: string
12791289
value: '\u{FDD0}'
12801290
JSON_NULL:
1291+
slua-deprecated:
1292+
use: lljson.null
12811293
tooltip: ''
12821294
type: string
12831295
value: '\u{FDD5}'
12841296
JSON_NUMBER:
1297+
slua-deprecated:
1298+
use: typeof
12851299
tooltip: ''
12861300
type: string
12871301
value: '\u{FDD3}'
12881302
JSON_OBJECT:
1303+
slua-deprecated:
1304+
use: lljson.object_mt
12891305
tooltip: ''
12901306
type: string
12911307
value: '\u{FDD1}'
12921308
JSON_STRING:
1309+
slua-deprecated:
1310+
use: typeof
12931311
tooltip: ''
12941312
type: string
12951313
value: '\u{FDD4}'
12961314
JSON_TRUE:
1315+
slua-deprecated:
1316+
use: "true"
12971317
tooltip: ''
12981318
type: string
12991319
value: '\u{FDD6}'
@@ -8103,6 +8123,8 @@ functions:
81038123
- JSON:
81048124
tooltip: ''
81058125
type: string
8126+
slua-deprecated:
8127+
use: lljson.decode
81068128
energy: 10.0
81078129
func-id: 513
81088130
pure: true
@@ -8120,6 +8142,9 @@ functions:
81208142
# But we don't support that in the bindgen yet.
81218143
# index-semantics: true
81228144
type: list
8145+
slua-deprecated:
8146+
use: lljson.decode
8147+
reason: Also, the indices are zero-based.
81238148
energy: 10.0
81248149
func-id: 511
81258150
pure: true
@@ -8140,6 +8165,9 @@ functions:
81408165
- Value:
81418166
tooltip: ''
81428167
type: string
8168+
slua-deprecated:
8169+
use: lljson.encode
8170+
reason: Also, the indices are zero-based.
81438171
energy: 10.0
81448172
func-id: 510
81458173
pure: true
@@ -8158,6 +8186,8 @@ functions:
81588186
# But we don't support that in the bindgen yet.
81598187
# index-semantics: true
81608188
type: list
8189+
slua-deprecated:
8190+
reason: Use 'lljson.decode' and 'typeof' instead. Also, the indices are zero-based.
81618191
energy: 10.0
81628192
func-id: 512
81638193
pure: true
@@ -8572,6 +8602,9 @@ functions:
85728602
- Values:
85738603
tooltip: List of values to convert.
85748604
type: list
8605+
slua-deprecated:
8606+
use: lljson.encode
8607+
selene-replace: ["lljson.encode(%2)"]
85758608
energy: 10.0
85768609
func-id: 514
85778610
pure: true

lsl_definitions/lsl.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class LSLConstant(NamedTuple):
146146
"""
147147
tooltip: str
148148
deprecated: Deprecated | None
149+
slua_deprecated: Deprecated | None
149150
private: bool
150151
"""Whether this should this be included in the syntax file"""
151152

@@ -204,7 +205,7 @@ def to_slua_dict(self, slua: "SLuaDefinitions") -> dict:
204205
try:
205206
return remove_worthless(
206207
{
207-
"deprecated": self.deprecated is not None,
208+
"deprecated": (self.deprecated or self.slua_deprecated) is not None,
208209
# Will always use a <string> node, but that's fine for our purposes.
209210
# That's already the case for vector and hex int constants, anyway.
210211
"tooltip": self.tooltip,
@@ -648,6 +649,7 @@ def _handle_constant(self, const_name: str, const_data: dict) -> LSLConstant:
648649
tooltip=const_data.get("tooltip", ""),
649650
private=const_data.get("private", False),
650651
deprecated=Deprecated.from_definition(const_data.get("deprecated", False)),
652+
slua_deprecated=Deprecated.from_definition(const_data.get("slua-deprecated", False)),
651653
)
652654
if const.type not in {"float", "integer", "string", "vector", "rotation"}:
653655
raise ValueError(f"Invalid constant type {const.type}")

0 commit comments

Comments
 (0)