-
Notifications
You must be signed in to change notification settings - Fork 145
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
3139 rust projects names #3157
3139 rust projects names #3157
Changes from all commits
451162b
fac6e1f
491bad0
8cf3a7f
973b612
66f20b9
f518726
d83314c
734bc02
7f374f5
c643b1f
4c23dd5
fa69993
ba468f5
142cdf3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -47,7 +47,7 @@ public PrimeModule(final String method, final String file) { | |||||||||
"use eo::eo_enum::EO::EOError;", | ||||||||||
"#[no_mangle]", | ||||||||||
"pub extern \"system\" fn", | ||||||||||
String.format("Java_EOrust_natives_%s_%s", method, method), | ||||||||||
translate(method), | ||||||||||
"<'local> (env: JNIEnv<'local>, _class: JClass<'local>, universe: JObject<'local>) -> JByteArray<'local>", | ||||||||||
"{ let mut eo = Portal::new(env, _class, universe); ", | ||||||||||
"let arr = foo(&mut eo)", | ||||||||||
|
@@ -58,4 +58,35 @@ public PrimeModule(final String method, final String file) { | |||||||||
file | ||||||||||
); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Translates ("mangles") Java method name to native method name. | ||||||||||
* For example, translated "native0_custom" to | ||||||||||
* Java_EOrust_natives_native0_1custom_native0_1custom. | ||||||||||
* See {@link PrimeModule#translate(String, String)} for motivation. | ||||||||||
* @param jname Name of this function (and class) in Java. | ||||||||||
* @return How it named in Rust. | ||||||||||
*/ | ||||||||||
private static String translate(final String jname) { | ||||||||||
return PrimeModule.translate( | ||||||||||
"EOrust.natives.".concat(jname), | ||||||||||
jname | ||||||||||
); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Translates ("mangles") Java method name to native method name according to | ||||||||||
* <a href="https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/design.html">documentation</a> | ||||||||||
* or <a href="https://stackoverflow.com/questions/32470463/what-is-the-naming-convention-for-java-native-interface-method-and-module-name">stackoverflow</a>. | ||||||||||
* @param clazz Simple name of class. | ||||||||||
* @param method Name of method. | ||||||||||
* @return How it named in Rust. | ||||||||||
*/ | ||||||||||
private static String translate(final String clazz, final String method) { | ||||||||||
return String.format( | ||||||||||
"Java_%s_%s", | ||||||||||
clazz.replace("_", "_1").replace(".", "_"), | ||||||||||
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. @levBagryansky I didn't get what is 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. @maxonfjvipon There are 2 refs in commentary: https://stackoverflow.com/questions/32470463/what-is-the-naming-convention-for-java-native-interface-method-and-module-name">stackoverflow
In our case we have |
||||||||||
method.replace("_", "_1") | ||||||||||
); | ||||||||||
} | ||||||||||
} |
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.
@levBagryansky let's add an example to the doc. Something like "before -> after"