This repository was archived by the owner on Nov 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Overhaul for Rust 0.12 #14
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As of GLib 2.36, it's not necessary to call g_type_init(). This was the only reason for a global init function.
Update to the Rust syntax as of rustc 0.12.0-nightly (740905042 2014-09-29). Rearranged the API conventions: * The imported structure types are now represented as the C structures themselves and declared in the crate root. * The interface traits live in the interface:: submodule. They still have the same name as their instance structure, but I consider the little disambiguation boilerplate on usage as better than having to deal with name mangling issues. There are some other submodules for other utility stuff such as callback shims. * Upcasting is implemented in interface traits, as well as a way to get at the instance structure by reference (cumbersome as it is pending the trait reform and UFCS). The dynamic casting continues to be available for types implementing ObjectType. * A generic reference type refcount::Ref provides safe reference counting, and is made non-sendable and non-sync.
With this, we need just the raw function table from Refcount, no need for the default-impl methods. Also, the generic impl of Ref got slim.
This reference type is for sendable, synchronized wrappers of GLib objects such as GMainLoop and GMainContext. There is a need to pass these objects into sendable closures, for example to quit the mainloop, or to send callback closures to another task's mainloop.
Want to be explicit as to the costs at the call site.
Added a RAII wrapper LoopRunner around creating a GMainContext, pushing it as the thread default, and creating a GMainLoop to run it. The MainLoop wrapper can be reffed out for closures and such. While Rust RFC 0062 (removal of non-native runtimes) hasn't landed, MainLoop and LoopRunner are kept in the module native as a reminder that they are only safe to use with the native runtime.
The idea is to ensure that the API user can only access the MainLoop and the MainContext after those have been properly set up, and also they can be sure to invoke async closures in the thread-default context of the loop as long as they do it in the closure. With the thread context setup done implicitly when calling LoopRunner::new(), it was possible to get confusing behavior by inadvertently swapping creation of the runner and issuing async operations. The users can still get their callbacks to never be called by invoking async methods outside run_after, but it's not a program safety issue, and it should be familiar to any Gio programmer.
Implemented an into_string() method and Equiv for Str.
Changed the bogus signature and implementation of gio::File::get_path to one returning a gstr::Utf8. Test all the limited ways we can now get at the string data.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #12, #7, #4, #10.