json.anubis
2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* Created by PyramIDE.
* User: フランスのトトロ
* Date: 12/12/2015
* Time: 21:48
* © Calexium
*/
read tools/basis.anubis
public define String
lib_error_to_string
(
LibraryError err
)=
if err is
{
cant_load_library then "Can't load library.",
symbol_not_found then "Symbol not found.",
external_call_failed then "External call failed.",
unknown_error then "Unknown error."
}.
public define String
to_JS_String
(
Library json_lib,
String unescaped_string
)=
if unescaped_string = "" then
"''"
else
if extension_library_call(json_lib, "to_JS_String", serialize(unescaped_string), length(unescaped_string)+30) is
{
error(err) then
println("Can't call to_JS_String");
println(" --> " + lib_error_to_string(err));
"''",
ok(ba) then to_string(ba)
}.
public define String
to_JSON_String
(
Library json_lib,
String unescaped_string
)=
if unescaped_string = "" then
"\"\""
else
if extension_library_call(json_lib, "to_JSON_String", serialize(unescaped_string), length(unescaped_string)+30) is
{
error(err) then
println("Can't call to_JSON_String");
println(" --> " + lib_error_to_string(err));
"\"\"",
ok(ba) then to_string(ba)
}.
public define String
to_CRLF_String
(
Library json_lib,
String unchecked_string
)=
if unchecked_string = "" then
""
else
if extension_library_call(json_lib, "to_CRLF_String", serialize(unchecked_string), length(unchecked_string)+300) is
{
error(err) then
println("Can't call to_CRLF_String");
println(" --> " + lib_error_to_string(err));
"\"\"",
ok(ba) then to_string(ba)
}.
public define ByteArray
to_CRLF_ByteArray
(
Library json_lib,
String unchecked_string
)=
if unchecked_string = "" then
to_byte_array("")
else
if extension_library_call(json_lib, "to_CRLF_String", serialize(unchecked_string), length(unchecked_string)+300) is
{
error(err) then
println("Can't call to_CRLF_String");
println(" --> " + lib_error_to_string(err));
to_byte_array(unchecked_string),
ok(ba) then ba
}.