Skip to content

Commit

Permalink
Fix errors when first creating a script.
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzybinary committed Sep 6, 2024
1 parent 9b590fc commit beef3bc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/cpp/script/dart_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ void DartScript::refresh_type() const {
String path = get_path();

Dart_Handle dart_type = language->get_type_for_script(path);
if (dart_type != nullptr) {
if (!Dart_IsNull(dart_type)) {
_dart_type = Dart_NewPersistentHandle(dart_type);
DART_CHECK(type_info, Dart_GetField(dart_type, Dart_NewStringFromCString("sTypeInfo")),
"Failed getting type info");
Expand Down
49 changes: 26 additions & 23 deletions src/cpp/script/dart_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,36 @@ class DartScript : public godot::ScriptExtension {
DartScript();
~DartScript();

virtual godot::Ref<Script> _get_base_script() const override;
virtual godot::ScriptLanguage *_get_language() const override;
virtual void _set_source_code(const godot::String& code);
virtual godot::String _get_source_code() const override;
virtual bool _has_source_code() const override;
virtual bool _can_instantiate() const override;
virtual bool _has_method(const godot::StringName &method) const override;
virtual bool _has_static_method(const godot::StringName &method) const override;
virtual godot::Dictionary _get_method_info(const godot::StringName &method) const override;
virtual bool _is_valid() const override;
virtual bool _has_script_signal(const godot::StringName &signal) const override;
virtual godot::TypedArray<godot::Dictionary> _get_script_signal_list() const override;
virtual godot::TypedArray<godot::Dictionary> _get_script_method_list() const override;
virtual godot::TypedArray<godot::Dictionary> _get_script_property_list() const override;
virtual godot::Error _reload(bool keep_state) override;
virtual bool _is_tool() const override;
virtual godot::StringName _get_instance_base_type() const override;
virtual godot::TypedArray<godot::Dictionary> _get_documentation() const override;
virtual bool _has_property_default_value(const godot::StringName &property) const override;
virtual godot::Variant _get_property_default_value(const godot::StringName &property) const override;
virtual godot::StringName _get_global_name() const override;
bool _editor_can_reload_from_file() override {
return false;
}
godot::Ref<Script> _get_base_script() const override;
godot::ScriptLanguage *_get_language() const override;
void _set_source_code(const godot::String& code);
godot::String _get_source_code() const override;
bool _has_source_code() const override;
bool _can_instantiate() const override;
bool _has_method(const godot::StringName &method) const override;
bool _has_static_method(const godot::StringName &method) const override;
godot::Dictionary _get_method_info(const godot::StringName &method) const override;
bool _is_valid() const override;
bool _has_script_signal(const godot::StringName &signal) const override;
godot::TypedArray<godot::Dictionary> _get_script_signal_list() const override;
godot::TypedArray<godot::Dictionary> _get_script_method_list() const override;
godot::TypedArray<godot::Dictionary> _get_script_property_list() const override;
godot::Error _reload(bool keep_state) override;
bool _is_tool() const override;
godot::StringName _get_instance_base_type() const override;
godot::TypedArray<godot::Dictionary> _get_documentation() const override;
bool _has_property_default_value(const godot::StringName &property) const override;
godot::Variant _get_property_default_value(const godot::StringName &property) const override;
godot::StringName _get_global_name() const override;


void load_from_disk(const godot::String &path);

virtual void *_instance_create(Object *for_object) const override;
virtual void *_placeholder_instance_create(Object *for_object) const override;
void *_instance_create(Object *for_object) const override;
void *_placeholder_instance_create(Object *for_object) const override;


protected:
Expand Down
2 changes: 2 additions & 0 deletions src/cpp/script/dart_script_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ godot::Ref<godot::Script> DartScriptLanguage::_make_template(const godot::String
script->set_source_code(source);
script->set_name(class_name);

GodotDartBindings::instance()->reload_code();

return script;
}

Expand Down

0 comments on commit beef3bc

Please sign in to comment.