Skip to content

Commit a66faad

Browse files
authored
refactor: moved javascript_language.cpp and split it to multiple files (#210)
1 parent dc3a52b commit a66faad

33 files changed

+640
-466
lines changed

.github/workflows/static_checks.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Checkout workaround
3232
run: |
3333
mv tmp/misc/scripts misc/scripts
34-
cp misc/formatting/clang_format.sh misc/scripts/clang_format.sh
34+
cp clang_format.sh misc/scripts/clang_format.sh
3535
3636
- name: Install APT dependencies
3737
uses: awalsh128/cache-apt-pkgs-action@latest
@@ -62,10 +62,6 @@ jobs:
6262
run: |
6363
bash ./misc/scripts/file_format.sh changed.txt
6464
65-
- name: Header guards formatting checks (header_guards.sh)
66-
run: |
67-
bash ./misc/scripts/header_guards.sh changed.txt
68-
6965
- name: Python scripts static analysis (mypy_check.sh)
7066
run: |
7167
if grep -qE '\.py$|SConstruct|SCsub' changed.txt || [ -z "$(cat changed.txt)" ]; then

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
- ``.github``: Runs custom CI/CD in GitHub
2121
- ``docs``: Add some additional stuff for README.md
2222
- ``src``: Contains custom C++ code
23+
- [language](src/language/README.md)
2324

2425

2526
## Preparing your PR
2627

2728
The project is using [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) to format C++ files.
28-
You need to run `bash ./misc/formatting/clang_format.sh` before your PR for a successful pipeline.
29+
You need to run `bash clang_format.sh` before your PR for a successful pipeline.
2930

3031
Furthermore, there is an `utf-8` and `LF` checker to fix file formats. Additionally, some spellchecks run inside the [pipeline](.github/workflows/static_checks.yml).
3132

SCsub

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,24 @@ if env["tests"]:
6969

7070
sources = [
7171
"register_types.cpp",
72-
"javascript_language.cpp",
7372
"javascript_instance.cpp",
7473
"javascript.cpp",
7574
]
7675

7776
# Add all required files for "Javascript" language into godot
7877
env_javascript.Append(CPPPATH=["#modules/javascript"])
7978
env_javascript.add_source_files(env.modules_sources, sources)
79+
env_javascript.add_source_files(env.modules_sources, "src/language/*.cpp")
80+
env_javascript.add_source_files(env.modules_sources, "src/language/templates/*.cpp")
81+
82+
# --- Generate template files ---
83+
from misc.generate.templates import get_templates_header
84+
from misc.generate.templates import get_templates_files
85+
from misc.generate.generate_files import generate_templates
86+
87+
files = get_templates_files()
88+
generate_templates(javascript_dir, get_templates_header(), files)
89+
env_javascript.add_source_files(env.modules_sources, files.keys())
8090

8191
# --- Generate binding files ---
8292
# Binding script to run at engine initializing
File renamed without changes.

editor/editor_tools.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "editor/editor_help.h"
99
#include "editor/filesystem_dock.h"
1010

11-
#include "../javascript_language.h"
11+
#include "../src/language/javascript_language.h"
1212

1313
#define TS_IGNORE "//@ts-ignore\n"
1414
static HashMap<String, HashSet<String>> ts_ignore_errors;

javascript.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
/* After loading it contains the code/bytecode of the loaded file. */
33

44
#include "javascript.h"
5-
#include "core/config/engine.h"
65
#include "core/io/file_access_encrypted.h"
76
#include "javascript_instance.h"
8-
#include "javascript_language.h"
97
#include "scene/resources/resource_format_text.h"
8+
#include "src/language/javascript_language.h"
109

1110
ScriptLanguage *JavaScript::get_language() const {
1211
return JavaScriptLanguage::get_singleton();

javascript.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
#include "javascript_binder.h"
1111

12+
#define EXT_NAME "JavaScript"
1213
#define EXT_JSCLASS "mjs"
14+
#define EXT_TSCLASS "ts"
1315
#define EXT_JSMODULE "js"
1416
#define EXT_JSON "json"
1517

javascript_instance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "javascript_instance.h"
22
#include "javascript.h"
3-
#include "javascript_language.h"
3+
#include "src/language/javascript_language.h"
44

55
Ref<Script> JavaScriptInstance::get_script() const {
66
return script;

0 commit comments

Comments
 (0)