New upstream snapshot.
Debian Janitor
1 year, 4 months ago
0 | # These are supported funding model platforms | |
1 | ||
2 | github: alemart # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | |
3 | patreon: # Replace with a single Patreon username | |
4 | open_collective: # Replace with a single Open Collective username | |
5 | ko_fi: # Replace with a single Ko-fi username | |
6 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | |
7 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | |
8 | liberapay: # Replace with a single Liberapay username | |
9 | issuehunt: # Replace with a single IssueHunt username | |
10 | otechie: # Replace with a single Otechie username | |
11 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
0 | # Specifies intentionally untracked files to ignore when using Git | |
1 | # http://git-scm.com/docs/gitignore | |
2 | ||
3 | # vscode | |
4 | .vscode | |
5 | .vscode/* | |
6 | !.vscode/settings.json | |
7 | !.vscode/tasks.json | |
8 | !.vscode/launch.json | |
9 | !.vscode/extensions.json | |
10 | ||
11 | # msvc | |
12 | .vs/ | |
13 | out/ | |
14 | CMakeSettings.json | |
15 | ||
16 | # vim | |
17 | # swap | |
18 | [._]*.s[a-v][a-z] | |
19 | [._]*.sw[a-p] | |
20 | [._]s[a-v][a-z] | |
21 | [._]sw[a-p] | |
22 | # session | |
23 | Session.vim | |
24 | # temporary | |
25 | .netrwhist | |
26 | *~ | |
27 | ||
28 | # mine | |
29 | docs_html/ | |
30 | build/ | |
31 | private/ | |
32 | CMakeFiles/ | |
33 | !src/** |
0 | 0 | # Release Notes |
1 | ||
2 | ## 0.5.6.1 - September 22nd, 2022 | |
3 | ||
4 | * Tweaks to the build system | |
1 | 5 | |
2 | 6 | ## 0.5.6 - September 1st, 2022 |
3 | 7 |
7 | 7 | cmake_minimum_required(VERSION 3.2) |
8 | 8 | project( |
9 | 9 | surgescript |
10 | VERSION 0.5.6 | |
10 | VERSION 0.5.7 | |
11 | 11 | LANGUAGES C |
12 | 12 | ) |
13 | 13 | include(GNUInstallDirs) |
130 | 130 | generate_file("misc/info.c") |
131 | 131 | generate_file("util/version.h") |
132 | 132 | |
133 | # Use relative paths in __FILE__ | |
134 | function(drop_compilation_paths TARGET) | |
135 | if(NOT MSVC) | |
136 | target_compile_options(${TARGET} PUBLIC "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.") | |
137 | endif() | |
138 | endfunction() | |
139 | ||
133 | 140 | # Build the library |
134 | 141 | if(NOT WANT_SHARED AND NOT WANT_STATIC) |
135 | 142 | message(FATAL_ERROR "Options WANT_SHARED and WANT_STATIC are both set to OFF. Nothing to do.") |
144 | 151 | target_link_libraries(surgescript m) |
145 | 152 | endif() |
146 | 153 | set_target_properties(surgescript PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${LIB_SOVERSION}) |
147 | install(TARGETS surgescript DESTINATION "${CMAKE_INSTALL_LIBDIR}") | |
154 | drop_compilation_paths(surgescript) | |
148 | 155 | endif() |
149 | 156 | |
150 | 157 | if(WANT_STATIC) |
155 | 162 | target_link_libraries(surgescript-static m) |
156 | 163 | endif () |
157 | 164 | set_target_properties(surgescript-static PROPERTIES VERSION ${PROJECT_VERSION}) |
158 | install(TARGETS surgescript-static DESTINATION "${CMAKE_INSTALL_LIBDIR}") | |
159 | endif() | |
160 | ||
161 | # Install headers | |
165 | drop_compilation_paths(surgescript-static) | |
166 | endif() | |
167 | ||
168 | # Install the headers | |
162 | 169 | install(DIRECTORY src/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h") |
163 | 170 | install(DIRECTORY "${CMAKE_BINARY_DIR}/src/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" FILES_MATCHING PATTERN "*.h") |
171 | ||
172 | # Install the library | |
173 | if(WANT_SHARED) | |
174 | install(TARGETS surgescript DESTINATION "${CMAKE_INSTALL_LIBDIR}") | |
175 | endif() | |
176 | ||
177 | if(WANT_STATIC) | |
178 | install(TARGETS surgescript-static DESTINATION "${CMAKE_INSTALL_LIBDIR}") | |
179 | endif() | |
164 | 180 | |
165 | 181 | # Build the SurgeScript CLI |
166 | 182 | if(WANT_EXECUTABLE) |
176 | 192 | set(LIBTHREAD "") |
177 | 193 | set(ENABLE_THREADS 0) |
178 | 194 | if(WANT_EXECUTABLE_MULTITHREAD) |
179 | message(STATUS "Will use multithreading on the SurgeScript CLI") | |
180 | ||
181 | # hmmmm... | |
182 | set(LIBTHREAD "pthread") | |
183 | set(ENABLE_THREADS 1) | |
195 | ||
196 | # Header search | |
197 | find_path(THREADS_H NAMES "threads.h" PATHS "${CMAKE_INCLUDE_PATH}") | |
198 | if(NOT THREADS_H) | |
199 | message(WARNING "Can't find threads.h. Will not use multithreading on the SurgeScript CLI") | |
200 | else() | |
201 | message(STATUS "Will use multithreading on the SurgeScript CLI") | |
202 | set(ENABLE_THREADS 1) | |
203 | ||
204 | # hmmmm... | |
205 | set(LIBTHREAD "pthread") | |
206 | endif() | |
207 | ||
184 | 208 | endif() |
185 | 209 | |
186 | 210 | # Create the executable |
190 | 214 | target_link_libraries(surgescript.bin ${LIBSURGESCRIPT} ${LIBTHREAD}) |
191 | 215 | target_include_directories(surgescript.bin PRIVATE src) |
192 | 216 | set_target_properties(surgescript.bin PROPERTIES OUTPUT_NAME surgescript) |
217 | drop_compilation_paths(surgescript.bin) | |
193 | 218 | |
194 | 219 | # WebAssembly |
195 | 220 | if(EMSCRIPTEN) |
0 | surgescript (0.5.6-1) UNRELEASED; urgency=low | |
0 | surgescript (0.5.6.1+git20221022.1.eec5a3d-1) UNRELEASED; urgency=low | |
1 | 1 | |
2 | 2 | * New upstream release. |
3 | * New upstream snapshot. | |
3 | 4 | |
4 | -- Debian Janitor <janitor@jelmer.uk> Thu, 08 Sep 2022 11:22:06 -0000 | |
5 | -- Debian Janitor <janitor@jelmer.uk> Mon, 19 Dec 2022 10:08:55 -0000 | |
5 | 6 | |
6 | 7 | surgescript (0.5.4.4-1) unstable; urgency=medium |
7 | 8 |
0 | 0 | // |
1 | 1 | // package.ss |
2 | 2 | // Package example |
3 | // Copyright 2018, 2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | // Copyright 2018-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | // |
5 | 5 | |
6 | 6 | // import the package |
0 | 0 | // |
1 | 1 | // unit_testing.ss |
2 | 2 | // A Unit Testing Script for SurgeScript |
3 | // Copyright (C) 2017-2020 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | // Copyright 2017-2020 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | // |
5 | 5 | |
6 | 6 | object "Application" |
2 | 2 | site_author: 'Alexandre Martins' |
3 | 3 | site_description: 'SurgeScript is a scripting language for games.' |
4 | 4 | site_dir: 'docs_html/' |
5 | copyright: 'SurgeScript is a scripting language for games. Copyright © 2016-2021 Alexandre Martins.' | |
5 | copyright: 'SurgeScript is a scripting language for games. Copyright © 2016-2022 Alexandre Martins.' | |
6 | 6 | google_analytics: ['UA-120511928-1', 'opensurge2d.org'] |
7 | 7 | repo_url: 'https://github.com/alemart/surgescript' |
8 | 8 | strict: false |
19 | 19 | */ |
20 | 20 | |
21 | 21 | #include <surgescript.h> |
22 | #include <locale.h> | |
22 | 23 | #include <string.h> |
23 | 24 | #include <stdio.h> |
24 | 25 | |
51 | 52 | int main(int argc, char* argv[]) |
52 | 53 | { |
53 | 54 | uint64_t time_limit = DEFAULT_TIME_LIMIT; |
55 | ||
56 | /* SurgeScript uses UTF-8 */ | |
57 | setlocale(LC_ALL, "en_US.UTF-8"); | |
54 | 58 | |
55 | 59 | /* Create the VM and compile the input file(s) */ |
56 | 60 | surgescript_vm_t* vm = make_vm(argc, argv, &time_limit); |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
22 | 22 | #include <stdlib.h> |
23 | 23 | #include <string.h> |
24 | 24 | #include <locale.h> |
25 | #include <errno.h> | |
26 | 25 | #include <ctype.h> |
27 | 26 | #include "parser.h" |
28 | 27 | #include "lexer.h" |
182 | 181 | return ssfree(parser); |
183 | 182 | } |
184 | 183 | |
184 | ||
185 | 185 | /* |
186 | * surgescript_parser_parsefile() | |
187 | * Parse a script file; returns false on error | |
186 | * surgescript_parser_parse() | |
187 | * Parse a script stored in memory | |
188 | * You may pass NULL to the (optional) filename if the script doesn't belong to a (possibly virtual) file | |
188 | 189 | */ |
189 | bool surgescript_parser_parsefile(surgescript_parser_t* parser, const char* absolute_path) | |
190 | { | |
191 | FILE* fp = surgescript_util_fopen_utf8(absolute_path, "rb"); /* use binary mode, so offsets don't get messed up */ | |
192 | if(fp) { | |
193 | const size_t BUFSIZE = 1024; | |
194 | char* data = NULL; | |
195 | size_t read_chars = 0, data_size = 0; | |
196 | ||
197 | /* read file to data[] */ | |
198 | sslog("Reading file %s...", absolute_path); | |
199 | do { | |
200 | data_size += BUFSIZE; | |
201 | data = ssrealloc(data, data_size + 1); | |
202 | read_chars += fread(data + read_chars, sizeof(char), BUFSIZE, fp); | |
203 | data[read_chars] = '\0'; | |
204 | } while(read_chars == data_size); | |
205 | fclose(fp); | |
206 | ||
207 | /* parse it */ | |
208 | ssfree(parser->filename); | |
209 | parser->filename = ssstrdup(surgescript_util_basename(absolute_path)); | |
210 | surgescript_lexer_set(parser->lexer, data); | |
211 | parse(parser); | |
212 | ||
213 | /* done! */ | |
214 | ssfree(data); | |
215 | return true; | |
216 | } | |
217 | else { | |
218 | ssfatal("Parse Error: can't read file \"%s\": %s", absolute_path, strerror(errno)); | |
219 | return false; | |
220 | } | |
221 | } | |
222 | ||
223 | /* | |
224 | * surgescript_parser_parsemem() | |
225 | * Parse a script stored in memory | |
226 | */ | |
227 | bool surgescript_parser_parsemem(surgescript_parser_t* parser, const char* code_in_memory) | |
190 | bool surgescript_parser_parse(surgescript_parser_t* parser, const char* code_in_memory, const char* filename) | |
228 | 191 | { |
229 | 192 | ssfree(parser->filename); |
230 | parser->filename = ssstrdup("<memory>"); | |
193 | parser->filename = ssstrdup(filename != NULL ? filename : "<memory>"); | |
231 | 194 | surgescript_lexer_set(parser->lexer, code_in_memory); |
232 | 195 | parse(parser); |
233 | 196 | return true; |
234 | 197 | } |
198 | ||
199 | ||
235 | 200 | |
236 | 201 | /* |
237 | 202 | * surgescript_parser_filename() |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
148 | 148 | surgescript_parser_t* surgescript_parser_destroy(surgescript_parser_t* parser); |
149 | 149 | |
150 | 150 | /* operations */ |
151 | bool surgescript_parser_parsefile(surgescript_parser_t* parser, const char* absolute_path); /* parse a script file */ | |
152 | bool surgescript_parser_parsemem(surgescript_parser_t* parser, const char* code_in_memory); /* parse a script (in memory) */ | |
151 | bool surgescript_parser_parse(surgescript_parser_t* parser, const char* code_in_memory, const char* filename); /* parse a script in memory with an optional filename */ | |
153 | 152 | void surgescript_parser_foreach_plugin(surgescript_parser_t* parser, void* data, void (*fun)(const char*,void*)); /* foreach plugin object found in any parsed script, run fun(object_name, data) */ |
154 | 153 | void surgescript_parser_set_flags(surgescript_parser_t* parser, surgescript_parser_flags_t flags); /* set parser options (flags) */ |
155 | 154 | surgescript_parser_flags_t surgescript_parser_get_flags(surgescript_parser_t* parser); /* get parser flags */ |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
340 | 340 | |
341 | 341 | /* generate the bytecode to access the plugin */ |
342 | 342 | surgescript_program_add_line(program, SSOP_MOVO, SSOPu(0), SSOPu(plugin_object)); |
343 | while(next = strchr(tok, '.')) { | |
343 | while((next = strchr(tok, '.')) != NULL) { | |
344 | 344 | *next = 0; |
345 | 345 | surgescript_program_add_line(program, SSOP_PUSH, SSOPu(0), SSOPu(0)); |
346 | 346 | surgescript_program_add_line(program, SSOP_CALL, SSOPu( |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | #!/bin/bash |
1 | 1 | # This utility packs the Windows build of SurgeScript |
2 | # Copyright 2016-2021 Alexandre Martins | |
3 | 2 | |
4 | 3 | UNIX2DOS="todos" #"unix2dos" |
5 | 4 | SOURCE_FOLDER="../../.." |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019, 2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018, 2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018, 2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018, 2020 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2020 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2020 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019, 2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019, 2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018, 2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
18 | 18 | * SurgeScript Virtual Machine - Runtime Engine |
19 | 19 | */ |
20 | 20 | |
21 | #include <locale.h> | |
21 | #include <string.h> | |
22 | #include <errno.h> | |
22 | 23 | #include <time.h> |
23 | 24 | #include "vm.h" |
24 | 25 | #include "stack.h" |
142 | 143 | */ |
143 | 144 | bool surgescript_vm_compile(surgescript_vm_t* vm, const char* absolute_path) |
144 | 145 | { |
145 | return surgescript_parser_parsefile(vm->parser, absolute_path); | |
146 | const size_t BUFSIZE = 1024; | |
147 | size_t read_chars = 0, data_size = 0; | |
148 | char* data = NULL; | |
149 | ||
150 | /* open the file in binary mode, so that offsets don't get messed up */ | |
151 | FILE* fp = surgescript_util_fopen_utf8(absolute_path, "rb"); | |
152 | if(!fp) { | |
153 | ssfatal("Can't read file \"%s\": %s", absolute_path, strerror(errno)); | |
154 | return false; | |
155 | } | |
156 | ||
157 | /* read file to data[] */ | |
158 | sslog("Reading file %s...", absolute_path); | |
159 | do { | |
160 | data_size += BUFSIZE * sizeof(char); | |
161 | data = ssrealloc(data, data_size + 1); | |
162 | read_chars += fread(data + read_chars, sizeof(char), BUFSIZE, fp); | |
163 | data[read_chars] = '\0'; | |
164 | } while(read_chars == data_size); | |
165 | fclose(fp); | |
166 | ||
167 | /* parse it */ | |
168 | bool success = surgescript_parser_parse(vm->parser, data, absolute_path); | |
169 | ||
170 | /* done! */ | |
171 | ssfree(data); | |
172 | return success; | |
146 | 173 | } |
147 | 174 | |
148 | 175 | /* |
149 | 176 | * surgescript_vm_compile_code_in_memory() |
150 | * Compiles the given code, stored in memory | |
177 | * Compiles the given code stored in memory | |
151 | 178 | * Returns true on success; false otherwise |
152 | 179 | */ |
153 | 180 | bool surgescript_vm_compile_code_in_memory(surgescript_vm_t* vm, const char* code) |
154 | 181 | { |
155 | return surgescript_parser_parsemem(vm->parser, code); | |
182 | return surgescript_parser_parse(vm->parser, code, NULL); | |
183 | } | |
184 | ||
185 | /* | |
186 | * surgescript_vm_compile_virtual_file() | |
187 | * Compiles the given code stored in memory and specify a virtual filename or filepath | |
188 | * Returns true on success; false otherwise | |
189 | */ | |
190 | bool surgescript_vm_compile_virtual_file(surgescript_vm_t* vm, const char* code, const char* filename) | |
191 | { | |
192 | return surgescript_parser_parse(vm->parser, code, filename); | |
156 | 193 | } |
157 | 194 | |
158 | 195 | /* |
173 | 210 | /* Already launched? */ |
174 | 211 | if(surgescript_vm_is_active(vm)) |
175 | 212 | return; |
176 | ||
177 | /* SurgeScript uses UTF-8 */ | |
178 | setlocale(LC_ALL, "en_US.UTF-8"); | |
179 | 213 | |
180 | 214 | /* Setup the pseudo-number generator */ |
181 | 215 | surgescript_util_srand(time(NULL)); |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018, 2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
42 | 42 | /* SurgeScript Compiler */ |
43 | 43 | bool surgescript_vm_compile(surgescript_vm_t* vm, const char* absolute_path); /* compiles a file */ |
44 | 44 | bool surgescript_vm_compile_code_in_memory(surgescript_vm_t* vm, const char* code); /* compiles the given code */ |
45 | bool surgescript_vm_compile_virtual_file(surgescript_vm_t* vm, const char* code, const char* filename); /* compiles the given code specifying a virtual filename */ | |
45 | 46 | |
46 | 47 | /* VM lifecycle */ |
47 | 48 | bool surgescript_vm_is_active(surgescript_vm_t* vm); /* is the vm active? (i.e., turned on) */ |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2018 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2019 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
0 | 0 | /* |
1 | 1 | * SurgeScript |
2 | 2 | * A scripting language for games |
3 | * Copyright 2016-2021 Alexandre Martins <alemartf(at)gmail(dot)com> | |
3 | * Copyright 2016-2022 Alexandre Martins <alemartf(at)gmail(dot)com> | |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |