Skip to content

Commit b290cc9

Browse files
committed
Separate Languages codes
1 parent 3f71a49 commit b290cc9

9 files changed

+138
-89
lines changed

register_types.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "register_types.h"
22

33
#include "weaver/jsb_script_language.h"
4+
#include "weaver/jsb_script_language_ts.h"
5+
#include "weaver/jsb_script_language_js.h"
46
#include "weaver/jsb_script.h"
57
#include "weaver/jsb_resource_loader.h"
68
#include "weaver/jsb_resource_saver.h"

weaver-editor/jsb_editor_pch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "../internal/jsb_settings.h"
1515

1616
#include "../weaver/jsb_script_language.h"
17+
#include "../weaver/jsb_script_language_ts.h"
1718

1819
#if GODOT_4_3_OR_NEWER
1920
# include "editor/plugins/editor_plugin.h"

weaver/jsb_script.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "jsb_script.h"
22
#include "jsb_script_language.h"
3+
#include "jsb_script_language_ts.h"
4+
#include "jsb_script_language_js.h"
35
#include "jsb_script_instance.h"
46
#include "../internal/jsb_path_util.h"
57

weaver/jsb_script_language.cpp

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -319,62 +319,3 @@ void GodotJSScriptLanguageBase::thread_exit()
319319
#endif
320320
}
321321

322-
// GodotJSScriptLanguage definitions
323-
324-
GodotJSScriptLanguage * GodotJSScriptLanguage::singleton_ = nullptr;
325-
326-
void GodotJSScriptLanguage::get_recognized_extensions(List<String>* p_extensions) const
327-
{
328-
p_extensions->push_back(JSB_TYPESCRIPT_EXT);
329-
}
330-
331-
GodotJSScriptBase* GodotJSScriptLanguage::create_godotjsscript() const
332-
{
333-
return memnew(GodotJSScript);
334-
}
335-
336-
bool GodotJSScriptLanguage::handles_global_class_type(const String& p_type) const
337-
{
338-
return p_type == jsb_typename(GodotJSScript);
339-
}
340-
341-
String GodotJSScriptLanguage::get_name() const
342-
{
343-
return jsb_typename(GodotJSScript);
344-
}
345-
346-
String GodotJSScriptLanguage::get_type() const
347-
{
348-
return jsb_typename(GodotJSScript);
349-
}
350-
351-
// GodotJavascriptLanguage definition
352-
353-
GodotJavascriptLanguage * GodotJavascriptLanguage::singleton_ = nullptr;
354-
355-
void GodotJavascriptLanguage::get_recognized_extensions(List<String>* p_extensions) const
356-
{
357-
p_extensions->push_back(JSB_JAVASCRIPT_EXT);
358-
}
359-
360-
GodotJSScriptBase* GodotJavascriptLanguage::create_godotjsscript() const
361-
{
362-
return memnew(GodotJavaScript);
363-
}
364-
365-
366-
bool GodotJavascriptLanguage::handles_global_class_type(const String& p_type) const
367-
{
368-
return p_type == jsb_typename(GodotJavaScript);
369-
}
370-
371-
String GodotJavascriptLanguage::get_name() const
372-
{
373-
return jsb_typename(GodotJavaScript);
374-
}
375-
376-
String GodotJavascriptLanguage::get_type() const
377-
{
378-
return jsb_typename(GodotJavaScript);
379-
}
380-

weaver/jsb_script_language.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -148,34 +148,4 @@ class GodotJSScriptLanguageBase : public ScriptLanguage
148148

149149
};
150150

151-
class GodotJSScriptLanguage : public GodotJSScriptLanguageBase {
152-
static GodotJSScriptLanguage * singleton_;
153-
public:
154-
static GodotJSScriptLanguage * get_singleton() { return singleton_; }
155-
static GodotJSScriptLanguage * create_singleton() { if (singleton_) return singleton_; return singleton_ = memnew(GodotJSScriptLanguage); }
156-
static void destroy_singleton() { if (singleton_) memdelete(singleton_); singleton_ = nullptr; }
157-
virtual String get_extension() const override { return JSB_TYPESCRIPT_EXT; }
158-
virtual GodotJSScriptBase* create_godotjsscript() const override;
159-
virtual void get_recognized_extensions(List<String>* p_extensions) const override;
160-
virtual bool handles_global_class_type(const String& p_type) const override;
161-
virtual String get_name() const override;
162-
virtual String get_type() const override;
163-
164-
};
165-
166-
class GodotJavascriptLanguage : public GodotJSScriptLanguageBase {
167-
static GodotJavascriptLanguage * singleton_;
168-
public:
169-
static GodotJavascriptLanguage * get_singleton() { return singleton_; }
170-
static GodotJavascriptLanguage * create_singleton() { if (singleton_) return singleton_; return singleton_ = memnew(GodotJavascriptLanguage); }
171-
static void destroy_singleton() { if (singleton_) memdelete(singleton_); singleton_ = nullptr; }
172-
virtual String get_extension() const override { return JSB_JAVASCRIPT_EXT; }
173-
virtual GodotJSScriptBase* create_godotjsscript() const override;
174-
virtual void get_recognized_extensions(List<String>* p_extensions) const override;
175-
virtual bool handles_global_class_type(const String& p_type) const override;
176-
virtual String get_name() const override;
177-
virtual String get_type() const override;
178-
179-
};
180-
181151
#endif

