Skip to content

Commit

Permalink
refactor: moved javascript_language.cpp and split it to multiple files (
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerget authored Sep 24, 2024
1 parent dc3a52b commit a66faad
Show file tree
Hide file tree
Showing 33 changed files with 640 additions and 466 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Checkout workaround
run: |
mv tmp/misc/scripts misc/scripts
cp misc/formatting/clang_format.sh misc/scripts/clang_format.sh
cp clang_format.sh misc/scripts/clang_format.sh
- name: Install APT dependencies
uses: awalsh128/cache-apt-pkgs-action@latest
Expand Down Expand Up @@ -62,10 +62,6 @@ jobs:
run: |
bash ./misc/scripts/file_format.sh changed.txt
- name: Header guards formatting checks (header_guards.sh)
run: |
bash ./misc/scripts/header_guards.sh changed.txt
- name: Python scripts static analysis (mypy_check.sh)
run: |
if grep -qE '\.py$|SConstruct|SCsub' changed.txt || [ -z "$(cat changed.txt)" ]; then
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
- ``.github``: Runs custom CI/CD in GitHub
- ``docs``: Add some additional stuff for README.md
- ``src``: Contains custom C++ code
- [language](src/language/README.md)


## Preparing your PR

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

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).

Expand Down
12 changes: 11 additions & 1 deletion SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,24 @@ if env["tests"]:

sources = [
"register_types.cpp",
"javascript_language.cpp",
"javascript_instance.cpp",
"javascript.cpp",
]

# Add all required files for "Javascript" language into godot
env_javascript.Append(CPPPATH=["#modules/javascript"])
env_javascript.add_source_files(env.modules_sources, sources)
env_javascript.add_source_files(env.modules_sources, "src/language/*.cpp")
env_javascript.add_source_files(env.modules_sources, "src/language/templates/*.cpp")

# --- Generate template files ---
from misc.generate.templates import get_templates_header
from misc.generate.templates import get_templates_files
from misc.generate.generate_files import generate_templates

files = get_templates_files()
generate_templates(javascript_dir, get_templates_header(), files)
env_javascript.add_source_files(env.modules_sources, files.keys())

# --- Generate binding files ---
# Binding script to run at engine initializing
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion editor/editor_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "editor/editor_help.h"
#include "editor/filesystem_dock.h"

#include "../javascript_language.h"
#include "../src/language/javascript_language.h"

#define TS_IGNORE "//@ts-ignore\n"
static HashMap<String, HashSet<String>> ts_ignore_errors;
Expand Down
3 changes: 1 addition & 2 deletions javascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
/* After loading it contains the code/bytecode of the loaded file. */

#include "javascript.h"
#include "core/config/engine.h"
#include "core/io/file_access_encrypted.h"
#include "javascript_instance.h"
#include "javascript_language.h"
#include "scene/resources/resource_format_text.h"
#include "src/language/javascript_language.h"

ScriptLanguage *JavaScript::get_language() const {
return JavaScriptLanguage::get_singleton();
Expand Down
2 changes: 2 additions & 0 deletions javascript.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

#include "javascript_binder.h"

#define EXT_NAME "JavaScript"
#define EXT_JSCLASS "mjs"
#define EXT_TSCLASS "ts"
#define EXT_JSMODULE "js"
#define EXT_JSON "json"

Expand Down
2 changes: 1 addition & 1 deletion javascript_instance.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "javascript_instance.h"
#include "javascript.h"
#include "javascript_language.h"
#include "src/language/javascript_language.h"

Ref<Script> JavaScriptInstance::get_script() const {
return script;
Expand Down
Loading

0 comments on commit a66faad

Please sign in to comment.