-
Notifications
You must be signed in to change notification settings - Fork 0
#14 Clean up a bunch of repeated patterns and use result/option where useful. Convert structs to classes to add deinit to clear memory #16
Conversation
…ial tests for User/Util
Sources/IronOxide/Util.swift
Outdated
result.initialize(from: baseAddress, count: count) | ||
} | ||
return CRustStrView(data: result, len: UInt(str.utf8.count)) | ||
static func intFromBool(_ b: Bool) -> Int8 { |
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.
For consistency I'd name this boolToInt.
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.
Done
Sources/IronOxide/Util.swift
Outdated
/** | ||
* Return true if the provided Int8 represents a true value | ||
*/ | ||
static func isTrue(_ int: Int8) -> Bool { |
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.
I would name this intToBool
for consistency.
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.
Done
Sources/IronOxide/Util.swift
Outdated
* Convert the provided Array of IronOxide bytes into Swift UInt8 bytes | ||
*/ | ||
static func toBytes(_ bytes: CRustVeci8) -> [UInt8] { | ||
Array(UnsafeBufferPointer(start: bytes.data, count: Int(bytes.len))).map(UInt8.init) |
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.
We should comment here about expecting those bytes to be copied into swift managed memory.
Also, does anything free the CRustVeci8? I guess whenever the structure it was in gets freed we're just counting on it.
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.
Added a comment. Following up about freeing the Rust bytes in Slack.
…e method names and free Rust memory where possible
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.
Couple cleanups in the README, but overall LGTM.
+ Now you can compile this project via `swift build -Xlinker -L{path_to_your_ironoxide_target_ios_release_directory}`. If successful this should generate a `.build` directory which is similar to the `target` directory generated in Rust projects. | ||
+ This repo should be checked out as a sibling of the [IronOxide Java repo](https://github.com/IronCoreLabs/ironoxide-java). | ||
+ Build the C/C++ bindings within your `ironoxide-java` checkout | ||
+ [Mac Only?] Go into the `cpp` directory and modify the `Cargo.toml` file to build a `staticlib` instead of a `dylib` |
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.
I did this change on linux too, but I haven't tried without it.
|
||
## Adding Library to iOS Project in XCode | ||
|
||
XCode dependencies are added via URLs, usually pointing directly to a GitHub repository. You can also use the `file://` protocol to have it point to a local library on disk. | ||
|
||
+ Compile the `ironoxide-java` binary for the `x86_64-apple-ios` target. From the `ironoxide-java/cpp` directry run `cargo build --release --target x86_64-apple-ios` |
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.
This isn't right for linux. I just didn't put --target
on it at all.
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.
This is in the section for how to add this library to an iOS project in XCode where this is necessary. The steps above about getting this library setup don't include this.
No description provided.