package dyvil.ref;

import dyvil.annotation._internal.DyvilModifiers;
import dyvil.ref.unboxed.*;
import dyvil.reflect.Modifiers;

public interface ObjectRef<T>
{
	T get();

	void set(T value);

	// De-referencing operators

	@DyvilModifiers(Modifiers.INLINE)
	static <T> T $times(ObjectRef<T> ref)
	{
		return ref.get();
	}

	@DyvilModifiers(Modifiers.INLINE | Modifiers.INFIX)
	static <T> void $times_$eq(ObjectRef<T> ref, T value)
	{
		ref.set(value);
	}

	// Unbox Conversion Methods

	@DyvilModifiers(Modifiers.INFIX)
	static BooleanRef unboxed_$_boolean(ObjectRef<Boolean> booleanRef)
	{
		return new UnboxedBooleanRef(booleanRef);
	}

	@DyvilModifiers(Modifiers.INFIX)
	static ByteRef unboxed_$_byte(ObjectRef<Byte> byteRef)
	{
		return new UnboxedByteRef(byteRef);
	}

	@DyvilModifiers(Modifiers.INFIX)
	static ShortRef unboxed_$_short(ObjectRef<Short> shortRef)
	{
		return new UnboxedShortRef(shortRef);
	}

	@DyvilModifiers(Modifiers.INFIX)
	static CharRef unboxed_$_char(ObjectRef<Character> charRef)
	{
		return new UnboxedCharRef(charRef);
	}

	@DyvilModifiers(Modifiers.INFIX)
	static IntRef unboxed_$_int(ObjectRef<Integer> intRef)
	{
		return new UnboxedIntRef(intRef);
	}

	@DyvilModifiers(Modifiers.INFIX)
	static LongRef unboxed_$_long(ObjectRef<Long> longRef)
	{
		return new UnboxedLongRef(longRef);
	}

	@DyvilModifiers(Modifiers.INFIX)
	static FloatRef unboxed_$_float(ObjectRef<Float> floatRef)
	{
		return new UnboxedFloatRef(floatRef);
	}

	@DyvilModifiers(Modifiers.INFIX)
	static DoubleRef unboxed_$_double(ObjectRef<Double> doubleRef)
	{
		return new UnboxedDoubleRef(doubleRef);
	}
}

@@ -63,16 +63,61 @@
 ifiers;%0A
+import dyvil.annotation._internal.DyvilName;%0A
 import d
@@ -136,16 +136,16 @@
 oxed.*;%0A
-
 import d
@@ -527,16 +527,39 @@
 ethods%0A%0A
+%09@DyvilName(%22unboxed%22)%0A
 %09@DyvilM
@@ -610,20 +610,17 @@
  unboxed
-_$_b
+B
 oolean(O
@@ -692,32 +692,55 @@
 ooleanRef);%0A%09%7D%0A%0A
+%09@DyvilName(%22unboxed%22)%0A
 %09@DyvilModifiers
@@ -784,12 +784,9 @@
 oxed
-_$_b
+B
 yte(
@@ -847,32 +847,55 @@
 f(byteRef);%0A%09%7D%0A%0A
+%09@DyvilName(%22unboxed%22)%0A
 %09@DyvilModifiers
@@ -940,12 +940,9 @@
 oxed
-_$_s
+S
 hort
@@ -1008,32 +1008,55 @@
 (shortRef);%0A%09%7D%0A%0A
+%09@DyvilName(%22unboxed%22)%0A
 %09@DyvilModifiers
@@ -1100,12 +1100,9 @@
 oxed
-_$_c
+C
 har(
@@ -1168,32 +1168,55 @@
 f(charRef);%0A%09%7D%0A%0A
+%09@DyvilName(%22unboxed%22)%0A
 %09@DyvilModifiers
@@ -1259,12 +1259,9 @@
 oxed
-_$_i
+I
 nt(O
@@ -1321,32 +1321,55 @@
 ef(intRef);%0A%09%7D%0A%0A
+%09@DyvilName(%22unboxed%22)%0A
 %09@DyvilModifiers
@@ -1413,12 +1413,9 @@
 oxed
-_$_l
+L
 ong(
@@ -1476,32 +1476,55 @@
 f(longRef);%0A%09%7D%0A%0A
+%09@DyvilName(%22unboxed%22)%0A
 %09@DyvilModifiers
@@ -1569,12 +1569,9 @@
 oxed
-_$_f
+F
 loat
@@ -1641,24 +1641,47 @@
 atRef);%0A%09%7D%0A%0A
+%09@DyvilName(%22unboxed%22)%0A
 %09@DyvilModif
@@ -1731,12 +1731,9 @@
 oxed
-_$_d
+D
 oubl

Update ObjectRef unbox methods