generated from Serial-ATA/sscrt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82b0ff5
commit 1d90028
Showing
33 changed files
with
252 additions
and
81 deletions.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use crate::classpath::classloader::ClassLoader; | ||
use crate::native::Reference; | ||
|
||
use std::cell::UnsafeCell; | ||
use std::ptr::NonNull; | ||
use std::sync::atomic::{AtomicBool, Ordering}; | ||
|
||
use ::jni::env::JniEnv; | ||
use ::jni::sys::{jboolean, jint}; | ||
use symbols::sym; | ||
|
||
include_generated!("native/java/io/def/FileOutputStream.definitions.rs"); | ||
|
||
/// `java.io.FileInputStream#fd` field offset | ||
static mut fd: UnsafeCell<usize> = UnsafeCell::new(0); | ||
|
||
// throws FileNotFoundException | ||
pub fn open0(_: NonNull<JniEnv>, _this: Reference, _name: Reference /* java.lang.String */) { | ||
unimplemented!("java.io.FileOutputStream#open0"); | ||
} | ||
|
||
// throws IOException | ||
pub fn write(_: NonNull<JniEnv>, _this: Reference, _b: jint, _append: jboolean) { | ||
unimplemented!("java.io.FileOutputStream#write"); | ||
} | ||
|
||
// throws IOException | ||
pub fn writeBytes( | ||
_: NonNull<JniEnv>, | ||
_this: Reference, | ||
_b: Reference, // byte[] | ||
_off: jint, | ||
_len: jint, | ||
_append: jboolean, | ||
) { | ||
unimplemented!("java.io.FileOutputStream#write"); | ||
} | ||
|
||
pub fn initIDs(_: NonNull<JniEnv>) { | ||
static ONCE: AtomicBool = AtomicBool::new(false); | ||
if ONCE | ||
.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst) | ||
.is_err() | ||
{ | ||
// TODO | ||
panic!("java.io.FileOutputStream#initIDs: attempt to initialize more than once."); | ||
} | ||
|
||
let class = ClassLoader::lookup_class(sym!(java_io_FileOutputStream)).unwrap(); | ||
unsafe { | ||
crate::globals::classes::set_java_io_FileOutputStream(class); | ||
} | ||
|
||
let mut field_set = false; | ||
for (index, field) in class.fields().enumerate() { | ||
if field.name == sym!(fd) { | ||
unsafe { | ||
*fd.get_mut() = index; | ||
} | ||
field_set = true; | ||
break; | ||
} | ||
} | ||
|
||
assert!(field_set, "Field must be present"); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import java.lang.String; | ||
|
||
public class FileOutputStream { | ||
// Opens a file, with the specified name, for overwriting or appending. | ||
// @param name name of file to be opened | ||
// @param append whether the file is to be opened in append mode | ||
private native void open0(String name) throws FileNotFoundException; | ||
|
||
// Writes the specified byte to this file output stream. | ||
// | ||
// @param b the byte to be written. | ||
// @param append true if the write operation first advances the position to the end of file | ||
private native void write(int b, boolean append) throws IOException; | ||
|
||
// Writes a sub array as a sequence of bytes. | ||
// @param b the data to be written | ||
// @param off the start offset in the data | ||
// @param len the number of bytes that are written | ||
// @param append true to first advance the position to the end of file | ||
// @throws IOException If an I/O error has occurred. | ||
private native void writeBytes(byte[] b, int off, int len, boolean append) | ||
throws IOException; | ||
|
||
private static native void initIDs(); | ||
} |
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
17 changes: 17 additions & 0 deletions
17
runtime/src/native/jdk/internal/misc/ScopedMemoryAccess.rs
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use crate::reference::Reference; | ||
|
||
use std::ptr::NonNull; | ||
|
||
use ::jni::env::JniEnv; | ||
|
||
include_generated!("native/jdk/internal/misc/def/ScopedMemoryAccess.definitions.rs"); | ||
include_generated!("native/jdk/internal/misc/def/ScopedMemoryAccess.registerNatives.rs"); | ||
|
||
pub fn closeScope0( | ||
_env: NonNull<JniEnv>, | ||
_this: Reference, // jdk.internal.misc.ScopedMemoryAccess | ||
_session: Reference, // jdk.internal.foreign.MemorySessionImpl | ||
_error: Reference, // jdk.internal.misc.ScopedMemoryAccess.ScopedAccessError | ||
) -> Reference { | ||
unimplemented!("jdk.internal.misc.ScopedMemoryAccess#closeScope0") | ||
} |
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
8 changes: 8 additions & 0 deletions
8
runtime/src/native/jdk/internal/misc/def/ScopedMemoryAccess.def
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import jdk.internal.foreign.MemorySessionImpl; | ||
import jdk.internal.misc.ScopedMemoryAccess.ScopedAccessError; | ||
|
||
public class ScopedMemoryAccess { | ||
private static native void registerNatives(); | ||
|
||
native void closeScope0(MemorySessionImpl session, ScopedAccessError error); | ||
} |
Oops, something went wrong.