Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option<Gd<T>> does not implement ToVariant #240

Closed
TitanNano opened this issue Apr 21, 2023 · 0 comments · Fixed by #247
Closed

Option<Gd<T>> does not implement ToVariant #240

TitanNano opened this issue Apr 21, 2023 · 0 comments · Fixed by #247
Labels
bug c: ffi Low-level components and interaction with GDExtension API

Comments

@TitanNano
Copy link
Contributor

While tring to implement ScriptLanguageExtensionVirtual::make_template(&self, template: GodotString, class_name: GodotString, base_class_name: GodotString) -> Option<Gd<Script>> the compiler gives me the following two errors:

error[E0277]: the trait bound `Option<godot::prelude::Gd<Script>>: EngineEnum` is not satisfied
  --> src/rust_script.rs:39:1
   |
39 | #[godot_api]
   | ^^^^^^^^^^^^ the trait `EngineEnum` is not implemented for `Option<godot::prelude::Gd<Script>>`
   |
   = help: the following other types implement trait `EngineEnum`:
             ASTCFormat
             ActionMode
             ActionType
             AdvanceMode
             AfterGUIInput
             AlphaAntiAliasing
             AlphaMode
             AmbientMode
           and 602 others
   = note: required for `Option<godot::prelude::Gd<Script>>` to implement `godot::prelude::ToVariant`
   = note: required for `(Option<godot::prelude::Gd<Script>>, GodotString, GodotString, GodotString)` to implement `godot::prelude::meta::SignatureTuple`
   = note: this error originates in the macro `$crate::gdext_ptrcall` which comes from the expansion of the attribute macro `godot_api` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `Option<godot::prelude::Gd<Script>>: GodotFfi` is not satisfied
  --> src/rust_script.rs:39:1
   |
39 | #[godot_api]
   | ^^^^^^^^^^^^ the trait `GodotFfi` is not implemented for `Option<godot::prelude::Gd<Script>>`
   |
   = help: the following other types implement trait `GodotFfi`:
             ()
             ASTCFormat
             ActionMode
             ActionType
             AdvanceMode
             AfterGUIInput
             AlphaAntiAliasing
             AlphaMode
           and 650 others
   = note: required for `Option<godot::prelude::Gd<Script>>` to implement `GodotFuncMarshal`
   = note: required for `(Option<godot::prelude::Gd<Script>>, GodotString, GodotString, GodotString)` to implement `godot::prelude::meta::SignatureTuple`
   = note: this error originates in the macro `$crate::gdext_ptrcall` which comes from the expansion of the attribute macro `godot_api` (in Nightly builds, run with -Z macro-backtrace for more info)

It's unclear to me if the wrong return type is being generated or if ToVariant and GodotFfi should be implemented for Option<Gd<T>>

@TitanNano TitanNano changed the title Option<Gd<T>> does not implement ToVariant Option<Gd<T>> does not implement ToVariant Apr 21, 2023
@lilizoey lilizoey added bug c: ffi Low-level components and interaction with GDExtension API labels Apr 21, 2023
TitanNano added a commit to TitanNano/gdext that referenced this issue Apr 27, 2023
TitanNano added a commit to TitanNano/gdext that referenced this issue Apr 28, 2023
TitanNano added a commit to TitanNano/gdext that referenced this issue May 1, 2023
…t-rust#240

Additionally FromVariant and ToVariant are also implemented for Option<Gd<T>>
to satisfy all the requirements for ffi and godot_api.
TitanNano added a commit to TitanNano/gdext that referenced this issue May 1, 2023
…t-rust#240

Additionally FromVariant and ToVariant are also implemented for Option<Gd<T>>
to satisfy all the requirements for ffi and godot_api.
TitanNano added a commit to TitanNano/gdext that referenced this issue May 9, 2023
…t-rust#240

Additionally FromVariant and ToVariant are also implemented for Option<Gd<T>>
to satisfy all the requirements for ffi and godot_api.
TitanNano added a commit to TitanNano/gdext that referenced this issue May 10, 2023
…t-rust#240

