Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Add method to get the ValueType of a TypedValue as a keyword to Android API #820

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sc13-bioinf
Copy link
Contributor

Also remove a println (leftover from debug?)

This makes life easier when dealing with query results, as it allows them to be extracted without knowing the types in advance. This makes use from clojure easier.

Returning standard data structures and types instead (commented on elsewhere) is something that I think is also worth a look.

I would be interested in helping out with this project so I would be happy to chat sometime.

Copy link
Member

@ncalexan ncalexan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works, but we're allocating memory on both sides of the FFI boundary. If we turned the underlying int into a static Java String on the Java side of the FFI boundary, we'd both have a simpler memory-safety story, and we'd allocate less. How do you feel about doing that?

ffi/src/lib.rs Outdated
@@ -1666,6 +1666,14 @@ pub unsafe extern "C" fn typed_value_value_type_kw(typed_value: *mut Binding) ->
string_to_c_char(value.clone())
}

/// Returns the size of a `row` as usize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: full sentences please, so: trailing period.

let values = &*values;
values.len () as c_int
}

/// Returns the value at the provided `index` as a `Vec<ValueType>`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no space between function and arguments, so: .len().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting is done. I am happy to try and implement your suggestion but I don't understand. Please could you walk me through it? What should all the return types be? Should the java class size method return a String?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, reading this again, I am guessing that you mean rust to write to some memory owned by the java class (which just happens to be a static string)
Are there any good examples or bits of docs that would help me?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, my current idea would be to do this by passing a direct allocated static final byteBuffer from java. To do this it seems easiest if I have access to JNIEnv, is there a reason why you don't seem to use this style?
https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-21-rust-on-android.html

Would need to use synchronise(this) around the call to rust within the constructor.

@sc13-bioinf sc13-bioinf force-pushed the android-typed-value-introspection branch from 8ad05c8 to ca460fa Compare September 6, 2018 13:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants