Skip to content

Commit

Permalink
Add objective-c and java to clang-format (#3154)
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre authored Jan 20, 2025
1 parent ab3572e commit dc29194
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/formatting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: DoozyX/[email protected]
with:
source: '.'
extensions: 'h,c,cc,proto'
extensions: 'h,c,cc,proto,java,m'
clangFormatVersion: 14
- uses: actionsx/prettier@v2
with:
Expand Down
21 changes: 11 additions & 10 deletions examples/android/AndroidMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
import android.widget.TextView;

public class AndroidMain extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.android_main);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.android_main);

Log.v("Bazel", "Android app launched");
System.loadLibrary("android_app"); // 'android_app' is the name of the native library in this example
Log.v("Bazel", "Value from rust: " + JniShim.getValue());
Log.v("Bazel", "Android app launched");
System.loadLibrary(
"android_app"); // 'android_app' is the name of the native library in this example
Log.v("Bazel", "Value from rust: " + JniShim.getValue());

final TextView helloTextView = (TextView) findViewById(R.id.text_view);
helloTextView.setText("Value from rust: " + JniShim.getValue());
}
final TextView helloTextView = (TextView) findViewById(R.id.text_view);
helloTextView.setText("Value from rust: " + JniShim.getValue());
}
}
2 changes: 1 addition & 1 deletion examples/android/JniShim.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.example.androidapp;

public class JniShim {
public static native int getValue();
public static native int getValue();
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.example.rustjni;

import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import org.junit.Test;

public class RustJniTest {
@Test
public void testCallsJniToRust() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import com.google.devtools.build.runfiles.AutoBazelRepository;
import com.google.devtools.build.runfiles.Runfiles;

import com.sun.jna.Library;
import com.sun.jna.Native;

import java.io.IOException;

@AutoBazelRepository
Expand All @@ -22,7 +20,9 @@ static RustStringLength loadNativeLibrary() throws IOException {
extension = "dll";
}
Runfiles.Preloaded runfiles = Runfiles.preload();
String dylibPath = runfiles.withSourceRepository(AutoBazelRepository_RustStringLength.NAME).rlocation("rules_rust_example_ffi/java_calling_rust/rust-crate/" + prefix + "rstrlen." + extension);
String dylibPath = runfiles.withSourceRepository(AutoBazelRepository_RustStringLength.NAME)
.rlocation("rules_rust_example_ffi/java_calling_rust/rust-crate/"
+ prefix + "rstrlen." + extension);

return Native.load(dylibPath, RustStringLength.class);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/ios/main_lib.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
extern void print_something_from_rust(void);

int main() {
print_something_from_rust();
printf("Some value from rust: %d\n", get_a_value_from_rust());
return 0;
print_something_from_rust();
printf("Some value from rust: %d\n", get_a_value_from_rust());
return 0;
}

0 comments on commit dc29194

Please sign in to comment.