Skip to content

Commit

Permalink
Remove unused config stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Aug 1, 2024
1 parent 91d6005 commit 91cb7a4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 54 deletions.
40 changes: 0 additions & 40 deletions java-spaghetti-gen/src/config/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,6 @@ use serde_derive::Deserialize;

use crate::identifiers::{FieldManglingStyle, MethodManglingStyle};

/// How should the JNIEnv be passed around.
///
/// In the future, I plan to support an "Implicit" mode for platforms like Android - where there's at most one JVM at a
/// time - and said JVM lives for the lifetime of the application - so we can save some boilerplate for end users by
/// hiding it's use as an implementation detail.
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
#[derive(Default)]
pub enum StaticEnvStyle {
/// All static methods, static field getters, global hydration, etc. requires an explicit env parameter.
#[default]
Explicit,

#[doc(hidden)]
__NonExhaustive,
}

/// How should the generated Rust code be split up.
#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
#[derive(Default)]
pub enum CodeShardingStyle {
/// Keep generated code all together in one gigantic autogenerated .rs file.
None,

/// Split up autogenerated code into a series of .rs files, one per Java class.
#[default]
PerClass,

#[doc(hidden)]
__NonExhaustive,
}

fn default_true() -> bool {
true
}
Expand All @@ -53,10 +20,6 @@ fn default_method_naming_style_collision() -> MethodManglingStyle {
/// The \[codegen\] section.
#[derive(Debug, Clone, Deserialize)]
pub struct CodeGen {
/// How static methods should accept their Env.
#[serde(default = "Default::default")]
pub static_env: StaticEnvStyle,

/// How methods should be named by default.
#[serde(default = "default_method_naming_style")]
pub method_naming_style: MethodManglingStyle,
Expand All @@ -77,7 +40,6 @@ pub struct CodeGen {
impl Default for CodeGen {
fn default() -> Self {
Self {
static_env: Default::default(),
method_naming_style: default_method_naming_style(),
method_naming_style_collision: default_method_naming_style_collision(),
field_naming_style: Default::default(),
Expand Down Expand Up @@ -452,7 +414,6 @@ fn load_well_configured_toml() {
"#;
let file = File::read_str(well_configured_toml).unwrap();

assert_eq!(file.codegen.static_env, StaticEnvStyle::Explicit);
assert_eq!(file.codegen.method_naming_style, MethodManglingStyle::Java);
assert_eq!(
file.codegen.method_naming_style_collision,
Expand Down Expand Up @@ -534,7 +495,6 @@ fn load_minimal_toml() {
"#;
let file = File::read_str(minimal_toml).unwrap();

assert_eq!(file.codegen.static_env, StaticEnvStyle::Explicit);
assert_eq!(file.codegen.method_naming_style, MethodManglingStyle::Rustify);
assert_eq!(
file.codegen.method_naming_style_collision,
Expand Down
16 changes: 2 additions & 14 deletions java-spaghetti-gen/src/emit_rust/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::io;
use jreflection::method;

use super::known_docs_url::KnownDocsUrl;
use crate::config;
use crate::emit_rust::Context;
use crate::identifiers::MethodManglingStyle;

Expand Down Expand Up @@ -94,13 +93,7 @@ impl<'a> Method<'a> {

// Contents of fn name<'env>(...) {
let mut params_decl = if self.java.is_constructor() || self.java.is_static() {
match context.config.codegen.static_env {
config::toml::StaticEnvStyle::Explicit => String::from("__jni_env: ::java_spaghetti::Env<'env>"),
config::toml::StaticEnvStyle::__NonExhaustive => {
emit_reject_reasons.push("ERROR: StaticEnvStyle::__NonExhaustive is invalid, silly goose!");
String::new()
}
}
String::from("__jni_env: ::java_spaghetti::Env<'env>")
} else {
String::from("&'env self")
};
Expand Down Expand Up @@ -352,12 +345,7 @@ impl<'a> Method<'a> {
)?;
writeln!(out, "{} unsafe {{", indent)?;
writeln!(out, "{} let __jni_args = [{}];", indent, params_array)?;
if self.java.is_constructor() || self.java.is_static() {
match context.config.codegen.static_env {
config::toml::StaticEnvStyle::Explicit => {}
config::toml::StaticEnvStyle::__NonExhaustive => writeln!(out, "{} let __jni_env = ...?;", indent)?, // XXX
};
} else {
if !self.java.is_constructor() && self.java.is_static() {
writeln!(
out,
"{} let __jni_env = ::java_spaghetti::Env::from_raw(self.0.env);",
Expand Down

0 comments on commit 91cb7a4

Please sign in to comment.