Additionally FromVariant and ToVariant are also implemented for Option<Gd<T>>
to satisfy all the requirements for ffi and godot_api.
TitanNano added a commit to TitanNano/gdext that referenced this issue May 22, 2023
…t-rust#240

Additionally FromVariant and ToVariant are also implemented for Option<Gd<T>>
to satisfy all the requirements for ffi and godot_api.
gg-yb pushed a commit to gg-yb/gdext that referenced this issue May 23, 2023
…t-rust#240

Additionally FromVariant and ToVariant are also implemented for Option<Gd<T>>
to satisfy all the requirements for ffi and godot_api.
TitanNano added a commit to TitanNano/gdext that referenced this issue May 24, 2023
…t-rust#240

Additionally FromVariant and ToVariant are also implemented for Option<Gd<T>>
to satisfy all the requirements for ffi and godot_api.
@bors bors bot closed this as completed in 9e6a8a0 May 24, 2023
Hapenia-Lans pushed a commit to Hapenia-Lans/gdextension that referenced this issue May 26, 2023
# This is the 1st commit message:

Parse gdextension_interface.h declarations using regex

# This is the commit message #2:

AsUninit trait to convert FFI pointers to their uninitialized versions

# This is the commit message godot-rust#3:

GodotFfi::from_sys_init() now uses uninitialized pointer types

# This is the commit message godot-rust#4:

Introduce GDExtensionUninitialized*Ptr, without changing semantics

# This is the commit message godot-rust#5:

Adjust init code to new get_proc_address mechanism

# This is the commit message godot-rust#6:

Make `trace` feature available in godot-ffi, fix interface access before initialization

# This is the commit message godot-rust#7:

Compatibility layer between Godot 4.0 and 4.1 (different GDExtension APIs)

# This is the commit message godot-rust#8:

Add GdextBuild to access build/runtime metadata

# This is the commit message godot-rust#9:

Detect 4.0 <-> 4.1 mismatches in both directions + missing `compatibility_minimum = 4.1`

# This is the commit message godot-rust#10:

Detect legacy/modern version of C header (also without `custom-godot` feature)

# This is the commit message godot-rust#11:

CI: add jobs that use patched 4.0.x versions

# This is the commit message godot-rust#12:

Remove several memory leaks by constructing into uninitialized pointers

# This is the commit message godot-rust#13:

CI: memcheck jobs for both 4.0.3 and nightly

# This is the commit message godot-rust#14:

Remove ToVariant, FromVariant, and VariantMetadata impls for pointers

This commit splits SignatureTuple into two separate traits:
PtrcallSignatureTuple and VarcallSignatureTuple. The latter is a child
of the former. PtrcallSignatureTuple is used for ptrcall and only
demands GodotFuncMarshall of its arguments. VarcallSignatureTuple is
used for varcall and additionally demands ToVariant, FromVariant, and
VariantMetadata of its arguments, so pointers cannot benefit from the
optimizations provided by varcall over ptrcall.

# This is the commit message godot-rust#15:

Adds FromVariant and ToVariant proc macros

# This is the commit message godot-rust#16:

godot-core: builtin: reimplement Plane functions/methods

# This is the commit message godot-rust#17:

impl GodotFfi for Option<T> when T is pointer sized and nullable godot-rust#240

Additionally FromVariant and ToVariant are also implemented for Option<Gd<T>>
to satisfy all the requirements for ffi and godot_api.

# This is the commit message godot-rust#18:

Fix UB in virtual method calls that take objects
Fix incorrect incrementing of refcount when calling in to godot
Fix refcount not being incremented when we receive a refcounted object in virtual methods

# This is the commit message godot-rust#19:

fix UB caused by preload weirdness

# This is the commit message godot-rust#20:

Implements swizzle and converts from/to tuples
T4rmyn pushed a commit to T4rmyn/gdext that referenced this issue Jun 4, 2023
…t-rust#240

Additionally FromVariant and ToVariant are also implemented for Option<Gd<T>>
to satisfy all the requirements for ffi and godot_api.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c: ffi Low-level components and interaction with GDExtension API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants