MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / init

Method init

modules/gdscript/gdscript.cpp:2265–2307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2263}
2264
2265void GDScriptLanguage::init() {
2266 //populate global constants
2267 int gcc = CoreConstants::get_global_constant_count();
2268 for (int i = 0; i < gcc; i++) {
2269 _add_global(StringName(CoreConstants::get_global_constant_name(i)), CoreConstants::get_global_constant_value(i));
2270 }
2271
2272 _add_global(StringName("PI"), Math::PI);
2273 _add_global(StringName("TAU"), Math::TAU);
2274 _add_global(StringName("INF"), Math::INF);
2275 _add_global(StringName("NAN"), Math::NaN);
2276
2277 //populate native classes
2278
2279 List<StringName> class_list;
2280 ClassDB::get_class_list(&class_list);
2281 for (const StringName &n : class_list) {
2282 if (globals.has(n)) {
2283 continue;
2284 }
2285 Ref<GDScriptNativeClass> nc = memnew(GDScriptNativeClass(n));
2286 _add_global(n, nc);
2287 }
2288
2289 //populate singletons
2290
2291 List<Engine::Singleton> singletons;
2292 Engine::get_singleton()->get_singletons(&singletons);
2293 for (const Engine::Singleton &E : singletons) {
2294 _add_global(E.name, E.ptr);
2295 }
2296
2297#ifdef TOOLS_ENABLED
2298 if (Engine::get_singleton()->is_editor_hint()) {
2299 GDExtensionManager::get_singleton()->connect("extension_loaded", callable_mp(this, &GDScriptLanguage::_extension_loaded));
2300 GDExtensionManager::get_singleton()->connect("extension_unloading", callable_mp(this, &GDScriptLanguage::_extension_unloading));
2301 }
2302#endif
2303
2304#ifdef TESTS_ENABLED
2305 GDScriptTests::GDScriptTestRunner::handle_cmdline();
2306#endif
2307}
2308
2309#ifdef TOOLS_ENABLED
2310void GDScriptLanguage::_extension_loaded(const Ref<GDExtension> &p_extension) {

Callers 5

initializeMethod · 0.45
init_languageFunction · 0.45

Calls 6

GDScriptNativeClassClass · 0.85
get_singletonsMethod · 0.80
connectMethod · 0.65
StringNameClass · 0.50
hasMethod · 0.45
is_editor_hintMethod · 0.45

Tested by 1

init_languageFunction · 0.36