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
Added FFI bindings to lib.rs #1
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7bdb9f8
added basic ffi bindings
ddefisher abaae23
rust FFI bindings
ddefisher 804380e
add example tinytest
ddefisher 868aeea
add future proof rustc flags
ddefisher 8d04809
remove test block
ddefisher cf8c4f1
change colorchooser argument types
ddefisher e09b855
Turn on TravisCI tests.
jdm b556d69
Rename .travis to .travis.yml
jdm 482a266
Merge pull request #1 from jdm/patch-1
ddefisher fdd6af7
pull request fixes
ddefisher ca76776
change function signatures and pull request tweaks
ddefisher 6bb8c89
move maping to as_ptr into local variable
ddefisher 50cd834
move vector as_ptr method to function call argument
ddefisher File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,12 +33,13 @@ fn save_file_dialog(title: &CStr, path: &CStr, | |
num_patterns: c_int, | ||
filter_pattern_one: &CStr, des: &CStr) -> *const c_char { | ||
let filter_patterns : [&CStr; 1] = [filter_pattern_one]; | ||
let ptr_filter_patterns = filter_patterns.iter().map(|c| c.as_ptr()).collect::<Vec<*const c_char>>().as_ptr(); | ||
unsafe { | ||
let result: *const c_char = tinyfiledialogs::tinyfd_saveFileDialog( | ||
title.as_ptr(), | ||
path.as_ptr(), | ||
num_patterns, | ||
filter_patterns.iter().map(|c| c.as_ptr()).collect::<Vec<*const c_char>>().as_ptr(), | ||
ptr_filter_patterns, | ||
des.as_ptr()); | ||
|
||
result | ||
|
@@ -49,12 +50,13 @@ fn open_file_dialog(title: &CStr, path: &CStr, | |
num_patterns: c_int, filter_pattern_one: &CStr, | ||
des: &CStr, multi_select: c_int) -> *const c_char { | ||
let filter_patterns : [&CStr; 1] = [filter_pattern_one]; | ||
let ptr_filter_patterns = filter_patterns.iter().map(|c| c.as_ptr()).collect::<Vec<*const c_char>>().as_ptr(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. |
||
unsafe { | ||
let result: *const c_char = tinyfiledialogs::tinyfd_openFileDialog( | ||
title.as_ptr(), | ||
path.as_ptr(), | ||
num_patterns, | ||
filter_patterns.iter().map(|c| c.as_ptr()).collect::<Vec<*const c_char>>().as_ptr(), | ||
ptr_filter_patterns, | ||
des.as_ptr(), | ||
multi_select); | ||
|
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this is still unsafe. The as_ptr() is what makes the Vec go out of scope; it should be moved to the actual argument to the function call instead.