From 6c5900e79a8cba2f3778010746b7230d78b02696 Mon Sep 17 00:00:00 2001 From: james Date: Tue, 21 Oct 2025 17:55:39 +1030 Subject: [PATCH] spacetime start --- .gitignore | 23 +++++++++++++++ Cargo.toml | 12 ++++++++ src/main.rs | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c3c6f30 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +/target +### Rust template +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# RustRover +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..0eb5201 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "jvm-rs" +version = "0.1.0" +edition = "2024" + +[dependencies] +spacetimedb-sdk = { git = "https://github.com/infernap12/SpacetimeDB", branch = "class_de" } +#spacetimedb-core = { git = "https://github.com/infernap12/SpacetimeDB", branch = "class_de" } +#spacetimedb-lib = { git = "https://github.com/infernap12/SpacetimeDB", branch = "class_de" } +#spacetimedb-sats = { git = "https://github.com/infernap12/SpacetimeDB", branch = "class_de" } +#spacetimedb-client-api-messages = { git = "https://github.com/infernap12/SpacetimeDB", branch = "class_de" } +#bindings = { git = "https://github.com/infernap12/bitcraft-bindings", branch = "class_de" } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..8f7d295 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,84 @@ +mod primatives; +use std::fs; +use std::fs::File; +use std::io::Read; +use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws}; +use spacetimedb_sdk::__codegen::__lib::SpacetimeType; +use spacetimedb_sdk::__codegen::__sats::bsatn; +use deku_derive + +fn main() { + let mut class_file = File::open("./data/main.class").unwrap(); + let mut bytes = Vec::new(); + class_file.read_to_end(&mut bytes).unwrap(); + let cf = bsatn::from_slice::(&*bytes).unwrap(); + println!("{:?}", cf); +} + + + +#[deku(magic="")] +pub struct ClassFile { + pub magic: u32, + pub minor_version: u16, + pub major_version: u16, + pub constant_pool: Vec, // Note: count is pool.len() + 1 + pub access_flags: u16, + pub this_class: u16, + pub super_class: u16, + pub interfaces: Vec, + pub fields: Vec, + pub methods: Vec, + pub attributes: Vec, +} + +// Placeholder types - you'd need to define these based on the JVM spec +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub enum CpInfo { + NULL, // i think this is needed? + Utf8(&'static str), + NULLTWO, // needed again i think? + Integer(i32), + Float(f32), + Long(i64), + Double(f64), + Class(u16), + String(u16), + FieldRef, + MethodRef(u16, u16), + InterfaceMethodRef, + NameAndType, + NULLTHIRTEEN, + NULLFOURTEEN, + MethodHandle, + MethodType, + NULLSEVENTEEN, + InvokeDynamic, + Module, + Package +} + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub struct FieldInfo { + // Field structure +} + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub struct MethodInfo { + // Method structure +} + +#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)] +#[sats(crate = __lib)] +pub struct AttributeInfo { + // Attribute structure +} + +pub struct ConstantUtf8Info { + length: u16, + bytes: [u8], + vec: Vec +} \ No newline at end of file