| 2263 | } |
| 2264 | |
| 2265 | void 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 |
| 2310 | void GDScriptLanguage::_extension_loaded(const Ref<GDExtension> &p_extension) { |