diff --git a/jdescriptor/src/lib.rs b/jdescriptor/src/lib.rs index 63c64d00..964e101a 100644 --- a/jdescriptor/src/lib.rs +++ b/jdescriptor/src/lib.rs @@ -39,7 +39,7 @@ pub fn default_value(type_descriptor: &TypeDescriptor) -> Vec { Byte | Char | Int | Short | Boolean => vec![0], Long => vec![0, 0], Float => from_f32(0.0), - Double => todo!(), + Double => from_f64(0.0), Void => panic!("field can't be a void type"), Array(_, _) => vec![0], Object(_) => vec![0], @@ -180,6 +180,11 @@ fn from_f32(value: f32) -> Vec { vec![value.to_bits() as i32] } +fn from_f64(value: f64) -> Vec { + let bits = value.to_bits(); + vec![(bits >> 32) as i32, bits as i32] +} + #[cfg(test)] mod tests { use super::*; diff --git a/tests/test_data/CompositePattern.java b/tests/test_data/CompositePattern.java index 8fd542cf..6dfa4053 100644 --- a/tests/test_data/CompositePattern.java +++ b/tests/test_data/CompositePattern.java @@ -1,14 +1,17 @@ package samples.inheritance.interfaces.compositepattern; +import java.util.ArrayList; +import java.util.List; + public class CompositePattern { public static void main(String[] args) { - Composite outerComposite = new Composite(5); + Composite outerComposite = new Composite(); outerComposite.addUnit(new Zealot()); outerComposite.addUnit(new Zealot()); outerComposite.addUnit(new DarkTemplar()); outerComposite.addUnit(new DarkTemplar()); - Composite innerComposite = new Composite(3); + Composite innerComposite = new Composite(); innerComposite.addUnit(new Zealot()); innerComposite.addUnit(new Unit() { @Override @@ -44,16 +47,14 @@ public int attack() { class Composite implements Unit { - private final Unit[] units; - private int currentIndex; + private final List units; - public Composite(int size) { - units = new Unit[size]; - currentIndex = 0; + public Composite() { + units = new ArrayList<>(); } public void addUnit(Unit unit) { - units[currentIndex++] = unit; + units.add(unit); } @Override diff --git a/tests/test_data/samples/inheritance/interfaces/compositepattern/Composite.class b/tests/test_data/samples/inheritance/interfaces/compositepattern/Composite.class index be449383..e8c353ab 100644 Binary files a/tests/test_data/samples/inheritance/interfaces/compositepattern/Composite.class and b/tests/test_data/samples/inheritance/interfaces/compositepattern/Composite.class differ diff --git a/tests/test_data/samples/inheritance/interfaces/compositepattern/CompositePattern$1.class b/tests/test_data/samples/inheritance/interfaces/compositepattern/CompositePattern$1.class index 744b5fc3..765653b0 100644 Binary files a/tests/test_data/samples/inheritance/interfaces/compositepattern/CompositePattern$1.class and b/tests/test_data/samples/inheritance/interfaces/compositepattern/CompositePattern$1.class differ diff --git a/tests/test_data/samples/inheritance/interfaces/compositepattern/CompositePattern.class b/tests/test_data/samples/inheritance/interfaces/compositepattern/CompositePattern.class index bcfaa991..485687e6 100644 Binary files a/tests/test_data/samples/inheritance/interfaces/compositepattern/CompositePattern.class and b/tests/test_data/samples/inheritance/interfaces/compositepattern/CompositePattern.class differ diff --git a/tests/test_data/samples/inheritance/interfaces/compositepattern/DarkTemplar.class b/tests/test_data/samples/inheritance/interfaces/compositepattern/DarkTemplar.class index f10416bb..7cd0bb07 100644 Binary files a/tests/test_data/samples/inheritance/interfaces/compositepattern/DarkTemplar.class and b/tests/test_data/samples/inheritance/interfaces/compositepattern/DarkTemplar.class differ diff --git a/tests/test_data/samples/inheritance/interfaces/compositepattern/Unit.class b/tests/test_data/samples/inheritance/interfaces/compositepattern/Unit.class index 0d818f24..ec59bf68 100644 Binary files a/tests/test_data/samples/inheritance/interfaces/compositepattern/Unit.class and b/tests/test_data/samples/inheritance/interfaces/compositepattern/Unit.class differ diff --git a/tests/test_data/samples/inheritance/interfaces/compositepattern/Zealot.class b/tests/test_data/samples/inheritance/interfaces/compositepattern/Zealot.class index 730198db..568186bb 100644 Binary files a/tests/test_data/samples/inheritance/interfaces/compositepattern/Zealot.class and b/tests/test_data/samples/inheritance/interfaces/compositepattern/Zealot.class differ