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

[tracker] Tidy public internal interfaces #357

Closed
16 tasks done
ghost opened this issue May 23, 2020 · 4 comments
Closed
16 tasks done

[tracker] Tidy public internal interfaces #357

ghost opened this issue May 23, 2020 · 4 comments
Labels
breaking-change Issues and PRs that are breaking to fix/merge. c: bindings Component: GDNative bindings (mod api) c: core Component: core (mod core_types, object, log, init, ...)
Milestone

Comments

@ghost
Copy link

ghost commented May 23, 2020

To facilitate macros and generated bindings, the bindings expose a considerable number of internal interfaces that are pub at the language level. This alone is not a problem. However, they currently float freely in the codebase, and have inconsistent #[doc(hidden)] attributes. There are also some items that are unnecessarily #[doc(hidden)] pub. This complicates maintenance and future improvements (support for multiple engine versions, for example).

As a general rule, all items that expose types from gdnative-sys will be considered internal starting 0.9 (#291). If there are no higher-level replacements for them, such wrappers should be created.

Following is a non-exhaustive listing of items that need attention. New instances may be added here as they are discovered.

Top-level items in gdnative-core

These are mostly used in macros, and will be moved to a module named private that is #[doc(hidden)] pub. There are two items without #[doc(hidden)], result_from_sys and report_init_error, that need special intervention:

Generated unsafe methods in bindings_methods.rs

These are only used in the generated inherent methods, and thus should simply be private.

this field in generated binding types

These should also just be private. Macros should use to_sys() instead.

GodotObject and similar traits

The GodotObject trait is only meant to be implemented by the binding generator. However, there has been confused users trying to implement it (usually because they want downcasting). The trait should be "semi-sealed" with a supertrait in gdnative_code::private.

Traits that are `#[doc(hidden)] but should be public and sealed

The Export trait and ExportInfo

It's not sure if Export should be sealed, since making custom types usable in properties is a reasonable use case. However, ExportInfo exposes sys::godot_property_hint as a public field, making it unsuitable to be public interface in future versions. The current plan is to deprecate the public fields in ExportInfo and make them private in 0.9.

init_handle field of ClassBuilder

sys::godot_gdnative_terminate_options argument in godot_gdnative_init and gdnative_terminate callbacks

  • Add high-level wrapper for init_options in 0.9.
  • Add high-level wrapper for terminate_options in 0.9.

Opinions and items to add to the list are welcome!

@ghost ghost added c: core Component: core (mod core_types, object, log, init, ...) c: bindings Component: GDNative bindings (mod api) breaking-change Issues and PRs that are breaking to fix/merge. labels May 23, 2020
@ghost ghost added this to the 0.9 milestone May 23, 2020
@halzy
Copy link
Member

halzy commented Jun 9, 2020

Make generated unsafe methods private.

It appears that the remaining public functions are used across crates in the workspace. Were there specific functions you had in mind?

@ghost
Copy link
Author

ghost commented Jun 9, 2020

@halzy All the generated unsafe methods in bindings_methods.rs. They are #[doc(hidden)] so they won't show up in rustdoc, but they affect code completion apparently. Some changes might need to be made other than simply making them private.

halzy added a commit to halzy/godot-rust that referenced this issue Jun 9, 2020
halzy added a commit to halzy/godot-rust that referenced this issue Jun 9, 2020
halzy added a commit to halzy/godot-rust that referenced this issue Jun 9, 2020
ghost pushed a commit that referenced this issue Jun 10, 2020
ghost pushed a commit that referenced this issue Jun 10, 2020
@karroffel karroffel linked a pull request Jun 13, 2020 that will close this issue
@halzy
Copy link
Member

halzy commented Jun 26, 2020

@toasteater

Add high-level wrapper for init_options in 0.9.
Add high-level wrapper for terminate_options in 0.9.

Could you elaborate a bit more?

@ghost
Copy link
Author

ghost commented Jun 26, 2020

@halzy These types are used in the godot_gdnative_init and godot_gdnative_terminate macros as arguments to the callbacks. In 0.9 we want to have no gdnative-sys types in the public interface, so we should create high-level wrappers for them in gdnative-core to be used as arguments for those callbacks if that makes sense.

Otherwise, if there aren't any uses for them, we can also remove the arguments from the signatures of callbacks.

bors bot added a commit that referenced this issue Jun 27, 2020
477: [357] Sealing access::{Guard, WritePtr} r=toasteater a=halzy

Resolves part of #357 
`Traits that are #[doc(hidden)] but should be public and sealed`


Co-authored-by: Benjamin Halsted <[email protected]>
@halzy halzy closed this as completed Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Issues and PRs that are breaking to fix/merge. c: bindings Component: GDNative bindings (mod api) c: core Component: core (mod core_types, object, log, init, ...)
Projects
None yet
Development

No branches or pull requests

1 participant