| 539 | } |
| 540 | |
| 541 | jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &name) override { |
| 542 | if (GodotModule::get_singleton()->get_instance() == nullptr) { |
| 543 | throw jsi::JSINativeException("Godot Engine not initialized yet."); |
| 544 | } |
| 545 | |
| 546 | std::string typeName = name.utf8(rt); |
| 547 | |
| 548 | if (builtin_types.count(typeName)) { |
| 549 | return jsi::Value(rt, builtin_types[typeName]); |
| 550 | } |
| 551 | |
| 552 | godot::StringName godotTypeName(name.utf8(rt).c_str()); |
| 553 | if (godot::ClassDB::class_exists(godotTypeName)) { |
| 554 | if (godot::Engine::get_singleton()->has_singleton(godotTypeName)) { |
| 555 | std::shared_ptr<HostObject> ho(new GodotHostObject(_workletContext, godot::Variant(godot::Engine::get_singleton()->get_singleton(godotTypeName)))); |
| 556 | return jsi::Object::createFromHostObject(rt, ho); |
| 557 | } else { |
| 558 | return createClassConstructor(_workletContext, rt, name.utf8(rt)); |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | throw jsi::JSINativeException(std::string("Unable to resolve name as a type: ") + name.utf8(rt)); |
| 563 | } |
| 564 | |
| 565 | void set(jsi::Runtime &rt, const jsi::PropNameID &name, const jsi::Value &value) override { |
| 566 | throw jsi::JSINativeException("Setting property values is not supported on API Object"); |
no test coverage detected