|
44 | 44 | #define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB"
|
45 | 45 | #define RUSTG_JOB_ERROR "JOB PANICKED"
|
46 | 46 |
|
| 47 | +#define rustg_dmi_strip_metadata(fname) call_ext(RUST_G, "dmi_strip_metadata")(fname) |
| 48 | +#define rustg_dmi_create_png(path, width, height, data) call_ext(RUST_G, "dmi_create_png")(path, width, height, data) |
| 49 | + |
| 50 | +#define rustg_noise_get_at_coordinates(seed, x, y) call_ext(RUST_G, "noise_get_at_coordinates")(seed, x, y) |
| 51 | + |
47 | 52 | #define rustg_git_revparse(rev) call_ext(RUST_G, "rg_git_revparse")(rev)
|
48 | 53 | #define rustg_git_commit_date(rev) call_ext(RUST_G, "rg_git_commit_date")(rev)
|
49 | 54 |
|
|
66 | 71 | #define rustg_sql_connected(handle) call_ext(RUST_G, "sql_connected")(handle)
|
67 | 72 | #define rustg_sql_disconnect_pool(handle) call_ext(RUST_G, "sql_disconnect_pool")(handle)
|
68 | 73 | #define rustg_sql_check_query(job_id) call_ext(RUST_G, "sql_check_query")("[job_id]")
|
69 |
| - |
70 |
| -/** |
71 |
| - * Sets up the Aho-Corasick automaton with its default options. |
72 |
| - * |
73 |
| - * The search patterns list and the replacements must be of the same length when replace is run, but an empty replacements list is allowed if replacements are supplied with the replace call |
74 |
| - * Arguments: |
75 |
| - * * key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls |
76 |
| - * * patterns - A non-associative list of strings to search for |
77 |
| - * * replacements - Default replacements for this automaton, used with rustg_acreplace |
78 |
| - */ |
79 |
| -#define rustg_setup_acreplace(key, patterns, replacements) call_ext(RUST_G, "setup_acreplace")(key, json_encode(patterns), json_encode(replacements)) |
80 |
| - |
81 |
| -/** |
82 |
| - * Sets up the Aho-Corasick automaton using supplied options. |
83 |
| - * |
84 |
| - * The search patterns list and the replacements must be of the same length when replace is run, but an empty replacements list is allowed if replacements are supplied with the replace call |
85 |
| - * Arguments: |
86 |
| - * * key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls |
87 |
| - * * options - An associative list like list("anchored" = 0, "ascii_case_insensitive" = 0, "match_kind" = "Standard"). The values shown on the example are the defaults, and default values may be omitted. See the identically named methods at https://docs.rs/aho-corasick/latest/aho_corasick/struct.AhoCorasickBuilder.html to see what the options do. |
88 |
| - * * patterns - A non-associative list of strings to search for |
89 |
| - * * replacements - Default replacements for this automaton, used with rustg_acreplace |
90 |
| - */ |
91 |
| -#define rustg_setup_acreplace_with_options(key, options, patterns, replacements) call_ext(RUST_G, "setup_acreplace")(key, json_encode(options), json_encode(patterns), json_encode(replacements)) |
92 |
| - |
93 |
| -/** |
94 |
| - * Run the specified replacement engine with the provided haystack text to replace, returning replaced text. |
95 |
| - * |
96 |
| - * Arguments: |
97 |
| - * * key - The key for the automaton |
98 |
| - * * text - Text to run replacements on |
99 |
| - */ |
100 |
| -#define rustg_acreplace(key, text) call_ext(RUST_G, "acreplace")(key, text) |
101 |
| - |
102 |
| -/** |
103 |
| - * Run the specified replacement engine with the provided haystack text to replace, returning replaced text. |
104 |
| - * |
105 |
| - * Arguments: |
106 |
| - * * key - The key for the automaton |
107 |
| - * * text - Text to run replacements on |
108 |
| - * * replacements - Replacements for this call. Must be the same length as the set-up patterns |
109 |
| - */ |
110 |
| -#define rustg_acreplace_with_replacements(key, text, replacements) call_ext(RUST_G, "acreplace_with_replacements")(key, text, json_encode(replacements)) |
111 |
| - |
112 |
| -/** |
113 |
| - * This proc generates a cellular automata noise grid which can be used in procedural generation methods. |
114 |
| - * |
115 |
| - * Returns a single string that goes row by row, with values of 1 representing an alive cell, and a value of 0 representing a dead cell. |
116 |
| - * |
117 |
| - * Arguments: |
118 |
| - * * percentage: The chance of a turf starting closed |
119 |
| - * * smoothing_iterations: The amount of iterations the cellular automata simulates before returning the results |
120 |
| - * * birth_limit: If the number of neighboring cells is higher than this amount, a cell is born |
121 |
| - * * death_limit: If the number of neighboring cells is lower than this amount, a cell dies |
122 |
| - * * width: The width of the grid. |
123 |
| - * * height: The height of the grid. |
124 |
| - */ |
125 |
| -#define rustg_cnoise_generate(percentage, smoothing_iterations, birth_limit, death_limit, width, height) call_ext(RUST_G, "cnoise_generate")(percentage, smoothing_iterations, birth_limit, death_limit, width, height) |
126 |
| - |
127 |
| -/** |
128 |
| - * This proc generates a grid of perlin-like noise |
129 |
| - * |
130 |
| - * Returns a single string that goes row by row, with values of 1 representing an turned on cell, and a value of 0 representing a turned off cell. |
131 |
| - * |
132 |
| - * Arguments: |
133 |
| - * * seed: seed for the function |
134 |
| - * * accuracy: how close this is to the original perlin noise, as accuracy approaches infinity, the noise becomes more and more perlin-like |
135 |
| - * * stamp_size: Size of a singular stamp used by the algorithm, think of this as the same stuff as frequency in perlin noise |
136 |
| - * * world_size: size of the returned grid. |
137 |
| - * * lower_range: lower bound of values selected for. (inclusive) |
138 |
| - * * upper_range: upper bound of values selected for. (exclusive) |
139 |
| - */ |
140 |
| -#define rustg_dbp_generate(seed, accuracy, stamp_size, world_size, lower_range, upper_range) call_ext(RUST_G, "dbp_generate")(seed, accuracy, stamp_size, world_size, lower_range, upper_range) |
141 |
| - |
142 |
| -#define rustg_dmi_strip_metadata(fname) call_ext(RUST_G, "dmi_strip_metadata")(fname) |
143 |
| -#define rustg_dmi_create_png(path, width, height, data) call_ext(RUST_G, "dmi_create_png")(path, width, height, data) |
144 |
| -#define rustg_dmi_resize_png(path, width, height, resizetype) call_ext(RUST_G, "dmi_resize_png")(path, width, height, resizetype) |
145 |
| -/** |
146 |
| - * input: must be a path, not an /icon; you have to do your own handling if it is one, as icon objects can't be directly passed to rustg. |
147 |
| - * |
148 |
| - * output: json_encode'd list. json_decode to get a flat list with icon states in the order they're in inside the .dmi |
149 |
| - */ |
150 |
| -#define rustg_dmi_icon_states(fname) call_ext(RUST_G, "dmi_icon_states")(fname) |
151 |
| - |
152 |
| -#define rustg_file_read(fname) call_ext(RUST_G, "file_read")(fname) |
153 |
| -#define rustg_file_exists(fname) (call_ext(RUST_G, "file_exists")(fname) == "true") |
154 |
| -#define rustg_file_write(text, fname) call_ext(RUST_G, "file_write")(text, fname) |
155 |
| -#define rustg_file_append(text, fname) call_ext(RUST_G, "file_append")(text, fname) |
156 |
| -#define rustg_file_get_line_count(fname) text2num(call_ext(RUST_G, "file_get_line_count")(fname)) |
157 |
| -#define rustg_file_seek_line(fname, line) call_ext(RUST_G, "file_seek_line")(fname, "[line]") |
158 |
| - |
159 |
| -#ifdef RUSTG_OVERRIDE_BUILTINS |
160 |
| - #define file2text(fname) rustg_file_read("[fname]") |
161 |
| - #define text2file(text, fname) rustg_file_append(text, "[fname]") |
162 |
| -#endif |
163 |
| - |
164 |
| -/** |
165 |
| - * Returns the formatted datetime string of HEAD using the provided format. |
166 |
| - * Defaults to returning %F which is YYYY-MM-DD. |
167 |
| - * This is different to rustg_git_commit_date because it only needs the logs directory. |
168 |
| - */ |
169 |
| -/proc/rustg_git_commit_date_head(format = "%F") |
170 |
| - return call_ext(RUST_G, "rg_git_commit_date_head")(format) |
171 |
| - |
172 |
| -#define rustg_json_is_valid(text) (call_ext(RUST_G, "json_is_valid")(text) == "true") |
173 |
| - |
174 |
| -#define rustg_noise_get_at_coordinates(seed, x, y) call_ext(RUST_G, "noise_get_at_coordinates")(seed, x, y) |
175 |
| - |
176 |
| -/** |
177 |
| - * Generates a 2D poisson disk distribution ('blue noise'), which is relatively uniform. |
178 |
| - * |
179 |
| - * params: |
180 |
| - * `seed`: str |
181 |
| - * `width`: int, width of the noisemap (see world.maxx) |
182 |
| - * `length`: int, height of the noisemap (see world.maxy) |
183 |
| - * `radius`: int, distance between points on the noisemap |
184 |
| - * |
185 |
| - * returns: |
186 |
| - * a width*length length string of 1s and 0s representing a 2D poisson sample collapsed into a 1D string |
187 |
| - */ |
188 |
| -#define rustg_noise_poisson_map(seed, width, length, radius) call_ext(RUST_G, "noise_poisson_map")(seed, width, length, radius) |
189 |
| - |
190 |
| -/* |
191 |
| - * Takes in a string and json_encode()"d lists to produce a sanitized string. |
192 |
| - * This function operates on whitelists, there is currently no way to blacklist. |
193 |
| - * Args: |
194 |
| - * * text: the string to sanitize. |
195 |
| - * * attribute_whitelist_json: a json_encode()'d list of HTML attributes to allow in the final string. |
196 |
| - * * tag_whitelist_json: a json_encode()'d list of HTML tags to allow in the final string. |
197 |
| - */ |
198 |
| -#define rustg_sanitize_html(text, attribute_whitelist_json, tag_whitelist_json) call_ext(RUST_G, "sanitize_html")(text, attribute_whitelist_json, tag_whitelist_json) |
199 |
| - |
200 |
| -#define rustg_time_microseconds(id) text2num(call_ext(RUST_G, "time_microseconds")(id)) |
201 |
| -#define rustg_time_milliseconds(id) text2num(call_ext(RUST_G, "time_milliseconds")(id)) |
202 |
| -#define rustg_time_reset(id) call_ext(RUST_G, "time_reset")(id) |
203 |
| - |
204 |
| -/// Returns the timestamp as a string |
205 |
| -/proc/rustg_unix_timestamp() |
206 |
| - return call_ext(RUST_G, "unix_timestamp")() |
207 |
| - |
208 |
| -#define rustg_raw_read_toml_file(path) json_decode(call_ext(RUST_G, "toml_file_to_json")(path) || "null") |
209 |
| - |
210 |
| -/proc/rustg_read_toml_file(path) |
211 |
| - var/list/output = rustg_raw_read_toml_file(path) |
212 |
| - if (output["success"]) |
213 |
| - return json_decode(output["content"]) |
214 |
| - else |
215 |
| - CRASH(output["content"]) |
216 |
| - |
217 |
| -#define rustg_raw_toml_encode(value) json_decode(call_ext(RUST_G, "toml_encode")(json_encode(value))) |
218 |
| - |
219 |
| -/proc/rustg_toml_encode(value) |
220 |
| - var/list/output = rustg_raw_toml_encode(value) |
221 |
| - if (output["success"]) |
222 |
| - return output["content"] |
223 |
| - else |
224 |
| - CRASH(output["content"]) |
225 |
| - |
226 |
| -#define rustg_url_encode(text) call_ext(RUST_G, "url_encode")("[text]") |
227 |
| -#define rustg_url_decode(text) call_ext(RUST_G, "url_decode")(text) |
228 |
| - |
229 |
| -#ifdef RUSTG_OVERRIDE_BUILTINS |
230 |
| - #define url_encode(text) rustg_url_encode(text) |
231 |
| - #define url_decode(text) rustg_url_decode(text) |
232 |
| -#endif |
0 commit comments