weaver/jsb_script_language_js.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include "jsb_script_language_js.h"
2+
3+
#include <iterator>
4+
5+
#include "../jsb_project_preset.h"
6+
#include "../internal/jsb_internal.h"
7+
#include "../bridge/jsb_worker.h"
8+
#include "../bridge/jsb_amd_module_loader.h"
9+
10+
#include "jsb_script.h"
11+
#include "editor/editor_settings.h"
12+
13+
#include "modules/regex/regex.h"
14+
15+
#ifdef TOOLS_ENABLED
16+
#include "../weaver-editor/templates/templates.gen.h"
17+
#endif
18+
19+
GodotJavascriptLanguage * GodotJavascriptLanguage::singleton_ = nullptr;
20+
21+
void GodotJavascriptLanguage::get_recognized_extensions(List<String>* p_extensions) const
22+
{
23+
p_extensions->push_back(JSB_JAVASCRIPT_EXT);
24+
}
25+
26+
GodotJSScriptBase* GodotJavascriptLanguage::create_godotjsscript() const
27+
{
28+
return memnew(GodotJavaScript);
29+
}
30+
31+
32+
bool GodotJavascriptLanguage::handles_global_class_type(const String& p_type) const
33+
{
34+
return p_type == jsb_typename(GodotJavaScript);
35+
}
36+
37+
String GodotJavascriptLanguage::get_name() const
38+
{
39+
return jsb_typename(GodotJavaScript);
40+
}
41+
42+
String GodotJavascriptLanguage::get_type() const
43+
{
44+
return jsb_typename(GodotJavaScript);
45+
}
46+

weaver/jsb_script_language_js.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef GODOTJS_SCRIPT_LANGUAGE_JS_H
2+
#define GODOTJS_SCRIPT_LANGUAGE_JS_H
3+
4+
#include "jsb_script_language.h"
5+
6+
class GodotJavascriptLanguage : public GodotJSScriptLanguageBase {
7+
static GodotJavascriptLanguage * singleton_;
8+
public:
9+
static GodotJavascriptLanguage * get_singleton() { return singleton_; }
10+
static GodotJavascriptLanguage * create_singleton() { if (singleton_) return singleton_; return singleton_ = memnew(GodotJavascriptLanguage); }
11+
static void destroy_singleton() { if (singleton_) memdelete(singleton_); singleton_ = nullptr; }
12+
virtual String get_extension() const override { return JSB_JAVASCRIPT_EXT; }
13+
virtual GodotJSScriptBase* create_godotjsscript() const override;
14+
virtual void get_recognized_extensions(List<String>* p_extensions) const override;
15+
virtual bool handles_global_class_type(const String& p_type) const override;
16+
virtual String get_name() const override;
17+
virtual String get_type() const override;
18+
19+
};
20+
21+
#endif

weaver/jsb_script_language_ts.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include "jsb_script_language_ts.h"
2+
3+
#include <iterator>
4+
5+
#include "../jsb_project_preset.h"
6+
#include "../internal/jsb_internal.h"
7+
#include "../bridge/jsb_worker.h"
8+
#include "../bridge/jsb_amd_module_loader.h"
9+
10+
#include "jsb_script.h"
11+
#include "editor/editor_settings.h"
12+
13+
#include "modules/regex/regex.h"
14+
15+
#ifdef TOOLS_ENABLED
16+
#include "../weaver-editor/templates/templates.gen.h"
17+
#endif
18+
19+
GodotJSScriptLanguage * GodotJSScriptLanguage::singleton_ = nullptr;
20+
21+
void GodotJSScriptLanguage::get_recognized_extensions(List<String>* p_extensions) const
22+
{
23+
p_extensions->push_back(JSB_TYPESCRIPT_EXT);
24+
}
25+
26+
GodotJSScriptBase* GodotJSScriptLanguage::create_godotjsscript() const
27+
{
28+
return memnew(GodotJSScript);
29+
}
30+
31+
bool GodotJSScriptLanguage::handles_global_class_type(const String& p_type) const
32+
{
33+
return p_type == jsb_typename(GodotJSScript);
34+
}
35+
36+
String GodotJSScriptLanguage::get_name() const
37+
{
38+
return jsb_typename(GodotJSScript);
39+
}
40+
41+
String GodotJSScriptLanguage::get_type() const
42+
{
43+
return jsb_typename(GodotJSScript);
44+
}
45+

weaver/jsb_script_language_ts.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef GODOTJS_SCRIPT_LANGUAGE_TS_H
2+
#define GODOTJS_SCRIPT_LANGUAGE_TS_H
3+
4+
#include "jsb_script_language.h"
5+
6+
class GodotJSScriptLanguage : public GodotJSScriptLanguageBase {
7+
static GodotJSScriptLanguage * singleton_;
8+
public:
9+
static GodotJSScriptLanguage * get_singleton() { return singleton_; }
10+
static GodotJSScriptLanguage * create_singleton() { if (singleton_) return singleton_; return singleton_ = memnew(GodotJSScriptLanguage); }
11+
static void destroy_singleton() { if (singleton_) memdelete(singleton_); singleton_ = nullptr; }
12+
virtual String get_extension() const override { return JSB_TYPESCRIPT_EXT; }
13+
virtual GodotJSScriptBase* create_godotjsscript() const override;
14+
virtual void get_recognized_extensions(List<String>* p_extensions) const override;
15+
virtual bool handles_global_class_type(const String& p_type) const override;
16+
virtual String get_name() const override;
17+
virtual String get_type() const override;
18+
19+
};
20+
21+
#endif

0 commit comments

Comments
 (0)